Automation is falsely triggered when sensor value doesn't exist

I have an automation that is aimed to notify me when my washer is done. I have a Kasa smart plug connected to the washer, and the automation is basically triggered when the plug’s current drops below 2.

The problem with this automation is that it often falsely triggered. When I go into the logs, I see that when it happens, there are missing data points from the plug (see picture below). How can I configure the automation basically ignore missing data points? I tried to add a condition that current should be above 0 but it is still falsely triggered.

This is my automation:

alias: Washer done
description: ""
trigger:
  - type: power
    platform: device
    device_id: 7c65683372901df044ce43c0e2dc31c0
    entity_id: sensor.washer_plug_current_consumption
    domain: sensor
    for:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
    below: 2
condition:
  - type: is_power
    condition: device
    device_id: 7c65683372901df044ce43c0e2dc31c0
    entity_id: 9bb5b6fd36855c4d92ec6a9658bb4fa6
    domain: sensor
    above: 0
action:
  - service: notify.all_devices
    data:
      message: Washer is done
  - service: media_player.play_media
    target:
      entity_id: media_player.kitchen_speaker
    data:
      media_content_id: >-
        media-source://tts/tts.google_en_com?message=Washer+is+done&language=en-us
      media_content_type: provider
    metadata:
      title: Washer is done
      thumbnail: https://brands.home-assistant.io/_/tts/logo.png
      media_class: app
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: >-
            media-source://tts/tts.google_en_com?message=Washer+is+done&language=en-us
mode: single

This is indication of the missing data points from the history graph:

The gaps in the graph occur when the state value of sensor.washer_plug_current_consumption is non-numeric such as unavailable.

I’m not certain but what may be happening is that it changes from unavailable to 0.04 which is below the threshold value (2) of your Numeric Device Trigger and, after 1 minute, serves to trigger the automation.

If this is what is happening (just a theory) then you can try adding this Template Condition which blocks further execution if the sensor’s previous value isn’t a number.

condition:
  - condition: template
    value_template: "{{ trigger.from_state.state | is_number }}"

NOTE

You may also wish to replace the Numeric Device Trigger with a Numeric State Trigger which does the same thing but is more concise.

trigger:
  - platform: numeric_state
    entity_id: sensor.washer_plug_current_consumption
    below: 2
    for:
      minutes: 1

Appreciate the quick response, made both changes. This is the current configuration:

alias: Washer done
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.washer_plug_current_consumption
    below: 2
condition:
  - condition: template
    value_template: "{{ trigger.from_state.state | is_number }}"
action:
  - service: notify.all_devices
    data:
      message: Washer is done
  - service: media_player.play_media
    target:
      entity_id: media_player.kitchen_speaker
    data:
      media_content_id: >-
        media-source://tts/tts.google_en_com?message=Washer+is+done&language=en-us
      media_content_type: provider
    metadata:
      title: Washer is done
      thumbnail: https://brands.home-assistant.io/_/tts/logo.png
      media_class: app
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: >-
            media-source://tts/tts.google_en_com?message=Washer+is+done&language=en-us
mode: single

Will test is for few days and report back.