-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaesthetic-automation.yaml
More file actions
109 lines (109 loc) · 4 KB
/
Copy pathaesthetic-automation.yaml
File metadata and controls
109 lines (109 loc) · 4 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
alias: The Internet Desk
description: The Internet as it was meant to be.
triggers:
- trigger: state
entity_id:
- sensor.the_internet_desk_the_internet_desk_tag
conditions: []
actions:
- choose:
- conditions:
- condition: template
value_template: >-
{{ trigger.to_state.state != '' and trigger.to_state.state in
device_map }}
sequence:
- target:
entity_id: light.<your_light_id>
data:
rgb_color:
- 251
- 255
- 0
brightness_pct: 60
action: light.turn_on
- data:
media_content_id: media-source://media_source/local/dialup.mp3
media_content_type: audio/mpeg
target:
entity_id: media_player.<your_media_player_id>
action: media_player.play_media
# These `wait_template`s ensure that the tag is still present before continuing
- wait_template: >-
{{ is_state('sensor.the_internet_desk_the_internet_desk_tag', '')
}}
timeout:
# I fudge this a bit - it takes roughly 12 seconds from "unblock" to my device
# being able to reconnect. The dialup sound is 30s, to allow for the "illusion"
# of connecting once the dialup sound is completed we flip the switch on a
# a little earlier than the other parts of this automation.
seconds: 18
continue_on_timeout: true
- condition: template
value_template: >-
{{ not is_state('sensor.the_internet_desk_the_internet_desk_tag',
'') }}
- target:
entity_id: "{{ device_map[trigger.to_state.state] }}"
action: switch.turn_on
- wait_template: >-
{{ is_state('sensor.the_internet_desk_the_internet_desk_tag', '')
}}
timeout:
# 18 + 12 = 30, the duration of our dialup.mp3
seconds: 12
continue_on_timeout: true
- condition: template
value_template: >-
{{ not is_state('sensor.the_internet_desk_the_internet_desk_tag',
'') }}
- data:
rgb_color:
- 0
- 255
- 0
target:
entity_id: light.<your_light_id>
action: light.turn_on
- data:
media_content_id: media-source://media_source/local/Welcome.mp3
media_content_type: audio/mpeg
target:
entity_id: media_player.<your_media_player_id>
action: media_player.play_media
- conditions:
- condition: template
value_template: >
{% set new_state = trigger.to_state.state %} {% set old_state =
trigger.from_state.state %} {{ new_state == '' and old_state !=
'' and old_state in device_map }}
sequence:
- target:
entity_id: "{{ device_map.values() | list }}"
action: switch.turn_off
- target:
entity_id: media_player.<your_media_player_id>
action: media_player.media_stop
data: {}
- target:
entity_id: light.<your_light_id>
data:
rgb_color:
- 255
- 0
- 0
brightness_pct: 90
action: light.turn_on
- data:
media_content_id: media-source://media_source/local/Goodbye.mp3
media_content_type: audio/mpeg
target:
entity_id: media_player.<your_media_player_id
action: media_player.play_media
mode: restart
variables:
# The device_map is {"An NFC Tag ID to be scanned": "A switch in HA that when set to On allows internet access, and when Off will disable it"}
device_map: |
{{ {
"<your_nfc_tag_id>": "switch.<your_switch_id>",
} }}