homecontrol: use numbers instead of strings for values/levels
This commit is contained in:
parent
577dd4f78b
commit
e8cdc5de17
3 changed files with 7 additions and 8 deletions
|
@ -231,7 +231,6 @@ class Core:
|
||||||
while True:
|
while True:
|
||||||
for n in self.cws.nodes:
|
for n in self.cws.nodes:
|
||||||
await self.cws.node_send_command(n, "get_status", {})
|
await self.cws.node_send_command(n, "get_status", {})
|
||||||
|
|
||||||
status = self.cws.nodes[n].get_status()
|
status = self.cws.nodes[n].get_status()
|
||||||
if status and len(status) > 0:
|
if status and len(status) > 0:
|
||||||
self.actor_add_level(n, status["level"], status["ts"])
|
self.actor_add_level(n, status["level"], status["ts"])
|
||||||
|
@ -286,11 +285,11 @@ class Core:
|
||||||
try:
|
try:
|
||||||
q = self.db["actors"].find_one(actorId=actorId)
|
q = self.db["actors"].find_one(actorId=actorId)
|
||||||
ret["actorId"] = actorId
|
ret["actorId"] = actorId
|
||||||
ret["maxLevel"] = f"0x{q['maxLevel']}"
|
ret["maxLevel"] = q['maxLevel']
|
||||||
ret["actorType"] = q["actorType"]
|
ret["actorType"] = q["actorType"]
|
||||||
q = self.db["actor_levels"].find_one(actorId=actorId, order_by="-ts")
|
q = self.db["actor_levels"].find_one(actorId=actorId, order_by="-ts")
|
||||||
ret["ts"] = q["ts"]
|
ret["ts"] = q["ts"]
|
||||||
ret["level"] = f"0x{q['level']}"
|
ret["level"] = q['level']
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.logger.error(f"Exception Type:{type(ex).__name__}, args: {ex.args}")
|
self.logger.error(f"Exception Type:{type(ex).__name__}, args: {ex.args}")
|
||||||
return ret
|
return ret
|
||||||
|
@ -307,7 +306,7 @@ class Core:
|
||||||
query = self.db["actor_levels"].find(actorId=actorId)
|
query = self.db["actor_levels"].find(actorId=actorId)
|
||||||
levels = []
|
levels = []
|
||||||
for q in query:
|
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
|
ret["levels"] = levels
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.logger.error(f"Exception Type:{type(ex).__name__}, args: {ex.args}")
|
self.logger.error(f"Exception Type:{type(ex).__name__}, args: {ex.args}")
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
REQ=GET
|
REQ=GET
|
||||||
URL=http://localhost:5000/actor/get
|
URL=http://localhost:8200/actor/get
|
||||||
|
|
||||||
echo "$REQ $URL"
|
# echo "$REQ $URL"
|
||||||
read -p "continue?" -n 1 foo
|
# read -p "continue?" -n 1 foo
|
||||||
curl \
|
curl \
|
||||||
-X $REQ $URL \
|
-X $REQ $URL \
|
||||||
-H "Content-Type: application/json"
|
-H "Content-Type: application/json"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
ACTORID=${1:-11111111}
|
ACTORID=${1:-11111111}
|
||||||
LIMIT=${2:-0}
|
LIMIT=${2:-0}
|
||||||
REQ=GET
|
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"
|
echo "$REQ $URL"
|
||||||
read -p "continue?" -n 1 foo
|
read -p "continue?" -n 1 foo
|
||||||
|
|
Loading…
Reference in a new issue