LAB02-Research / HASS.Agent

Windows-based client for Home Assistant. Provides notifications, quick actions, commands, sensors and more.
https://hassagent.lab02-research.org
MIT License
1.59k stars 73 forks source link

Bug: with _monitorpowerstate when pc turned off showing Unavailable #303

Open fizzy6868 opened 1 year ago

fizzy6868 commented 1 year ago

At first, I could shut down the pc, and it would show Power Off in the _monitorpowerstate, but now it will only show Unavailable I have no idea what has happened but every time I shut down it will not change from Unavailable

Home Assistant 2023.4.4 Supervisor 2023.04.0 Operating System 9.5 Frontend 20230411.1 - latest

Mosquitto broker Current version: 6.2.0 and the latest version of hass.agent Windows 11 just updated to latest patches

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

KrX3D commented 1 year ago

hi, i got exactly the same problem. i got the same configuration as above, exept that i use win10

when i change the update every value it gets reported again. for me it seems that it stopped working since the last HA update 2023.04.X

amadeo-alex commented 1 year ago

Hello,

If I understand correctly this is intended behaviour, when you shut down the PC the HASS.Agent receives this information and sets the sensor availability topic to "offline" - that's why HA shows this state as "Unavailable". The only option would be not to make the sensor offline but that's counter intuitive. Please see https://community.home-assistant.io/t/sensor-display-last-known-value-instead-of-unavailable/200081

sirmeili commented 1 year ago

@amadeo-alex, the problem is that some of the sensors really make sense to retain their value after the computer is shut down. I.e. last logged in user. Having that go "unavailable" doesn't make sense to me (just an example). I think there is a way to send a availability topic that basically says "Hey, even if I go offline, don't make me unavailable"

I would like this option for HASS.agent

https://www.reddit.com/r/homeassistant/comments/ywtd3g/what_makes_an_mqtt_sensor_go_unavailable/

sirmeili commented 1 year ago

@amadeo-alex, so I played around with this, and I got the following option. When setting up a sensor in either the Satellite or the normal ones, can we have an option to not send the availability_topic in the configuration for the sensor? From my testing this will mean the sensor never goes "offline", but I'm good with that. For things like "Last active" and "Last logged in user", I want those values to persist, not become "unavailable"