ldotlopez / ha-ideenergy

ideenergy integration for home-assistant
GNU General Public License v3.0
73 stars 13 forks source link

Platform ideenergy does not generate unique IDs. #36

Closed feserdel closed 1 year ago

feserdel commented 1 year ago

Good morning, after installing ideenergy and creating several contracts, by adding integration again, only the first contract show values. Second and third contracts do not show values for accumulated consumption.

E5034B5F-C180-4922-AD57-2F25F67E27D8_4_5005_c

On HA log the following lines appear:

2023-02-02 13:56:19.348 ERROR (MainThread) [homeassistant.components.sensor] Platform ideenergy does not generate unique IDs. ID accumulated-consumption already exists - ignoring sensor.es0021_accumulated_consumption 2023-02-02 13:57:49.128 ERROR (MainThread) [homeassistant.components.sensor] Platform ideenergy does not generate unique IDs. ID accumulated-consumption already exists - ignoring sensor.es0021_accumulated_consumption 2023-02-02 14:01:28.681 ERROR (MainThread) [homeassistant.components.sensor] Platform ideenergy does not generate unique IDs. ID accumulated-consumption already exists - ignoring sensor.es0021_accumulated_consumption 2023-02-02 14:01:28.683 ERROR (MainThread) [homeassistant.components.sensor] Platform ideenergy does not generate unique IDs. ID historical-consumption already exists - ignoring sensor.es0021_historical_consumption

ldotlopez commented 1 year ago

The multi-contract stuff is not tested at all… I don't have access to any contract with multiple contacts.

But I can see some code that can be conflictive: https://github.com/ldotlopez/ha-ideenergy/blob/main/custom_components/ideenergy/entity.py#L134

Changing unique_id generation method (and therefore changing it for existing installations) may have side effects.

Let me run some tests.

ldotlopez commented 1 year ago

Hi.

(Please read the warnings at the bottom.)

I made some modifications to the 'main' branch to resolve the issue with unique_id generation. This should resolve part of the problem, potentially entirely. If you are using HACS, switch to version 'main'.

Let me known how it goes

Warnings: The changes include registry migrations, so be sure to backup your data.

feserdel commented 1 year ago

Good morning. After switching to "main", and delete contracts (migration did not work, error received), adding integrations again, now I have all three contracts working. Lets wait a few days until confirm that sensor measurements are working. Thanks!

ldotlopez commented 1 year ago

Hi @feserdel

Thanks for the feedback :+1:

i-de is a bit fussy with multiple contracts, some user have reported bans from i-de.es.