Adding Engineering data to Live Data

Adds Engineers data to Live Data to be surfaced in Home-Assistant to be able to correctly act against DEVICE_TYPE.
This commit is contained in:
MindrustUK 2023-05-04 17:42:51 +01:00
parent 54ca38d4d6
commit 3ad3a73bb8
1 changed files with 18 additions and 1 deletions

View File

@ -435,16 +435,33 @@ class NeoHub:
"""
message = {"GET_LIVE_DATA": 0}
hub_data = await self._send(message)
# We need the engineers data to get things like Device Type, Sensor Mode etc.
get_eng_data_msg = {"GET_ENGINEERS": 0}
eng_hub_data = await self._send(get_eng_data_msg)
devices = hub_data.devices
delattr(hub_data, "devices")
# Combine the live data and engineers data to produce a full dataset to work from.
# Start by working through each device in the devices
for index, device in enumerate(devices):
# Find matching device ID in Engineers data
for key, value in eng_hub_data.__dict__.items():
if device.DEVICE_ID == value.DEVICE_ID:
# Now add the engineers data dictionary entries to the existing device dictionary.
for x in value.__dict__.items():
setattr(device, x[0], x[1])
thermostat_list = list(filter(lambda device: hasattr(device, 'THERMOSTAT') and device.THERMOSTAT, devices))
timeclock_list = list(filter(lambda device: hasattr(device, 'TIMECLOCK') and device.TIMECLOCK, devices))
thermostats = []
timeclocks = []
for thermostat in thermostat_list:
thermostats.append(NeoStat(self, thermostat))