From e95688c68b6efc73d57d6b061746e9eae0873232 Mon Sep 17 00:00:00 2001 From: Karel Blavka Date: Sun, 3 Jan 2021 09:45:16 +0100 Subject: [PATCH] Fix get devices for empty zone --- xComfortMQTT/shc_client.py | 4 +++- xComfortMQTT/xComforMqtt.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/xComfortMQTT/shc_client.py b/xComfortMQTT/shc_client.py index ef16dd9..faca258 100644 --- a/xComfortMQTT/shc_client.py +++ b/xComfortMQTT/shc_client.py @@ -60,7 +60,9 @@ def rpc(self, method, params=None): "http://" + self._host + "/remote/json-rpc", json=payload) if response.status_code == 200: - return response.json()['result'] + payload = response.json() + logging.debug("Response: %s", payload) + return payload.get('result', []) raise xComfortApiException('RPC erron %s' % response.status_code) diff --git a/xComfortMQTT/xComforMqtt.py b/xComfortMQTT/xComforMqtt.py index 634573a..9def09f 100644 --- a/xComfortMQTT/xComforMqtt.py +++ b/xComfortMQTT/xComforMqtt.py @@ -130,7 +130,7 @@ def _get(self, client, userdata, message): self._mqtt.publish(device_topic, json.dumps(device['value'])) def start(self): - self._zones_load() + self._load_zones() while True: self._update() @@ -156,11 +156,13 @@ def _update(self): for topic in device['topics']: self._mqtt.publish(topic, payload) - def _zones_load(self): + def _load_zones(self): + logging.debug("Load Zones") self._devices = {} self._zones = {} for zone in self._shc.get_zones(): + logging.debug("Load device for zone \"%s\" param: %s", zone['zoneId'], zone) zone_devices = self._shc.get_devices(zone['zoneId']) zone['devices'] = {} zone['zoneName'] = zone['zoneName'].strip()