-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathschedule-switch.yaml
More file actions
53 lines (50 loc) · 1.34 KB
/
schedule-switch.yaml
File metadata and controls
53 lines (50 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
blueprint:
name: Schedule Switch
description: Turn a switch on/of based a helper schedule changed state
domain: automation
input:
entity_switch:
name: Switch
description: Switch to turn on/off based on schedule state
selector:
entity:
domain: switch
multiple: false
entity_schedule:
name: Schedule
description: Schedule to listen for state triggers
selector:
entity:
domain: schedule
multiple: false
extra_actions:
name: Actions to fire when state occurred
default: []
selector:
action: { }
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: !input "entity_schedule"
to: 'on'
- platform: state
entity_id: !input "entity_schedule"
to: 'off'
action:
- variables:
entity_schedule: !input "entity_schedule"
payload: "{% if trigger.to_state|default(false,true) %}{{ trigger.to_state.state }}{% else %}{{ states(entity_schedule) }}{% endif %}"
- if:
- condition: template
value_template: "{{ payload == 'on' }}"
then:
- service: switch.turn_on
target:
entity_id: !input "entity_switch"
else:
- service: switch.turn_off
target:
entity_id: !input "entity_switch"
- choose: [ ]
default: !input extra_actions