hass-agent / HASS.Agent

Unofficial development project for the HASS.Agent platform.
https://hass-agent.io
MIT License
338 stars 9 forks source link

Feature: Don't send sensor state if value is null #59

Open barrelltitor opened 7 months ago

barrelltitor commented 7 months ago

Please make sure that the feature you'd like to request is not already requested :)


Is your feature request related to a problem? Please describe. I have some custom sensors that sometimes will not return a value for various reasons. When this happens, it gets passed on to HA as null, which will make the state appear as unknown.

Describe the solution you'd like Ability to pass a specific exit code to cancel sending the new value, or to optionally disable sending state if null

Describe alternatives you've considered Storing the previous state of the sensor and having the custom code check this and return the previous state if null, but this seems overly complicated instead of just being able to have a way to cancel sending the new value

Additional context

amadeo-alex commented 5 months ago

Hello,

Could you please provide example of the custom sensor? HASS.Agent will not send the update if value returned by the sensor is "null" - that however is "c#'s null". I could add another case that checks if the state string returned by sensors is "null" (text) however then someone may call this unwanted behaviour because their sensor needs to send "null" in text.

barrelltitor commented 5 months ago

The sensor just prints a blank string, it's just a powershell sensor that checks the lghub sql db for mouse battery values, and returns a blank string if none was found. This blank string gets passed on to HA as null

barrelltitor commented 5 months ago

My computer is a bit out of commission for the moment, will give an exact code once I can, but it's basically what I described above