1
0
mirror of https://github.com/USA-RedDragon/badnest.git synced 2024-10-05 21:00:49 +01:00

Merge pull request #54 from nonsleepr/thermostat-as-a-sensor

Expose thermostat as a sensor
This commit is contained in:
Jacob McSwain 2020-02-03 14:41:14 -06:00 committed by GitHub
commit 857463f3d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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"]})'