In former times this worked with ha-bridge. Then Amazon decided to change the way to transmit commands in the network.
Amazon Echo Round Robin execution – New Filter IP feature not working correctly. #386
With the script from blog.loetzimmer.de you can login to your Amazon-Account and send commands to alexas, read data, connect bluetooth-devices and more. The author Alexander Noack added a command to get the name (or serialnumber) of the last command-receiving alexa:
Which alexa-device sent the last command?
Whith this info it is possible to switch the light (or your shutters) in your rooms, where you asked one of your alexas.
Installation Howto „alexa_remote_control.sh“
ha-bridge should already be installed.
Now its time to test it
alexa_remote_control.sh -lastalexa
it will show you the name of the last used alexa-device.
We can use this in our licht.sh – script
on /home/pi/alexa/licht.sh on dim /home/pi/alexa/licht.sh dim ${intensity.percent} off /home/pi/alexa/licht.sh off
This command shows your possible devices
alexa_remote_control.sh -a
the licht.sh-script may look like this (download):
#!/bin/bash
#
#alexa_remote_control.sh -a shows your devicelist
#
val=$(/home/pi/alexa/alexa_remote_control.sh -lastalexa)
if [[ $val == *"Schlafzimmer"* ]]; then
FHEMSWITCH='http://rpi:8083/fhem/?cmd=set ZWave_SWITCH_MULTILEVEL_14'
command="$FHEMSWITCH $1 $2&XHR=1"
wget -q -nv "$command" &
fi
if [[ $val == *"Badezimmer"* ]]; then
if [ "$1" == "on" ]; then
wget -q -nv "http://sonoff03/control?cmd=GPIO,12,1" &
fi
if [ "$1" == "off" ]; then
wget -q -nv "http://sonoff03/control?cmd=GPIO,12,0" &
fi
fi
#if [[ $val == *"myalexa"* ]]; then
# echo name is $val
#fi
Variable $1 has one of the three possible values „on“, „off“ or „dim“.
The line 11 shows how the dim-value is transported. Variable $2 is the value.
You should add the hostnames (here rpi and sonoff03) used to the /etc/hosts file.
It brings better performance.
Feel free to contact me if you need help!