homecontrol: return properly formatted json

This commit is contained in:
Konstantin Koslowski 2019-11-03 16:39:08 +01:00
parent bf941ae701
commit c82216b5f9

View file

@ -12,7 +12,7 @@ class Client:
self.ts = time.time() self.ts = time.time()
def get_info(self): def get_info(self):
return "id: %s, type: %s, ts: %s" % (self.id_c, self.type_c, self.ts) return {"id": self.id_c, "type": self.type_c, "ts": self.ts}
class Sensor(Client): class Sensor(Client):
def __init__(self, id_s, type_s, num_values): def __init__(self, id_s, type_s, num_values):
@ -42,8 +42,8 @@ class Actor(Client):
def get_info(self): def get_info(self):
return "id: %s, type: %s, ts: %s, levels: 0x%x, level: 0x%06x" % ( return {"id": self.id_a, "type": self.type_a, "ts": self.ts,
self.id_a, self.type_a, self.ts, self.levels, self.level) "levels": self.levels, "level": self.level}
def add_queue(self, command, data): def add_queue(self, command, data):
print("add_queue: {\"command\": %s, \"data\": %s}" % (command, data)) print("add_queue: {\"command\": %s, \"data\": %s}" % (command, data))