Alexa Smart Home Skill for Particle Devices

Many thanks to @harrisonhjones, @jeiden and @Dave for helping me to figure out how to setup Particle OAuth2 for this sample :smile:.

As you all know Amazon recently release Alexa Smart Home Skill API. Amazon Alexa provides built-in smart home capabilities like turning on/off lights, control air conditioners, etc… Developer can use Alexa Smart Home Skill API to extend the smart home capabilities of Alexa. For Smart Home Skill APIs you don’t need to create a custom voice interaction models. Alexa has built-in standard interaction models for smart home, like:

Alexa, turn on lights
Alexa, set light to 50 percentage,
Alexa, set the temperature to 24

Previously Alexa works with a limited number of smart home devices like Philips Hue, etc… But with this newly introduced Smart Home Skill APIs we can integrate devices that are not supported by Alexa by default.

Recently I started working on integrating Particle Device and Smart Home Skill API. I is fairly simple to create a Smart Home Skill if you already know how to create a Alexa Skill. I have created a Skill before using Particle Photon.

The only issue was to figure out how to integrate OAuth2 login with Particle. Smart Home Skill API needs a server that supports OAuth2 Authorization Code Flow. With the help awesome peoples like … I was able to integrate OAuth2 with Particle.

In this project I emulate two lights that can be turned on/off using Alexa Voice Interaction. For the purpose of this demo, I have connected two LEDs to pins A4 and A5.

Describing how to create a Smart Home Skill is not in the scope of this article. For a detailed explanation of how to create a Smart Home Skill, please refer to this link.

In order create Smart Home Skill, Amazon requires a server that supports OAuth2 Authoriation Code Flow and Cloud APIs to control devices. At time writing this article, Amazon does not supports devices without Cloud APIs. Also as of now Alexa Smart Home Skill API supports only two types of devices, lights and air conditioners. But you can hack it to work with other type of devices also.

By default the Skill you creates will be private to your account. After testing you can submit to Amazon for review and if it is approved you cna make open for public. After the Skill is created, you have to enable it using the Alexa application. To enable it select Skills from side menu and find and enable your skill. Then start discovering devices using the Smart Home menu item. This will ask you to logon to the cloud using the OAuth2. Once you successfully authenticated the access token will be saved and it will be passed on to your Lambda function.

When the device discovery is performed, the Smart Home Skill API will call the Lambda function attached to the Skill with Alexa.ConnectedHome.Discovery event. When this event is recevied your Lambda function will return the device list. When the user controls these devices using voice input, the Lambda function attached to the Skill will be called with Alexa.ConnectedHome.Control event and you can call the Cloud APIs to control the device. For a more detailed explanation of how to create Skill and Lambda function refer to this link.

Some of the screenshots of the Skill Information and Lambda function is given below:

Skill Information

Skill Configuration

Lambda Function Eventsource

Sample Application

The sample has two components, Alexa Smart Home Skill and Particle Firmware.

Particle Firmare

The Particle firmware emulates two lights using LEDs. These LEDs are attached to A4 and A5 pins. The firmware has functions to turn on/off the LEDs and to set the brightness of the LEDs.

Alexa Smart Home Skill

Alexa Smart Home Skill has Skill information and the Lambda function. The Skill information contains the details about the skill such as Skill name, OAuth details, etc… The Lambda function responds to the Smart Home Skill Events.

User can interact with skill using voice input such as:

  • Alexa, turn on bedroom light
  • Alexa, turn off bedroom light
  • Alexa, turn on kitchen light
  • Alexa, turn off kitchen light
  • Alexa, set kitchen light to 50 percentage

Demo Video

Enabling the Smart Home Skill

Interacting with the Skill


This reminded me of you.

1 Like

HI @krvarma :

1.Good Project!! I want to try your project but I don’t have a Amazon echo in hand , but I have a raspberry Pi and I’ve set it could work with the Amazone Voice Service .If I can use my raspberry Pi as a Amazon echo to control my photon?
2.I saw your vedio “Enabling the Smart Home Skill” ,I found you could discover two device .One of them is Particle,another is what?It’s too vague to see :sweat_smile: . Now I use the APP to discover the device ,but discovered nothing.Do you have any advice? :grinning:



  1. Yes you can use RPi and AVS for the demo.

  2. The other device you are seeing may something I have used for testing but don’t remember exactly what it is :frowning:

  3. It should display the device, can you check the lambda log to any possible errors?



Thank a lot for your replying!! I am new to Lambda and I want to ask some questions. :sweat_smile:

1.I read your js code and want to confirm something.Where are the kitchenLightApplianceId (in L3) , bedroomLightApplianceId (in L4) and fullApplianceId: (in L91,L118) from?The deviceId in L92 is the Photon’s device ID?

2.What’s the runtime I should choose?I chose NodeJS now.

@Jackson_lv, answers

  1. kitchenLightApplianceId, bedroomLightApplianceId and fullApplianceId are just GUIDs, you can replace it with any you want. the deviceId is the device id of the Photon Device.

  2. Yes, is runtime.

You should definitely choose the 4.3 NodeJS runtime. Amazon is sunsetting 0.10 in October of this year.

Thanks for your replying although I still can’t discover the device no matter using the APPs or ask Alexa to did it.Anyway,I will continue to make some try and keep updating.THS again! :grinning:

oh !! I will try it and thanks a lot for your advice! :smile:

Would this work with an Echo dot? Amazon has also updated their website as well. Will this still work?

Yes, I’m also interested in doin this but am curious as to what changes have happened since this article was originally written. Anyone still doing Alexa integration? Any gotchas?

How about after you create the skill and implement it/get it working, do Amazon’s changes to Alexa potentially break your work such that you have to rework it?

Great post! Thanks.

I didn’t test with Echo Dot, but it should work with Dot.

I didn’t test after the recent changes, I will do it and get back here.

1 Like

Same API, same functions… I’m using with Dot, no issues.

The big change comes in February with an API change that affects what they called Literals, they are going away. They added some nice built-in methods that eliminate the need for creating Input lists. A nice improvement.


I’m a bit confused about a couple items and I realize this should be obvious. The ClientID and the Client Secret - are these my Particle login username and the access token from my IDE Setting page?

Also, I used “profile” for scope and wanted to confirm that’s correct.

This example has been a huge help! I think things have changed a bit since you posted this, but I’m hoping I’ve stumbled through enough to get it to work.

Thanks for sharing!


@ctmorrison, please follow the steps outlined here:

I just followed the instructions and got it right. This link also discuss the OAuth2 flow

I realize I have a mental block on this issue, but I simply can’t get it to work. On the Alexa companion app (iPhone), I get {“code”:400} as soon as I try to enable the skill. I even used the sample Lambda function from @krvarma, with without success. I believe the issue stems from incorrect Oauth setting when I configure the Smart Home Skill.

Fortunately, through some digging in hackster, I discovered a technique using IFTTT and had it working within minutes and without the complexity of building a Smart Home Skill. If anyone is interested, I’d be happy to detail what I had to do with IFTTT, but it truly is simple. I’m not thrilled with having to say, “Alexa trigger…”, but for now I’m happy to include “trigger” since it works!

For most of you, evidently, my struggles incomprehensible, as I’ve yet to get guidance beyond being pointed to what I’ve already read about 50 times (no, I’m not complaining–just tired of trying and failing for hours).

This is an amazing forum and I truly appreciate all the support I’ve received on various issues.


I feel like I’m in the same boat here. I tried to make the lambda and smart home skill outlined in this tutorial and failed in the same ways you did. I too checked IFTTT and was again reminded how easy it is to use.

Telling Alexa to “trigger” something is kind of annoying.

@ctmorrison, @nrobinson2000

you may want to try this method, to simply use for a single device. It will get you there (follow directions exactly) and put you in a nice place to build from. I went from here to managing a device with many commands, very quickly.

1 Like

Thanks. This looks nice.

Alexa, ask particle light to…

This is still kind of a cumbersome phrase, but I will try this out soon.