Below is a sample automation created using the Home Assistant YAML editor. This automation turns on and off a dimmer switch using an Insert with motion capabilities. In this case, the switch is controlling bathroom lights. The lights will immediately turn on when motion is detected, and turn off when no motion has been detected in 2.5 minutes (150 seconds).
- alias: ‘[Lights] Turn on bathroom lights using motion’ id: ‘lights_bathroom_lights_motion_turn_on’ trigger: - platform: state entity_id: sensor.motion from: ‘off’ to: ‘on’ action: - service: light.turn_on data: entity_id: light.dimmer - alias: ‘[Lights] Turn off bathroom lights using motion’ id: ‘lights_bathroom_lights_motion_turn_offf’ trigger: - platform: state entity_id: sensor.motion to: ‘off’ for: seconds: 150 action: - service: light.turn_off entity_id: light.dimmer