I’ve been trying for a while to create an automation for turning a smart bulb (Tapo) on/off based on motion detected by a sensor (Ikea Zigbee motion sensor).
What do I want to achieve? I want to turn on the light (in the bathroom) between 7 PM and 12 AM at a brightness of 70%, and between 12 AM and 7 AM at a brightness of 10%, when the motion sensor detects presence. After detecting motion, the light should turn on for 2 minutes and then turn off.
I tried the following script, but i cant save it because it gave me the error " Message malformed: extra keys not allowed @ data[‘trigger’] "
description: "Turn on the light on motion, turn off after no motion for 2 minutes."
mode: restart
trigger:
- platform: state
entity_id:
- binary_sensor.ikea_motion_sensor_occupancy
from: "off"
to: "on"
id: "on_motion"
- platform: state
entity_id:
- binary_sensor.ikea_motion_sensor_occupancy
from: "on"
to: "off"
for:
hours: 0
minutes: 2
seconds: 0
condition: []
action:
- if:
- condition: trigger
id:
- "on_motion"
then:
- choose:
- conditions:
- condition: time
after: "00:00:00"
before: "07:00:01"
sequence:
- action: light.turn_on
data:
brightness_pct: 10
target:
entity_id: light.bathroom
- conditions:
- condition: time
before: "00:00:00"
after: "19:00:00"
sequence:
- action: light.turn_on
data:
brightness_pct: 70
target:
entity_id: light.bathroom
else:
- action: light.turn_off
data: {}
target:
entity_id: light.bathroom
I’m using HA core 2024.8.2 running as a container in docker ( Portainer ).