Daily usage chart

Hello

I have an energy meter (water, electricity,…) which just gives off a meter value.
This is ever increasing and sent to Losant.
I would like to extract a daily usage (monthly, weekly) chart by subtracting the last value with the first value of each day.
This should then be shown on the dashboard in a bar chart.
Can this be done in Losant and what is the best way to do this?

Kind Regards,
Gwen Vanheusden

Hi @Gwen_Vanheusden,

Yes, this would be possible in Losant. However, keep in mind that state data in Losant is subject to a retention limit, which, in the sandbox, is 30 days.

If you were to build this functionality, you would need to report the usage value to a device as state, as dashboards are intended to display device data. I would likely begin by automating a workflow to fire at midnight to then grab the previous day’s state reports and calculate the usage.

This could begin with a Timer Trigger Node configured with a cron string set to midnight. Then, you can utilize the Data: Gauge Query Node or Data: Time Series Node to do an advanced query for the last 24 hours of data. You would then likely use a Math Node to compare the first entry with the last, and would then report this comparison value as device state. This state value could then be used in your dashboard bar chart!

Please let me know if this solution will not suffice for your use case or if you have any additional questions.

Thanks!
Julia

Hello @JuliaKempf

I’ve successfully used this approach!
I used 2 gauge query’s, one for the last and the other for the first value.

Kind Regards,
Gwen Vanheusden