andrew-codechimp / HA-Battery-Notes

A Home Assistant integration to provide battery notes of devices
MIT License
503 stars 87 forks source link

Adding a device twice creates inconsistent state #1685

Closed zoechi closed 4 months ago

zoechi commented 4 months ago

System Health details

System Information

version core-2024.5.2
installation_type Unknown
dev false
hassio false
docker false
user hass
virtualenv false
python_version 3.12.3
os_name Linux
os_version 6.6.21-hardened1
arch x86_64
timezone Europe/Vienna
config_dir /var/lib/hass
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.34.0 Stage | running Available Repositories | 1462 Downloaded Repositories | 61
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Dashboards dashboards | 3 -- | -- resources | 30 views | 6 mode | storage
Recorder oldest_recorder_run | May 15, 2024 at 05:38 -- | -- current_recorder_run | May 23, 2024 at 21:52 estimated_db_size | 588.33 MiB database_engine | sqlite database_version | 3.45.2

Checklist

Describe the issue

I have added my Nuki 2.0 Pro for the door sensor battery. It was not recognized automatically. I guess this is because it's using MQTT integration instead of Homekit.

I have 3 of them and added one twice accidentally. Now it shows under Devices & Services > MQTT > Main Entrance > "Device Info"
"MQTT, Battery Notes, Battery Notes" but under Devices & Services > Battery Notes > Devices
is only one entry for this device. When I delete the device from Battery Notes the entry is removed, one integration vanishes, but one remains
Devices & Services > MQTT > Main Entrance > "Device Info"
"MQTT, Battery Notes"

Main Entrance Battery notes still shows up in the Devices and Entities list (1 and 4 entries), but I can't delete it.

When I add the Mainentrance to Battery Notes again, it shows up there once as expected, but in Devices (2) and Entities (8) list, all the Battery Notes entries show up twice (2 and 8 entries).

Reproduction steps

  1. Add device to Battery Notes manually
  2. Add the same device to Battery Notes manually again
  3. Check the duplicate Battery Notes entries in Devices and Entities, while Battery Notes shows the device only once
  4. Delete the device from Battery Notes
  5. Check the orphan Battery Notes entries in Devices and Entities
  6. Add the same device to Battery Notes manually again
  7. Check the duplicate Battery Notes entries in Devices and Entities

Debug logs

No response

Diagnostics dump

No response

andrew-codechimp commented 4 months ago

I have just tested this and I cannot add the same DEVICE twice. Are you sure you have not added entities? If so they may be showing as the name of the entity rather than the name of the device within battery notes. If you click on the Battery Notes within the Nuki device info panel that should take you to the correct battery notes entry where you can use the 3 dot menu to delete that battery notes. The example below has the Battery which is an entity related battery note for the Ikea switch, even though I have a battery note for the device already.

CleanShot 2024-05-25 at 12 22 01@2x

zoechi commented 3 months ago

Thank you a lot for looking into it. I'm currently fighting another problem that prevents me from checking. As soon as possible I'll try again and report back.