Allow the ability to create a custom device which can contain multiple entities.
For example defining multiple entities for my smart meter’s MQTT feed results in multiple entities, however it would be great to pull these all together under a single device.
The idea is that devices can only be automatically created. I get the idea, but don’t agree with it. It would be nice to have the ability to add custom devices to any integration.
if you mean add discovery entries just to create devices, then yes. Following this logic we could drop yaml for mqtt at all replacing with discovery entirely.
I believe OP meant to add ability to create device via yaml configuration. And tbh why not? there are attributes for that ready to use.
I voted for this WTH but here’s a workaround from 123 which is just using the MQTT discovery feature but the device and entities are still “manually” created
I also voted for that - I did see the script, but couldn’t get my head around how I could fit a bunch of entities from my smart meter under a light… then gave up as too much faff.
Personally I changed all my MQTT yaml definitions by automations running at home assistant start when they changed the syntax for MQTT in yaml. Since I had to rewrite it anyway. The good way is to set the payload as a variable where you can use yaml syntax that looks a lot like classical yaml definitions, then do a loop like that:
You can see that in the for_each I put settings in a config entry that look like the YAML for MQTT configuration (in fact I copy-pasted most of it). I decided to move unique_id out of the config because it is used in the discovery topic but I could as well have fetched it from the config and not needing to merge it afterwards.
The good part is that you can have common configuration without repeating it, and you also can use other kind of loops to create entities programmatically, as in the following (which is part of a recurring todolist implementation).
Also note I saw here or on GitHub discussions about devices made from the UI to group entities. AFAIU nobody is against it, it is just a matter of when/how to do that. I tend to think this is a bigger scale project with multiple ramifications so don’t hope too much I guess.
What is the implementation when working with other entities not related to MQTT? For example SNMP and templates?
I have a PDU that has switched outlets and power monitoring. I use SNMP switches to change the state and an SNMP sensor to monitor usage. All of the entities are separate in HA even through they are the same device.
Additionally if you create any template sensors it would be nice to tie them into the new or existing devices.
I have a SwitchBot Tilt on my blinds. To get the % open/closed correct you need to create a template cover. However, that template sensor is not part of the device in HA, making harder to manage that device and all related entities.
Yes there is still no implementation to add entities to non-MQTT devices. See petro’s comment earlier in this thread with links to two other WTH’s that relate more to that: