mirror of
https://github.com/home-assistant/core
synced 2024-09-06 10:29:55 +02:00
Add unique_id to Nest Sensors (#16869)
* Add unique_id * Add device_info * Fix typo * Update __init__.py
This commit is contained in:
parent
92a5068977
commit
bab079f649
@ -309,6 +309,37 @@ class NestSensorDevice(Entity):
|
||||
"""Do not need poll thanks using Nest streaming API."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return unique id based on device serial and variable."""
|
||||
return "{}-{}".format(self.device.serial, self.variable)
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return information about the device."""
|
||||
if not hasattr(self.device, 'name_long'):
|
||||
name = self.structure.name
|
||||
model = "Structure"
|
||||
else:
|
||||
name = self.device.name_long
|
||||
if self.device.is_thermostat:
|
||||
model = 'Thermostat'
|
||||
elif self.device.is_camera:
|
||||
model = 'Camera'
|
||||
elif self.device.is_smoke_co_alarm:
|
||||
model = 'Nest Protect'
|
||||
else:
|
||||
model = None
|
||||
|
||||
return {
|
||||
'identifiers': {
|
||||
(DOMAIN, self.device.serial)
|
||||
},
|
||||
'name': name,
|
||||
'manufacturer': 'Nest Labs',
|
||||
'model': model,
|
||||
}
|
||||
|
||||
def update(self):
|
||||
"""Do not use NestSensorDevice directly."""
|
||||
raise NotImplementedError
|
||||
|
Loading…
Reference in New Issue
Block a user