What Grafana version and what operating system are you using?
10.0.3, running as Home Assistant add-on
What are you trying to achieve?
For a boolean variable (HA: binary_sensor), summarize for each month how many hours the variable was true.
Note: I’m new to grafana, have been able to build some basic dashboards showing graphs that I find useful. However, figuring out how to do this … I don’t even know where to begin as it seems not a simple query but rather a sequence of steps that needs doing.
Thank you so much for any indications on where to look / how to approach.
Hi Grant - thank you for the response. I am indeed using InfluxDB as a datasource. Pardon my ignorance, but what do you mean by “and you are using Flux” ?
TLDR; InfluxDB has 2 “languages”. Flux a scripting engine, and influxQL an SQL like syntax.
@grant2 and other engineers like me on the industrial world have found Flux “unleashes” the full power of time series databases for complex and specific use cases. influxQL works great if you need something more like a relational database.
Thanks to @grant2 and @fercasjr for the comments. For my use case, diving into learning another query language is perhaps a bit overkill. Especially given my rudimentary-only knowledge of InfluxDB and Grafana.
I did read through the thread linked to above and tried out that ‘Discrete’ plugin. That displays a “it was in this state for int% of the time selected” under the graph, which I can turn into a (very) rough estimate of time spent in a certain state. It’s a rather manual process, but sometimes those save the most time
You do not need to use a plugin to accomplish what you want. The question was merely about what datasource and language you are presently using. You stated it was InfluxDB, so therefore you must be using either InfluxQL or Flux. It will be obvious if you share a screenshot of the panel query that you currently have working in Grafana.
Apologies for the slow response, @yosiasz. I was away from home, unable to look up the answer to your question.
Although: I am back now and still unable to answer your question. I am trying to query a Home Assistant-created database, but am not sure how to get a list of field names. I’ve tried all sorts of things from this link but could not get anything out of it that made sense to me. As mentioned, I’m only a beginning user of InfluxDB and Grafana.
It’s definitely an Influx question that could be summarized as “How do I get availability % of a given period based on a boolean sensor ?”. You should ask on their forum.