Hello,
I’m looking for a way to get a label’s value as query result rather than just a 1 or a 0
I’ve been knocking my head all around the web for hours but I’ve yet to find a definitive working answer. I’ve found the topic been asked on different websites (including but not limited to stackoverflow and github of course) and tried everything suggested without success.
Even on this very forum I’ve found someone with the same need:
But nobody ever answered the poor chap, si I’,m trying my luck and see.
I’ve the following query:
homeassistant_climate_mode{entity="climate.livingroom",mode=~"cool|heat|off"}
Instead of 3 entities representing the boolean state for each possible value of mode
at a given time, I need a single entity returning the string value for mode
at the given time.
For instance instead of:
homeassistant_climate_mode{domain="climate", entity="climate.livingroom", friendly_name="Livingroom", instance="10.6.9.3:8123", job="homeassistant", mode="cool"} --> 0
homeassistant_climate_mode{domain="climate", entity="climate.livingroom", friendly_name="Livingroom", instance="10.6.9.3:8123", job="homeassistant", mode="heat"} --> 1
homeassistant_climate_mode{domain="climate", entity="climate.livingroom", friendly_name="Livingroom", instance="10.6.9.3:8123", job="homeassistant", mode="off"} --> 0
I need
homeassistant_climate_mode{domain="climate", entity="climate.livingroom", friendly_name="Livingroom", instance="10.6.9.3:8123", job="homeassistant"} --> heat
and rather than plotting 3 entities I’m looking to produce a graph where the X axis represent time and the Y axis represent the possible values of mode
:
Please note: My goal is to graph this stuff on grafana using the discrete graph, in my example I used the screenshot I took from prometheus only because it was faster to edit into a visual sample of what I need. I know prometheus’ graph probably cannot place text labels on its axis, but that’s not the point of my question.