Power cunsumption from unknown state forces a trigger

Hi there,
I´ve got this automation:

alias: Waschmaschine fertig
description: Info wenn die Waschmaschine fertig ist.
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.waschmaschine_derzeitiger_verbrauch
    for:
      hours: 0
      minutes: 3
      seconds: 0
    below: 15
conditions:
  - condition: time
    after: "09:00:00"
    before: "21:00:00"
actions:
  - data:
      message: >-
        Waschmaschine ist ferig.
      data:
        type: announce
      target: >-
        media_player.buro, media_player.kuche
    action: notify.alexa_media
mode: single

But sometimes the trigger came from unknown state and forces the automation. Heres the trace:

this:
  entity_id: automation.waschmaschine_fertig_neu
  state: 'on'
  attributes:
    id: '1746707177081'
    last_triggered: '2025-05-22T07:37:10.117913+00:00'
    mode: single
    current: 0
    friendly_name: Waschmaschine fertig
  last_changed: '2025-05-30T11:47:30.448289+00:00'
  last_reported: '2025-05-30T11:47:30.448289+00:00'
  last_updated: '2025-05-30T11:47:30.448289+00:00'
  context:
    id: 01JWGG9HGFW3WCZ3591ECMF48D
    parent_id: null
    user_id: e9661830aacb4504a38350ffdb63478f
trigger:
  id: '0'
  idx: '0'
  alias: null
  platform: numeric_state
  entity_id: sensor.waschmaschine_derzeitiger_verbrauch
  below: 15
  above: null
  from_state:
    entity_id: sensor.waschmaschine_derzeitiger_verbrauch
    state: unavailable
    attributes:
      state_class: measurement
      unit_of_measurement: W
      device_class: power
      friendly_name: Waschmaschine  Derzeitiger Verbrauch
    last_changed: '2025-05-31T13:53:05.963596+00:00'
    last_reported: '2025-05-31T13:53:05.963596+00:00'
    last_updated: '2025-05-31T13:53:05.963596+00:00'
    context:
      id: 01JWK9W7DBQHBEJYRV39467MGQ
      parent_id: null
      user_id: null
  to_state:
    entity_id: sensor.waschmaschine_derzeitiger_verbrauch
    state: '0.0'
    attributes:
      state_class: measurement
      unit_of_measurement: W
      device_class: power
      friendly_name: Waschmaschine  Derzeitiger Verbrauch
    last_changed: '2025-05-31T13:53:10.764798+00:00'
    last_reported: '2025-05-31T13:53:20.758714+00:00'
    last_updated: '2025-05-31T13:53:10.764798+00:00'
    context:
      id: 01JWK9WC3CCCE5YH03Q48T5ANE
      parent_id: null
      user_id: null
  for:
    __type: <class 'datetime.timedelta'>
    total_seconds: 180
  description: numeric state of sensor.waschmaschine_derzeitiger_verbrauch

How can I write my automation, that it don´t react to trigger change from unknow or unavailable state?

Thanks
padde

Add this condition:

  - condition: template
    value_template: "{{trigger.from_state.state != 'unavailable'}}"

Hi Tom,

thank you, I´ll try.

Best whishes
padde

Hi,

this morning I became another message, now with the state unknown.

above: null
  from_state:
    entity_id: sensor.waschmaschine_derzeitiger_verbrauch
    state: unknown
    attributes:
      state_class: measurement
      unit_of_measurement: W
      device_class: power
      friendly_name: Waschmaschine  Derzeitiger Verbrauch
    last_changed: '2025-06-03T07:27:46.170040+00:00'

How can I combine these to states with an or?

Thnak you
padde

- condition: template
    value_template: "{{trigger.from_state.state != 'unavailable'}}"
- condition: template
    value_template: "{{trigger.from_state.state != 'unknown'}}"

Thank you Francis.

Best regards
padde

Or combined:

- condition: template
    value_template: "{{ trigger.from_state.state not in ['unavailable', 'unknown'] }}"

This is, what I meant.

value_template: “{{ trigger.from_state.state != ‘unavailable’ OR ‘unknown’ }}”
value_template: “{{ trigger.from_state.state != ‘unavailable’ OR trigger.from_state.state != ‘unknown’ }}”

I thought, it can be like this, but now, I know, how it works.
Thank you Tom

Francis’s example does the same thing.