Last total value for total_increasing sensor

How can I get the final value before reset of a total_increasing sensor?

I haven’t done this before, but at least I thought I would give you some ideas to look at.

It may be possible to use a trigger based template sensor that monitors the state change of your total_increasing_sensor. In your case, you could use platform: numeric_state with entity_id of your total_increasing_sensor.

Your template’s state logic/code would look to at the total_increasing_sensor’s “from” and “to” values to see if they actually decreased, and if it did then change the numeric state of the template sensor to the “from” value. If you take a look this doc you’ll see you have the trigger.from and states available from the event bus that you should be able to use in your template sensor.

Beyond this, I’d have to put more thought into it.

1 Like

Thanks - seems an obvious need (how much energy did we use yesterday).

I’m just doing a Node-Red flow. I know I get an object that contains last sate new state, so when new state is lower than old state, old state is my value.

@123 I saw your comment here

and wondered if this could be used to get the last state before reset?

Sorry, I don’t know the answer.

Seems to be working for me, thanks for pointing me to this direction.

Just to close this, I’m sure I got the answer from somewhere else

      - platform: numeric_state
        entity_id: sensor.komfovent_ahu_consumption_day_kwh
        below: 0.01
      - service: notify.persistent_notification
          message: Heater consumption yesterday {{trigger.from_state.state}}kWh