async def main__turn_light_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_light(telegram): print(f'Callback light: {telegram}') # Lys kino light = Light(hdl, (1, 74), 1, "kino") light.register_telegram_received_cb(callback_received_for_light) await light.set_on(3) print("{} {}".format(light.current_brightness, light.is_on)) await asyncio.sleep(5) await light.set_off() print("{} {}".format(light.current_brightness, light.is_on)) await asyncio.sleep(5) await light.set_brightness(20, 5) print("{} {}".format(light.current_brightness, light.is_on)) await asyncio.sleep(10) await light.set_off()
async def main__kino(): # taklys 1, 74, 1 # se film scene 1, 74, 1, 1 # høre musikk scene 1, 74, 1, 2 # spille scene 1, 74, 1, 3 # dlp media 1, 23 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() light = Light(hdl, (1, 74), 1) # await light.set_on(0) scene = Scene(hdl, (1, 74), (1, 1)) # await scene.run() scene = Scene(hdl, (1, 74), (1, 3)) # await scene.run() # await light.set_off() # def heat_received(telegram): # print(telegram) heat = Climate(hdl, (1, 23)) # heat.register_telegram_received_cb(heat_received) # await heat.read_heating_status() # await asyncio.sleep(5) # print("temo kino: {}".format(heat.temperature)) fhs = ControlFloorHeatingStatus # fhs.normal_temperature = 22 fhs.status = OnOffStatus.OFF.value # noinspection PyTypeChecker await heat.control_heating_status(floor_heating_status=fhs)
async def main__turn_light_on_off_with_device_updated_cb(): 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() async def device_updated_callback(light_): print(f"AFTER UPDATE: {light_.current_brightness}") def callback_received_for_light(telegram): print(f'Callback light: {telegram}') # Lys kino light = Light(hdl, (1, 74), 1, "kino") light.register_device_updated_cb(device_updated_callback) light.register_telegram_received_cb(callback_received_for_light) await light.set_brightness(30) # light.read_current_state() await light.set_on(3) print(f"{light.current_brightness} {light.is_on}")