mhwlng / fipha

Home Assistant integration with HWINFO, MQTT and optionally Logitech Flight Instrument Panel

Home Page:https://community.home-assistant.io/t/home-assistant-integration-with-logitech-flight-instrument-panel-hwinfo-mqtt/443045

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to make HA sensors unavailable when pc is off

BoOmka opened this issue · comments

Now if you turn your PC off or close HWINFO, the sensors get stuck at the last known value. Is there an option to make them take "unavailable" state if there's no updates for a set timeout?

It's not technically possible to influence that from this software.
All my HWINFO sensor values say 'unavailable' in Home assistant after a while of inactivity (days).

It could also be that it's 'unavailable' because I restarted Home Assistant during that period. I don't know ?

perhaps if you disable the history function in home assistant, that will happen sooner, I don't know...
https://www.home-assistant.io/integrations/history/

I will preface this by saying I've never written a C# or windows desktop program before, but I believe that this is achievable by listening for the SystemEvents.SessionEnding event and then calling DisconnectAsync in the MQTTnet.Client.

I have used a different application to report my hardware info and while not as customizable as this one, it properly sets the MQTT status as unavailable when I shut down my computer. It'd be awesome if you could get it working in this application as I really like the customizability of it. Thanks for your work on it!

https://github.com/LAB02-Research/HASS.Agent/blob/main/src/HASS.Agent/MQTT/MqttManager.cs#L534
https://github.com/LAB02-Research/HASS.Agent/blob/c859e6e98deb81d84d8c3098444cbea9098c4e44/src/HASS.Agent/Functions/HelperFunctions.cs#LL166
https://github.com/LAB02-Research/HASS.Agent/blob/c859e6e98deb81d84d8c3098444cbea9098c4e44/src/HASS.Agent/Managers/SystemStateManager.cs#L68
https://github.com/LAB02-Research/HASS.Agent/blob/c859e6e98deb81d84d8c3098444cbea9098c4e44/src/HASS.Agent/Managers/SystemStateManager.cs#L46

Feel free to provide a working PR

see 0.0.1.5

added home assistant availability_topic logic (to show sensor unavailable if application is not running)

It works great, thanks for the update!