Convert history_stats time to seconds

I have a history_stats sensor which gives water pump on time:

  - platform: history_stats
    name: Water Pump On Time Today
    entity_id: binary_sensor.esp32_waterpump_mon_esp32_waterpump_mon_pump_state
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

I know how many liters / second the pump moves (1.2 l/second) - how do I create a template sensor to give the liters pumped today? The history_stats sensor gives minutes:seconds - How do I convert that to seconds? (decimal minutes would work as well)

  - sensor:
      - name: "Water Pump Estimated Liters Today"
        unit_of_measurement: "Liters"
        device_class: volume
        state: >
           {{ (states("sensor.water_pump_on_time_today") | float * 1.2) | round(2) }}
        availability: "{{ states('sensor.water_pump_on_time_today') | is_number }}"

That may be what it displays in your dashboard, but what is the actual state value?

Look in Developer Tools → States.

Thank you… too easy, and something else learnt :slight_smile:

1 Like