Hello, I have an automation that notifies me when household devices like dishwasher/washing machine are done.
The monitoring is done using smart sockets and the automation detects if the power draw drops below a certain value.
However, sometimes the automation triggers at seemingly random times because the state changes from “unavailable” to a value below the threshold. This happens for example if I restart HA or the device has connectivity issues.
I tried to fix this with a condition, but I cannot seem to be able to get the condition right.
This is what I have right now, but the condition always evaluates to false, even if the old state was a number.
alias: Machine done alerts
description: ''
triggers:
- trigger: numeric_state
entity_id:
- sensor.washing_machine_power
for:
hours: 0
minutes: 5
seconds: 0
below: 3
- trigger: numeric_state
entity_id:
- sensor.dishwasher_power
for:
hours: 0
minutes: 5
seconds: 0
below: 1
conditions:
- condition: template
value_template: trigger.from_state.state != "unknown"
actions:
- action: notify.notify
metadata: {}
data:
message: '{{ trigger.to_state.name }} is done!'
mode: single
Here are some sample trace excerpts:
This one should be ignored
trigger:
from_state:
entity_id: sensor.dishwasher_power
state: unknown
attributes:
state_class: measurement
unit_of_measurement: W
device_class: power
friendly_name: Dishwasher Power
to_state:
entity_id: sensor.dishwasher_power
state: '0'
attributes:
state_class: measurement
unit_of_measurement: W
device_class: power
friendly_name: Dishwasher Power
This one should not be ignored but is
trigger:
from_state:
entity_id: sensor.washing_machine_power_2
state: '99.1'
attributes:
state_class: measurement
unit_of_measurement: W
device_class: power
friendly_name: Washing Machine Power
to_state:
entity_id: sensor.washing_machine_power_2
state: '2'
attributes:
state_class: measurement
unit_of_measurement: W
device_class: power
friendly_name: Washing Machine Power