Hello, I built this automation for out livingroom lights but it does not trigger. Any tips what might be wrong?
- id: 'iltavalot'
alias: Ilta-valot
trigger:
platform: numeric_state
entity_id: sensor.hue_motion_sensor_1_light_level
below: 25
condition:
condition: and
conditions:
- condition: time
after: '14:00:00'
before: '23:30:00'
- condition: or
conditions:
- condition: state
entity_id: person.123
state: home
- condition: state
entity_id: person.abc
state: home
- condition: state
entity_id: person.dfg
state: home
action:
- service: script.iltavalot_on
First, make sure the automation is turned on. There are some conditions under which an automation will be turned off without notifying that this has happened.
Next, the way I read it, the action (running script.iltavalot_on) should happen when the state of sensor.hue_motion_sensor_1_light_level changes from 25 or above to below 25, if, when that happens, the time is between 14:00:00 and 23:30:00, and at least one of those people are home. Is that what you want?
Have you tried manually triggering the automation to see if the script runs, and it does what you want?
Yes, the automation is on and you understood the goal of the automation right.
I have tried it manually and the lights go on.
Tried what manually? The script?
Or triggering the automation?
I was asking about the latter. Note that when you click the TRIGGER button the automation’s action will run regardless of the trigger and conditions. I.e., it just tests the action part. Oh, also, in case it wasn’t obvious, that toggle switch is what turns the automation on and off. In this picture you can see the automation is on.
Have you looked at the history of sensor.hue_motion_sensor_1_light_level? Did it go from 25 or above to below 25 when the conditions of the automation were met?
The Trigger one.
Yes, I have checked the history and the conditions have met. I tried it when I was at home between that time window and put a hanky on top of the light sensor so it went to 1.00 from 50 something.
The way you have it indented you don’t have any OR conditions, just a load of AND conditions, one of which is an empty OR with nothing in it.
condition:
condition: and
conditions:
- condition: time
after: '14:00:00'
before: '23:30:00'
- condition: or
conditions:
- condition: state
entity_id: person.123
state: 'home'
- condition: state
entity_id: person.abc
state: 'home'
- condition: state
entity_id: person.dfg
state: 'home'
1 Like
Just noticed that myself!
1 Like
OK, I am a a bit of a newbie with this. Could you please show me how it should be? I do not get it.
I was trying to follow this AND/OR example in the Conditions page:
condition:
condition: and
conditions:
- condition: state
entity_id: 'device_tracker.paulus'
state: 'home'
- condition: or
conditions:
- condition: state
entity_id: sensor.weather_precip
state: 'rain'
- condition: numeric_state
entity_id: 'sensor.temperature'
below: 20
I did show you how it should be in my post
Oh!!! Doh… the indents!!. Thanks
1 Like
That’s the one
The way you had it originally all of the conditions fell under the AND condition, the OR condition didn’t have anything in it.
Thank You! Now it works like a charm.
1 Like