- alias: Turn on/off Main Bathroom Light using sensor4
trigger:
- platform: mqtt
topic: "zigbee2mqtt/IKEA Sensor 4"
payload: true
value_template: "{{ value_json.occupancy }}"
action:
- choose:
- conditions:
- condition: time
after: '01:00:00'
before: '06:00:00'
- condition: state
entity_id: light.master_bathroom
state: "off"
sequence:
- service: light.turn_on
target:
entity_id: light.master_bathroom
data:
brightness: 35
color_temp: 554
- delay:
minutes: 3
- service: light.turn_off
target:
entity_id: light.master_bathroom
- conditions:
- condition: state
entity_id: light.master_bathroom
state: "off"
sequence:
- service: light.turn_on
target:
entity_id: light.master_bathroom
data:
brightness: 255
color_temp: 225
- delay:
minutes: 3
- service: light.turn_off
target:
entity_id: light.master_bathroom
default: []
mode: restart
That version isn’t mine and contains an error from tamsy’s example. Both sequence blocks are over-indented.
For your convenience, here it is:
- alias: Turn on/off Main Bathroom Light using sensor4
trigger:
- platform: mqtt
topic: "zigbee2mqtt/IKEA Sensor 4"
payload: true
value_template: "{{ value_json.occupancy }}"
action:
- choose:
- conditions:
- condition: time
after: '01:00:00'
before: '06:00:00'
- condition: state
entity_id: light.master_bathroom
state: "off"
sequence:
- service: light.turn_on
target:
entity_id: light.master_bathroom
data:
brightness: 35
color_temp: 554
- delay:
minutes: 3
- service: light.turn_off
target:
entity_id: light.master_bathroom
- conditions:
- condition: state
entity_id: light.master_bathroom
state: "off"
sequence:
- service: light.turn_on
target:
entity_id: light.master_bathroom
data:
brightness: 255
color_temp: 225
- delay:
minutes: 3
- service: light.turn_off
target:
entity_id: light.master_bathroom
default: []
mode: restart
Thank you. I moved the sequence back 2 spaces and now the error is done.
Thank a million for the help. Where can I read more about the indentation rules for yaml? If you have any good resources I would appreciate it very much,
Glad to hear it finally resolved the problem.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic is resolved. This helps other users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.
Start here: YAML
Then review the syntax for choose
.