From 3ad3a73bb83b56eda11410662546fee6021f3fab Mon Sep 17 00:00:00 2001 From: MindrustUK Date: Thu, 4 May 2023 17:42:51 +0100 Subject: [PATCH] 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. --- neohubapi/neohub.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/neohubapi/neohub.py b/neohubapi/neohub.py index bd1bd85..36e1227 100644 --- a/neohubapi/neohub.py +++ b/neohubapi/neohub.py @@ -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))