Closed SciFi-Bob closed 1 year ago
Hi again, doing a bit of digging and it looks like for some reason the battery serial number is not iterating for the BatteryBasicSensor creation. The behaviour I am seeing is that when my three batteries are added it will only create the basic sensors for the first battery.
Interestingly the batteryCellsVoltageSensor and remainingCapacitySensor that get created after DO take the serial number as a unique ID correctly and get created.
The end result is that we get the batteries but only one has all the sensors, the remaining have just the voltage and capacity as mentioned above.
Hey!
I have 3 batteries on my system and because of this as your integration creates the battery sensors I get the following errors:-
2023-03-02 23:59:07.900 ERROR (MainThread) [homeassistant.components.sensor] Platform givenergy_local does not generate unique IDs. ID BI2221G078_battery_soc already exists - ignoring sensor.battery_charge 2023-03-02 23:59:07.906 ERROR (MainThread) [homeassistant.components.sensor] Platform givenergy_local does not generate unique IDs. ID BI2221G078_battery_num_cycles already exists - ignoring sensor.battery_cycles 2023-03-02 23:59:07.907 ERROR (MainThread) [homeassistant.components.sensor] Platform givenergy_local does not generate unique IDs. ID BI2221G078_v_battery_out already exists - ignoring sensor.battery_output_voltage 2023-03-02 23:59:07.933 ERROR (MainThread) [homeassistant.components.sensor] Platform givenergy_local does not generate unique IDs. ID BI2221G078_battery_soc already exists - ignoring sensor.battery_charge 2023-03-02 23:59:07.934 ERROR (MainThread) [homeassistant.components.sensor] Platform givenergy_local does not generate unique IDs. ID BI2221G078_battery_num_cycles already exists - ignoring sensor.battery_cycles 2023-03-02 23:59:07.934 ERROR (MainThread) [homeassistant.components.sensor] Platform givenergy_local does not generate unique IDs. ID BI2221G078_v_battery_out already exists - ignoring sensor.battery_output_voltage
This means that 2 of the three batteries are missing their cycle counts etc. In my own basic sensors I have used a standard GUID as the unique_id value and it seems to work well.
Would it be possible to change your code so it generates a unique id for each sensor ?