def switch_water_to(water_device, on): """ Switches the water_device to state on Args: water_device: The id of the WaterDevice on (bool): On / Off Returns: """ if water_device.state() == on: # Already right state. return if app.config['HARDWARE']: from app.hardware import remote_socket remote_socket.switch(map(int, water_device.key), water_device.device, on)
def switch_light(light_id, on): """ Switches light to state of the variable on. Args: light_id (str): The database id from the Light. on (bool): True if the light should be turned on, False if off. Returns: """ light_device = appbuilder.session.query(LightDevice).filter(LightDevice.id == light_id).first() if app.config['HARDWARE']: from app.hardware import remote_socket remote_socket.switch(map(int, light_device.key), light_device.device, on)
def view(self): if current_app.config['HARDWARE']: from app.hardware import remote_socket remote_socket.switch([1, 0, 0, 1, 1], 1, False) return "bla"