Ok, here we go. As I assuming from your initial post you are using the Alexa Skill for Smart Friends, because it is neccessary to use this, though we can trigger it over Alexa. I will try organize the steps, so everyone can understand.
1 Base to install in HA
First thing you need in HA is to install HACS. Shouldn’t be a big deal to install, you only need a GitHub token, but everything is documented there.
So with HACS installed, we can use it to install Alexa Media Player. They also describe it on the linked GitHub Page how to configure. I think the most important thing is the correct url. As I am using Alexa in Germany i use amazon.de
.
2 Configure a Shutter
2.1 Alexa Routine
First we need to setup two routines in the Alexa App. One to open and one to close the Shutters.
I called one Routine “Gästezimmer hoch” and set “Alexa, Gaestezimmer hoch” as the trigger. As Action I used SmartHome, searched for the right Shutter and set the right state, in this case “offen”.
For everyone who is not speaking German: Gästezimmer --> Guestroom / offen --> open.
So for closing, I setup a second routine.
2.2 Input boolean and sensor
As we have to somehow manage the state of the Shutter in HA i used template sensors which are linked to input boolean.
This is my input boolean gaestezimmer.
gaestezimmer:
name: Gaestezimmer
icon: mdi:window-shutter
And the sensor, which is in state open if the input boolean is on, otherwise it is closed
- platform: template
sensors:
gaestezimmer:
value_template: >-
{% if is_state('input_boolean.gaestezimmer', 'on') %}
open
{% else %}
closed
{% endif %}
2.3 Scripts to open and close the shutter
Now we need a script to call the Alexa Routine, which we setup prior. My Script to close the shutter looks like this:
rollo_gaestezimmer_down:
alias: Rollo Gaestezimmer Down
sequence:
- service: media_player.play_media
data:
entity_id: media_player.marcels_2_echo_dot
media_content_id: Gaestezimmer runter
media_content_type: routine
- service: input_boolean.turn_off
data:
entity_id: input_boolean.gaestezimmer
This Script does two things:
- It Calls the Service
media_player.play_media
with the given data
. In the data
we specify the entity_id
(which is the ID from one of my echo dots), the media_content_id
(which is the name of the routine) and the media_content_type
(which specifies, that we are calling a routine)
- It turns off the input boolean, though the sensor will change its state to closed
My Script to open the shutter looks like this:
rollo_gaestezimmer_up:
alias: Rollo Gaestezimmer Up
sequence:
- service: media_player.play_media
data:
entity_id: media_player.marcels_2_echo_dot
media_content_id: Gaestezimmer hoch
media_content_type: routine
- service: input_boolean.turn_on
data:
entity_id: input_boolean.gaestezimmer
2.4 The template cover in HA
In HA we can define template covers, which I used to bring it all together.
My cover looks like this:
cover:
- platform: template
covers:
rollo_gaestezimmer:
device_class: shade
friendly_name: "Gästezimmer Rollo"
value_template: "{{is_state('sensor.gaestezimmer', 'open')}}"
open_cover:
service: script.rollo_gaestezimmer_up
close_cover:
service: script.rollo_gaestezimmer_down
I used the device_class: shade
, as it fits best for my type. The value_template
is set to use the template sensor. I couldn’t use the input boolean directly, as the state on/off would not fit. To open or close the cover it used the scripts.
As the scripts change the states of the input boolean, there is a short delay of a second or two, until the status is visible in Lovelace.
I hope this helps to integrate it to you HA. It’s real pity, that the Smart Friends Box does not have a clear API to use, but sometimes we need to do it a dirty way to have a good SmartHome.