henaa
(hen)
January 12, 2020, 3:42pm
1
Hi
I want to create automation
when the:
door sensor on AND shower lamp light off AND motion sensor on
then
turn on shower lamp light
what wrong in the code?
- id: '1578843093281'
alias: new automation
description: ''
trigger:
- entity_id: binary_sensor.door_window_sensor_158d00042e4298
from: 'on'
platform: state
condition:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.motion_sensor_158d0003956207
state: 'on'
- condition: and
conditions:
- condition: state
entity_id: light.showerlamp
state: 'off'
action:
- data:
entity_id: light.showerlamp
service: light.turn_on
No need for these nested AND conditions, conditions are anyway AND by default.
Are you sure that you want the door to trigger the automation? Is your motion sensor already βonβ when you open the door? If the motion sensor turns βonβ after the door sensor turns βonβ, this will not work, because at the moment the door sensor triggers the automation, the motion sensor is not βonβ and therefore it will not fire.
henaa
(hen)
January 12, 2020, 4:36pm
3
The door sensor is on (open)
light is off
when the motion sensor change off to on
I want the trigger will work
metbril
(Robert π³π±πͺπΊ)
January 12, 2020, 4:48pm
4
In that case you would want the trigger to be the motion sensor to βonβ and use the door sensor and light state as conditions.
henaa
(hen)
January 12, 2020, 4:53pm
5
I change the code to this
And still not work
- id: '1578843093281'
alias: new automation
description: ''
trigger:
- platform: template
value_template: "{{ is_state('binary_sensor.door_window_sensor_158d00042e4298', 'on')\
\ and\n is_state('binary_sensor.motion_sensor_158d0003956207', 'on')\
\ and\n is_state('light.showerlamp', 'off')\
\ }}\n"
action:
- data:
entity_id: light.showerlamp
service: light.turn_on
Why are you using a template now?
Try like this:
- id: '1578843093281'
alias: new automation
description: ''
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d0003956207
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.door_window_sensor_158d00042e4298
state: 'on'
- condition: state
entity_id: light.showerlamp
state: 'off'
action:
- service: light.turn_on
entity_id: light.showerlamp
1 Like