Skip to content
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

Merged
merged 4 commits into from
Sep 26, 2018

Conversation

cgarwood
Copy link
Member

Description:

Adds a unique_id property to the Nest sensor and binary_sensor components. Unique ID is generated based on device.serial (like the climate 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:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

@balloob
Copy link
Member

balloob commented Sep 25, 2018

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 ?

@cgarwood
Copy link
Member Author

I don't have a Nest camera to test with unfortunately :(

@balloob
Copy link
Member

balloob commented Sep 25, 2018

I know @awarecan has 4 👍 Care to take a look if we can use serial instead of device_id ?

@awarecan
Copy link
Contributor

That is overwhelming

image

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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment

@awarecan
Copy link
Contributor

I also think we should use this PR to add device_info to those sensors

@ghost ghost assigned balloob Sep 26, 2018
@@ -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'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

@balloob balloob merged commit bab079f into home-assistant:dev Sep 26, 2018
@ghost ghost removed the in progress label Sep 26, 2018
@awarecan awarecan changed the title Add unique_id to Nest Sensors Add unique_id and device_info to Nest Sensors Sep 26, 2018
@awarecan awarecan added this to the 0.79 milestone Sep 26, 2018
@cgarwood cgarwood deleted the nest_sensor_unique_id branch September 26, 2018 12:16
balloob pushed a commit that referenced this pull request Sep 27, 2018
* Add unique_id

* Add device_info

* Fix typo

* Update __init__.py
@balloob balloob mentioned this pull request Sep 28, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants