Custom sensor for washing machine

Hello,
I got some plugs for my washing machine and dryer. I wanted to create a custom sensor
with a template now to watch the state of the wasching machine. But sadly sometimes the washing machine power draw jumps to 0W so I can’t just ask if its smaller than 3 as example then its not running anymore. I may have to do it if its longer than 2 minutes at 0W it is finished.
But I have no idea ho to do that with value templates?
Can anyone help me with that?

Use a statistics sensor to even out the power consumption over a few minutes that way when the statistics sensor say 0 then it is off, but that will happen with a delay of the same time as your statistics sensor is looking at.

I use the following:

  - alias: Laundry Set Washer Status
    id: laundry_set_washer_status
    trigger:
      - platform: numeric_state
        id: 'off'
        entity_id: sensor.washer_plug_power
        below: 1
        for:
          minutes: 5
      - platform: numeric_state
        id: 'on'
        entity_id: sensor.washer_plug_power
        above: 1
        for: 
          minutes: 2
    condition:
      - "{{ trigger.from_state.state not in ['unknown', 'unavailable'] }}"
    action:
      - service: input_boolean.turn_{{ 'on' if trigger.id == 'on' else 'off' }}
        entity_id: input_boolean.laundry_washer_status

  - alias: Laundry TTS Washer is Done
    id: laundry_tts_washer_is_done
    trigger:
      - platform: state
        entity_id: input_boolean.laundry_washer_status
        to: 'off'
    condition:
      - condition: time
        after: '09:00:00'
        before: '23:00:00'
      - condition: or
        conditions:
          - condition: state
            entity_id: person.spouse
            state: 'home'
          - condition: state
            entity_id: person.me
            state: 'home'
    action:
      - service: notify.alexa_media
        data:
          target: 
            - media_player.basement_dot
            - media_player.computer_room_dot
            - media_player.garage_dot
            - media_player.kitchen_dot
            - media_player.livingroom_dot
          data:
            type: tts 
          message: "The washer is finished"

Mhhh yes this could be a solution, but honestly don’t want to create another automation for that.
Would love to get this into a template for a sensor.

If you want a sensor then just use a similar format as the trigger and use that to set the state of a trigger template sensor.

I’m not sure what the difference is between an automation that sets a boolean or a triggered sensor that sets the state of a sensor. either way you will need to create something.