I’m trying to find a somewhat elegant way to force an update to my input_numbers once a minute so that there is data for grafana to plot. If I don’t do this and there has been no update for a while, the data series disappears from grafana until the next update occurs, which may be ages.
I’ve been trying in many different ways to have an array of entity_id’s for input_numbers to update, and have the automation run through them and set them to their current values. My latest attempt was:
But the value doesn’t resolve to an actual entity_id:
Error rendering data template: UndefinedError: 'entity_id' is undefined
I know that I can create a list of input_number.set_state for each entity, but I wanted to keep things less verbose and easier to follow. I even tried stashing the input_numbers in a group and processing the entity_ids from the group, but couldn’t figure it out. I’ve tried scripts but couldn’t get that to work either.
I was also hoping for a more generic solution so that I could pass input_booleans and possibly other compatible entities, but this more narrow solution would help for now.
Does someone have a suggestion on which way to go?
They are sliders on the UI. I’m setting up a grow room for gourmet mushrooms, and have sliders to set things like min/max temperature, trigger for co2 and humidity levels etc. There are unique recommended values for different strains of mushrooms, so I want to be able to customize the climate based on strain. But once set on the UI, they won’t change for days, making any attempt to graph these on grafana pretty futile.
I wish there were a more general solution to this for all entities. We record everything when a state changes, but there is no way to simply say “record the state of this thing every minute”. I do see some entities have a force_update key, but it seems ad-hoc. If we generally had an optional “graph: 1” for all entities that would solve this problem for good.
You can think of the gr_* vars as aliases for the underlying input_numbers, sensors etc, and only used for graphing. You can then exclude the underlying sensors from influxdb, and use these aliases instead. So with this set up, I should get an entry whenever the underlying entity updates, and also each minute, to guaranty a value sent to influxdb at least each minute.
The reason I had asked what supplied values to your input_numbers is if it had been anything other than “manually” then there might have been an easy solution.
As it stands, you are using an input_number in a very unique way to satisfy Grafana’s graphing needs. Normally, no one would need (or want) Home Assistant’s state-machine to periodically report an entity’s non-changing state. It’s needlessly verbose behavior. For example, if a switch entity’s state is currently on then there’s no need to report that state every minute.
Entities that acquire their values through polling are refreshed every 30 seconds by default and that interval is governed by the scan_interval option. So it’s not as ‘ad hoc’ as you may think. An input_number does not acquire its value by polling so scan_interval does not apply.
I am unfamiliar with the intricacies of Grafana. However it’s seems odd that a graphing engine has difficulties graphing a time-series with unchanging values. It seems to me this would simply be some sort of graphing option to specify how to handle a value that remains static of over time (i.e. use last known value until another one is received).
I agree it’s more of a grafana problem than hass. I’m quite new to all this so there may be something I’m still missing but I’ve been digging around for a couple of days and this is the only solution I could come up with.
Grafana does include a “use previous value” to join up the samples, but the problem is when you zoom in to a certain point where there is no state at all for that particular entity in the time sample you are querying, it just removes that entity all together from the graph, as if you had not defined it at all. Everything goes, including the legend entry. When you zoom out again it magically reappears. It’s a very shitty user experience. My input_numbers again can potentially remain static for days, so it’s just not worth putting them on graph since there will be no “previous value” to grab unless you zoom out a long way.
What I’m doing is essentially setting thresholds lines, which grafana does support, however, in my case, the thresholds are variable so I need to get them from the database as opposed to setting a static line on the graph. I need to be able to see the threshold values that have been set in order to properly ascertain and tune the performance of the automation.
A more elegant solution so far eludes me. I can move forward with this ugly hack I’ve created for now. Perhaps as I learn more about all these tools something better will jump up.