mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00: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."""
|
"""Do not need poll thanks using Nest streaming API."""
|
||||||
return False
|
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):
|
def update(self):
|
||||||
"""Do not use NestSensorDevice directly."""
|
"""Do not use NestSensorDevice directly."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
Loading…
x
Reference in New Issue
Block a user