Skip to content

Historical Data query #165

Answered by erwinvol
erwinvol asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the quick answer. When I take september or last week as the dataset, and /1000 it aligns with the data from the Vue app. Jan and Feb are off though where Vuegraf shows more than Emporia itself but the difference is not large enough to care about but enough to throw me off.

For posterity, this query gives me an accurate kWh usage in the selected time range for the chosen device.

from(bucket: "vuegraf")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "energy_usage")
|> filter(fn: (r) => r["device_name"] == v.Device)
|> filter(fn: (r) => (r["detailed"] == "Day"))
|> map(fn: (r) => ({ r with _value: (r._value / 1000.0)}))
|> group()

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by erwinvol
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants