From e8cdc5de1766a61ef45391109b4cc4a088028803 Mon Sep 17 00:00:00 2001 From: Konstantin Koslowski Date: Mon, 2 Mar 2020 00:39:01 +0100 Subject: [PATCH] homecontrol: use numbers instead of strings for values/levels --- homecontrol/core.py | 7 +++---- scripts/actor_get.sh | 6 +++--- scripts/actor_get_levels.sh | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/homecontrol/core.py b/homecontrol/core.py index ed971d1..c46e93f 100755 --- a/homecontrol/core.py +++ b/homecontrol/core.py @@ -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}") diff --git a/scripts/actor_get.sh b/scripts/actor_get.sh index f1d44d7..2d7359b 100755 --- a/scripts/actor_get.sh +++ b/scripts/actor_get.sh @@ -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" diff --git a/scripts/actor_get_levels.sh b/scripts/actor_get_levels.sh index 2991212..99c460e 100755 --- a/scripts/actor_get_levels.sh +++ b/scripts/actor_get_levels.sh @@ -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