ualex73 / monitor_docker

Monitor Docker containers from Home Assistant
Apache License 2.0
267 stars 34 forks source link

Request: unique_id registry for entities, to allow giving sensors an Area and UI customization #62

Closed jtaseff closed 1 month ago

jtaseff commented 3 years ago

Right now all of the automatically created sensors and switches just reside under the area "Switch" and "Sensor" in lovelace and the entity list. Would love to be able to group them into their own area, either using the UI or a config flag.

Been messing with it a bit to give a unique_id, and can get it to show up with "integration" of "monitor_docker" sometimes, but always errors when its tries to add to the entity registry.

This entity ("switch.docker_homeassistant") does not have a unique ID, therefore its settings cannot be managed from the UI.

heinz-matt commented 1 year ago

Hi @jtaseff, I wanted the same thing so I did a bit of digging. You can change instances of entity_id to unique_id in the sensor.py and switch.py scripts, these are located in the custom_components/monitor_docker folder. Then when you restart Home Assistant you should be able to add them to areas.

mcarlosro commented 1 year ago

Hi @ualex73,

I'm also interested on this request because I have my own naming convention for the id.

I've seen suggestion from @heinz-matt but the problem is that I would need to make the change any time there is a new release.

As it looks the change is not complex at all, maybe @jtaseff and I will be lucky for the next release as a Christmas present.

Thanks for this great integration.

ualex73 commented 1 year ago

The problem is that we do not have a real unique identifier to generate "unique_id" from, normally things like a MAC/serialnumber is used for this (I use the MAC in one of my other integrations).

Using the docker name itself for "unique_id" is more a hack, not a real proper solution. In the new year I will investigate if I can add a switch for it (so leave the current behavior, and make "unique_id" possible if you want to use it).

Anyway, PRs are always welcome.

Hadatko commented 9 months ago

+1

QuaiGoner commented 6 months ago

Hi @jtaseff, I wanted the same thing so I did a bit of digging. You can change instances of entity_id to unique_id in the sensor.py and switch.py scripts, these are located in the custom_components/monitor_docker folder. Then when you restart Home Assistant you should be able to add them to areas.

Hello @heinz-matt , do you have an example on what to change in the py scripts? Simply changing all entity_id to unique_id did not do the trick for me.

Thank in advance

deluxestyle commented 2 months ago

any update on this? even now with labes and categories a unique_id would be great.

ualex73 commented 1 month ago

The original problem exist, I cannot generate unique identifier in HA. the entity name must have the docker name, otherwise we cannot re-use it across restarts/recreates. I will add this note to the README.md and close this one. @deluxestyle I will look at labels in the near future.