Action when laundry is done

Check this out

input_boolean:
  stopwatch:
    name: Stopwatch
    initial: off
  dummy:
    name: Dummy
    initial: off
    
automation:
  - alias: Stopwatch start
    trigger:
      platform: state
      entity_id: input_boolean.stopwatch
      state: "on"
    action:
      - service: input_boolean.toggle
        entity_id: input_boolean.dummy
          
  - alias: Stopwatch stop
    trigger:
      platform: state
      entity_id: input_boolean.stopwatch
      state: 'off'
    action:
      - service: input_boolean.toggle
        entity_id: input_boolean.dummy
          
  - alias: Stopwatch update
    trigger:
      platform: time
      seconds: '/1'
    condition:
      condition: state
      entity_id: input_boolean.stopwatch
      state: 'on'
    action:
      service: input_boolean.toggle
      entity_id: input_boolean.dummy
          
sensor:
  - platform: template
    sensors:
      stopwatch:
        friendly_name: "Stopwatch"
        value_template: >
          {% if is_state('input_boolean.stopwatch', 'on') %}
            {{ (now() - states.automation.stopwatch_start.attributes.last_triggered).total_seconds() | int }}
          {% elif is_state('sensor.stopwatch', 'unknown') %}
            0
          {% else %}
            {{ states('sensor.stopwatch') }}
          {% endif %}
        unit_of_measurement: 'sec'
        entity_id:
          - automation.stopwatch_start
          - automation.stopwatch_update
          - automation.stopwatch_stop
        
group:
  stopwatch:
    name: Stopwatch
    entities:
      - input_boolean.stopwatch
      - sensor.stopwatch

That creates a sensor to display the number of seconds since input_boolean.stopwatch was turned on. I’m sure someone could come up with a custom component that works better, but it was interesting that this is possible with just the components currently available.

6 Likes