How do I solve this? Can’t think by myself apparently.
The automation below didn’t start today because sun condition didn’t pass.
Automation consists of a Hue outdoor motion sensor (light level) and sun condition.
Triggered by the numeric state of sensor.infart_motion_light_level at 28 September 2021, 18:31:08
Test sun condition
Stopped because a condition failed at 28 September 2021, 18:31:08 (runtime: 0.00 seconds)
Not all shown logbook entries might be related to this automation.
Normally, the sun sets before the lightlevel drops below 25 lux, but today with heavy clouds and rain, the sun triggered after the light level dropped to 25 lux.
How do I prevent this to happen again? I wan’t the automation to run like the snippet below, but also if the sun has dropped below horizon before the lux level hasn’t.
Suggestions highly appreciated!
If you are happy for the automation to run on either sunset and or lux below 25 then just remove the sunset condition and add it as the 2nd trigger that way causing the automation to run on either state.
Unless of course you want or need both conditions to be true?
Ok what about having them both as triggers then and using the choose option and under each action use the trigger id and set the other as the condition?
That way it will trigger twice, and will only action when both conditions are true
alias: New Automation
description: ''
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.garage_motion_sensor_lux_level
below: '25'
id: lux below 25 or some other frinedly name
- platform: sun
event: sunset
id: sunset or some other friendly name
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: lux below 25 or some other frinedly name
- condition: sun
after: sunset
sequence:
- service: light.turn_on
target:
entity_id: light.bathroom
- conditions:
- condition: trigger
id: sunset or some other friendly name
- condition: numeric_state
entity_id: sensor.garage_motion_sensor_lux_level
below: '25'
sequence:
- service: light.turn_on
target:
entity_id: light.bathroom
Yours should also achieve the same thing as in basic form you want both conditions to be true and therefore want it to trigger on both states but only proceed to actions if both states are true.
Not really I don’t think, like most things in home assistant there are 101 ways to achieve the same thing in most cases!
I use the choose a lot so that’s the first thing that tends to come to my mind when writing an automation to script, what ever my brain finds easier to compute i guess.