1
0
mirror of https://github.com/USA-RedDragon/badnest.git synced 2025-01-18 22:50:44 +00:00

Expose thermostat as a sensor

This commit is contained in:
Alexander Bessonov 2019-12-11 10:55:17 -05:00
parent e55159b465
commit 63da0e61b0

View File

@ -163,6 +163,7 @@ class NestAPI():
elif bucket.startswith('device.'): elif bucket.startswith('device.'):
sn = bucket.replace('device.', '') sn = bucket.replace('device.', '')
self.thermostats.append(sn) self.thermostats.append(sn)
self.temperature_sensors.append(sn)
self.device_data[sn] = {} self.device_data[sn] = {}
self.cameras = self._get_cameras() self.cameras = self._get_cameras()
@ -209,7 +210,7 @@ class NestAPI():
for bucket in r.json()["updated_buckets"]: for bucket in r.json()["updated_buckets"]:
sensor_data = bucket["value"] sensor_data = bucket["value"]
sn = bucket["object_key"].split('.')[1] sn = bucket["object_key"].split('.')[1]
# Thermostats # Thermostats (thermostat and sensors system)
if bucket["object_key"].startswith( if bucket["object_key"].startswith(
f"shared.{sn}"): f"shared.{sn}"):
self.device_data[sn]['current_temperature'] = \ self.device_data[sn]['current_temperature'] = \
@ -242,6 +243,14 @@ class NestAPI():
self.device_data[sn]['name'] = self._wheres[ self.device_data[sn]['name'] = self._wheres[
sensor_data['where_id'] sensor_data['where_id']
] ]
# When acts as a sensor
if 'backplate_temperature' in sensor_data:
self.device_data[sn]['temperature'] = \
sensor_data['backplate_temperature']
if 'battery_level' in sensor_data:
self.device_data[sn]['battery_level'] = \
sensor_data['battery_level']
if sensor_data.get('description', None): if sensor_data.get('description', None):
self.device_data[sn]['name'] += \ self.device_data[sn]['name'] += \
f' ({sensor_data["description"]})' f' ({sensor_data["description"]})'