Skip to content

Commit

Permalink
update catch for TRV
Browse files Browse the repository at this point in the history
  • Loading branch information
Khole Jones authored and Khole Jones committed Jan 7, 2025
1 parent b3ee963 commit 91a96f8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
18 changes: 11 additions & 7 deletions pyhiveapi/apyhiveapi/helper/hive_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def getDeviceData(self, product: dict):
Returns:
[type]: Device data.
"""
device = product
device_id = product["id"]
type = product["type"]
if type in ("heating", "hotwater"):
for aDevice in self.session.data.devices:
Expand All @@ -91,19 +91,23 @@ def getDeviceData(self, product: dict):
product["props"]["zone"]
== self.session.data.devices[aDevice]["props"]["zone"]
):
device = self.session.data.devices[aDevice]
device_id = self.session.data.devices[aDevice]["id"]
except KeyError:
pass
elif type == "trvcontrol":
device = self.session.data.devices[product["props"]["trvs"][0]]
trv_present = len(product["props"]["trvs"]) > 0
if trv_present:
device_id = self.session.data.devices[product["props"]["trvs"][0]]["id"]
else:
raise KeyError
elif type == "warmwhitelight" and product["props"]["model"] == "SIREN001":
device = self.session.data.devices[product["parent"]]
device_id = self.session.data.devices[product["parent"]]
elif type == "sense":
device = self.session.data.devices[product["parent"]]
device_id = self.session.data.devices[product["parent"]]
else:
device = self.session.data.devices[product["id"]]
device_id = self.session.data.devices[product["id"]]

return device
return device_id

def convertMinutesToTime(self, minutes_to_convert: str):
"""Convert minutes string to datetime.
Expand Down
22 changes: 11 additions & 11 deletions pyhiveapi/apyhiveapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ def addList(self, entityType: str, data: dict, **kwargs: dict):
Returns:
dict: Entity.
"""
device = self.helper.getDeviceData(data)
device_name = (
device["state"]["name"]
if device["state"]["name"] != "Receiver"
else "Heating"
)
formatted_data = {}

try:
device = self.helper.getDeviceData(data)
device_name = (
device["state"]["name"]
if device["state"]["name"] != "Receiver"
else "Heating"
)
formatted_data = {}

formatted_data = {
"hiveID": data.get("id", ""),
"hiveName": device_name,
Expand All @@ -154,11 +154,11 @@ def addList(self, entityType: str, data: dict, **kwargs: dict):
else:
formatted_data["haName"] = device_name
formatted_data.update(kwargs)
self.deviceList[entityType].append(formatted_data)
return formatted_data
except KeyError as error:
self.logger.error(error)

self.deviceList[entityType].append(formatted_data)
return formatted_data
return None

async def updateInterval(self, new_interval: timedelta):
"""Update the scan interval.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def requirements_from_file(filename="requirements.txt"):


setup(
version="0.5.16",
version="0.5.17",
package_data={"data": ["*.json"]},
include_package_data=True,
cmdclass={
Expand Down

0 comments on commit 91a96f8

Please sign in to comment.