Value in graph not showing when changing time

I have a door sensor that retunes a 1 when the door is open and 0 when closed stored in influxdb.

This is the query in Grafana:

SELECT mode("value") FROM "bedroom" WHERE $timeFilter GROUP BY time(1s) fill(previous)

This works ok if the value has changed during the set time period.

i.e. if the time period window is set to say 8 hours and the door is opened, a value of 1 is displayed with a line showing the time the door is open. after 4 hours if I change the time window to 3 hours the value is showing anymore as open or closed.

Hope this makes sense, can anyone help with this please.

I have a door sensor that retunes a 1 when the door is open and 0 when
closed stored in influxdb.

How often are you sampling the value?

This is the query in Grafana:

SELECT mode("value") FROM "bedroom" WHERE $timeFilter GROUP BY time(1s)
fill(previous) ```
This works ok if the value has changed during the set time period.

Ah, so do you actually mean “a sensor that returns a 1 when the door gets
opened, and a 0 when it gets closed”, in other words it only reports changes,
no the current state?

i.e. if the time period window is set to say 8 hours and the door is
opened, a value of 1 is displayed with a line showing the time the door is
open. after 4 hours if I change the time window to 3 hours the value is
showing anymore as open or closed.

Well, if the door has not been opened or closed during the time window, I
wouldn’t expect the graph to show any activity…?

Hope this makes sense, can anyone help with this please.

I guess it means you are actually interested in the continuous state of the
door (is it open or is it closed), and not so interested in the state changes
(has it just been opened or has it just been closed)?

The best way to do this would be to take continuous readings of the door’s
state (I suppose once per minutes would be accurate enough?), and then you
have the ideal thing for Grafana - time-series data which can be plotted over
whatever timescales you like.

If you cannot do this sort of pre-processing in whatever system is feeding
your sensor data into influxdb, then I suspect a Continuous Query might be able
to convert the state changes into continuous time-series data for you -
however I’m no expert on that, so maybe someone else can suggest if this would
work or how to do it.

You might also benefit from asking about this on the InfluxDB list, because it’s
more of a question about the data you’re putting into your data store than it
is about what Grafana does with it afterwards.

Grafana can’t show you the state of the door in the past hour if it hasn’t
been opened or closed for 2 hours - there just isn’t any information for
Grafana to work on.

Antony.

1 Like

Ahhrr, that helps a lot in explaining why things are happening as they are.

Im using NodeRed to read the sensor and return a 1 for open and 0 for closed feeding into influxDB

My thoughts where that if the data in influxDB was last set to 1 Grafana would still show that information until the next change regardless of the time window.

Thank you for your time on this. I will have to have another rethink.

Hi jjdenver,

I struggle with a similar issue.
I get over it by putting a ‘trigger node’ in the connection to the database.
The trigger node is configured:
send : the message object
then : repeat every 10 Minutes or whatever suits for you.

Thats it.

1 Like