Add notify for Loriot

This commit is contained in:
Nico Schottelius 2016-11-02 18:27:49 +01:00
parent 598619f00c
commit 76f6fed0cc

View file

@ -21,14 +21,20 @@ class Loriot():
jdata = lorautil.jsonToDict(result) jdata = lorautil.jsonToDict(result)
eui = self.devEUI(jdata) eui = self.devEUI(jdata)
lorautil.insert_json("loriot", result, deveui=eui)
try:
payload = get_payload(jdata)
except Exception:
payload = ""
lorautil.db_insert_json("loriot", result, payload=payload, deveui=eui)
lorautul.db_notify("loriot", payload=payload, deveui=eui)
def devEUI(self, data): def devEUI(self, data):
return data['EUI'] return data['EUI']
def get_payload(self, data): def get_payload(self, data):
return "" return bytes.fromhex(data['payload']).decode('utf-8')
# return data['EUI']
if __name__ == '__main__': if __name__ == '__main__':
l = Loriot() l = Loriot()