async def lys_kino(): loop__ = asyncio.get_event_loop() hdl = Buspro(GATEWAY_ADDRESS_SEND_RECEIVE, loop__) hdl.register_telegram_received_all_messages_cb(callback_received_for_all_messages) await hdl.start() switch = Switch(hdl, (1, 74), 1) # await switch.set_on() await switch.set_off()
async def main__turn_switch_on_off(): loop__ = asyncio.get_event_loop() hdl = Buspro(GATEWAY_ADDRESS_SEND_RECEIVE, loop__) hdl.register_telegram_received_all_messages_cb(callback_received_for_all_messages) await hdl.start() def callback_received_for_switch(telegram): print(f'Callback switch: {telegram}') # Lys kino switch = Switch(hdl, (1, 74), 1, "kino") switch.register_telegram_received_cb(callback_received_for_switch) await switch.set_on() print(f"{switch.is_on}") await asyncio.sleep(5) await switch.set_off() print(f"{switch.is_on}")