control loads of unsupported devices with Alexa (or Google Home)

or how to selectively expose Home Assistant entities to Alexa with emulated hue

Home automation platforms like Alexa, Google Home and Home Assistant show major differences in the devices that they can discover and control. I currently have loads of devices in Home Assistant that neither the Amazon echo or Google Home are aware of. This project shows you how to put some of those into the Amazon echo app so that you can control then using your voice or an echo button or a timer routine. If you prefer to put the devices into Google Home, stay with me because the approach is similar.

Setup the ’emulated Hue’ component in Home Assistant

The trick to adding devices to Alexa is to get Home Assistant to pretend to be a Philips Hue hub. This is nothing to do with the Hue light system – you don’t need any Philips hardware. What the ’emulator’ does is to make Alexa aware that you’ve a new light, even though that light might be a smart socket or indeed an automation or script. The other half of the trick is be selective and not to flood Alexa with too many new devices. If you fail to do this your Alexa system will be filled with stuff you don’t need and it will take time to remove manually afterwards.

Edit your configuration.yaml with File Editor

Go to the file editor in the Home Assistant frontend. You start by ‘exposing’ your device entities to Alexa.

  • In File editor open your configuration.yaml and add this code.
  • My code is annotated. In my case I am ‘exposing’ a script which sets up several lights in one shot (more below)
  • Save the edits and shut down and restart the Raspberry Pi
# For exposing entities to ALEXA
emulated_hue:
# the IP of your Raspberry pi host can be left out. Alexa and Google may access your system from outside your network. If you're unlucky start looking here for the fix.
#  host_ip: 192.168.1.X
  listen_port: 80
  off_maps_to_on_domains:
    - script
  exposed_domains:
    - script
  entities:
    script.1605808203118:
    name: "Zoom room lighting"   
    hidden: false
  expose_by_default: false   
# For each entity you want to use in Alexa, list its name and COLON followed by a 
# friendly name and hidden: false. The script has the odd name above. You don't have 
# to use a script, you can use a light or a switch or almost anything you'd change.
# Don't use "expose: true". it doesn't work anymore. What works is "hidden: false"
# If expose by default is true you will likely add an unmanageable number of entities to Alexa
# Read the Emulated hue doc (link below) if you want to expose just the entities you need. 
# Only add the following if you're using my Zoom light timer script below
timer:
   zoomtime:
     duration: '01:20:00'
   

Example project part a – a script which turns on various lights as Zoom background lighting

This script needed to exist before the configuration.yaml edit and restart above. When you create a script in the Home Assistant frontend, it automatically gives it a unique number.

  • The alias is simply a reminder for you / me.
  • Sequence starts the list of commands in the script. A list is made of items each starting with a hyphen and a space.
  • As it’s a Zoom call I created a timer lasting 80 minutes in configuration.yaml above. The script below starts the timer.
  • Note the next list item. It activates a scene called “Zoom” that I’ve set up in the Philips Hue app.
  • The mode setting of single means that if I restart this it restarts. The icon is optional.
'1605808203118':
   alias: DINING Zoom background lighting
   sequence:
   - service: timer.start
     entity_id: timer.zoomtime
     data: {}
   - service: hue.hue_activate_scene
     data:
     group_name: Dining Room
     scene_name: Zoom
  mode: single
  icon: mdi:power 

Example project part b – an automation which turns off the Zoom background lighting when the timer is done

There are numerous ways to say, turn on things for a set time, here I use a Home Assistant timer. You could do something similar with an Alexa routine eg after 80 minutes ask Alexa to say ‘turn off dining room lights’.

 id: '1609610506848'
 alias: DINING Zoom lighting off or dimmed
 description: 'dims the lights'
 trigger:
 platform: event
 event_type: timer.finished
 event_data:
   entity: timer.zoomtime
 condition: []
 action:
 service: hue.hue_activate_scene
 data:
   group_name: Dining Room
   scene_name: Dimmed
 mode: single 

Example project part c – trigger your Home Assistant entity with an Alexa routine.

  • Outline:
    • Go to the Alexa app and Discover Devices (or say “Alexa, Discover Devices’)
    • Go to the Alexa app and find ‘Routines’. Create a new routine
    • Decide on the trigger event: there’s a huge choice. I used an echo button.
    • Under add action > Smart Home > Control device. Find your script (it’s a light bulb) called ‘Zoom room lighting’
  • For a similar project which TOGGLES lights with an Echo button see here.

What about adding devices similarly to Google home?

According to the docs, all the above, except ‘how you create routines’ in part c, should work for Google Home. I’ve had more luck with Alexa than Google Home. For the updated docs see here.

Leave a Reply

Your email address will not be published. Required fields are marked *