def METHOD_NAME():
    r = request.args
    try:
        r["device_id"]
    except (KeyError, TypeError):
        return jsonify({"error": "missing key"}), 400
    db = get_cached_db()
    with db:
        row = db.execute("SELECT * FROM devices_table WHERE device_id IS :device_id", r)
    try:
        status = next(row)[1]
    except StopIteration:
        return (
            jsonify(
                {"error": "could not find device with id {}".format(r["device_id"])}
            ),
            400,
        )
    onoff = "on" if status else "off"
    logging.info("Lights are %s", onoff)
    return jsonify({"lights": onoff})