Skip to content

Commit

Permalink
Remove unique ID from netatmo (#12317)
Browse files Browse the repository at this point in the history
* Remove unique ID from netatmo

* Shame platform in error message
  • Loading branch information
balloob committed Feb 12, 2018
1 parent 34ccfae commit 56b185f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
7 changes: 0 additions & 7 deletions homeassistant/components/binary_sensor/netatmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ def __init__(self, data, camera_name, module_name, home,
self._name += ' / ' + module_name
self._sensor_name = sensor
self._name += ' ' + sensor
self._unique_id = data.camera_data.cameraByName(
camera=camera_name, home=home)['id']
self._cameratype = camera_type
self._state = None

Expand All @@ -141,11 +139,6 @@ def name(self):
"""Return the name of the Netatmo device and this sensor."""
return self._name

@property
def unique_id(self):
"""Return the unique ID for this sensor."""
return self._unique_id

@property
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
Expand Down
7 changes: 0 additions & 7 deletions homeassistant/components/camera/netatmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ def __init__(self, data, camera_name, home, camera_type, verify_ssl):
self._vpnurl, self._localurl = self._data.camera_data.cameraUrls(
camera=camera_name
)
self._unique_id = data.camera_data.cameraByName(
camera=camera_name, home=home)['id']
self._cameratype = camera_type

def camera_image(self):
Expand Down Expand Up @@ -112,8 +110,3 @@ def model(self):
elif self._cameratype == "NACamera":
return "Welcome"
return None

@property
def unique_id(self):
"""Return the unique ID for this camera."""
return self._unique_id
6 changes: 0 additions & 6 deletions homeassistant/components/sensor/netatmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,12 @@ def __init__(self, netatmo_data, module_name, sensor_type):
module_id = self.netatmo_data.\
station_data.moduleByName(module=module_name)['_id']
self.module_id = module_id[1]
self._unique_id = '{}-{}'.format(self.module_id, self.type)

@property
def name(self):
"""Return the name of the sensor."""
return self._name

@property
def unique_id(self):
"""Return the unique ID for this sensor."""
return self._unique_id

@property
def icon(self):
"""Icon to use in the frontend, if any."""
Expand Down
6 changes: 5 additions & 1 deletion homeassistant/helpers/entity_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,12 @@ def _async_add_entity(self, entity, update_before_add, component_entities,
raise HomeAssistantError(
'Invalid entity id: {}'.format(entity.entity_id))
elif entity.entity_id in component_entities:
msg = 'Entity id already exists: {}'.format(entity.entity_id)
if entity.unique_id is not None:
msg += '. Platform {} does not generate unique IDs'.format(
self.platform_name)
raise HomeAssistantError(
'Entity id already exists: {}'.format(entity.entity_id))
msg)

self.entities[entity.entity_id] = entity
component_entities.add(entity.entity_id)
Expand Down

0 comments on commit 56b185f

Please sign in to comment.