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

Adapt @therealryanbonham's PR (#79)

This removes the formatting portion, which should have been a separate PR
This commit is contained in:
Jacob McSwain 2020-02-03 15:00:20 -06:00
parent 59bb5ae237
commit 7ab48d968e

View File

@ -166,6 +166,17 @@ class NestAPI():
self.login() self.login()
return self.get_devices() return self.get_devices()
def _map_nest_protect_state(self, value):
if value == 0:
return "Ok"
elif value == 1 or value == 2:
return "Warning"
elif value == 3:
return "Emergency"
else:
return "Unknown"
def update(self): def update(self):
try: try:
# To get friendly names # To get friendly names
@ -270,11 +281,11 @@ class NestAPI():
f' ({sensor_data["description"]})' f' ({sensor_data["description"]})'
self.device_data[sn]['name'] += ' Protect' self.device_data[sn]['name'] += ' Protect'
self.device_data[sn]['co_status'] = \ self.device_data[sn]['co_status'] = \
sensor_data['co_status'] self._map_nest_protect_state(sensor_data['co_status'])
self.device_data[sn]['smoke_status'] = \ self.device_data[sn]['smoke_status'] = \
sensor_data['smoke_status'] self._map_nest_protect_state(sensor_data['smoke_status'])
self.device_data[sn]['battery_health_state'] = \ self.device_data[sn]['battery_health_state'] = \
sensor_data['battery_health_state'] self._map_nest_protect_state(sensor_data['battery_health_state'])
# Temperature sensors # Temperature sensors
elif bucket["object_key"].startswith( elif bucket["object_key"].startswith(
f"kryptonite.{sn}"): f"kryptonite.{sn}"):