Futuristic, Advanced Automations with Room Assistant
Warning! If you are not a lunatic, like me, then I suggest you don’t attempt any of this. Not only is this going to use Home Assistant, but all the advanced features of it.
Stop! Don’t read any more. I’m warning you…
Well if you are still reading, then you are a brave soul. Just know, I’ve had so much fun with these advanced features and I think it’s worth it, if you have a technical background.
There are already some great videos and articles explaining how to do a lot of the set up. I’m going to link to those since there is no need to replicate them. What I will do is explain what I did afterward to get everything working smoothly. For me that was the most difficult part, finding those missing puzzle pieces.
Alexa Actions
Something I’ve wanted for so long is the option to have Alexa initiate a conversation, and for me to only need to say “yes” or “no.” This is finally possible, and I set this up with the latest Home Assistant updates, so everything should be working fine.
The only issue I ran into was not following the instructions EXACTLY. I had an extra “/” at the end of my URL and it didn’t work because of that. So if you follow the instructions exactly, you should be okay.
Mark Watt Tech made this video and it walks you through Alexa actions: https://youtu.be/uoifhNyEErE
Here is the link to the project as well on GitHub: https://github.com/keatontaylor/alexa-actions
Once that is set up, you will be able to have Alexa ask you a question and you can trigger an automation by just responding with the word “yes”!
But in my opinion, it’s still missing the another key ingredient. That’s knowing which room you are in, so Alexa can talk to you on the nearest Echo device. Here’s where Room Assistant comes in.
Room Assistant Installation
There are probably some good videos out there explaining how to set up Room Assistant, but again, Mark Watt Tech was so clear and easy to follow. Those are the videos I used to set mine up and I highly recommend watching these and subscribing.
It’s a 4 part video series, so buckle up!
Video 1, Video 2, Video 3, Video 4
If you want to reference the Room Assistant project, here it is.
Here are the Raspberry Pi zeros I used. Link 1 and Link 2. They are very is inexpensive, because these things don’t need to do much. At the time of writing this the Pi zeros I bought are sold out.
Following those steps should get the majority of the Room Assistant installation done. If it’s not fully working, don’t worry this next section will get everything working smoothly.
You thought this would be easy… I warned you. Don’t worry, you are almost there. Okay not really, but I believe in you! Yep that’s a lie too.
Okay moving on!
Configuring Room Assistant
If you are using iOS, make sure you have the companion app installed: https://www.room-assistant.io/integrations/bluetooth-low-energy.html#tracking-ios-devices
Right now I’m using a Pixel 5a as my phone. Here’s how to set up the BLE sensor on an Android phone:
- Open up the Home Assistant Android app on your phone.
- On the left menu select “Configuration”
- Scroll down and select “Companion App”
- Select “Manage Sensors” under the Sensors section.
- Scroll down to the “Bluetooth Sensor” section and select “BLE Transmitter”
- Enable that, and I set my Transmitter power to “Low”. You might need to adjust yours, but this is where you find that.
- Take note of the “id” because you will need that for this next step.
Now you are going to need to open up that config file for Room Assistant on the Raspberry Pi you installed it on. You are going to want to add that “id” so Room Assistant can track your device. Add it to the allowlist and tagOverrides sections. Here is what my config file looks like.
cluster:
autoDiscovery: false
port: 6425
peerAddresses:
- 192.168.1.62:6425
- 192.168.1.144:6425
weight: 10
quorum: 2
global:
instanceName: Office Pi
integrations:
- homeAssistant
- bluetoothLowEnergy
homeAssistant:
mqttUrl: 'mqtt://********:1883'
mqttOptions:
username: *******
password: *******
bluetoothLowEnergy:
allowlist:
- 43**********************-100-1
maxDistance: 5
minDiscoveryLogRssi: -30
tagOverrides:
43**********************-100-1:
name: PixelBLE
Make sure to use Bluetooth Low Energy, not Bluetooth Classic. The Bluetooth Low Energy is going to be much more accurate and use less power.
The only field you might need to change is the “maxDistance”. This is the max distance in meters from the Raspberry Pi to your phone for Room Assistant to say your phone is in the room. It will make sense after this next part.
To figure out what distance Room Assistant thinks the phone is, go to http://**Pi_URL**:6415/entities …so mine is http://192.168.1.143:6415/entities
This will spit out some JSON. Copy and paste it into a JSON formatter to read it better. I’ve always used https://jsonlint.com/
There are 3 important fields to watch: “distance”, “lastUpdatedAt”, and “outOfRange”. If your phone has a BLE connection to the Raspberry Pi, the “lastUpdatedAt” field will update with the current timestamp. If you look at that field and it’s a timestamp from an hour ago, that means that was when it was last connected.
So if the BLE on your phone is connected to the Raspberry Pi, then it will update the “distance”. By default it should update around every 30 seconds, but if you changed that it might be different. This is where you have to move around the room or go to different rooms to make sure you have the right distance set in the config file.
If the distance is too high, you might be detected in another room. If the distance is too low, it might not detect you if your phone is in your pocket.
Also the higher the Transmitter power is in the Home Assistant companion app setting, the more accurate the distance will be. But setting that too high can also reach much further across the house than it should. It’s a balancing act.
Once you get all that done, the rest of it isn’t too bad.
Home Assistant Scripts
Before I go over the automations, there are a few scripts I’ll be referencing. One will automatically select the nearest Echo device for the Alexa Notification. That way I can just pass a few variables to the script and it can handle the rest.
Then if I ever change how many Raspberry Pis are in my Room Assistant setup, I can just modify one script. Same goes for my phone’s push notifications.
You do not need to do this, but it could save you a lot of time if you’re setting up more than a handful of automations.
Here’s what the first script is doing.
- Sets the volume level to 40% so I can hear it and it’s not too loud.
- Selects the Echo device using a template with if, elif, else. Depending on the “sensor.6proble_room_presence” which is my Room Assistant BLE sensor.
- Then I’m just passing a few variables to the next script. {{ message }} is being set to “text” and {{ event_identification }} is being set to event_id
alias: Alexa Notification Wrapper
sequence:
- service: media_player.volume_set
data:
volume_level: 0.4
target:
entity_id: |-
{% if is_state("sensor.6proble_room_presence", "Office Pi") -%}
media_player.reed_s_echo_show_5_2nd_gen
{% elif is_state("sensor.6proble_room_presence", "Kitchen Pi") %}
media_player.reed_s_2nd_echo_show
{% elif is_state("sensor.6proble_room_presence", "Bedroom Pi") %}
media_player.blue_dot
{%- else -%}
media_player.reed_s_echo
{%- endif %}
- service: script.actionable_alexa_notification
data:
text: '{{ message }}'
event_id: '{{ event_identification }}'
alexa_device: |-
{% if is_state("sensor.6proble_room_presence", "Office Pi") -%}
media_player.reed_s_echo_show_5_2nd_gen
{% elif is_state("sensor.6proble_room_presence", "Kitchen Pi") %}
media_player.reed_s_2nd_echo_show
{% elif is_state("sensor.6proble_room_presence", "Bedroom Pi") %}
media_player.blue_dot
{%- else -%}
media_player.reed_s_echo
{%- endif %}
mode: single
My script “actionable_alexa_notification” is the same as the project. This script above just acts as the middle man to automatically set the Echo device and pass the rest of the info to it.
This next one is for my push notifications. It’s pretty straight forward, and just allows me to quickly change the “mobile_app_pixel_5a” when ever I switch my phone. I need to make a more generic one for all my devices.
alias: Actionable Notification Android
sequence:
- service: notify.mobile_app_pixel_5a
data:
title: ' {{title}} '
message: ' {{message}} '
data:
ttl: 0
priority: high
actions:
- action: ' {{replyevent}} '
title: ' {{buttontitle}} '
mode: single
Oh and there is one more condition in every automation that you will see. The input_boolean.advanced_automations has to be true for the automation to run. This just acts as a kill switch in case I want to turn all of these automations off.
I doubted all these automations would be family-friendly, so I added it as a condition to every automation. All the automations have worked so well that I haven’t turned them off and I don’t plan to.
Ok, now let’s get into the specific automations I showed in the video!
Blast Music
For this one, there are actually three automations. One to start the music if I say “yes.” The second to play music everywhere if I leave the room. The third, and most important, to stop the music if my wife Aly comes home.
For the first one, it selects the Echo next to me if I’m in range of Room Assistant. If not, it sends a notification to my phone. It’s a long automation, but I prefer it to all be in one for less clutter.
alias: Adv - Blast Music
description: >-
If I'm home and Aly isn't. Prompt me to blast music in the room I'm in or play
everywhere if I'm not detected in a room.
trigger:
- platform: state
entity_id: device_tracker.alys_iphone_se
for:
hours: 0
minutes: 1
seconds: 0
to: not_home
condition:
- condition: state
entity_id: device_tracker.pixel_5a
state: home
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
- condition: time
after: '07:45:00'
before: '19:00:00'
action:
- choose:
- conditions:
- condition: state
entity_id: sensor.6proble_room_presence
state: not_home
sequence:
- service: script.actionable_notification_android
data:
title: Blast Music
message: Only you are home. Play music?
replyevent: echoblastmusic
buttontitle: Play!
default:
- service: script.alexa_notification_wrapper
data:
message: Everyone is gone, do you want me to blast some music?
event_identification: actionable_notification_blast_music
- wait_for_trigger:
- platform: event
event_data:
action: echoblastmusic
event_type: mobile_app_notification_action
- platform: event
event_type: alexa_actionable_notification
event_data:
event_id: actionable_notification_blast_music
event_response_type: ResponseYes
- choose:
- conditions:
- condition: state
entity_id: sensor.6proble_room_presence
state: not_home
sequence:
- service: media_player.play_media
data:
media_content_type: routine
media_content_id: musiceverywhere
target:
entity_id: media_player.reed_s_echo
default:
- service: media_player.volume_set
data:
volume_level: 0.7
target:
entity_id: |-
{% if is_state("sensor.6proble_room_presence", "Office Pi") -%}
media_player.reed_s_echo_show_5_2nd_gen
{% elif is_state("sensor.6proble_room_presence", "Kitchen Pi") %}
media_player.reed_s_2nd_echo_show
{% elif is_state("sensor.6proble_room_presence", "Bedroom Pi") %}
media_player.blue_dot
{%- else -%}
media_player.reed_s_echo
{%- endif %}
- service: media_player.play_media
data:
media_content_id: Queens Greatest
media_content_type: SPOTIFY
target:
entity_id: |-
{% if is_state("sensor.6proble_room_presence", "Office Pi") -%}
media_player.reed_s_echo_show_5_2nd_gen
{% elif is_state("sensor.6proble_room_presence", "Kitchen Pi") %}
media_player.reed_s_2nd_echo_show
{% elif is_state("sensor.6proble_room_presence", "Bedroom Pi") %}
media_player.blue_dot
{%- else -%}
media_player.reed_s_echo
{%- endif %}
- service: input_text.set_value
data:
value: '{{states(''sensor.6proble_room_presence'')}}'
target:
entity_id: input_text.blast_music_room
mode: single
The second automation plays music everywhere if I leave the room.
I have an input_text to keep track of the room where I started to listen to music. I change the input_text if I move the music.
alias: Adv - Blast Music Change Room
description: If I walk out of the room where it started, then play music everywhere
trigger:
- platform: state
entity_id: sensor.6proble_room_presence
from: Office Pi
- platform: state
entity_id: sensor.6proble_room_presence
from: Kitchen Pi
- platform: state
entity_id: sensor.6proble_room_presence
from: Bedroom Pi
condition:
- condition: not
conditions:
- condition: state
entity_id: input_text.blast_music_room
state: '{{states(''device_tracker.pixel_5a'')}}'
- condition: not
conditions:
- condition: state
entity_id: input_text.blast_music_room
state: none
- condition: not
conditions:
- condition: state
entity_id: input_text.blast_music_room
state: Everywhere
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
- condition: state
entity_id: media_player.spotify_kleinman_family
state: playing
- condition: time
after: '07:45:00'
before: '19:00:00'
action:
- service: input_text.set_value
data:
value: Everywhere
target:
entity_id: input_text.blast_music_room
- service: media_player.select_source
data:
source: Everywhere
target:
entity_id: media_player.spotify_kleinman_family
mode: single
The third automation stops the music when my wife comes home.
alias: Adv - Blast Music Stop
description: 'Aly is home so stop blasting music. '
trigger:
- platform: state
entity_id: device_tracker.alys_iphone_se
to: home
condition:
- condition: state
entity_id: media_player.spotify_kleinman_family
state: playing
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
action:
- service: media_player.media_pause
target:
entity_id: media_player.spotify_kleinman_family
data: {}
- service: input_text.set_value
data:
value: none
target:
entity_id: input_text.blast_music_room
mode: single
Kitchen morning weather
The idea behind this automation is to hear what to wear based on the weather. So far it’s been pretty helpful since our weather in Arizona actually hasn’t been 100% hot lately.
The automation triggers only once in the morning when the Room Assistant sensor detects me in the kitchen. After that it’s just some long templates selecting text to say out loud based on the weather. I’m using the Ecobee thermostat api weather for this. That’s why it says living room.
alias: Adv - Kitchen Morning Routine
description: ''
trigger:
- platform: state
entity_id: sensor.6proble_room_presence
to: Kitchen Pi
condition:
- condition: time
after: '07:00:00'
before: '09:30:00'
- condition: template
value_template: >
{% if states.automation.adv_kitchen_morning_routine.last_triggered is not
none %}
{% if as_timestamp(now()) | int - as_timestamp(states.automation.adv_kitchen_morning_routine.attributes.last_triggered) | int > 43200 %} true {% else %} false
{% endif %}
{% else %}
false
{% endif %}
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
action:
- service: script.actionable_alexa_notification
data:
text: Good morning Reed. Do you want to hear what you should wear today?
event_id: actionable_notification_morning_weather_kitchen
alexa_device: media_player.reed_s_2nd_echo_show
- wait_for_trigger:
- platform: event
event_type: alexa_actionable_notification
event_data:
event_id: actionable_notification_morning_weather_kitchen
event_response_type: ResponseYes
- service: notify.alexa_media
data:
message: >-
Today it will be {{state_attr('weather.living_room',
'forecast')[0]['condition']}}. You should wear {% if
state_attr('weather.living_room', 'forecast')[0]['temperature'] > 80 -%}
some shorts and flip flops because it will be hot outside.
{% elif state_attr('weather.living_room', 'forecast')[0]['temperature']
> 70 -%}
a tee shirt and shorts because it will be really nice weather outside.
{% elif state_attr('weather.living_room', 'forecast')[0]['temperature']
> 60 -%}
a tee shirt and pants because it will be slightly cooler outside.
{% elif state_attr('weather.living_room', 'forecast')[0]['temperature']
> 40 %}
a light jacket and pants because it will be chilly out.
{%- else -%}
a bigger jacket because its going to be really cold out outside!
{%- endif %}
Tonight wear {% if state_attr('weather.living_room',
'forecast')[0]['templow'] > 80 -%}
some shorts and flip flops because it will be hot outside.
{% elif state_attr('weather.living_room', 'forecast')[0]['templow'] > 60
-%}
a tee shirt and pants because it will be cool outside.
{% elif state_attr('weather.living_room', 'forecast')[0]['templow'] > 40
%}
a light jacket and pants because it will be chilly out.
{%- else -%}
a bigger jacket because its going to be really cold out outside!
{%- endif %}
data:
type: tts
target: media_player.reed_s_2nd_echo_show
mode: single
Office automation for only me
Like I mentioned in the video, I only wanted certain automations to run when I enter the office. What I didn’t mention in the video is that the motion sensor has to be triggered first so that this automation doesn’t get accidentally triggered if I walk by in the hallway. Yes… that has happened before fixing it.
For the lights:
alias: Adv - Office Lights Reed
description: ''
trigger:
- platform: state
entity_id: sensor.6proble_room_presence
to: Office Pi
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: device
device_id: 66d3bbfe1b49efc82ba2482250a00e01
domain: cover
entity_id: cover.ikea_office_left_shade
type: is_closed
- condition: device
device_id: 0a5ae87a773d0d87e4cb9f18b9349259
domain: cover
entity_id: cover.ikea_office_right_shade
type: is_closed
- condition: not
conditions:
- type: is_no_motion
condition: device
device_id: 7e36ea0b70533c24bc8577776b26c416
entity_id: binary_sensor.hue_motion_sensor_motion
domain: binary_sensor
for:
hours: 0
minutes: 2
seconds: 0
action:
- type: turn_off
device_id: db228927d421f4d49e5f668c2ba7c229
entity_id: light.office_office_ceiling
domain: light
- service: script.turn_on
data: {}
target:
entity_id: script.alexa_routine_office_2_button
- condition: numeric_state
entity_id: weather.home
attribute: temperature
above: '90'
- type: turn_on
device_id: 6a816807ffb6fa88e76dc5a8cf554a8a
entity_id: switch.smart_power_strip_1
domain: switch
mode: single
And here’s for the dashboard. It’s pretty much the same thing and I should combine them. I just learned about the dashboard casting from another Mark Watt Tech video.
alias: Adv - Office Dashboard
description: ''
trigger:
- platform: state
entity_id: sensor.6proble_room_presence
to: Office Pi
condition:
- condition: state
entity_id: media_player.kitchen_display
state: idle
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
- condition: not
conditions:
- type: is_no_motion
condition: device
device_id: 7e36ea0b70533c24bc8577776b26c416
entity_id: binary_sensor.hue_motion_sensor_motion
domain: binary_sensor
for:
hours: 0
minutes: 2
seconds: 0
action:
- service: script.turn_on
data: {}
target:
entity_id: script.office_dash_display
mode: single
Then here’s for the news to be read to me if I say “yes” to the Echo asking me.
alias: Adv - Office Morning Routine
description: ''
trigger:
- platform: state
entity_id: sensor.6proble_room_presence
to: Office Pi
condition:
- condition: time
after: '08:00:00'
before: '11:00:00'
- condition: template
value_template: >
{% if states.automation.adv_office_morning_routine.last_triggered is not
none %}
{% if as_timestamp(now()) | int - as_timestamp(states.automation.adv_office_morning_routine.attributes.last_triggered) | int > 43200 %} true {% else %} false
{% endif %}
{% else %}
false
{% endif %}
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
- condition: not
conditions:
- type: is_no_motion
condition: device
device_id: 7e36ea0b70533c24bc8577776b26c416
entity_id: binary_sensor.hue_motion_sensor_motion
domain: binary_sensor
for:
hours: 0
minutes: 2
seconds: 0
action:
- service: script.actionable_alexa_notification
data:
text: Good morning Reed. Do you want to hear your morning briefing now?
event_id: actionable_notification_morning_briefing
alexa_device: media_player.reed_s_echo_show_5_2nd_gen
- wait_for_trigger:
- platform: event
event_type: alexa_actionable_notification
event_data:
event_id: actionable_notification_morning_briefing
event_response_type: ResponseYes
- service: media_player.play_media
data:
media_content_type: sequence
media_content_id: Alexa.FlashBriefing.Play
target:
entity_id: media_player.reed_s_echo_show_5_2nd_gen
mode: single
Movie prompt
If my theater system isn’t turned on by 9pm, then I get asked if I want to watch a movie. I’ve used this automation way more than I thought I would and it hasn’t been annoying. When trying to put kids down to sleep, 9pm can sneak up on me way faster than I would like.
alias: Adv - Movie Night Prompt
description: >-
If it's in the evening and I'm home and not watching a movie in the theater
room, ask me to
trigger:
- platform: time
at: '21:00:00'
condition:
- condition: state
entity_id: device_tracker.pixel_5a
state: home
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
- condition: device
device_id: f438486407447a4be3ddc349a7707ab7
domain: media_player
entity_id: media_player.denon_avr_x4700h
type: is_off
action:
- choose:
- conditions:
- condition: state
entity_id: sensor.6proble_room_presence
state: not_home
sequence:
- service: script.actionable_notification_android
data:
title: Movie Night
message: Do you want me to turn on the theater room?
replyevent: echotheateron
buttontitle: Turn On!
default:
- service: script.alexa_notification_wrapper
data:
message: Do you want to watch a movie in the theater room right now?
event_identification: actionable_notification_theater_on
- wait_for_trigger:
- platform: event
event_data:
action: echotheateron
event_type: mobile_app_notification_action
- platform: event
event_type: alexa_actionable_notification
event_data:
event_id: actionable_notification_theater_on
event_response_type: ResponseYes
- service: script.turn_on
data: {}
target:
entity_id: script.alexa_routine_movie_preview
mode: single
Welcome home routine
There’s nothing that will put me in a bad more than driving in bad traffic. BUT when I come home and music starts playing for me I’m in a way better mood.
Trying to figure out the best way to only run this automation if I’ve arrived home in the last 10 minutes was tricky. There might be a better way to do it but this is what I have.
alias: Adv - Welcome Home Music
description: ''
trigger:
- platform: state
entity_id: sensor.6proble_room_presence
to: Kitchen Pi
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
- condition: not
conditions:
- condition: state
entity_id: device_tracker.pixel_5a
state: home
for:
hours: 0
minutes: 10
seconds: 0
- condition: template
value_template: >
{% if states.automation.adv_welcome_home_music.last_triggered is not none
%}
{% if as_timestamp(now()) | int - as_timestamp(states.automation.adv_welcome_home_music.attributes.last_triggered) | int > 3600 %} true {% else %} false
{% endif %}
{% else %}
false
{% endif %}
- condition: time
after: '08:00:00'
before: '19:00:00'
action:
- service: notify.alexa_media
data:
message: |-
Welcome home Reed!
{% if is_state("cover.garage_door_main", "closed") -%}
The main garage door closed {{ relative_time(states.cover.garage_door_main.last_changed) }} ago.
{%- else -%}
The main garage door is still open.
{%- endif %}
{% if is_state("cover.garage_door_small", "closed") -%}
The small garage door closed {{ relative_time(states.cover.garage_door_small.last_changed) }} ago.
{%- else -%}
The small garage door is still open.
{%- endif %}
{% for state in states.climate -%}
The thermostat {{state.name}} is currently
{{state_attr(state.entity_id, 'current_temperature') | round(0)}} degrees,
{%- endfor %}
data:
type: tts
target: media_player.reed_s_2nd_echo_show
- service: media_player.volume_set
data:
volume_level: 0.5
target:
entity_id: media_player.reed_s_2nd_echo_show
- service: media_player.play_media
data:
media_content_id: Queens Greatest
media_content_type: SPOTIFY
target:
entity_id: media_player.reed_s_2nd_echo_show
mode: single
Office shades and jokes
With Room Assistant, it can track how long you have been in a room. For the shades to open up, it just looks for me being in the room for at least a minute. Then if there’s motion and it’s the right time of day/temperature it will ask me to open them.
alias: Adv - Office Shades Up
description: ''
trigger:
- platform: state
entity_id: sensor.6proble_room_presence
to: Office Pi
for:
hours: 0
minutes: 1
seconds: 0
- type: motion
platform: device
device_id: 7e36ea0b70533c24bc8577776b26c416
entity_id: binary_sensor.hue_motion_sensor_motion
domain: binary_sensor
condition:
- condition: state
entity_id: sensor.6proble_room_presence
state: Office Pi
- condition: time
after: '10:00:00'
before: '16:00:00'
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
- condition: numeric_state
entity_id: weather.home
attribute: temperature
below: '100'
- condition: device
device_id: 66d3bbfe1b49efc82ba2482250a00e01
domain: cover
entity_id: cover.ikea_office_left_shade
type: is_closed
- condition: device
device_id: 0a5ae87a773d0d87e4cb9f18b9349259
domain: cover
entity_id: cover.ikea_office_right_shade
type: is_closed
- condition: template
value_template: |
{% if states.automation.adv_office_shades_up.last_triggered is not none %}
{% if as_timestamp(now()) | int - as_timestamp(states.automation.adv_office_shades_up.attributes.last_triggered) | int > 43200 %} true {% else %} false
{% endif %}
{% else %}
false
{% endif %}
action:
- service: script.actionable_alexa_notification
data:
text: >-
Hey Reed. It is nice outside. Do you want me to open the office window
shades?
event_id: actionable_notification_office_shades_open
alexa_device: media_player.reed_s_echo_show_5_2nd_gen
- wait_for_trigger:
- platform: event
event_type: alexa_actionable_notification
event_data:
event_id: actionable_notification_office_shades_open
event_response_type: ResponseYes
- device_id: 66d3bbfe1b49efc82ba2482250a00e01
domain: cover
entity_id: cover.ikea_office_left_shade
type: set_position
position: 100
- device_id: 0a5ae87a773d0d87e4cb9f18b9349259
domain: cover
entity_id: cover.ikea_office_right_shade
type: set_position
position: 100
mode: single
To ask me about a joke, I have to be sitting there longer.
alias: Adv - Office Joke Ask
description: ''
trigger:
- platform: state
entity_id: sensor.6proble_room_presence
to: Office Pi
for:
hours: 0
minutes: 30
seconds: 0
condition:
- condition: time
after: '10:00:00'
before: '17:00:00'
- condition: template
value_template: |
{% if states.automation.adv_office_joke.last_triggered is not none %}
{% if as_timestamp(now()) | int - as_timestamp(states.automation.adv_office_joke.attributes.last_triggered) | int > 3600 %} true {% else %} false
{% endif %}
{% else %}
false
{% endif %}
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
action:
- service: media_player.volume_set
data:
volume_level: 0.6
target:
entity_id: media_player.reed_s_echo_show_5_2nd_gen
- service: script.actionable_alexa_notification
data:
text: Hey Reed. Do you want to hear a joke?
event_id: actionable_notification_tell_joke_office_respond
alexa_device: media_player.reed_s_echo_show_5_2nd_gen
mode: single
Since I wanted to be able to keep saying “yes” and telling more jokes I had to break this automation up into two. Here’s the second part.
alias: Adv - Office Joke Respond
description: ''
trigger:
- platform: event
event_type: alexa_actionable_notification
event_data:
event_id: actionable_notification_tell_joke_office_respond
event_response_type: ResponseYes
condition: []
action:
- service: media_player.play_media
data:
media_content_type: sequence
media_content_id: Alexa.Joke.Play
target:
entity_id: media_player.reed_s_echo_show_5_2nd_gen
- service: script.actionable_alexa_notification
data:
text: Do you want to hear another joke?
event_id: actionable_notification_tell_joke_office_respond
alexa_device: media_player.reed_s_echo_show_5_2nd_gen
mode: single
Bedroom at night
Since I have a Raspberry Pi and a bed pressure sensor, I can tell when I’m in the room and also when I’m on the bed. Usually if I am just getting in bed I’m not wanting to watch TV, so that’s why I have it set up like this. It uses the Alexa Media Player to trigger an Alexa Routine to control the Fire TV. I’m sure there are plenty of different ways to do this same thing.
alias: Adv - Bedtime Wind Down
description: ''
trigger:
- platform: state
entity_id: sensor.6proble_room_presence
to: Bedroom Pi
condition:
- condition: time
after: '22:00:00'
before: '23:55:00'
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
- condition: template
value_template: >
{% if states.automation.adv_bedtime_wind_down.last_triggered is not none
%}
{% if as_timestamp(now()) | int - as_timestamp(states.automation.adv_bedtime_wind_down.attributes.last_triggered) | int > 43200 %} true {% else %} false
{% endif %}
{% else %}
false
{% endif %}
- condition: state
entity_id: binary_sensor.withings_in_bed_reed
state: 'off'
action:
- service: media_player.volume_set
data:
volume_level: 0.2
target:
entity_id: media_player.blue_dot
- service: script.actionable_alexa_notification
data:
text: Hey Reed, do you want to watch some TV?
event_id: actionable_notification_bedroom_tv
alexa_device: media_player.blue_dot
- wait_for_trigger:
- platform: event
event_type: alexa_actionable_notification
event_data:
event_id: actionable_notification_bedroom_tv
event_response_type: ResponseYes
- service: script.turn_on
data: {}
target:
entity_id:
- script.alexa_routine_bedroom_tv
mode: single
Then to set my alarm for the next day, it will read off my next day’s calendar and then ask me if the alarm isn’t set already. For the dashboard I just learned how to do that from another Mark Watt Tech video.
alias: Adv - Bedtime Alarm Set
description: ''
trigger:
- platform: state
entity_id: binary_sensor.withings_in_bed_reed
to: 'on'
condition:
- condition: time
after: '22:00:00'
before: '23:55:00'
- condition: state
entity_id: input_boolean.advanced_automations
state: 'on'
- condition: template
value_template: >
{% if states.automation.adv_bedtime_alarm_set.last_triggered is not none
%}
{% if as_timestamp(now()) | int - as_timestamp(states.automation.adv_bedtime_alarm_set.attributes.last_triggered) | int > 43200 %} true {% else %} false
{% endif %}
{% else %}
false
{% endif %}
- condition: state
entity_id: sensor.6proble_room_presence
state: Bedroom Pi
action:
- service: script.turn_on
data: {}
target:
entity_id: script.bedroom_dash_display_on
- service: media_player.volume_set
data:
volume_level: 0.2
target:
entity_id: media_player.blue_dot
- service: media_player.play_media
data:
media_content_type: sequence
media_content_id: Alexa.Calendar.PlayTomorrow
target:
entity_id:
- media_player.blue_dot
- condition: state
entity_id: input_boolean.morning_wakeup
state: 'off'
- service: script.actionable_alexa_notification
data:
text: Hey Reed, do you want to set the alarm for tomorrow?
event_id: actionable_notification_bedroom_alarm_on
alexa_device: media_player.blue_dot
- wait_for_trigger:
- platform: event
event_type: alexa_actionable_notification
event_data:
event_id: actionable_notification_bedroom_alarm_on
event_response_type: ResponseYes
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.morning_wakeup
mode: single
Well hopefully you don’t try and do ALL of this in one day. It took me weeks working on it a little at a time. It’s been so much fun though and I feel like I’m just getting started with all the possibilities!