Context: my dishwasher is starting to fail randomly, it’s cycles do not finish every time (and it continues to heat for hours); i have a connected metering smart plug on it, so i figured i would notify myself and/or cut power if the cycle takes longer than expected.
To do this, i created a template binary sensor helper using the UI, with the following template, so that a binary state reflects whether the dishwasher is consuming power:
{% if states('sensor.lave_vaisselle_power') | int > 0 %} {{ true }} {% else %} {{ false }} {% endif %}
The full yaml from .storage/core.config_entries is the following:
{
"entry_id": "b81da1ef5aaea9ff5716d706efdb1958",
"version": 1,
"domain": "template",
"title": "Lave vaisselle actif",
"data": {},
"options": {
"template_type": "binary_sensor",
"name": "Lave vaisselle actif",
"state": "{% if states('sensor.lave_vaisselle_power') | int > 0 %} {{ true }} {% else %} {{ false }} {% endif %}",
"device_class": "running"
},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "user",
"unique_id": null,
"disabled_by": null
}
This sensor works as expected:
Then i wanted to trigger some action (e.g. notification) when this binary sensor turns to “on” for more than 3 hours.
alias: dishwasher debug
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.lave_vaisselle_actif
for:
hours: 3
minutes: 0
seconds: 0
to: "on"
condition: []
action:
- service: notify.mobile_app_me
data:
message: Dishwasher is taking too long !
mode: single
However, this is never triggering (despite having reached the right duration on the sensor, as seen in the history and state change journal.
There is probably something really obvious here, but what am i missing here ? Thanks a lot for your help.
PS: running 2023.9.2