home-assistant / iOS

:iphone: Home Assistant for Apple platforms
https://companion.home-assistant.io
Other
1.6k stars 309 forks source link

Sensors become stale and not unavailable and can't be deleted #3120

Open golles opened 4 weeks ago

golles commented 4 weeks ago

Device model, version and app version

Model Name: Apple M3 Pro macOS Version: 15.0.1 App Version: 2024.9.2 Safari Version: I don't use safari

Home Assistant Core Version

2024.10.4

Describe the bug Sensors become stale and not unavailable and can't be deleted

To Reproduce I had issues with my UPS and have connected it to my MacBook, I got a new one and also connected that to the Macbook to check it before installing. After disconnecting, the sensors remain active and can't be deleted.

Expected behavior Something should happen with these sensors, I think what other integrations do is make them unavailable, which probably makes the most sense. In my case, I would see them deleted, if they would become unavailable I could delete them manually.

Screenshots

In HA the sensors remain there and look active:

Scherm­afbeelding 2024-11-01 om 11 41 16

After restarting the app on my Macbook, the sensors were removed from here:

Scherm­afbeelding 2024-11-01 om 11 41 01

The delete button isn't clickable, so can't delete them

Scherm­afbeelding 2024-11-01 om 11 46 49

Additional context

bgoncal commented 3 weeks ago

Correct me if I'm wrong but your UPS entities have no relation to macOS App right? How did you add them to Home Assistant?

golles commented 3 weeks ago

I guess the app detects all batteries connected to the Mac? The only thing I did is plug in the USB cable.

bgoncal commented 3 weeks ago

Oh, sweet! I honestly didn't know this was a feature haha, I'll update you as soon as I have more info

golles commented 3 weeks ago

It is actually nice indeed, this is what I see in my Mac battery settings when the UPS is connected

Scherm­afbeelding 2024-11-04 om 19 40 07
bgoncal commented 3 weeks ago

After you restarted your mac, were you able to remote those sensors? You can also disable them if needed. Also, if you delete your macbook entry from mobile_app integration, the next time you launch the app form scratch it will recreate everything

golles commented 3 weeks ago

After I restarted the Mac, they still show up in HA.

Scherm­afbeelding 2024-11-05 om 23 19 29

and they still look active, which still doesn't allow me to remove them.

I understand I can fix this by removing the integration for this Macbook, but that would be ignoring this bug.

But now I think of it, is this a bug from the app or within core? As the app doesn't show these sensors anymore, shouldn't the integration in core detect them as stale and mark them as unavailable? What do you think?

bgoncal commented 3 weeks ago

Sorry, I didn't mean to close this bug with the workaround, just giving you short term solution.

I think iOS app needs to ask core to remove those sensors, but I am not sure, @dshokouhi what do you do in Android in such cases?

dshokouhi commented 3 weeks ago

what do you do in Android in such cases?

ours are also not removed in these cases, @jpelgrom and I discussed this recently actually as he worked on the sync status between the server for when sensors get enabled/disabled

jpelgrom commented 3 weeks ago

ours are also not removed in these cases

I don't believe there are sensors like these which can completely disappear on Android so not completely comparable. But yes, it disables/enables like other integrations do.