I have what I hope is a simple use case:
Sensor 1 counts cars going into a park
Sensor 2 counts cars leaving the park
Every hour the two sensors connect to Ubidots and post their totals. I am hoping to use the difference between these two numbers to estimate how many cars are in the park.
I can compute the difference with a synthetic variable using fill_missing() but, it is calculated twice every hour:
- once when the first sensor reports and filling in the hour-old data from the second sensor
- again when the second sensor reports with the counts from the same hourly period - this is what I want
I tried to use the When() functionality (original post edited with Sergio’s help):
where (fill_missing({{var1}}.timestamp - {{var2}}.timestamp) < 300,000, fill_missing({{var1}} - {{var2}}))
I am assuming that the timestamp is in milliseconds so this should be 5 minutes.
If the difference is more than 5 minutes or if one sensor does not connect in an hourly period, I don’t want to create a synthetic variable “dot” for that hour.
But I still see two “dots” created each hour as if the where() conditional is not being applied. Is there a better way to do this?
Thanks, Chip