Shelly 3EM dashboard

I know this question has been asked many times but I couldn’t find a straight answer.

I have a shelly 3EM that sends data directly to influxDB.

I want to create a dashboard with the hourly and daily consumption (from all 3 phases)
I’ve really tried very much without luck.

For your help I have create a small query with bucket and entity_id names

from(bucket: "ha")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "kWh")
  |> filter(fn: (r) => r["_field"] == "value")
  |> filter(fn: (r) => r["domain"] == "sensor")
  |> filter(fn: (r) => r["entity_id"] == "shellyem3_c45bbe6ad1c5_channel_a_energy" or r["entity_id"] == "shellyem3_c45bbe6ad1c5_channel_b_energy" or r["entity_id"] == "shellyem3_c45bbe6ad1c5_channel_c_energy")

Hello @makis_solomos,
Welcome!
Im not intimately familiar with the data that 3EM sends.
Do you have a field that measures consumption or are you looking to calculate it?

Could it be something like…
For the calculation (current feed-in number - feed-in number the day before at 23:59), let’s rewrite as:

t1 - t2

Is that what you’re looking to do?

import "experimental/date/boundaries"
day = boundaries.yesterday()

t1 = from(bucket: "bucket")
|> range(start: -1m)
|> filter(fn: (r) => r["_measurement"] == "meas")
|> filter(fn: (r) => r["_field"] == "value")
|> last()

t2 = from(bucket: "bucket")
|> range(start: day.start, stop: day.stop)
|> filter(fn: (r) => r["_measurement"] == "meas")
|> filter(fn: (r) => r["_field"] == "value")
|> last()

result = join(tables: {t1: t1, t2: t2}, on: ["_time"])
|> map(fn: (r) => ({_value: (r._value_t1 - r._value_t2)}))
|> yield(name: "t1_minus_t2  for a day")

... reapeat as needed for the different types of consumption (hourly etc.) 

I also don’t know if this could be useful to you:

Potentially with aggregateWindow() function | Flux Documentation