-
-
Notifications
You must be signed in to change notification settings - Fork 28
Improve HA device registry and support multiple devices in one config #1335
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
Improve HA device registry and support multiple devices in one config #1335
Comments
I would also like to see this, I have an ESP32 reading Xiaomi ble temp sensors, and it would be nice if they were different devices. Might be possible to get the platform to register as sub device of the integration? or something like this in yaml esp32_ble_tracker:
device:
bedroom:
name: Bedroom
model: lywsdcgq
manufacturer: Xiaomi
sensor:
- platform: xiaomi_lywsdcgq
mac_address: xx:xx:xx:xx:xx:xx
temperature:
name: ${name} Temperature
state_class: measurement
humidity:
name: ${name} Humidity
state_class: measurement
battery_level:
name: ${name} Battery Level
state_class: measurement I also think this will require work on the HomeAssistant integration as well to add device support. |
This is certainly possible from the HA side, and is also on our list TODO at some point. But will probably require quite a bit of work. |
I am not super familiar with ESPHome development, however I am able and willing to help with the implementation in Home Assistant, where needed. And indeed, I can imagine that this requires a lot of work and planning. |
I also think this will be an excellent feature, and have started some of the groundwork in esphome/esphome#2560. At the moment, this will only make the device registry more configurable for a single entry, but I'd be happy to participate in a follow-up PR to expand that to multiple devices. |
May be related to #1714 |
I've also been wanting to do this, and I've got the time to work on the implementation as well (it will definitely be a significant amount of work). This is the same request as in #1714 (which was closed) and in #2275. As a first step, I've written a proposal document describing why this would be useful, and how I'd go about implementing it. The doc is here and comments are most welcome. For those who don't want to use Google Docs, I've attached V1 of the proposal doc to this comment, and I'll attach future versions as well as we make progress towards a decision. V1 - Proposal Connected Devices in ESPHome.pdf @nagyrobi If you want to close #2275 in favor of this one, so the discussion can live in one issue, that might be good. |
I leave here the suggestion I made in #2275 to contribute to the discussion:We often use the same ESP device to connect sensors that are not always related but are physically close, taking better advantage of the ESP's GPIO. In these cases, things can get pretty confusing on the Home Assistant, as the device will have a lot of unrelated entities. With that in mind, I would like to suggest a resource so that it is possible to configure in ESPHome which device each entity will be linked to when exposed by the API or MQTT. It would look something like the code below (omitting
These secondary devices would be linked to the main (default) device by Home Assistant's I don't have the knowledge to implement such features, so if anyone is willing to evaluate this possibility I would be very grateful! This configuration would only have an effect on exposing the entities to the Home Assistant API or via MQTT (maybe including the webserver's dashbord?). |
If you take a look at the last example in the proposal document, it provides the functionality you are looking for (combining unrelated |
I read the proposal and I also think it is good. Greatly improves the user experience when the ESP board has multiple unrelated components. Thank you @kpfleming for your willingness to make this a reality. |
this is which I need |
Hi @kpfleming, please let us know if you proceeded with the implementation based on your proposal. This feature would be really nice! Thanks. |
I've got some non-work time coming up over the next two weeks so I plan to start working on this soon. Hopefully @jesserockz will get a few moments to give this idea a sanity check before I get too far into it! |
I have nothing against the idea, as long as it doesnt complicate the codebase too much. I would think something like this in config: esphome:
...
sub_devices:
- id: that_ble_thermometer
name: ...
manufacturer: ...
mac: ...
sensor:
- platform: some_ble_sensor_platform
name: Temperature
device_id: that_ble_thermometer
... In terms of c++, maybe |
@kpfleming reading your proposal I don't think that the components already defining their own device ID brings benefits... because in practice I can have things from different components on the same functional device in Home Assistant. I would limit the device id to be a user option to be defined in the ESP board code, in line with this suggestion from @jesserockz above. |
I totally didnt see your message above with examples @dougiteixeira. Thats exactly how I envision it being =) |
I think that's a misunderstanding; in the examples in the doc the 'device_id' attributes are references to device objects defined in the |
You're right, I think I confused options 1 and 3 thinking that the proposal was both. sorry... |
I would also love to see this feature implemented, my use case are 2 identical BLE devices with a lot of sensors and controls. |
I would really love to see this. There is integration of SAMSUNG ACs which would really benefit from this. SAMSUNG AC unit controller. |
Started looking into the codebase to implement this but realized it can be done in many ways. All from very complex and integrated ways to very simplistic but maybe also a bit "hacky". So a simple way to do this that I was thinking of was to do the config-changes as proposed above with a The more complex (and more correct) way would be to dig in to the ESPHome device registration architecture and actually create virtual devices to which entities are associated. This would then also allow for the extra requests to assign different native areas etc. to each device. But for this option someone more familiar with the ESPHome architecture will have to do the change. The DeviceRegistry part of Home Assistant is still a bit hazy to me and cant really say I know what the rules are to group entities together to a single device or if it should generate two individual devices. So input is welcomed. |
I have the same issue, where I have an |
Another use case: |
With introduction of esphome/esphome#8187 this feature could be even more relevant to add. |
my EPS32-S3 reads out multiple devices in my Camping-Van and publish the state to mqtt with HA-Discovery. 1x victron ble i really like to split them in multiple devices |
Got curious if I after some more experiences with ESPHome could solve this in another attempt. My local compare PR dala318/esphome#8 is in many parts the same as previous but actually implements a SubDevice section in the device registry which entities can reference by its id. But since it's necessary to fiddle around with a lot of Core components it should be at least partially approved by the maintainers of project before any more work is put in to it. |
This would exclude any/all using MQTT, no? |
I have not looked in to MQTT at all in this implementation, feel free to investigate where that would make sense to add if possible. |
Official PRs are now submitted for Core maintainers of ESPHome to have a look at it and give feedback on the approach. |
Describe the problem you have/What new integration you would like
I recently got started with ESPHome and I like it very much! Most of my cases for ESPHome are in situations where I try to build a 'digital twin' for multiple physical devices. Think of a physical standing desk or Xiaomi MiFlora devices.
However, currently when you configure this, it will add all entities to a single espressif device in Home Assistant. It would be great if you could use the ESPHome YAML to create devices and decide which sensors are linked to which devices.
Use cases:
(or even a combination of the ones above)
Eventually, this would allow us to show the
model
,manufacturer
andfirmware
of the device we mimic, instead of our ESPHome device. I was looking to port https://github.com/devWaves/SwitchBot-MQTT-BLE-ESP32, however the features regarding device registry and information are not possible (yet) with ESPHome. And for bluetooth devices, you could perhaps even add the mac address to the connection info.Screenshots

Current situation
Proposed situation:

(and with multiple devices, there would be multiple entries)
Please describe your use case for this integration and alternatives you've tried:
Prefixing all entities with the digital twin device name, however this will be messy at some point and doesn't show up nice in the Home Assistant device registry.
Additional context
This would mainly be a cosmetic change, so I can understand that this is not something which has any priority over the other issues. However, perhaps there is someone that would like to tackle this, or work with me to see how we can add this.
(unfortunately my C++ is really limited, however I can do Python :-)).
Example YAML
The text was updated successfully, but these errors were encountered: