예제 #1
0
    async def update_callback(device: SonoffSwitch):
        if device.basic_info is not None:

            if device.available:

                if inching is None:
                    print_device_details(device)

                    if device.is_on:
                        if new_state == "on":
                            device.shutdown_event_loop()
                        else:
                            await device.turn_off()

                    elif device.is_off:
                        if new_state == "off":
                            device.shutdown_event_loop()
                        else:
                            await device.turn_on()

                else:
                    logger.info("Inching device activated by switching ON for "
                                "%ss" % inching)
예제 #2
0
 async def device_id_callback(device: SonoffSwitch):
     if device.basic_info is not None:
         device.shared_state['device_id_at_current_ip'] = \
             device.device_id
         device.shutdown_event_loop()