britkat1980 / ha-addons

11 stars 1 forks source link

v3 error with duplicate sensor id's for battery entities #23

Open gcoan opened 1 day ago

gcoan commented 1 day ago

I have two Gen 1 hybrid inverters, called G and H in GivTCP.

G has a single 9.5kW battery connected, H has a single 5.2 connected.

Since ugrading to GivTCP v3.0.0 I can see a whole load of errors in the HA log about duplicate id's from MQTT:

2024-09-19 21:45:14.822 ERROR (MainThread) [homeassistant.components.sensor] Platform mqtt does not generate unique IDs. ID G_DX2327G139_Battery_Capacity is already used by sensor.g_dx2327g139_battery_capacity - ignoring sensor.g_dx2327g139_battery_capacity_2
2024-09-19 21:45:14.824 ERROR (MainThread) [homeassistant.components.sensor] Platform mqtt does not generate unique IDs. ID G_DX2327G139_Battery_Cell_10_Voltage is already used by sensor.g_dx2327g139_battery_cell_10_voltage - ignoring sensor.g_dx2327g139_battery_cell_10_voltage_2

This is occurring for both batteries, but only for the battery entities, no such warnings from any of the inverter entities.

Shutdown HA and all the add-ons, and the errors re-appeared in the clean log.

~~Curiously looking at the voltage history, it looks like the barry sensors were not being read for the last day (I upgraded to v3 last night), but are now being read OK: image

No such similar pattern with the inverter entities, e.g. SoC tracked OK overnight and through today.~~

Correction: the battery cell temperatures and voltages are NOT being reported by GivTCP v3, when I thought they were being reported after a reboot it was because I'd accidentally reverted back to GivTCP v2.4.9 which was working fine.

No issue with the inverter entities, only the battery entities.

I wonder from the error message if the issue is that the original battery sensor id was all in lower case but the new battery sensor id is in upper case which is why givtcp/mqtt tries to create new (duplicate) sensors and fails.

Shutdown and restarted everything again in case it was a one-off set of errors, but no, they all still appear again my logfile and the battery sensors are not being populated

gcoan commented 23 hours ago

Another observation, with MQTT Explorer I can see what appears to be duplicated battery sensors under the homeassistant/givenergy tree:

image

There are sensors named as voltage and also _voltage. Maybe one set created by GivTCP v2.4.9 and one set by v3 which is what's causing the problem?

SwiftRR commented 12 hours ago

I am having similar issues after moving to v3 from v2.4.9

My battery details are all 'unknown'. I have 11 MQTT devices shown and I can see duplicates:

image

I have GivTCP DY2218G702 (all blank), followed by GivTCP DY2218G702 Battery details (all unknown). With the same for GivTCP DY2219G082.

I can also see this error in System logs

image

I also see this error for my single inverter (I have 2 batteries)

image

Like @gcoan, in MQTT Explorer all the inverter and battery info shows up twice:

  1. under Givenergy
  2. under homeassistant. image

I am seeing one set of entries under 'Battery stack', the other not under 'Battery stack' The HA data shows all the battery details under my inverter but twice. e.g.

image

And again

image

The inverter/Battery entries appear to be under 'Battery stack'.

In conclusion, the battery details do appear to be there. It is just that they cannot be directly views in Devices and Services/Devices (MQTT list)

Rob

britkat1980 commented 12 hours ago

V3 is supposed to remove all old discovery messages, and replace with new, but it is clear that battery entries are not being removed. Temp fix is to manually delete the messages out of the MQTT broker, then restart GivTCP. This will remove the _2 entities and ensure your original entities are properly updated

gcoan commented 11 hours ago

V3 is supposed to remove all old discovery messages, and replace with new, but it is clear that battery entries are not being removed. Temp fix is to manually delete the messages out of the MQTT broker, then restart GivTCP. This will remove the _2 entities and ensure your original entities are properly updated

@britkat1980 Which entries are to be removed from MQTT?

I assume its under homeassistant tree, is it the entities with just battery id prefix or inverter then battery id prefix, or both?

At the moment I have reverted back to 2.4.9 which is working fine

qamar-yaunos commented 5 hours ago

@britkat1980 I hope you're well.

I am also having the same issue but I don't have 2 batteries.

My install was done in January but I needed a replacement battery and the entities for the old battery are still showing.

Can the entities for the old battery just be deleted?

gcoan commented 2 hours ago

My install was done in January but I needed a replacement battery and the entities for the old battery are still showing.

Can the entities for the old battery just be deleted?

I had my battery replaced earlier this year and had stale MQTT sensors for the old battery in HA. You can't delete them directly from Home Assistant, need to install MQTT Explorer add-on and delete the messages from the MQTT queues