I’ve been looking for a while for a button that I can use to integrate into my home automation. I was excited when Amazon announced the Echo Button, only to be disappointed to hear that it can’t toggle a light or a switch. They can be programmed to only turn something on or only turn something off. I’ve figured out a workaround to get it to toggle devices.

They recently had a price drop, so I figured I would just order them just to see if I could get any use out of them in other ways. My first thought after opening them is that they are larger than I had hoped for. However, after discovering that Amazon’s intention wasn’t just to use it as a way to trigger routines, but also play games, their size makes a little more sense. The best part is that I was actually able to figure out a fairly easy way(assuming you’re using Home Assistant), to toggle something using the Button.

Here’s what you would need:

You will need to setup the Echo and the Buttons. I’m not going to go into any detail on how to do that since there are tons of resources on it, and it’s pretty straightforward. If you do need help with it for some reason, post in the comments. The Buttons are pretty much telling Alexa you want to set them up, and she walks you through it.

Next, we need to setup Home Assistant(HASS). First, you need to setup the Emulated Hue Component. This component emulates Philips Hue devices, which can then be added to the Echo. Below is the yaml code I used. The IP addresses are just the IP of your HASS computer. The other settings are explained fairly well in the documentation link for this component. The most important is to have ‘script’ in the exposed_domains list and the ‘off_maps_to_on_domains:’ section.

emulated_hue:
  host_ip: 192.168.45.104
  listen_port: 80
  advertise_ip: 192.168.45.104
  off_maps_to_on_domains:
    - script
  expose_by_default: true
  exposed_domains:
    - light
    - switch
    - script
  entities: 
    script.restart_ha:
      hidden: true

Now, setup the script that will be called when the Button is pressed. The script just toggles a device. In this case, I am toggling my fireplace (because that’s still my favorite project). Of course, you will need to change the ‘alias’, ‘service’, and the line below ‘entity_id’.

toggle_fireplace:
  alias: Toggle Fireplace
  sequence:
    service: switch.toggle
    entity_id:
      - switch.fireplace

Save the config and restart Home Assistant. Then go into your Alexa app. Tap Devices -> Plus button at the top right -> Add Device. Tap Philips Hue, and then “Philips Hue V1 bridge”. It will take just under a minute to search for the devices and it should find that script that you setup. Just follow the steps to finish adding it. After that, the script will show up in Alexa as a bulb that you can turn on or off. And whether you turn it off or on, it will just run that script in HASS.

Finally, we setup the Routine for the Button.

  1. In the Alexa app, tap the menu button at the top left, and then ‘Routines’.
  2. Tap the + button at the top right to create a routine.
  3. Tap ‘When this happens’ and select “Echo Button” and then press your Echo Button and tap “Add”.
  4. Then tap Add action -> Smart Home -> Control Device.
  5. Find the ‘Toggle’ script (In my example, it would show up as ‘Toggle Fireplace’).
  6. Tap ‘Power’ and then ‘Next’ and ‘Save’.

That’s it. When you press the button, your device will turn off if it is on, and it will turn on if it is off. If you need help or have any questions, just leave a comment.

 

13 Replies to “Toggle Lights and Switches with an Amazon Echo Button

  1. Great write up! I am trying to replicate it in myself. I am using TP link light bulbs. So, I don’t think I need the first half. However, I can not get this thing to work! Would you mind taking a look and see where I am going wrong?

    Here is my code:

    switch: – platform: tplink alias: Toggle Bedroom Lights sequence: service: switch.toggle entity_id: – light.bottom_light – light.top_light

    I’m wondering if I need to change “switch.toggle” to “light.toggle”? I have tried that but I reverted because it still did not work. Any suggestions?

    1. Yes. If you are toggling a light, then you use light.toggle. Are you saying the toggling itself is not working when you turn that on via Home Assistant?

  2. As an absolute amateur who just figured this out… a few tips to help the next one…

     

    1 – yes, you can copy the configuration snippet above in its entirety and put it right into your configuration.yaml.  If you don’t know where the configuration.yaml file is, you can look in the ‘developer tools’ window in Hass.  The only thing to change in this snippet is the host id.  You can find your host id in a terminal by the ifconfig command.

    2 – the .YAML is extremely delicate and requires exact syntax.  White space is important.  You can find a .log file somewhere in the folder that has the configuration.yaml (mine was in a hidden subfolder).  This can help you debug, or at least see if the configuration.yaml had errors.

    3 – The .YAML file will have a line to include scripts.  You don’t need to put the script int a separate file, you can just put it into that section of the .YAML (it will be at the bottom).  The portion of the file containing scripts must start with ‘scripts:’ to indicate you are now defining a script.

    4-  Rename the script and its alias to whatever you want.  Mine toggled a light, so it is “toggle_light”.  switch.toggle is the correct service, so leave this.  You can understand the services available for any given integration by going to the Home Assistant Integrations page, finding the component and reading the documentation.

    5-  The big thing to change in the script is the entity id.  You can find a list of all entities somewhere in the folder (or a subfolder) where that configuration.YAML exists.  There is also a list of entities on the Home Assistant dash.

     

    Good Luck!

  3. Thank you for this!

     

    I managed to get this working, however, the Alexa app is showing my script as “all scripts” and not using the configured alias.

     

    Where do I put the script please?  At the moment, I’ve just put it directly into ‘scripts.yml’.

  4. Hi I’m trying to find a way to toggle a lamp that’s connected to a smart plug. Would this method require a computer of some sort to always be on to toggle the light? I ask because I’m not that informed about home assistant.

    1. Yes. You need a computer always running. You can use a raspberry Pi as that computer. That’s usually the easiest way to get it running.

  5. Ok thanks for responding so quickly, Simit. I’d rather not have a computer on all the time just for this. Do you know any other smart button that can toggle a smart plug while the smart plug also being able to connect to my echo plus? Basically I’m thinking maybe there’s a smart plug that can be controlled by a button with one connection while also being connected to alexa for when I run routines including it.

  6. Unfortunately I do not. The Alexa ecosystem still doesn’t have the ability to toggle something via an automation. You might be able to get the Ikea hub with an outlet and a button. I do believe they integrate with Alexa, but I’m not 100% sure of that.

  7. Ok thanks for the help, Simit. I have an idea. I’m going to use a switchbot to press the button on the side of my smart plug 😛

  8. Hey I found this product that could be the answer to what we are looking for. It’s a smart plug that has its own remote. The only problem is that I think it needs a hub to connect to alexa.

Leave a Reply