Help: Want to create a counting timer when my boat engine is turned on

Hi,

Forgive me for being a novice. Have limited knowledge of YAML and have trawled through every topic I can but cant find the answer.

I want to create a timer that counts the duration that my engine has been turned on. The snag is that I am using an unscientific method of determining the engine being turned on. I have a voltage sensor named sensor.victron_battery_voltage and when it the engine is running I get a reading above 14 volts. I would like to count the duration that the sensor is above ‘14’ volts.

My attempt at making this work doesn’t produce any results. Please point me in the right direction!

 - platform: history_stats
    name: Engine on all history
    entity_id: sensor.victron_battery_voltage
    state: > 14
    type: time
    start: '{{ 0 }}'
   end: '{{ now() }}'

Automation Triggers

trigger:
  - platform: numeric_state
    entity_id: sensor.victron_battery_voltage
    above: 14

action:
  - service: timer.start
    entity_id: <insert timer entity id here>
automation:
  trigger:
    platform: time_pattern
    # You can also match on interval. This will match every 1 minutes
    minutes: "/1"
  condition:
    - condition: numeric_state
      entity_id: sensor.victron_battery_voltage
      above: 14
  action:
    service: counter.increment
    data:
      entity_id: counter.motor_minute_run_still_to_be_defined

Amazing! The counter method worked. Thank you.

1 Like

No Problem