mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-13 12:26:50 +00:00
Remove unnecessary script usage (#2126)
Scripts are not necessary to perform this automation.
This commit is contained in:
parent
1336e15507
commit
b1717c35e1
@ -16,37 +16,22 @@ This recipe will turn on a light when there is motion and turn off the light whe
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
automation:
|
automation:
|
||||||
alias: Turn on kitchen lights when there is movement
|
- alias: Turn on kitchen light when there is movement
|
||||||
trigger:
|
trigger:
|
||||||
- platform: state
|
platform: state
|
||||||
entity_id: sensor.motion_sensor
|
entity_id: sensor.motion_sensor
|
||||||
to: 'on'
|
to: 'on'
|
||||||
action:
|
action:
|
||||||
service: homeassistant.turn_on
|
service: homeassistant.turn_on
|
||||||
entity_id: script.timed_lamp
|
|
||||||
|
|
||||||
script:
|
|
||||||
timed_lamp:
|
|
||||||
alias: "Turn on lamp and set timer"
|
|
||||||
sequence:
|
|
||||||
# Cancel ev. old timers
|
|
||||||
- service: script.turn_off
|
|
||||||
data:
|
|
||||||
entity_id: script.timer_off
|
|
||||||
- service: light.turn_on
|
|
||||||
data:
|
|
||||||
entity_id: light.kitchen
|
entity_id: light.kitchen
|
||||||
# Set new timer
|
|
||||||
- service: script.turn_on
|
|
||||||
data:
|
|
||||||
entity_id: script.timer_off
|
|
||||||
|
|
||||||
timer_off:
|
- alias: Turn off kitchen light 10 minutes after last movement
|
||||||
alias: "Turn off lamp after 10 minutes"
|
trigger:
|
||||||
sequence:
|
platform: state
|
||||||
- delay:
|
entity_id: sensor.motion_sensor
|
||||||
|
to: 'off'
|
||||||
|
for:
|
||||||
minutes: 10
|
minutes: 10
|
||||||
- service: light.turn_off
|
action:
|
||||||
data:
|
service: homeassistant.turn_off
|
||||||
entity_id: light.kitchen
|
entity_id: light.kitchen_light
|
||||||
```
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user