Skip to content

Commit

Permalink
Fix get devices for empty zone
Browse files Browse the repository at this point in the history
  • Loading branch information
blavka committed Jan 3, 2021
1 parent 6fe57d2 commit e95688c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion xComfortMQTT/shc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions xComfortMQTT/xComforMqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit e95688c

Please sign in to comment.