Input_Number Value in Grafana

I use an input_number as a threshold/trigger value for some automation. Specifically, I set an input_number to a temperature where I want certain heaters and other things to turn on and off. That part works fine.

What I am trying to do now is to build a Grafana dashboard that shows the sensor temps along with the input_number value threshold line so that I can see when the temp drops below the threshold. When I try to use the value of that input_number as a series in the graph itself, I only see the value when I have the graph showing the exact time it was changed, and I don’t change these often.

I think the solution will involve using a query variable in Grafana and using the “threshold” function of the visualization, but I can’t figure out the query to get the current state of an input_number.

I did try writing an Automation that re-sets the input_number to it’s current value on a regular basis, and it appears that works, but it seems like a complicated way to deal with it. Since the HA History graphs can show the value retained over time, I am thinking I should be able to do the same in Grafana directly.

1 Like

Here is an example of what I am trying to do. Note the red line at 68 degrees. I want the position of that line to be based on an input_number, either using a variable for the Threshold value or by graphing the history of that value.

I’m trying to do exactly the same thing. Did you ever find an elegant solution to this? It seems like we need a standard way to tell home assistant to drop the current state of any object periodically if we are trying to graph them. It’s a global problem for anything that doesn’t change state often. A couple of sensors have force_update flags built in, but it all seems add hoc to me.

Since I don’t know SQL, I used the query builder in the Grafana dashboard to get into the ballpark then I used the query inspector to see what it generated. I deleted everything in the query after the WHERE (because it didn’t seem relevant to my query) and pasted the result into the query box of the query variable I was making. I was trying to capture my latest electricity cost which hardly ever changes.

SELECT last("value") FROM "autogen"."Cents" WHERE ("entity_id"::tag = 'electricity_cost')

Sorry to bring this thread back from the dead!!