Shelly + Riemann Sum + template

Hi,

I’m trying to monitor a heating system with a shelly plug S, and data to influxdb.

The first trouble was the lost of the energy sum when the plug was disconnected. => I added Riemann sum on power and it was OK.

The second trouble when the heating switch on, the value raises with incorrect datas (high value).

I’m trying to avoid this with template but since I added this in configuration.yaml, there is no more data recorded in influxDB:

template:
    sensor:
      - platform: integration
        name: energy_spent
        unit_prefix: k
        round: 2
        state: "{{ states('sensor.shelly_chauffage_bureau_power')|round(0)}}"

I don’t know if I can write like this…

Thank you.

Hi,

By recording power data with Riemann sum, it works to get the energy calculation:

sensor:
  - platform: integration
    name: "energy_spent2"
    source: sensor.shelly_chauffage_bureau_power
    unit_prefix: k
    round: 2

But between activations huge energy is recorded in influxDB (as sometimes reported on this forum).

I don’t know hot to do in two steps in configuration.yaml, the Riemann and the round (if this is the solution) ?