-
-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unique_id and device_info to Nest Sensors #16869
Conversation
I would prefer serial over device_id, as re-pairing a device generates a new ID probably. However, I could not find docs about the serial field. I would prefer if camera could switch to serial, could you see if that could work ? |
I don't have a Nest camera to test with unfortunately :( |
I know @awarecan has 4 👍 Care to take a look if we can use |
That is overwhelming entity registry sample {
"config_entry_id": "2ec0420dfed44a20a25d608b4a70927e",
"device_id": null,
"disabled_by": null,
"entity_id": "binary_sensor.family_room_camera_motion_detected",
"name": null,
"platform": "nest",
"unique_id": "hBqsoU9F-yRI_2ElJSeSofs6yRft14U7ylclTSbGYaUwaBlGBMIdQQ-motion_detected"
} This unique_id is not Camera serial number show up in Nest App. Nest App used MAC address as camera's serial number. In python-nest, serial === device_id |
@@ -128,6 +128,11 @@ def device_class(self): | |||
"""Return the device class of the binary sensor.""" | |||
return _VALID_BINARY_SENSOR_TYPES.get(self.variable) | |||
|
|||
@property | |||
def unique_id(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property should move to NestSensorDevice
at
https://github.com/home-assistant/home-assistant/blob/b91a061cef55d38fa70a49b749c200eb793bf068/homeassistant/components/nest/__init__.py#L275
@@ -135,6 +135,11 @@ def device_class(self): | |||
"""Return the device class of the sensor.""" | |||
return SENSOR_DEVICE_CLASSES.get(self.variable) | |||
|
|||
@property | |||
def unique_id(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment
I also think we should use this PR to add device_info to those sensors |
@@ -317,7 +317,7 @@ def unique_id(self): | |||
@property | |||
def device_info(self): | |||
"""Return information about the device.""" | |||
if not hasattr(self.device, 'name_log'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣
* Add unique_id * Add device_info * Fix typo * Update __init__.py
Description:
Adds a unique_id property to the Nest
sensor
andbinary_sensor
components. Unique ID is generated based ondevice.serial
(like theclimate
entity) and the sensor type.I only have a thermostat to test with, it would be great if someone with a Nest Protect or Nest Camera could test it as well. I noticed the Nest camera component computed its unique_id with a different field, but I don't have a camera to confirm what data is available for it.
Related issue (if applicable): N/A
Pull request in home-assistant.io with documentation (if applicable): N/A
Example entry for
configuration.yaml
(if applicable):N/A
Checklist:
tox
. Your PR cannot be merged unless tests pass