tomaae/homeassistant-portainer

[Bug] Container entity environment attribute shows incorrect endpoint name

mash2k3 opened this issue · 1 comments

I have 5 environments, i connect 4 of them using portainer agent to portainer installed on my main environment.
So 4 portainer agents installs and 1 portainer install.
I connected the portainer install to the integration.
To make it easy to explain the issue lets name my 5 environments a b c d e
The integration created 2 devices and named them Portainer Endpoints and Portainer a
It added all the container entities under Portainer a which is not a big deal for me.
But inside every container entity there is a attribute called environment that is set to e on all of them.
That is the issue i wanted to point out because i have the same container running on more than 1 endpoint and i can not differentiate.

How to reproduce the issue

On initial install

Expected behavior

Each container entity to have the correct environment name

Screenshots

image

Software versions

  • Home Assistant version: 2023.10.5
  • Portainer integration version: v1.0.2
  • Portainer software version: 2.19.1

Diagnostics data

config_entry-portainer-e16601bca67a2762bd40d71edfa86a23.json.txt

I just discovered this really cool integration, but I can already confirm this bug. I have my Portainer-CE instance running on an Intel NUC, and I have 2 Portainer agents on my NAS and a Raspberry Pi. Every single container sensor has my NAS listed as its environment, which is incorrect. Sadly, #35 was auto-closed after going stale twice.

Update: being impatient as I am (😇), I manually applied the changes made to the 2 files in #35 and restarted HA. The changes seem to be working just fine:

  • Every container entity now shows the correct environment
  • Instead of having a single device for all container entities, every endpoint now has its own device with the appropriate container entities linked to it

As a last step, I removed the integration and added it back. I did this to get rid of the empty device that previously held all container entities and to update the entity_id of each container entity with the endpoint name.