-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Feature Request: Incorporate Home Assistant device registry attributes #646
Comments
Put together how i'd think the mqtt config payload would likely output using the pressure entity from a Xiaomi temp/pressure/humidity sensor I have as an example:
One problem I can see though would be the unique name / friendly name for the entire device that could be used for said device. Believe there would always need to be a unique_id set though at present it's only set if friendly name isn't? The main thing needed though would just be identifier being deviceID as that is what is used to differentiate between devices and pair up entities with devices within MQTT discovery now. |
This should be implemented, but I don't see anything that changed in home assistant. Where should I be looking for? |
I see, but what changes are visible in HA beacuse of this? Does it add any functionallity at all? |
HA is moving to a point of allowing more and more components to be set up in the front end (rather than configuration.yaml) via the integrations platform. components set up via this get a nice config front end showing entities that use that integration, and now also grouped in to devices. So, device X has sensor Y and switch Z. Without the commit you just added that page looked like this: With the single device i'd added via zigbee2mqtt showing under "Entities without devices". As i add more and more that box would grow with all the entities grouped up under the same heading. I've just installed the edge addon to test that commit and after a restart of homeassistant that page now looks like this: As i add more devices they will then get their own cards listing the entities associated with that device. Much cleaner :D I'm hoping HA will add a way to edit the names of devices though. As in ESPhomeLib (which the other devices are from) i edit the device name in the config before i write the firmware to the device. One other aspect of this registry is that you can also add devices without entities, such as hubs, and then link the devices to that hub using the Admittedly this is all just to make the integrations page cleaner but i'm assuming it'll be used more and more and get expanded further as the project gets bigger. |
Sorry for the wall of comments, but done some further testing of the commit. This will not currently work if friendly name is set as a uniqueID is not generated and added to the config payload. UniqueID is required for the entity to be added to the entity registry (or looked up within it), and the device will not be registered if it cannot find the entity in the entity registry. Without friendly name set, the config payload of the temperature sensor looks like this:
The entity is created, looked up in the entity registry, if it doesn't exist it is added, and then the device is added or updated in the device registry and both are associated with each other in the front end. If i change the friendly name for the device to livingroom_aqara_tph the config payload for the temperature sensor now looks like this:
The entities themselves are created, but are not added to the entity registry as there is no uniqueID, and thus no device is associated with it. Meaning it will not show up in the integrations config page for mqtt discovery. If #419 is merged that should fix the entity registry issue, allowing the device itself to be registered as well. I don't see how the uniqueID being present would cause any issue with entity creation which i believe was the concern in that pull? Also, I propose that the device name be changed to the friendly name if that is supplied, to differentiate between multiple connected devices of the same type. It will still work if there are multiple devices of the same name though, so having the default be the description should still be fine. eg:
I modified the payloads for each entity via a publish to each ones config path (without restarting zigbee2mqtt) to test and the result was the device showing up with the correct friendly name, and with the entities having the correct friendly name too. Once again, apologies for the long comments, just trying to be thorough. Also apologies for asking for these changes to be made rather doing them myself but at present I do not have an easily modifiable test setup as i'm running through the hassio addon. |
Looks like mqtt light is one component not yet fully integrated with the device registry. PR for that is found here 19013 Also looks like there has been a change with how mqtt light is discovered in mqtt discovery, which might be why the entities themselves aren't appearing though backwards compatibility was apparently implemented? PR to that is here 18227 EDIT: Ran your example, posting that payload to Had a bit of a look around and does look like it's due to the change i mention above, and that added the ability for an mqtt light to show up in integrations when the new Looks like light is the only one to use it within zigbee2mqtt so would have to replace MQTT lights will then get an entity entry in the current public version of HA (though if changed now it'll only appear as a basic light) and also a device entry when 19013 is merged. I'll submit a PR shortly to add support for lights in the integrations panel. Also, if you test changing the attribute on the config payload make sure to delete the |
added #656 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@cbrherms and @Koenkk sorry I missed the fun discussion last year, but just wanted to understand the reasoning behind having I'm just asking since I am using somewhat of a complicated naming scheme and the |
As far as I remember there is not a real reason for this, perhaps we should always use |
The breaking change is the reason why I am regretful that I haven't been discussing this with you last year. I don't even see a reason for having this value hardcoded - it only adds to the length but does not make it more unique than it already is. And given that in the HA documentation they explicitly try to make the MQTT payloads as small as possible by providing aliases and way to substitute base_topics, I was thinking that this should be a common goal for this project too. |
I completely agree, it was a wrong decision to include it. |
While we're at it - the |
The |
I understand your concern that this might cause unexpected behavior if and when someone updates his |
As a workaround I am using the newly introduced #1030 to overwrite the |
the latest change allows me to overwrite identifier too:
|
…kk/zigbee2mqtt#646" This reverts commit 7ea1fc66c27f1ff7fb88df66f288dc28f0228289.
As of homeassistant 0.81 we can now see entities grouped together as their devices within the front end when they are added using MQTT discovery.
If some further attributes can be added to Mqtt messages when the homeassistant option is enabled then this feature could be implemented.
The documentation for it is here:
https://developers.home-assistant.io/docs/en/device_registry_index.html
Mac address of device can be unique identifier, plus we could provide the device type and manufacturer.
The text was updated successfully, but these errors were encountered: