I have a really weird issue, no matter what I do I can’t get this trigger to work.
I tried numeric_state trigger with below 150, for “00:05:00” not working, tried making a numeric sensor via template to make sure it’s numeric, still same problem, instead of string tried to specify minutes, hours, seconds, now switched to a template trigger for better debugging, template works fine switches from false to true, but the trigger never fires, manually setting the entity to 160 for 10 minutes, then to 20 for 5 minutes nothing…
I tried so many other things but it never works and I don’t know what to try next.
There are no error logs etc.
- alias: "turn on ambient light on sunset"
trigger:
- platform: template
value_template: "{{ states('sensor.lightsensor1_bh1750_illuminance') | default(0) | int < 150 }}"
for: "00:05:00"
condition:
- condition: and
conditions:
- condition: time
after: "15:30:00"
before: "23:00:00"
- condition: state
entity_id: binary_sensor.at_home
state: "home"
action:
- service: script.chill_mode
data:
mode: "on"
If every version of the trigger you created has failed to work then your automation will not have created a single trace.
So has your automation never produced a trace?
If it has produced a trace, review what the trace reports when the automation’s condition was evaluated (see Edwin_D’s post below). It’s likely that your triggers have been functional but your condition prevents the automation from executing its actions.
Binary sensors never have the state home, so this will never pass. You can see the right values in developer tools, and you can see what blocks the automation in the automation trace.
When you suspect a trigger problem, always test with a simple notification automation without conditions.
And, not a problem, but the and is not needed. If you list two conditions in the conditions section, both need to pass. So it is and by default.
And a last comment, the trigger boils down to a numerical state condition. It is better to use that instead to reduce complexity and increase readability.