diff --git a/src/Logger.py b/src/Logger.py index 1dab788..b748690 100644 --- a/src/Logger.py +++ b/src/Logger.py @@ -57,6 +57,9 @@ if paramid == OpenThings.PARAM_SWITCH_STATE: switch = value flags[0] = 1 + elif paramid == OpenThings.PARAM_DOOR_SENSOR: + switch = value + flags[0] = 1 elif paramid == OpenThings.PARAM_VOLTAGE: flags[1] = 1 voltage = value diff --git a/src/energenie/Devices.py b/src/energenie/Devices.py index 7ffefcf..5cf8bfa 100644 --- a/src/energenie/Devices.py +++ b/src/energenie/Devices.py @@ -862,8 +862,11 @@ self.readings = Readings() self.capabilities.send = True + def __repr__(self): + return "MIHO033(%s)" % str(hex(self.device_id)) + def handle_message(self, payload): - print("MIHO033 new data %s %s" % (self.device_id, payload)) + ##print("MIHO033 new data %s %s" % (self.device_id, payload)) for rec in payload["recs"]: paramid = rec["paramid"] #TODO: consider making this table driven and allowing our base class to fill our readings in for us @@ -871,15 +874,16 @@ #it will then register a handler for that message for itself as a handler #we still need Readings() defined too as a cache. The decorator could add #an entry into the cache too for us perhaps? - value = rec["value"] - if paramid == OpenThings.DOOR_SENSOR: - self.readings.switch_state = ((value == True) or (value != 0)) - else: - try: - param_name = OpenThings.param_info[paramid]['n'] # name - except: - param_name = "UNKNOWN_%s" % str(hex(paramid)) - print("unwanted paramid: %s" % param_name) + if "value" in rec: + value = rec["value"] + if paramid == OpenThings.PARAM_DOOR_SENSOR: + self.readings.switch_state = ((value == True) or (value != 0)) + else: + try: + param_name = OpenThings.param_info[paramid]['n'] # name + except: + param_name = "UNKNOWN_%s" % str(hex(paramid)) + print("unwanted paramid: %s" % param_name) def get_switch_state(self): # -> switch:bool return self.readings.switch_state diff --git a/src/energenie/Registry.py b/src/energenie/Registry.py index 46a1a71..de0c10e 100644 --- a/src/energenie/Registry.py +++ b/src/energenie/Registry.py @@ -63,9 +63,9 @@ c = self.store[name] if self.fsk_router != None: - if c.can_receive(): + if c.can_send(): # if can transmit, we can receive from it if isinstance(c, Devices.MiHomeDevice): - ##print("Adding rx route for receive enabled device %s" % c) + print("Adding rx route for transmit enabled device %s" % c) address = (c.manufacturer_id, c.product_id, c.device_id) self.fsk_router.add(address, c) return c diff --git a/src/registry.kvs b/src/registry.kvs index bbacec5..bda63b2 100644 --- a/src/registry.kvs +++ b/src/registry.kvs @@ -6,3 +6,8 @@ type=MIHO005 device_id=1675 + +ADD door +type=MIHO033 +device_id=2817 + diff --git a/src/setup_tool.py b/src/setup_tool.py index 5d3457f..30f5b66 100644 --- a/src/setup_tool.py +++ b/src/setup_tool.py @@ -147,6 +147,7 @@ print("REGISTRY:") show_registry() + energenie.registry.fsk_router.list() def do_switch_device():