A custom Alexa skill paired with a Raspberry Pi to control a Dyson Pure Hot+Cool HP01 purifying heater + fan
This repo contains code to run a custom Alexa skill on the Alexa Skills Kit Developer Console and a Flask web server on your Raspberry Pi to control a Dyson fan via IR signals.
Although this setup is intended for a specific device, these files may be modified to use Alexa to control any device that can be controlled with an IR remote.
User speech command -> Alexa skill -> JSON with parsed arguments -> Flask server -> LIRC -> Dyson fan changes state
Tested with Python 3.7 running Raspbian Buster 2019-06-20 using an IR Remote Shield v1.0
The alexa-voice-model
directory contains everything needed to configure your custom Alexa skill.
- Create a new skill - choose Custom for model and Provision your own for backend resources
- In the Alexa Skills Kit Developer Console, find your new skill, and click on View Skill ID. Save this string somewhere as we will need it for later for authentification
- Go to Edit->Interaction Model->JSON Editor
- Copy
interaction_model.json
to the JSON Editor and save model - Go to Invocation and change Skill Invocation Name if desired. This will be the phrase that Alexa will listen for to activate your custom skill
- Go to Interaction Model->Intent and click on the new custom intents
- Under Sample Utterances, select Bulk Edit
- Upload
<intent_name>_sample_utterances.csv
for the respective intents, submit, and save model
The following instructions will be performed on the Raspberry Pi command line.
Note that IR Remote Shield v1.0 needs to be attached to the GPIO pins for IR signals to send.
git clone https://github.com/kvntng17/voice-dyson
cd voice-dyson
pip install -r requirements.txt
- Follow the instructions listed here to install LIRC for Raspbian Buster 4.19. It also contains instructions to create a custom config for your IR remote if desired
sudo mv dyson.lircd.conf /etc/lirc/lircd.conf
- Open
listen_alexa.py
and locate the line that containsapp.config["ASK_APPLICATION_ID"] = "amzn1.ask.skill.e033e61a-290c-46cf-b4cb-679d9ec858a4"
. Paste your own Skill ID here. sudo apt install tmux
tmux
./bin/start_ngrok
- Copy the
https://<unique_id>.ngrok.io
address displayed on your screen. Save this address somewhere as we will need to supply it to our Alexa skill so our server can receive information from Alexa. - Enter Ctrl-b and d to detach from this tmux session
tmux
python listen_alexa.py
- Enter Ctrl-b and d to detach from this tmux session
- Open the Alexa Skills Kit Developer Console
- Go to Edit->Endpoint
- Ensure HTTPS is selected
- Under Default Region, paste your ngrok address followed by
/voice_dyson
. It should look likehttps://<unique_id>.ngrok.io/voice_dyson
- Under the dropdown box, select My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority
- Save Endpoints
- Go to Intents and Save Model and Build Model
Your setup should now be done! Make sure your ir-tx IR LED is pointed towards your device, and try a few commands.
"Alexa, ask my fan to turn on."
"Alexa, ask my fan to turn off."
"Alexa, ask my fan to swivel."
"Alexa, ask my fan to change to hot."
"Alexa, ask my fan to change to hot at seventy degrees."
"Alexa, ask my fan to turn to eighty degrees."
"Alexa, ask my fan to change to cold."
"Alexa, ask my fan to change to cold on power level three."
"Alexa, ask my fan to turn to power level five."
Kevin Tang