async def testDevice(device: IotDevice): print("\n\nTesting {0} device.".format(type(device))) printTelemetry(device) print("\nTurning on valve, then waiting 5 seconds...") device.turn_valve_on() await asyncio.sleep(5) printTelemetry(device) if device.get_flow() == 0: print("\033[93mWARNING: *** NO FLOW DETECTED ***\033[0m") print("\nTurning off valve, then waiting 5 seconds...") device.turn_valve_off() await asyncio.sleep(5) printTelemetry(device) if device.get_flow() != 0: print("\033[93mWARNING: *** FLOW DETECTED ***\033[0m")
def _auto_shutoff_handlers(iot_device: IotDevice): iot_device.cancel_timer() print("Auto shutoff, turning device off..") iot_device.turn_valve_off()
def turn_valve_off(self): IotDevice.set_flow(self, 0.0) IotDevice.turn_valve_off(self)
async def turn_valve_off_handler(iot_device: IotDevice, values): iot_device.cancel_timer() print("Turning device off.") iot_device.turn_valve_off()
async def turn_valve_off_handler(iot_device: IotDevice, values): # TODO: Cancel any timers from turn_valve_on_handler print("Turning device off.") iot_device.turn_valve_off()