diff --git a/src/energenie/Registry.py b/src/energenie/Registry.py index ff2c537..5a46a3c 100644 --- a/src/energenie/Registry.py +++ b/src/energenie/Registry.py @@ -187,11 +187,16 @@ if self.incoming_cb != None: self.incoming_cb(address, message) + ##print("router.incoming addr=%s" % str(address)) + ##print("routes:%s" % str(self.routes)) + if address in self.routes: ci = self.routes[address] ci.incoming_message(message) - else: # unknown address + else: # address has no route + print("No route to an object, for device:%s" % str(address)) + #TODO: Could consult registry and squash if registry knows it self.handle_unknown(address, message) def when_incoming(self, callback): @@ -222,12 +227,12 @@ router.when_unknown(self.unknown_device) def unknown_device(self, address, message): - pass##print("message from unknown device:%s" % str(address)) + print("message from unknown device:%s" % str(address)) # default action is to drop message # override this method in sub classes if you want special processing def reject_device(self, address, message): - pass##print("message rejected from:%s" % (str(address))) + print("message rejected from:%s" % (str(address))) # default action is to drop message # override this method if you want special processing @@ -290,7 +295,7 @@ j = None if j == None: # not a join - self.unknown_device(address, message) + Discovery.unknown_device(self, address, message) else: # it is a join # but don't forward the join request as it will be malformed with no value ci = self.accept_device(address, message, forward=False) @@ -314,7 +319,7 @@ j = None if j == None: # not a join - self.unknown_device(address, message) + Discovery.unknown_device(self, address, message) else: # it is a join y = self.ask_fn(address, message) if y: diff --git a/src/energenie/__init__.py b/src/energenie/__init__.py index 50e1853..e31e487 100644 --- a/src/energenie/__init__.py +++ b/src/energenie/__init__.py @@ -48,7 +48,9 @@ if os.path.isfile(registry.DEFAULT_FILENAME): registry.load_from(registry.DEFAULT_FILENAME) - + print("loaded registry from file") + registry.list() + fsk_router.list() # Default discovery mode, unless changed by app ##discovery_none() diff --git a/src/mihome_energy_monitor.py b/src/mihome_energy_monitor.py index 5fae325..db913b0 100644 --- a/src/mihome_energy_monitor.py +++ b/src/mihome_energy_monitor.py @@ -26,7 +26,9 @@ switch_state = not switch_state # For all devices in the registry, if they have a get_power(), call it + print("Checking device status") for d in energenie.registry.devices(): + print(d) try: p = d.get_power() print("Power: %s" % str(p)) @@ -47,7 +49,7 @@ print("\nIncoming from %s" % str(address)) Logger.logMessage(message) energenie.fsk_router.when_incoming(incoming) - + print("Logging to file:%s" % Logger.LOG_FILENAME) try: while True: