HASS.Agent icon indicating copy to clipboard operation
HASS.Agent copied to clipboard

Bug: All entities unavailable once HASS.agent disconnects/machine is shutdown

Open bcutter opened this issue 2 years ago • 7 comments

Describe the bug Is it normal for all Home Assistant entities (buttons and sensors) provided by HASS.Agent through MQTT to render unavailable once the client/Windows machine running HASS.Agent is switched off?

To Reproduce Steps to reproduce the behavior:

  1. Connect an application to HA
  2. Make sure entities states are up to date
  3. Disconnect the client (shutdown Windows machine e. g.)
  4. See all entities of that machine rendering unavailable

Expected behavior I expected all entities to keep the latest state, as all integrations do. If it's not a bug but "works as designed": That "show current state" instead of "show latest state (which is not unavailable) approach has quite some downsides.

Screenshots grafik grafik

Misc info (please complete the following information):

  • Windows build (ideally screenshot/info of winver.exe output): grafik
  • Windows' UI language: German (DE)
  • HASS.Agent version: 2022.14.0

Please check what's applicable (multiple answers possible):

  • [x] Installed via installer
  • [ ] Installed manually
  • [x] Problem occurs in HASS.Agent
  • [ ] Problem occurs in Satellite Service
  • [x] Problem occurs after MQTT --> in HA!

Additional context I was not sure if this issue shall be created in https://github.com/LAB02-Research/HASS.Agent-Integration/issues instead. But the integration does nothing on that ("only" provides notifications and media player), right?

bcutter avatar Apr 02 '23 22:04 bcutter

I just set this up last night (6/18/2023) and I have run into the same issue. I don't know if it's the MQTT add-on or this one, but having it all set to "unavailable" kinda stinks. I have a feeling it's HA/MQTT doing it though when the connection is lost.

Edit: To be clear, my issue is that as soon as the computer is off/asleep, all sensors are set to "unavailable". Would be nice for some of them to keep the same value, like "lastsystemstatechange"

sirmeili avatar Jun 19 '23 13:06 sirmeili

Edit: To be clear, my issue is that as soon as the computer is off/asleep, all sensors are set to "unavailable". Would be nice for some of them to keep the same value, like "lastsystemstatechange"

Exactly that's the point here ✔

That current behaviour is not common sense and different to common implementation approaches where the last state is kept active until it is refreshed/overwritten by a newer state. Magical unavailable and unknown shall only be used for error situations. HASS.agent not being connected is not an error situation.

bcutter avatar Jun 19 '23 17:06 bcutter

Hello, HASS.Agent handles availability topic properly and sets the sensors as "offline", that's why the HA shows them as "Unavailable". If the device is not powered on the sensors should not stay available (for example, the CPU load of 45% wouldn't make sense on powered down PC).

amadeo-alex avatar Jul 06 '23 13:07 amadeo-alex

But not all sensors fall under that rule. I.e. (as I mentioned in the other issue), Last User Logged In would be nice to have it retain its value. From my understanding it is possible to configure MQTT to allow this (though I am not overly familiar with MQTT yet)

sirmeili avatar Jul 13 '23 20:07 sirmeili

Double what sirmeili said. Plus regarding the CPU load example: if the machine is off, the load is 0 %. 0 is a valid state. While unavailable and unknown stand for problematic states in the HA universe. My devices ('s entities) are not problematic, they are just off.

bcutter avatar Jul 13 '23 22:07 bcutter

A hard theory from my side (at least for now), but CPU Load will almost never be exactly zero, even if I do implement the option not to send availability topics, the last value from things like CPU Load Sensor most likely won't be zero but the last known value (and this applies to all other sensors that would be configured that way - it will be up to the user to handle this on the HA side, just like it is now with the "unavailable" problem, user can retrieve the last valid value from HA itself).

amadeo-alex avatar Jul 14 '23 05:07 amadeo-alex

Won't this be relevant here or at least be of interest?

https://www.home-assistant.io/blog/2023/03/01/release-20233/#breaking-changes

grafik

At least it shows how other folks (the HA core team) care about entity states and what they represent and might trigger.

bcutter avatar Aug 26 '23 17:08 bcutter