Skip to content

Commit a5aaf79

Browse files
New Demo Files
1 parent 99e3be3 commit a5aaf79

File tree

6 files changed

+240
-0
lines changed

6 files changed

+240
-0
lines changed

2023-ResponseVariables/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div align="center">
2+
<img src="../images/slacker_labs.png">
3+
<h1>Response Variable Examples</h1>
4+
<br>
5+
6+
[![Watch the video](../images/videos/tn-2023-response_variables3)](https://youtu.be/ey8MoQUDsRM)
7+
8+
</div>
9+
10+
11+
<h2>Files You Need</h2>
12+
13+
**automations.yaml**
14+
15+
Contains the Automations discussed in the video.
16+
17+
** scripts.yaml **
18+
19+
Contains the scripts discussed in the video.
20+
21+
If you are not using these files check the configuration.yaml for how to tell home assistant to use them.
22+
23+
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
- id: 8a08e182-8b64-43e0-8835-42a46acf228b
2+
alias: really_cool_automation
3+
trigger:
4+
- platform: state
5+
entity_id: button.get_tagline
6+
id: easy_button
7+
- platform: state
8+
entity_id: binary_sensor.aqara_vibrator
9+
to: 'on'
10+
id: baited_by_the_master
11+
- platform: state
12+
entity_id: sensor.3d_printer_state
13+
to: 'finished'
14+
id: nice
15+
action:
16+
- variables:
17+
slackerlabs: "Automate the Boring Stuff!"
18+
paulhibbert: "ooooh the Zigbee."
19+
everythingsmarthome: "nice"
20+
- choose:
21+
- conditions:
22+
- condition: trigger
23+
id: easy_button
24+
sequence:
25+
- service: notify.jeff_ios
26+
data:
27+
message: '{{ slackerlabs }}'
28+
- conditions:
29+
- condition: trigger
30+
id: baited_by_the_master
31+
sequence:
32+
- service: script.ohyeah
33+
- conditions:
34+
- condition: trigger
35+
id: nice
36+
sequence:
37+
- service: notify.jeff_ios
38+
data:
39+
message: '{{ everythingsmarthome }}'
40+
default: []
41+
42+
- id: dff6ec8c-afbe-40ab-9d9d-bda94539e9a0
43+
alias: really_really_cool_automation
44+
trigger:
45+
- platform: state
46+
entity_id: button.get_tagline
47+
id: easy_button
48+
- platform: state
49+
entity_id: binary_sensor.aqara_vibrator
50+
to: 'on'
51+
id: baited_by_the_master
52+
- platform: state
53+
entity_id: sensor.3d_printer_state
54+
to: 'finished'
55+
id: nice
56+
action:
57+
- service: script.get_taglines
58+
response_variable: "taglines"
59+
- choose:
60+
- conditions:
61+
- condition: trigger
62+
id: easy_button
63+
sequence:
64+
- service: notify.jeff_ios
65+
data:
66+
message: '{{ taglines.slackerlabs }}'
67+
- conditions:
68+
- condition: trigger
69+
id: baited_by_the_master
70+
sequence:
71+
- service: script.ohyeah
72+
- conditions:
73+
- condition: trigger
74+
id: nice
75+
sequence:
76+
- service: notify.jeff_ios
77+
data:
78+
message: '{{ taglines.everythingsmarthome }}'
79+
80+
- id: 618bd49f-3b0a-4b09-85ce-52f4e3b2f38c
81+
alias: Smart Kitchen Lighting
82+
description: ''
83+
trigger:
84+
# The jina here might work better as a binary_sensor entity, because you could
85+
# visually see the currnt state and be able to check timestamps. But this should work
86+
# and trigger your automation any time a motion, occupancy, or door sensor in the
87+
# kitchen area turns on.
88+
- platform: template
89+
value_template: >
90+
{{ states.binary_sensor |
91+
selectattr('entity_id', 'in', area_entities('kitchen')) |
92+
rejectattr('attributes.device_class', 'undefined') |
93+
selectattr('attributes.device_class', 'search', '(occupancy|motion|door)') |
94+
selectattr('state', 'eq', 'on') |
95+
map(attribute='entity_id') |
96+
list | count > 0}}
97+
id: Light_Needed
98+
- platform: template
99+
value_template: >
100+
{{ states.binary_sensor |
101+
selectattr('entity_id', 'in', area_entities('kitchen')) |
102+
rejectattr('attributes.device_class', 'undefined') |
103+
selectattr('attributes.device_class', 'search', '(occupancy|motion|door)') |
104+
selectattr('state', 'eq', 'on') |
105+
map(attribute='entity_id') |
106+
list | count > 0}}
107+
for: '00:01:00'
108+
id: lights_dim
109+
- platform: template
110+
value_template: >
111+
{{ states.binary_sensor |
112+
selectattr('entity_id', 'in', area_entities('kitchen')) |
113+
rejectattr('attributes.device_class', 'undefined') |
114+
selectattr('attributes.device_class', 'search', '(occupancy|motion|door)') |
115+
selectattr('state', 'eq', 'on') |
116+
map(attribute='entity_id') |
117+
list | count > 0}}
118+
for: '00:05:00'
119+
id: light_not_needed
120+
condition: []
121+
action:
122+
# This action calls our get_room_lights script and gets a list of all the light entities in your kitchen
123+
- service: script.get_room_lights
124+
data:
125+
room: kitchen
126+
response_variable: "room"
127+
- choose:
128+
- conditions:
129+
- condition: trigger
130+
id: Light_Needed
131+
sequence:
132+
- service: light.turn_on
133+
data:
134+
brightness_pct: 100
135+
target:
136+
entity_id: '{{room.lights}}' # this uses the response the get_room_lights script to the entity ids.
137+
- conditions:
138+
- condition: trigger
139+
id: Light_Needed
140+
- condition: state
141+
entity_id: input_boolean.audible_notifications
142+
state: 'off'
143+
sequence:
144+
- service: light.turn_on
145+
data:
146+
brightness_pct: 50
147+
target:
148+
entity_id: '{{room.lights}}'
149+
- conditions:
150+
- condition: trigger
151+
id: lights_dim
152+
sequence:
153+
- service: light.turn_on
154+
data:
155+
brightness_pct: 20
156+
target:
157+
entity_id: '{{room.lights}}'
158+
- conditions:
159+
- condition: trigger
160+
id: light_not_needed
161+
sequence:
162+
- service: light.turn_off
163+
target:
164+
entity_id: '{{room.lights}}'
165+
default: []
166+
mode: restart
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
# Configure a default setup of Home Assistant (frontend, api, etc)
4+
default_config:
5+
6+
automation: !include automations.yaml
7+
script: !include scripts.yaml
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
get_taglines:
2+
sequence:
3+
- variables:
4+
slackerlabs: "Automate the Boring Stuff!"
5+
paulhibbert: "ooooh the Zigbee."
6+
everythingsmarthome: "nice"
7+
taglines: >
8+
{"slackerlabs": "{{slackerlabs}}",
9+
"paulhibbert":"{{paulhibbert}}",
10+
"everythingsmarthome":"{{everythingsmarthome}}"}
11+
- stop: "Alight. Im done."
12+
response_variable: "taglines"
13+
14+
# jarvis_speaker only gets Echos by limiting to media players with the last_called attribute
15+
# audio speaker gets any device with the class speaker
16+
get_room_services:
17+
sequence:
18+
- variables:
19+
room_services: >-
20+
{% set jarvis_speaker = states.media_player |
21+
selectattr('entity_id', 'in', area_entities(room)) |
22+
rejectattr('attributes.last_called', 'undefined') |
23+
map(attribute='entity_id') |
24+
list | first %}
25+
26+
{% set audio_speaker = states.media_player |
27+
selectattr('entity_id', 'in', area_entities(room)) |
28+
rejectattr('attributes.device_class', 'undefined') |
29+
selectattr('attributes.device_class', 'search', '(speaker)') |
30+
map(attribute='entity_id') |
31+
list | first %}
32+
33+
{% set tts = 'amp' %}
34+
{"area":"{{room}}","jarvis_speaker":"{{jarvis_speaker}}","jarvis_tts":"{{tts}}","audio_speaker":"{{audio_speaker}}"}
35+
- stop: "ok, Im done."
36+
response_variable: "room_services"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Use this file to store secrets like usernames and passwords.
2+
# Learn more at https://www.home-assistant.io/docs/configuration/secrets/
3+
some_password: welcome
4+
5+
# Update these if you are going to use Amazon Polly config in
6+
# the configuration.yaml
7+
aws_key: fbvekjbvwblv
8+
aws_secret: nfegvwvlwbljew
134 KB
Loading

0 commit comments

Comments
 (0)