Recap - Control Alexa plugs or other Alexa only supported devices

Hi everyone,

I was investigating the options available to control Amazon Smart Plugs or other devices that might have supporting Alexa but not directly in HA.
I’ve done some experimentation and also discovered something new, I think, in the process, that I’d like to share here.

My goal:

  • control an Amazon Smart Plug from HA
  • control a cheap Led Strip made by Gosund that has Alexa support but that might not have yet support on HA
  • possible future stuff with closed source support on Alexa but does not have equivalent support in HA

Options:

  1. Use Alexa Media Player component to trigger an Alexa Routine
  2. Use Alexa Smart Home component to expose to Alexa virtual devices that can be used as triggers in routines.

Details:

  1. This is pretty straight forward. After you have Alexa Media Player configured you just need to invoke a service, passing as an input variable the same utternace you have configured in a corresponding Alexa routing voice activated:

Invoke service media_player.play_media with this data:

entity_id: media_player.MY_ECHO_HERE
media_content_type: routine
media_content_id: "UTTERANCE HERE"
  1. It’s more challanging and took me some good trial and error time to get it right.
    I’ve found the idea described first here and it’s also vaguely listed in the official docs here
    The idea is that if you have:
  • configured Alexa Smart Home integration and enabled pro-active events
    in Haaska custom Amazon Skill, you can create Template Sensors in HA, exposed them to Alexa, and then use their state as triggers to start an Alexa routine.
    This whole idea is also confirmed by Amazon support on this thread where they provide a longer list of options than those currently listed on Alexa Smart Home doc page.
    I’ve tried all of them, and I will give some example here. All of them, but the “Temperature Sensor” and the “Lock Sensor” worked for me.
    The most intresting aspect of my experiments has been that even stuff that was not supposed to work was indeed working!
    If you check this other official Amazon doc page some of the official API are supported only for specific languages. Well, I’ve discovered that some of the “unsuopported” ones are actually working if you just add your own language to the list of supported ones. To do so you have to patch the official HA Smart Home Components.
    Mind that I’ve performed this test only for the Italian language, this might not hold true for the other not officially supported languages.
    So, what I’ve managed to confirm is that, you can indeed use the following list of HA devices exposed to Alexa to be used as triggers for routines:
  • Motion Sensor
  • Contact Sensor
  • Doorbell Event
  • Security Panel

While I had issues with the following:

  • Temperature Sensor ( They were not even listed as possible Routines triggers in Alexa app)
  • Lock ( They were actually listed, but when selected an error message in the app says that they are not supported).

The interesting aspect in knowing that all those different kind of entities can be used is that they come with a different set of additional features (some of them are binaries, some are not. Doorbell for example allows you to ring a bell sound when activated in Alexa)

Below a sample list of partial configuration I’ve used to perform my tests. Mind that some of the templates are static and not fully dynamic. But you should be able to adjust them easily:

# Create first an helper input boolean to control the template sensors:
# input_boolean.amazon_smart_plug

# Binary sensors
- platform: template
  sensors:
    virtual_motion_sensor:
      friendly_name: "Virtual Motion Sensor"
      device_class: motion
      value_template: "{{ is_state('input_boolean.amazon_smart_plug', 'on') }}"
    virtual_door_sensor:
      friendly_name: "Virtual Door Sensor"
      device_class: garage_door
      value_template: "{{ is_state('input_boolean.amazon_smart_plug', 'on') }}"
    virtual_doorbell_sensor:
      friendly_name: "Virtual Door Sensor"
      value_template: "{{ is_state('input_boolean.amazon_smart_plug', 'on') }}"

# alarm control panel
alarm_control_panel:
  - platform: template
    panels:
      safe_alarm_panel:
        code_arm_required: false
        value_template: "DISARMED"
        arm_away:
          service: persistent_notification.create
          data_template:
            title: >-
              Alaram
            message: "Arm Away"
          data:
            notification_id: "virtual_alarm"
        arm_home:
          service: persistent_notification.create
          data_template:
            title: >-
              Alaram
            message: "Arm Home"
          data:
            notification_id: "virtual_alarm"
        disarm:
          service: persistent_notification.create
          data_template:
            title: >-
              Alaram
            message: "Disarm"
          data:
            notification_id: "virtual_alarm"

# important: for this to work you need to specify the correct "display_categories" field for each of the specific entity that you enable in your "smart_home:" config
...
  entity_config:
    input_boolean.amazon_smart_plug:
      name: Input Boolean
      description: Input Boolean
      display_categories: LIGHT
    binary_sensor.amazon_smart_plug:
      name: Template Binary Sensor TEMPLATE LOCK
      description: Template Binary Sensor TEMPLATE LOCK
      display_categories: SMARTLOCK
    binary_sensor.virtual_motion_sensor:
      name: Virtual Motion Sensor
      description: Virtual Motion Sensor
      display_categories: MOTION_SENSOR
    binary_sensor.virtual_doorbell_sensor:
      name: Virtual Door Bell Sensor
      description: Virtual Door Bell Sensor
      display_categories: DOORBELL
    alarm_control_panel.safe_alarm_panel:
      name: Virtual Alarm Control Panel
      description: Virtual Alarm Control Sensor
      display_categories: SECURITY_PANEL

If you do this and you take care that you specific language is enable for the corresponding sensor you want to use. ex. here you will be able to use the devices to trigger your Alexa routines and have access to every command you can trigger from there.

My plan is to open a PR to add the additional unofficial languages for the APIs I’ve tried directly.