Closed DanielLeone closed 1 month ago
Thank you! I pushed a commit on top, that makes the return signature simpler, by just wrapping the result in a dataclass. PTAL.
Thank you! I pushed a commit on top, that makes the return signature simpler, by just wrapping the result in a dataclass. PTAL.
@mweinelt LGTM! :)
Hi, thanks for making this project - I get some good use out of it!
I'm seeing this exception when my prometheus query returns no result.
As per the error, I believe it's an issue that we're setting
_attr_native_value
to"problem"
viaSTATE_PROBLEM
since in most cases a prometheus query will return a number, and most device classes probably don't support both numbers and strings as values (such as temperature here).I've made a change so we instead set the
available
property tofalse
if there's an error, and the native value toNone
- which seems to be allowed as per the sensor.py code.This has the added benefit of showing up in the HA UI when there's an issue (instead of breaking all prometheus sensors with the current exception):
I'm new to home assistant code, so I have no idea if this is right or wrong, I'm just fixing issues I ran into 🙏
For context, here's a snippet of the configuration yaml I'm using, which causes the error (when paired with a prometheus query which yields no value)