mirror of
https://github.com/home-assistant/core.git
synced 2025-05-13 02:19:16 +00:00
Remove unique ID from netatmo (#12317)
* Remove unique ID from netatmo * Shame platform in error message
This commit is contained in:
parent
f28fa7447e
commit
2e3524147c
homeassistant
@ -131,8 +131,6 @@ class NetatmoBinarySensor(BinarySensorDevice):
|
|||||||
self._name += ' / ' + module_name
|
self._name += ' / ' + module_name
|
||||||
self._sensor_name = sensor
|
self._sensor_name = sensor
|
||||||
self._name += ' ' + sensor
|
self._name += ' ' + sensor
|
||||||
self._unique_id = data.camera_data.cameraByName(
|
|
||||||
camera=camera_name, home=home)['id']
|
|
||||||
self._cameratype = camera_type
|
self._cameratype = camera_type
|
||||||
self._state = None
|
self._state = None
|
||||||
|
|
||||||
@ -141,11 +139,6 @@ class NetatmoBinarySensor(BinarySensorDevice):
|
|||||||
"""Return the name of the Netatmo device and this sensor."""
|
"""Return the name of the Netatmo device and this sensor."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self):
|
|
||||||
"""Return the unique ID for this sensor."""
|
|
||||||
return self._unique_id
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the class of this sensor, from DEVICE_CLASSES."""
|
"""Return the class of this sensor, from DEVICE_CLASSES."""
|
||||||
|
@ -67,8 +67,6 @@ class NetatmoCamera(Camera):
|
|||||||
self._vpnurl, self._localurl = self._data.camera_data.cameraUrls(
|
self._vpnurl, self._localurl = self._data.camera_data.cameraUrls(
|
||||||
camera=camera_name
|
camera=camera_name
|
||||||
)
|
)
|
||||||
self._unique_id = data.camera_data.cameraByName(
|
|
||||||
camera=camera_name, home=home)['id']
|
|
||||||
self._cameratype = camera_type
|
self._cameratype = camera_type
|
||||||
|
|
||||||
def camera_image(self):
|
def camera_image(self):
|
||||||
@ -112,8 +110,3 @@ class NetatmoCamera(Camera):
|
|||||||
elif self._cameratype == "NACamera":
|
elif self._cameratype == "NACamera":
|
||||||
return "Welcome"
|
return "Welcome"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self):
|
|
||||||
"""Return the unique ID for this camera."""
|
|
||||||
return self._unique_id
|
|
||||||
|
@ -113,18 +113,12 @@ class NetAtmoSensor(Entity):
|
|||||||
module_id = self.netatmo_data.\
|
module_id = self.netatmo_data.\
|
||||||
station_data.moduleByName(module=module_name)['_id']
|
station_data.moduleByName(module=module_name)['_id']
|
||||||
self.module_id = module_id[1]
|
self.module_id = module_id[1]
|
||||||
self._unique_id = '{}-{}'.format(self.module_id, self.type)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self):
|
|
||||||
"""Return the unique ID for this sensor."""
|
|
||||||
return self._unique_id
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Icon to use in the frontend, if any."""
|
||||||
|
@ -240,8 +240,12 @@ class EntityPlatform(object):
|
|||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
'Invalid entity id: {}'.format(entity.entity_id))
|
'Invalid entity id: {}'.format(entity.entity_id))
|
||||||
elif entity.entity_id in component_entities:
|
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(
|
raise HomeAssistantError(
|
||||||
'Entity id already exists: {}'.format(entity.entity_id))
|
msg)
|
||||||
|
|
||||||
self.entities[entity.entity_id] = entity
|
self.entities[entity.entity_id] = entity
|
||||||
component_entities.add(entity.entity_id)
|
component_entities.add(entity.entity_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user