homecontrol: use numbers instead of strings for values/levels

This commit is contained in:
Konstantin Koslowski 2020-03-02 00:39:01 +01:00
parent 577dd4f78b
commit e8cdc5de17
3 changed files with 7 additions and 8 deletions

View file

@ -231,7 +231,6 @@ class Core:
while True:
for n in self.cws.nodes:
await self.cws.node_send_command(n, "get_status", {})
status = self.cws.nodes[n].get_status()
if status and len(status) > 0:
self.actor_add_level(n, status["level"], status["ts"])
@ -286,11 +285,11 @@ class Core:
try:
q = self.db["actors"].find_one(actorId=actorId)
ret["actorId"] = actorId
ret["maxLevel"] = f"0x{q['maxLevel']}"
ret["maxLevel"] = q['maxLevel']
ret["actorType"] = q["actorType"]
q = self.db["actor_levels"].find_one(actorId=actorId, order_by="-ts")
ret["ts"] = q["ts"]
ret["level"] = f"0x{q['level']}"
ret["level"] = q['level']
except Exception as ex:
self.logger.error(f"Exception Type:{type(ex).__name__}, args: {ex.args}")
return ret
@ -307,7 +306,7 @@ class Core:
query = self.db["actor_levels"].find(actorId=actorId)
levels = []
for q in query:
levels.append({"ts": q["ts"], "value": f"0x{q['level']}"})
levels.append({"ts": q["ts"], "value": q["level"]})
ret["levels"] = levels
except Exception as ex:
self.logger.error(f"Exception Type:{type(ex).__name__}, args: {ex.args}")

View file

@ -1,9 +1,9 @@
#!/bin/bash
REQ=GET
URL=http://localhost:5000/actor/get
URL=http://localhost:8200/actor/get
echo "$REQ $URL"
read -p "continue?" -n 1 foo
# echo "$REQ $URL"
# read -p "continue?" -n 1 foo
curl \
-X $REQ $URL \
-H "Content-Type: application/json"

View file

@ -2,7 +2,7 @@
ACTORID=${1:-11111111}
LIMIT=${2:-0}
REQ=GET
URL=http://localhost:5000/actor/get_levels/$ACTORID?limit=$LIMIT
URL=http://localhost:8200/actor/get_levels/$ACTORID?limit=$LIMIT
echo "$REQ $URL"
read -p "continue?" -n 1 foo