Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Fix unique_ids
Browse files Browse the repository at this point in the history
* Make the lists of thermostats, sensors, and temperature sensors sets
 so we have a truely unique list
* Fix issue with import classes
  • Loading branch information
mattsch committed May 26, 2020
1 parent c52989b commit dc6fbbb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions custom_components/badnest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def __init__(self,
self._czfe_url = None
self._camera_url = f'https://nexusapi-{region}1.camera.home.nest.com'
self.cameras = []
self.thermostats = []
self.temperature_sensors = []
self.protects = []
self.thermostats = set()
self.temperature_sensors = set()
self.protects = set()
self.login()
self._get_devices()
self.update()
Expand Down Expand Up @@ -209,16 +209,16 @@ def _get_devices(self):
for bucket in buckets:
if bucket.startswith('topaz.'):
sn = bucket.replace('topaz.', '')
self.protects.append(sn)
self.protects.add(sn)
self.device_data[sn] = {}
elif bucket.startswith('kryptonite.'):
sn = bucket.replace('kryptonite.', '')
self.temperature_sensors.append(sn)
self.temperature_sensors.add(sn)
self.device_data[sn] = {}
elif bucket.startswith('device.'):
sn = bucket.replace('device.', '')
self.thermostats.append(sn)
self.temperature_sensors.append(sn)
self.thermostats.add(sn)
self.temperature_sensors.add(sn)
self.device_data[sn] = {}

self.cameras = self._get_cameras()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/badnest/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
try:
from homeassistant.components.climate import ClimateEntity
except ImportError:
from homeassistant.components.climate import ClimateEntity as ClimateEntity
from homeassistant.components.climate import ClimateDevice as ClimateEntity

from homeassistant.components.climate.const import (
ATTR_TARGET_TEMP_HIGH,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/badnest/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(self, device_id, sensor_type, api):
@property
def unique_id(self):
"""Return an unique ID."""
return self.device_id + '_' + self._sensor_type
return f"{self.device_id}_{self._sensor_type}"

@property
def name(self):
Expand Down

0 comments on commit dc6fbbb

Please sign in to comment.