1
0
mirror of https://github.com/USA-RedDragon/badnest.git synced 2024-10-05 21:10:48 +01: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.'):
sn = bucket.replace('device.', '')
self.thermostats.append(sn)
self.temperature_sensors.append(sn)
self.device_data[sn] = {}
self.cameras = self._get_cameras()
@ -209,7 +210,7 @@ class NestAPI():
for bucket in r.json()["updated_buckets"]:
sensor_data = bucket["value"]
sn = bucket["object_key"].split('.')[1]
# Thermostats
# Thermostats (thermostat and sensors system)
if bucket["object_key"].startswith(
f"shared.{sn}"):
self.device_data[sn]['current_temperature'] = \
@ -242,6 +243,14 @@ class NestAPI():
self.device_data[sn]['name'] = self._wheres[
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):
self.device_data[sn]['name'] += \
f' ({sensor_data["description"]})'