Some fun with Alexa on a Friday afternoon

Bummer. I think the second method is still a bit out of reach for me at the moment with my knowledge level of Alexa.

With the second method, would I be able to query states? For example, ask Alexa if the Front Door is locked or if my windows are open?

Definitely - I much prefer the second method because you can do practically anything with it. Hasska is a cool package and works great but for me, the Amazon approach is limited and confusing. Alexa didn’t understand what I wanted and I generally don’t want to work with individual lights and she didn’t seem to understand my scenes. (and Homekit doesn’t seem a lot better).

Here are a couple of automations I am using to query state - it really is pretty easy to setup after you figure out the first one.

Turn on night mode but remind me if the garage is open:

        service: script.turn_on
          entity_id: script.night
        type: plaintext
        text: > 
          {% if is_state('garage_door.garage', 'open') %}
            No problem, but you might want to close the garage door before you go to sleep
          {% else %}
            {{ ["Good night, sleep well", 
            "Night Night", 
            "See you in the morning", 
            "OK, but no snoring!",
            "don't let the bed bugs bite" 
            ] | random }}
          {% endif %}

Ask Alexa if the heat is on:

        type: plaintext
        text: >
          {% if is_state('input_boolean.heating', 'on') %}
            the heat is on
          {% else %}
            the heat is off
          {% endif %}

This is what I’m looking for. The examples you gave are so simple and easy for me to grasp; it’s just like any other automation. My concern is setting up the other side of it. I don’t have SSL setup and the link for the AWS Lambda proxy for Alexa skills is a 404. Is there another way to set up a Lambda proxy or another guide?

I went the SSL route since I already had it set up I don’t know anything about the Lambda Proxy, sorry.

The SSL setup isn’t too bad - I’d go ahead and do that first as its useful in its own right.

Having issues with the port forwarding. I’m sure you’ve never heard of Verizon FiOS, but they’re not the friendliest routers in the world. I have a cert set up with certbot, but having trouble getting the RPi to come up instead of the router.

Thanks for this. I started tying to do the same for sensors. But I’ve run into a dead end with the intent trying to distinguish sensors that have certain attributes. I suppose I could make anther intent but a catch all would be nice.

  type: plaintext
  text: >
    {%- for state in states.sensor -%}
      {%- if state.attributes.battery_level != None and == Sensor.lower() -%}
        {{ }} is {{ state.state }} as of {{ relative_time(state.last_updated) }} ago with a battery level of {{state.attributes.battery_level}} percent
     {%- elif state.attributes.battery_level == None and == Sensor.lower() -%}
        {{ }} is {{ state.state }} as of {{ relative_time(state.last_updated) }} ago
      {%- endif -%}
    {%- else -%}
      I could not find a sensor named {{ Sensor }}
    {%- endfor -%}

Any ideas?

1 Like

Did you figure out how to get this to work the way you wanted? I just got the example up and running and I’m looking to get into querying states next. Was just wondering.

Follow-up for anyone working with Alexa. I ran int an issue this morning where I was using a custom slot in my Alexa setup, but it wasn’t working. I was configuring “wake up” commands for my kids and using their name as part of the name of a script that gets triggered. My daughter’s name is Nora, but my intent was receiving “Norah”, which is not in the names slot for my skill. From Amazon:

Note: A custom slot type is not the equivalent of an enumeration. Values outside the list may still be returned if recognized by the spoken language understanding system. Although input to a custom slot type is weighted towards the values in the list, it is not constrained to just the items on the list. Your code still needs to include validation and error checking when using slot values.

So if you run into this kind of thing, you may have to do a bit of extra work in your intent handler to normalize inputs.

Hope someone can help with this.

When i try to add in the custom replies for alexa i get this in my error log for the alexa_confirm.yaml file:

16-12-07 19:42:30 homeassistant.util.yaml: expected '<document start>', but found '{' in "/home/hass/.homeassistant/alexa_confirm.yaml", line 2, column 1

i literally copied the text from above or the same from the Docs.

Any help would be appreciated

You included the greater-than? And be sure to indent everything after it.

1 Like

@ih8gates Thanks so much… it was the indention. I am still getting used to positional dependent configuration files.

With YAML, whenever you’ve got something that seems like a child of something else, you generally indent. That particular thing you ran into is tricky because the > would typically follow “text:”, but with it in a separate file, you can lose the plot a bit.

@ih8gates Just rename your kids. Simple fix.

1 Like

@ih8gates yeah because it was in a different file i didnt think it actually mattered. Good to know, thanks for the tip.

Hi Andrew

I am trying to change Alexa to respond to a different command/phase rather than just “ok”. I have setup HA using Emulated Hue Bridge. Would the “alexa_confirm.yaml” work? Can you please help?


Hi -

No, they are two completely different systems. You can use them together but you only get to customize actions and responses when you use intents. The emulated hue component is all hardwired in Alexa.


Thanks for the reply.

So if I wanted to setup Alexa to respond with a different command than “ok” what system would I have to use and how can I set it up?


You need to use the intents system as described in my original post. The only downside is it is an Alexa skill so you need a keyword (of your choice) to activate it, e.g. “home assistant”. You control the keyword and all the words after that but you have to add them all individually. So you would say something like:

Alexa, tell home assistant to open the garage door

Rather than

Alexa turn the garage door on

As you would with emulated hue.

The main docs for the intents setup are here.

Hi @aimc

I have setup everything but whenever I ask Alexa to activate something it says it couldnt find the device in my account. I was able to switch on and off my kitchen strip lights before with the emulated hue but now I cant. Also the kitchen strip lights are setup using MQTT as a switch.

Do you know what could be the problem? I have used your scenes code and set it up exactly how you described.


SOunds like you aren;t using the keyword correctly. You have to say something like:

“Alexa tell home assistant to turn on the kitchen linght”

Where “home assistant” is the keyword you added in the Alexa setup on Amazon;'s website.