diff --git a/src/energenie/Registry.py b/src/energenie/Registry.py index bd1c2cc..4abcf8f 100644 --- a/src/energenie/Registry.py +++ b/src/energenie/Registry.py @@ -379,16 +379,16 @@ d = AutoDiscovery(registry, fsk_router) print("Using auto discovery") -def discovery_ask(): - d = ConfirmedDiscovery(registry, fsk_router) +def discovery_ask(ask_fn): + d = ConfirmedDiscovery(registry, fsk_router, ask_fn) print("using confirmed discovery") def discovery_autojoin(): d = JoinAutoDiscovery(registry, fsk_router) print("using auto join discovery") -def discovery_askjoin(): - d = JoinConfirmedDiscovery(registry, fsk_router) +def discovery_askjoin(ask_fn): + d = JoinConfirmedDiscovery(registry, fsk_router, ask_fn) print("using confirmed join discovery") diff --git a/src/monitor_mihome.py b/src/monitor_mihome.py index 9286d72..bb9874b 100644 --- a/src/monitor_mihome.py +++ b/src/monitor_mihome.py @@ -8,7 +8,7 @@ MY_SENSOR_ID = 0x68b # manually captured from a previous run DUMMY_SENSOR_ID = 0x111 # for testing unknown messages - +APP_DELAY = 5 #----- TEST APPLICATION ------------------------------------------------------- @@ -30,12 +30,6 @@ ## Logger.logMessage(message) ##energenie.fsk_router.when_incoming(incoming) - # Provide an unknown message handler so we can show data from unregistered devices - # This is a useful hook point for later adding device discovery - def unknown(address, message): - print("\nUnknown device:%s" % str(address)) - message.dump() - energenie.fsk_router.when_unknown(unknown) # Register for update callbacks on a single device when a new message comes in. # This is a useful way to add data logging on a per-device basis @@ -53,11 +47,13 @@ while True: #TESTING: Poke synthetic unknown into the router and let it route to unknown handler + print("synthetic unknown device") msg.set(header_sensorid=DUMMY_SENSOR_ID) energenie.fsk_router.incoming_message( (energenie.Devices.MFRID_ENERGENIE, energenie.Devices.PRODUCTID_MIHO005, DUMMY_SENSOR_ID), msg) #TESTING: Poke synthetic known into the router and let it route to our class instance + print("synthetic known device") msg.set(header_sensorid=MY_SENSOR_ID) energenie.fsk_router.incoming_message( (energenie.Devices.MFRID_ENERGENIE, energenie.Devices.PRODUCTID_MIHO005, MY_SENSOR_ID), msg) @@ -67,7 +63,7 @@ ##energenie.loop() print("voltage:%s" % purple.get_voltage()) - time.sleep(1) + time.sleep(APP_DELAY) finally: energenie.finished()