Influx DB Query to get %

Hey all, not really a home-assistant question but I thought Id ask here…

Ive created a small sensor which reports if my boiler is active or not (1/0). I store this data in influxDB and what Id like to report is % of the time the boiler is on

the data in influxdb looks like this

time domain entity_id friendly_name_str value
2018-03-03T01:36:39.450928896Z “sensor” “max_boiler_status” “MAX Boiler Status” 1

Any idea how I can create a query which will give a percentage of time the state is zero or one?

Thanks all

Hi,

Are you using Grafana?
I use Grafana for similar things:
RGB%20lamp%201rgb%20lamp%202

In options I set up to show the percentage where state is on and off.

1 Like

Since this is an HA forum, this is the HA answer :grinning:

or possibly

thanks guys

@RogueCrow : yes I use grafana and this is precisely what I’m after, which grafana widget are you using??

@gpbenton : Id forgotten about those components :slight_smile: thanks, I’ll enable them and probably use them for short term stats (ie today) and grafana for long term…

thanks again all!

@RogueCrow : Ahhh I found this ! https://grafana.com/plugins/natel-discrete-panel/installation looks perfect, thanks for the hints!

Yep, should be easy to set up and configure. Note you can change colors etc.
I like this as you can choose whatever period you like and get stats on that dynamically.
Be it during the day, week, month or whatever…

works a treat, very happy :slight_smile:

image

Now I need to get my head around influxDB’s query language… slightly different to SQL…

and then integrate it all with the HA Dashboard…