Skip to content

Commit b1717c3

Browse files
scottocs11Landrash
authored andcommitted
Remove unnecessary script usage (home-assistant#2126)
Scripts are not necessary to perform this automation.
1 parent 1336e15 commit b1717c3

File tree

1 file changed

+15
-30
lines changed

1 file changed

+15
-30
lines changed

source/_cookbook/turn_on_light_for_10_minutes_when_motion_detected.markdown

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,22 @@ This recipe will turn on a light when there is motion and turn off the light whe
1616

1717
```yaml
1818
automation:
19-
alias: Turn on kitchen lights when there is movement
19+
- alias: Turn on kitchen light when there is movement
2020
trigger:
21-
- platform: state
22-
entity_id: sensor.motion_sensor
23-
to: 'on'
21+
platform: state
22+
entity_id: sensor.motion_sensor
23+
to: 'on'
2424
action:
2525
service: homeassistant.turn_on
26-
entity_id: script.timed_lamp
26+
entity_id: light.kitchen
2727

28-
script:
29-
timed_lamp:
30-
alias: "Turn on lamp and set timer"
31-
sequence:
32-
# Cancel ev. old timers
33-
- service: script.turn_off
34-
data:
35-
entity_id: script.timer_off
36-
- service: light.turn_on
37-
data:
38-
entity_id: light.kitchen
39-
# Set new timer
40-
- service: script.turn_on
41-
data:
42-
entity_id: script.timer_off
43-
44-
timer_off:
45-
alias: "Turn off lamp after 10 minutes"
46-
sequence:
47-
- delay:
48-
minutes: 10
49-
- service: light.turn_off
50-
data:
51-
entity_id: light.kitchen
52-
```
28+
- alias: Turn off kitchen light 10 minutes after last movement
29+
trigger:
30+
platform: state
31+
entity_id: sensor.motion_sensor
32+
to: 'off'
33+
for:
34+
minutes: 10
35+
action:
36+
service: homeassistant.turn_off
37+
entity_id: light.kitchen_light

0 commit comments

Comments
 (0)