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:
NightModeIntent:
action:
service: script.turn_on
data:
entity_id: script.night
speech:
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:
QueryHeatIntent:
speech:
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?
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.
SensorIntent:
speech:
type: plaintext
text: >
{%- for state in states.sensor -%}
{%- if state.attributes.battery_level != None and state.name.lower() == Sensor.lower() -%}
{{ state.name }} 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 state.name.lower() == Sensor.lower() -%}
{{ state.name }} is {{ state.state }} as of {{ relative_time(state.last_updated) }} ago
{%- endif -%}
{%- else -%}
I could not find a sensor named {{ Sensor }}
{%- endfor -%}
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.
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.
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.
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?
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.
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
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.