As you can’t set light colours via the emulated_hue component, I decided to go down the Custom Skill route.
Taking inspiration from the Working with Scenes section of the Alexa / Amazon Echo component page I created a skill that changes the colour of my RGB WiFi Bulbs running custom firmware, AiLight by @stelgenhof via Alexa. But this will work with any RGB light.
First follow the instructions under “Requirements” here to create a skill in the Amazon Developer Console.
Then add the following to your Skill.
Intent Schema
{
"intents": [
{
"slots": [
{
"name": "Light",
"type": "Lights"
},
{
"name": "Colour",
"type": "Colours"
}
],
"intent": "SetLightColour"
}
]
}
Custom Slot Types
Slot 1: Colours:
For this I used all of the CSS3 color names as mentioned for the service data attribute color_name for light.turn_on
CSS3 Color Names
aliceblue
antiquewhite
aqua
aquamarine
azure
beige
bisque
black
blanchedalmond
blue
blueviolet
brown
burlywood
cadetblue
chartreuse
chocolate
coral
cornflowerblue
cornsilk
crimson
cyan
darkblue
darkcyan
darkgoldenrod
darkgray
darkgreen
darkgrey
darkkhaki
darkmagenta
darkolivegreen
darkorange
darkorchid
darkred
darksalmon
darkseagreen
darkslateblue
darkslategray
darkslategrey
darkturquoise
darkviolet
deeppink
deepskyblue
dimgray
dimgrey
dodgerblue
firebrick
floralwhite
forestgreen
fuchsia
gainsboro
ghostwhite
gold
goldenrod
gray
green
greenyellow
grey
honeydew
hotpink
indianred
indigo
ivory
khaki
lavender
lavenderblush
lawngreen
lemonchiffon
lightblue
lightcoral
lightcyan
lightgoldenrodyellow
lightgray
lightgreen
lightgrey
lightpink
lightsalmon
lightseagreen
lightskyblue
lightslategray
lightslategrey
lightsteelblue
lightyellow
lime
limegreen
linen
magenta
maroon
mediumaquamarine
mediumblue
mediumorchid
mediumpurple
mediumseagreen
mediumslateblue
mediumspringgreen
mediumturquoise
mediumvioletred
midnightblue
mintcream
mistyrose
moccasin
navajowhite
navy
oldlace
olive
olivedrab
orange
orangered
orchid
palegoldenrod
palegreen
paleturquoise
palevioletred
papayawhip
peachpuff
peru
pink
plum
powderblue
purple
red
rosybrown
royalblue
saddlebrown
salmon
sandybrown
seagreen
seashell
sienna
silver
skyblue
slateblue
slategray
slategrey
snow
springgreen
steelblue
tan
teal
thistle
tomato
turquoise
violet
wheat
white
whitesmoke
yellow
yellowgreen
Slot 2: Lights:
List the lights you want to control using their entity ID, excluding “light.” and any _ (.e.g. ‘light.hallway_lights’ becomes ‘hallway lights’)
You don’t actually need to add this, it will still work without it by just saying the name to Alexa, however this might make it more accurate + in the future hopefully we’ll be able to use Synonyms in Home Assistant for each slot name (doesn’t work at the moment)… more on this later…
Sample Utterances
SetLightColour Set {Light} to {Colour}
Home Assistant Config
Configuration.yaml
alexa:
intent_script: !include intent_script.yaml
intent_script.yaml
SetLightColour:
action:
service: light.turn_on
data_template:
entity_id: light.{{ Light | replace(" ", "_") }}
color_name: '{{ Colour | replace(" ", "_") }}'
speech:
type: plain
text: >
Light Set to '{{ Colour | replace(" ", "_") }}'
Now I can ask: “Alexa, ask Home Assistant to set big lamp to blue” or “Alexa, ask Home Assistant to set Hallway Lights to coral”… Alexa will then set the colour and return the speech: “Light set to (colour she heard)”
I’ll try any upload a video of this later.
Now for a bit of a caveat, because Alexa requires the entity ID of the device and not the friendly name it can cause some issues with the utterance sentence being fluid… for example I have a light in my bedroom, light.mike with a friendly name of “Mikes Lamp” - to set the colour of the lamp, I would need to ask “Alexa, ask Home Assistant to set Mike to Blue”… which doesn’t really roll of the tongue… now yes I could set “light.mike” to become “light.mikes_lamp” in Home Assistant…
But what would be much better is support for Synonyms of Slots in the Alexa / Intent_scripts component of Home Assistant…
Then using the Amazon Skill Builder Beta I could define different Synonyms for my custom Slot, Lights > Mike for example “Mike’s Lamp”, “Mike’s Light”, “Michael’s Lamp”.
I’ve submitted a feature request for support of Alexa Slot Synonyms, I’ve tested this today and it doesn’t work. I think this could be down to the component looking for:
this.event.request.intent.slots.SlotName.value and not this.event.request.intent.slots.SlotName.resolutions.resolutionsPerAuthority according to this forum post?