Hi, Being an electronics and programming enthusiastic, I always wondered how can I automate my room appliances (not with smart bulbs). There were many different ways to come up with like Bluetooth, LAN, MQTT, etc. Then I thought of automating with Alexa for existing devices. There are 2 ways of doing it. The easy way and the hard way. So, for now, let's talk about the easy way.
There are a lot of automation skills in the Alexa skill store but most of them support smart devices. After doing some research I found a really good skill called sinric which let's me control existing appliances with some extra circuitry. Thanks to Aruna Tennakoon for providing this feature. Setting up this skill is straight forward.
- Get API key
- Add skill to your Alexa
- Use these examples
- That's It.
let's see how to set up the skill.
- Goto sinric pro website and signup.
- Verify your email.
- Click on the
Devicesbutton on the sidebar.
- Then select
- Select which device type you need and let the access key be the default for now.
- That's it.
- Goto to Alexa's skills & games and search for sinric pro skill.
- As soon you link the skill you will be redirected to the login page.
- Login with the credentials which you used signup for sinric pro website
- After successful login just go back to your Alexa app and it'll start discovering the devices which you added in sinric pro account.
- So linking skill is done.
- Here's where the coding part begins.
- Sinric Pro has supporting libraries for python, c++(nodemcu), nodejs.
- Let's start with python.
Installing python library for sinricpro
pip install sinricpro
You can find the source code for the python library here.
Just a reminder. This library is only supported for python versions 3.7+.
Initializing with access key and secret key
- Login to sinricpro here
- Click on credentials button on the sidebar.
- There you'll find 2 keys. One is
app keyand another is
app keyis used to provide API service.
secret keyis used to provide security for the information exchanged between devices.
- Device IDs are the unique ids that are used to differentiate between devices.
- As you can see there are 2 more fields
lightin the code above.
- Go to the devices page here.
- Copy the device ID as shown below and paste it in the code.
So moving forward, let's see how to connect to sinricpro. Basically there are 2 ways for controlling a device with sinricpro.
- Action is something that Alexa does for you. Like when say
Alexa, turn on lightor when you control device from website or app.
- Event is used to control the device manually. Like when you press a button so light should change its state or much more.
Defining action and event callbacks
Next step is to initialize the library with callbacks
Let's see how a complete code looks like.
Thank you :).