Skip to content

Commit

Permalink
Merge pull request #18 from MTrab:Minor-fixes-for-new-API
Browse files Browse the repository at this point in the history
Minor syntax fix for API changes
  • Loading branch information
MTrab authored Feb 8, 2024
2 parents a73009a + 397c991 commit ecd811f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions pydanfossally/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Module for handling Danfoss Ally API communication"""

# pylint: disable=invalid-name
from __future__ import annotations

import logging
Expand Down Expand Up @@ -47,14 +48,15 @@ def getDeviceList(self) -> None:
_LOGGER.error("No devices loaded, API connection error?!")
return

if not "result" in devices:
if "result" not in devices:
_LOGGER.error("Something went wrong loading devices!")
return

for device in devices["result"]:
self.handleDeviceData(device)

def handleDeviceData(self, device: dict):
"""Handle the device data."""
self.devices[device["id"]] = {}
self.devices[device["id"]]["isThermostat"] = False
self.devices[device["id"]]["name"] = device["name"].strip()
Expand Down Expand Up @@ -133,7 +135,8 @@ def handleDeviceData(self, device: dict):
self.devices[device["id"]]["valve_opening"] = status["value"]
elif status["code"] == "LoadRadiatorRoomMean":
self.devices[device["id"]]["load_room_mean"] = status["value"]
elif status["code"] == "ext_measured_rs":
elif status["code"] == "sensor_avg_temp":
# elif status["code"] == "ext_measured_rs":
self.devices[device["id"]]["external_sensor_temperature"] = (
float(status["value"]) / 10
)
Expand Down Expand Up @@ -186,7 +189,7 @@ def getDevice(self, device_id: str) -> None:
if device is None or not device:
_LOGGER.error("No device loaded, API error?!")
return
if not "result" in device:
if "result" not in device:
_LOGGER.error("Something went wrong loading devices!")
return

Expand Down
3 changes: 2 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""For testing the module."""

from os import environ
from pprint import pprint

Expand All @@ -12,4 +13,4 @@

ally.getDeviceList()

pprint(vars(ally))
pprint(vars(ally))

0 comments on commit ecd811f

Please sign in to comment.