Marked with ##HERE markers the refactoring required for new Message()
Disabled alterMessage showMessage and createMessage to force this issue
1 parent b93ccf9 commit f0ecb64f40ad5965c92f8d2214f3c70d97a2ebe7
@David Whale David Whale authored on 23 May 2016
Showing 6 changed files
View
4
src/combined.py
 
OpenThings.init(Devices.CRYPT_PID)
 
PURPLE_ID = 0x68B # captured from a real device using Monitor.py
m = OpenThings.alterMessage(
m = OpenThings.alterMessage( ####HERE use the new Message() abstraction
Devices.create_message(Devices.SWITCH),
header_sensorid=PURPLE_ID,
recs_0_value=1)
purple_on = OpenThings.encode(m)
 
m = OpenThings.alterMessage(
m = OpenThings.alterMessage( ####HERE use the new Message() abstraction
Devices.create_message(Devices.SWITCH),
header_sensorid=PURPLE_ID,
recs_0_value=0)
purple_off = OpenThings.encode(m)
View
7
src/energenie/Devices.py
}
 
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),
response = OpenThings.alterMessage(create_message(JOIN_ACK), ####HERE use the new Message()
header_mfrid=mfrid,
header_productid=productid,
header_sensorid=sensorid)
p = OpenThings.encode(response)
self.capabilities.receive = True
self.capabilities.switch = True
 
def incoming_message(self, payload):
####HERE####
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
# then just define the mapping table in __init__ (i.e. paramid->Readings field name)
return self.readings
 
def turn_on(self):
#TODO: header construction should be in MiHomeDevice as it is shared
payload = OpenThings.alterMessage(
payload = OpenThings.alterMessage( ####HERE use the new Message()
create_message(SWITCH),
header_productid = self.product_id,
header_sensorid = self.device_id,
recs_0_value = True)
self.send_message(payload)
 
def turn_off(self):
#TODO: header construction should be in MiHomeDevice as it is shared
payload = OpenThings.alterMessage(
payload = OpenThings.alterMessage( ####HERE use the new Message()
create_message(SWITCH),
header_productid = self.product_id,
header_sensorid = self.device_id,
recs_0_value = False)
View
src/energenie/OpenThings.py
View
src/energenie/Registry_test.py
View
src/monitor.py
View
src/switch.py