Amazon smart plugs via emulated_hue - device missing in the Alexa routine trigger?

Hi all,

New to HA… I have a bunch of amazon smart plugs that I want to control from Home Assistant app. I am using the emulated_hue approach, and have created an input_boolean/binary_sensor device that was properly discovered by Alexa app and working like a virtual light switch.

However, I need to use this “light switch” to trigger the actual on/off of the actual amazon smart plug. But when I go to create a Routine in Alexa app, the device does not appear under “Smart Home” at the “When this happens” step. I have tried different “device_class” in my configuration.yaml setup, but none of them worked.

In fact, in the Alexa app, I can’t seem to trigger the routine on any smart plugs (other than my Ring doorbell).

Am I missing something obvious here?

Has anyone recently used emulated_hue to control Amazon smart plug successfully?

Below is my emulated_hue and input_boolean sections in the configuration.yaml:

emulated_hue:
  host_ip: 192.168.X.XXX
  listen_port: 80
  expose_by_default: true
  exposed_domains:
    - light
    - switch
    - input_boolean

input_boolean:
  alexa_ha_lr_light:
    name: "LR light"

binary_sensor:
    platform: template
    sensors:
      alexa_ha_lr_light:
          friendly_name: "Alexa HA - LR Light"
          device_class: garage_door
          value_template: "{{ is_state('input_boolean.alexa_ha_lr_light', 'on') }}"

I am running HA in docker on a raspberry pi 3b+.

Thank you so much!

Well, thanks to various posts from this community, I finally figured out how to control Amazon smart plugs from Home Assistant (without going through nabu casa). I’m using the Alexa Media Player (downloaded from HACS) to trigger the routines in Alexa, in conjunction with emulated_hue to maintain the states between Alexa and HA.

Here’s my setup (in hopes that it’ll help some newbie like me with the same predicament):

  1. Create an emulated_hue input_boolean entity which is exposed to Alexa. Add these in HA’s configuration.yaml:
emulated_hue:
  host_ip: 192.168.X.XX
  listen_port: 80
  expose_by_default: false
  exposed_domains:
    - input_boolean
  entities:
    input_boolean.alexa_ha_lr_light:
      hidden: false

input_boolean:
  alexa_ha_lr_light:
    name: "LR light"
  • Restart HA.
  1. Then in Alexa app, add the above “LR light” (Living Room light) as a device:
  • Devices → “+” (add sign) → Add Device → Other → Discover Devices
  • it should say “1 light found and connected”
  • In HA Dashboard, Edit Dashboard → Add Card → search by entity “LR light”, and add the suggested card
  • whenever I toggle HA’s “LR light”, Alexa’s “LR light” will also toggle, and vice versa
  1. Download and set up Alexa Media Player via HACS

  2. In HA, create a pair of automations so that whenever the input_boolean “LR light” is toggled on/off, it will send a “voice” command to Alexa. I used the HA GUI/visual editor to set the automation for turning the light on as follows:

  • Name: HA to Alexa LR light ON
  • Mode: Single
  • Trigger Type: State
  • Entity: LR light
  • To: on
  • Action type: Play media
  • Select media player: (your echo dot device set up in step 3)
  • Media content ID: HA is awesome LR light ON
  • Media content type: routine

The corresponding automations.yaml (for ON) looks like this:

- id: 'XXXXXXXXXXXXX'
  alias: HA to Alexa LR light ON
  description: ''
  trigger:
  - platform: state
    entity_id:
    - input_boolean.alexa_ha_lr_light
    to: 'on'
  condition: []
  action:
  - service: media_player.play_media
    target:
      entity_id: media_player.(echo-dot-device-name)
    data:
      media_content_id: HA is awesome LR light ON
      media_content_type: routine
    metadata: {}
  mode: single
  • Duplicate the above automation, but this time change ON to OFF.
  1. In Alexa app, create a pair of routines to respond to the above “voice commands” and trigger the actual amazon smart plug:
  • Routines → “+”
  • Enter routine name: HA Alexa LR light ON (…or whatever you fancy)
  • When this happens: select “Voice” → enter “HA is awesome LR light ON” (this must be the same phrase as programmed in the HA automations above)
  • Add action: Smart Home → All Devices → Plug for LR light (this is the actual physical amazon smart plug device, assuming it is already added to Alexa) → select “On”
  • Save

– Then do another routine, but this time for the OFF trigger.

That should do it. So when HA toggles the input_boolean “LR light”, Alexa also “sees” the same state via emulated_hue. At the same time, HA’s automation triggers the Alexa Media Player to send a “voice” command to Alexa which in turn triggers the actual device (amazon smart plug in this case) to turn on/off. And vice versa - when Alexa app toggles the “LR light” device (don’t toggle the actual plug), HA sees the same state and triggers the automation to then trigger Alexa to turn on/off the actual device. The caveat is that when the plug is turned on/off via the physical button on the plug, then its state is not sync’d to “LR light”, but that’s a caveat I think I can live with.

Cheers!