diff --git a/src/energenie/Devices.py b/src/energenie/Devices.py index fb10d24..687c831 100644 --- a/src/energenie/Devices.py +++ b/src/energenie/Devices.py @@ -3,6 +3,7 @@ # Information about specific Energenie devices # This table is mostly reverse-engineered from various websites and web catalogues. +from lifecycle import * import OnAir import OpenThings @@ -66,6 +67,9 @@ BROADCAST_ID = 0xFFFFFF # Energenie broadcast #TODO: This might be deprecated now, and replaced with the DeviceFactory? +#Still used in deprecated methods in Registry.py + +@deprecated def getDescription(mfrid, productid): if mfrid == MFRID_ENERGENIE: mfr = "Energenie" @@ -88,6 +92,9 @@ #TODO this might be deprecated now, and replaced with the Device classes. #e.g. if there is a turn_on method or get_switch method, it has a switch. +#still used in switch.py demo (will be until device classes deployed into tests) + +@deprecated def hasSwitch(mfrid, productid): if mfrid != MFRID: return False if productid == PRODUCTID_MIHO005: return True @@ -148,6 +155,67 @@ } +MIHO005_REPORT = { + "header": { + "mfrid": MFRID_ENERGENIE, + "productid": PRODUCTID_MIHO005, + "encryptPIP": CRYPT_PIP, + "sensorid": 0 # FILL IN + }, + "recs": [ + { + "wr": False, + "paramid": OpenThings.PARAM_SWITCH_STATE, + "typeid": OpenThings.Value.UINT, + "length": 1, + "value": 0 # FILL IN + }, + { + "wr": False, + "paramid": OpenThings.PARAM_VOLTAGE, + "typeid": OpenThings.Value.UINT, + "length": 1, + "value": 0 # FILL IN + }, + { + "wr": False, + "paramid": OpenThings.PARAM_CURRENT, + "typeid": OpenThings.Value.UINT, + "length": 1, + "value": 0 # FILL IN + }, + { + "wr": False, + "paramid": OpenThings.PARAM_FREQUENCY, + "typeid": OpenThings.Value.UINT, + "length": 1, + "value": 0 # FILL IN + }, + { + "wr": False, + "paramid": OpenThings.PARAM_REAL_POWER, + "typeid": OpenThings.Value.UINT, + "length": 1, + "value": 0 # FILL IN + }, + { + "wr": False, + "paramid": OpenThings.PARAM_REACTIVE_POWER, + "typeid": OpenThings.Value.UINT, + "length": 1, + "value": 0 # FILL IN + }, + { + "wr": False, + "paramid": OpenThings.PARAM_APPARENT_POWER, + "typeid": OpenThings.Value.UINT, + "length": 1, + "value": 0 # FILL IN + }, + + ] +} + def send_join_ack(radio, mfrid, productid, sensorid): # send back a JOIN ACK, so that join light stops flashing response = OpenThings.alterMessage(create_message(JOIN_ACK), diff --git a/src/energenie/OnAir.py b/src/energenie/OnAir.py index e95b8de..7a5612b 100644 --- a/src/energenie/OnAir.py +++ b/src/energenie/OnAir.py @@ -39,7 +39,7 @@ timeout = 1000 #ms self.rx_defaults = RxDefaults() - @log_method + #@log_method def send(self, payload, radio_params=None): # payload is a pydict suitable for OpenThings # radio_params is an overlay on top of radio tx defaults @@ -53,7 +53,7 @@ radio.transmit(p, outer_times=1, inner_times=4, outer_delay=0) # radio auto-returns to previous state after transmit completes - @log_method + #@log_method def receive(self, radio_params): # -> (radio_measurements, address or None, payload or None) # radio_params is an overlay on top of radio rx defaults (e.g. poll rate, timeout, min payload, max payload) # radio_measurements might include rssi reading, short payload report, etc @@ -106,7 +106,7 @@ timeout = 1000 #ms self.rx_defaults = RxDefaults() - @log_method + #@log_method def send(self, payload, radio_params=None): # payload is just a list of bytes, or a byte buffer # radio_params is an overlay on top of radio tx defaults @@ -124,7 +124,7 @@ radio.transmit(bytes, outer_times=1, inner_times=8, outer_delay=0) #TODO: radio params # radio auto-pops to state before transmit - @log_method + #@log_method def receive(self, radio_params): # -> (radio_measurements, address or None, payload or None) # radio_params is an overlay on top of radio rx defaults (e.g. poll rate, timeout, min payload, max payload) # radio_measurements might include rssi reading, short payload report, etc diff --git a/src/energenie/Registry_test.py b/src/energenie/Registry_test.py index 8c85c79..4384e86 100644 --- a/src/energenie/Registry_test.py +++ b/src/energenie/Registry_test.py @@ -31,13 +31,17 @@ print("fan send:%s" % self.fan.can_send()) print("fan receive:%s" % self.fan.can_receive()) - def text_tx(self): + def test_ook_tx(self): """Test the transmit pipeline""" - tv.turn_on() - tv.turn_off() - fan.turn_on() - fan.turn_off() + self.fan.turn_on() + self.fan.turn_off() + + def test_fsk_tx(self): + """Test the transmit pipeline for MiHome FSK devices""" + + self.tv.turn_on() + self.tv.turn_off() def test_fsk_rx(self): """Test the receive pipeline for FSK MiHome adaptor""" @@ -54,68 +58,8 @@ #it should update voltage, power etc ## poor mans incoming synthetic message - MIHO005_REPORT = { - "header": { - "mfrid": Devices.MFRID_ENERGENIE, - "productid": Devices.PRODUCTID_MIHO005, - "encryptPIP": Devices.CRYPT_PIP, - "sensorid": 0 # FILL IN - }, - "recs": [ - { - "wr": False, - "paramid": OpenThings.PARAM_SWITCH_STATE, - "typeid": OpenThings.Value.UINT, - "length": 1, - "value": 0 # FILL IN - }, - { - "wr": False, - "paramid": OpenThings.PARAM_VOLTAGE, - "typeid": OpenThings.Value.UINT, - "length": 1, - "value": 0 # FILL IN - }, - { - "wr": False, - "paramid": OpenThings.PARAM_CURRENT, - "typeid": OpenThings.Value.UINT, - "length": 1, - "value": 0 # FILL IN - }, - { - "wr": False, - "paramid": OpenThings.PARAM_FREQUENCY, - "typeid": OpenThings.Value.UINT, - "length": 1, - "value": 0 # FILL IN - }, - { - "wr": False, - "paramid": OpenThings.PARAM_REAL_POWER, - "typeid": OpenThings.Value.UINT, - "length": 1, - "value": 0 # FILL IN - }, - { - "wr": False, - "paramid": OpenThings.PARAM_REACTIVE_POWER, - "typeid": OpenThings.Value.UINT, - "length": 1, - "value": 0 # FILL IN - }, - { - "wr": False, - "paramid": OpenThings.PARAM_APPARENT_POWER, - "typeid": OpenThings.Value.UINT, - "length": 1, - "value": 0 # FILL IN - }, - ] - } - - report = Devices.create_message(MIHO005_REPORT) + report = Devices.create_message(Devices.MIHO005_REPORT) report = OpenThings.alterMessage( report, recs_0_value=240, # voltage