How to Integrate Amazon Smart Plug with Home Assistant

Amazon Smart Plugs are an excellent addition to automate your home with Alexa. However, if you’re an advanced home automation user using a more robust solution like Home Assistant, you will find their limited usage to the Alexa app very frustrating!

I discovered a solution to get Amazon Smart Plugs accessible in Home Assistant using input booleans and template binary sensors. By pairing a binary sensor from Home Assistant with an Amazon Smart Plug inside of an Alexa Routine, we’re able to control the smart plug from Home Assistant!

I have a lamp by my fireplace that’s plugged into an Amazon Smart Plug that I want to control from Home Assistant:

Create Input Boolean and Template Binary Sensor

Let’s begin by creating the input boolean and the binary sensor in Home Assistant. I’ve chosen to create the input boolean using the Home Assistant UI. Navigate to Configuration -> Helpers then add a new Helper that is a Toggle:

When adding the Toggle, Home Assistant doesn’t give you the option to name the input boolean, so it will create a generic one based on the common name you enter. For my fireplace lamp, it created input_boolean.fireplace_lamp. I prefer it to be a little more descriptive so I modified it after creation to prepend alexa_ha_:

Alternatively, you can add the following code for the input boolean to configuration.yaml:

    name: "Fireplace Lamp"
    icon: "mdi:lamp"

Binary sensors aren’t available in the Home Assistant UI so it must be added to configuration.yaml:

  - platform: template
          friendly_name: "Alexa HA - Fireplace Lamp"
          device_class: garage_door
          value_template: "{{ is_state('input_boolean.alexa_ha_fireplace_lamp', 'on') }}"

If you have existing binary sensors, just include everything from the device’s name down.

After adding this, save the confguration.yaml file, run Check Configuration, then if the configuration passed, restart Home Assistant.

What’s Going on Here?

If you’re not familiar with input booleans and binary sensors: an input boolean is a virtual device that has an “on” or “off” value. A binary sensor stores the state of a device and has a device class that represents that state. I’m using the binary sensor as a virtual device to track the state of the Amazon Smart Plug as it changes across Home Assistant and the Alexa App. Together it allows me to track the state of the entity and control it from the UI.

Although binary sensors can have a device class of type plug which makes more sense, I’m using garage_door instead. When I’ve tried using type plug, the binary sensor doesn’t transfer to Alexa properly and is renamed _AccessorySwitch. 🤷🏼‍♂️

Once Home Assistant restarts, the Alexa App sees the input boolean and binary sensor as devices and sends me a push notification that new devices are available. If you don’t see them after restarting Home Assistant, manually sync the entities from Configuration -> Home Assistant Cloud menu.

Sync Entities If Necessary

Rename Amazon Smart Plug in Alexa App

Since I’ve named the input boolean “Fireplace Lamp” (which is the current name of the plug), we’ll need to rename the plug to avoid any confusion for Alexa. I prepend “HA -” to the name to differentiate it enough to not trigger when saying “fireplace lamp” and to remind me of the connection to Home Assistant:

Create Routines in Alexa App

Now we need to create two routines in the Alexa App that include both the Amazon Smart Plug and the binary sensor:

Routine for Turning On The Fireplace Lamp

My completed routine is shown below. Note that the when trigger is the binary sensor opening and the action is to turn on the Amazon Smart Plug and the input boolean. This will keep our device and the Home Assistant UI in sync.

Routine for Turning Off The Fireplace Lamp

My completed routine is shown below. Now the opposite as the example above: the when trigger is the binary sensor closing and the action is to turn off the Amazon Smart Plug and the input boolean. Again, this will keep our device and the Home Assistant UI in sync.

Add Input Boolean to Lovelace UI

Now we’re ready to control the Amazon Smart Plug from Home Assistant! Add the input boolean to Lovelace UI however you’d like. For illustration, I’m adding it to a new entity card named Living Room:

All Done!

I can now turn this device on and off from Home Assistant and by using voice with Alexa. Discovering and documenting this process has been helpful for me to better understand Home Assistant better and finally control all my Amazon Smart Plugs from it! Remember, we’re only going to toggle the input boolean in Home Assistant or in the Alexa App, never the binary sensor! The Alexa App can only control a binary sensor and it also stores the state of the plug.

Feel free to leave a comment below or message me on Twitter if this has been helpful or if you have questions!

40 thoughts on “How to Integrate Amazon Smart Plug with Home Assistant

  1. Joe

    Thanks for writing these up! I’ve used this technique with smartthings with a virtual contact sensor and am now making the transition to HAAS so was happy to see this was possible here too. I created the input boolean and can see it in the Alexa app. When I toggle it in HAAS I can see the contact sensor change from open to close in the Alexa app when viewing the device. I created a routine the same but it is not controlling the plug. If I manually trigger the routine it does turn the Amazon plug on/off. It seems like the routine is not reacting to the state change of the contact sensor/input boolean. Any ideas what else to check/try?

  2. Soul

    Thank you!
    I’ve been searching for a few weeks now trying to figure out a good solution to get my Amazon Smart Plug working with HA. Worked flawlessly!

      1. Krell

        Can’t get this to work. Like Joe and Manel, everything works EXCEPT toggling the plug from within Home Assistant. I am NOT a noob but I can’t get it to work. Seems like the Alexa doesn’t monitor the state change of the binary sensor. Any idea why this isn’t working?

  3. Manel

    Thanks! I´m starting with HA and this tutorial help me to understand how input_boolen works, but after following your tutorial I´m able to see the state of the plug in HA and turn it on and off from Alexa, but when I press the button in HA the state of the plug does not change, I´m not able to turn off and on the plug from HA. Any idea? again I´m a HA noobie and I´m still trying to understand how things intregrate etc. Thanks for you help.

  4. Joe

    I used to have something similar working in SmartThings with a virtual switch/virtual sensor combination device handler. That has stopped working too, so this could be an Amazon side issue not something with HA. Like HA, from the Alexa app it sees the ST virtual contact state change (open/close), but the routes are no longer triggered. I ended up loading the Alexa Media player add-in which can also be used for TTS and to trigger routines. I’ve got it working via NodeRed but you could also do this with a HA automation or script.

  5. nathanR

    Cool! I had to change the device class “garage_door” to “door” to make Alexa happy, otherwise she complained.
    It would be cool if you could turn this into a HA Blueprint if you feel inspired…

  6. reisertom

    I can see the input sensor as a “garage door” but I am unable to select any smart home device as a trigger in the routine. Alexa app tells me that there are no devices ?!

    1. nrutman2017

      I had to change the binary sensor in HA from
      device_class: garage_door
      device_class: door
      After that, Alexa could use it as a trigger.

  7. Alejandro

    Hello, I’m stuck creating the routine, i click When this happens, and i get some options, im clicking Smart Home, is this correct? I’m only seeing my Echo Speaker there. I tried changing the class from garage_door to door with no success. Or im i doing something wrong?

  8. David Clarke

    Great tutorial, works perfectly.
    However if I turn the lamp on or off via voice then the state change does not update the entities card in Hass.
    Is this supposed to happen or am I wishful thinking?

  9. Tom OD

    Really appreciated this. Works like a charm. Just started getting into Home Assistant and this was a slight annoyance as I only have the one Amazon Smart Plug that came free with an dEcho Dot a few years ago.

  10. Mondo

    So I went through this step by step and when I try to create a routine I have no devices available to choose when trying to set it up. The “When this happens” selection for smart home doesn’t show any devices. I did update the device_class to door as recommended by a previous comment but even this didn’t show any devices under that part of the routine. Anyone else get past that part?

  11. Rich

    Thanks to all for this thread and helpful tips.
    However, I’m confused. I have Alexa and HA working seamlessly together, with trial HA subscription. Works by default. Is the point of this thread to explain how to do that with mout the sub? Currently all controls and state changes are in sync and there is nothing for me to do…. sorry if it’s a banal question. I’m guessing you are looking to circumvent the need for an HA sub. Many thanks

  12. Chrism

    For those having trouble, I had to do “device_class: window” instead. If this doesn’t work for you, try other device types. I also had to go into the Alexa settings within the paid HA cloud service area and not only enable Alexa, but also Enable State Reporting. I glossed over this setting assuming it was a telemetry thing. This fixed the issue of toggling the switch within HA and it not triggering the routines within Alexa.

  13. Pingback: Amazon Smart Plug - Complete guide -

  14. René

    For me it only works after I’ve manually manage the entities in the Alexa integration to show/sync the recent created Input Boolean and Template Binary Sensor. After that it was shown/brought in the Alexa App immediately and as well visible in the routine => smart home tap which was empty for me before as well. So take care that HA is really sending the two created entities to Alexa! Then you can follow easy the above steps…and it’s really working smoothly after it.

  15. Matthew Mooney

    Having tried various device_class: settings and be able to see the contact sensor in alexa/routine/trigger/smart home I am still unable to integrate it into an actual routine. I keep getting the error “This device is not currently supported” guessing amazon has changed the way these worked. Any new updates on how to make this work?

  16. Chris Duke (@chrisduketv)

    Hey Brandon… thank you for an incredible article. I found it after much searching because I installed 20 or so Amazon Basics Light Switches in my home and THEN found out about Home Assistant, only to find out that they don’t integrate at all with HASS 😦

    I configured a few switches exactly how you’ve laid it out, paying particular attention to which is a binary and which is a boolean. I’ve also tried the device_class as a door and window. It doesn’t make a difference.

    Here’s the problem (and my solution is below):

    – When I use my HA dashboard, I can toggle the light switch on and off just fine. The state is correctly reported in the app (or web browser).

    – Doesn’t work: If I use the physical switch or use an Alexa command “Alexa, turn on the kitchen light”, the state is not reported back to HASS even though my Alexa routines are configured to turn on/off the boolean.

    Either way, the light does turn on or off, however they get out of sync if I don’t use HASS.

    According to your notes in your article, the Alexa routine should take care of the sync back to HASS, but it doesn’t. Maybe due to changes in HASS?

    BUT, I FOUND THE SOLUTION!! (I don’t have to install new switches, but it’s a lot of work!)

    – I set it up exactly how Brandon documented above
    – In the two routines, I deleted the boolean under ALEXA WILL, leaving only the power on/off to the physical switch configured in Alexa
    – I created two additional routines to trigger the boolean when the switch (or Alexa voice/app). WHEN (Alexa light switch) Turned Off, ALEXA WILL Power Off the boolean.

    I’m super stoked that I found this article which lead me to getting started, and figuring out a solution along the way. I hope this information helps others who got stuck like me. The only downside to this is that you have to set up 4 routines per switch. It’s madness! But it makes sense to me now, and hell–it works!

    1. Ron

      Thanks, Chris, it works! The HASS state/sync problem drives me nuts!

      One last issue, though. When using the Alexa App itself to turn the switch on or off — without voice/routine, the HASS state still does not update. Any thoughts? I may try Node-Red for the final piece of this thousand piece puzzle……

      I so WISH Amazon would just allow the integration!!!

  17. zSprawl

    The big piece missing for me is that you must expose the ContactSensor to Alexa by going into the Settings > Home Assistant Cloud > Alexa > Manage Entities, and then click on the little red X next to your item (Fireplace Lamp in this case), and expose it. Now the device can be found by the routine and the rest works.

  18. Pingback: Does Amazon’s Smart Plug Work With Google/Nest, HomeKit and More? - Smart Home Point

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s