Problem with Alexa Intent

Sorry for the delay. I did get something working and meant to update this post but forgot. Here’s what I am using:

SetDownstairsTemp:
      action:
        service: climate.set_temperature
        entity_id: climate.downstairs
        data_template:
          temperature: ({{ downtemp }} | float)

He,

hmm looks like this is not working.

Heres my Intent:

  VolumeDenon:
    action:
      service: input_slider.select_value
      entity_id: input_slider.volume_setpoint
      data_template:        
        value: ({{ volume }} | float)

Log now saying:

Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got '(20 | float)'

Twenty is what i tried to set via Alexa

Sorry, you’re right. I thought I had this working but apparently I don’t… I had moved on to something else and forgot to finish this. I just checked and I am getting the same error as you with this code.

I’m pretty sure you need:

SetDownstairsTemp:
      action:
        service: climate.set_temperature
        entity_id: climate.downstairs
        data_template:
          temperature: {{ downtemp | float }}

Not tested, but that’s how filters and templates work. You won’t ever have () around a template - at least at the outside.

I did try that again, but it’s still giving me this error:

ERROR:homeassistant.util.yaml:invalid key: “OrderedDict([(‘downtemp | float’, None)])”

This is what I wrote for my volume intents:

SetVolumeIntent:
  action:
    service: media_player.volume_set
    data_template:
      entity_id: media_player.yamaha_receiver
      volume_level: >-
        {%- if Level|int in range(10,81) -%}
          {%- set n = Level|float -%}
          {{ (1.0-( n / 100.0 )) | round(0.00) }}
        {%- endif -%}
  speech:
    type: plaintext
    text: OK

You are going to need to figure out the conversion from speech to input. In this case above, I wanted my intent input to be in decibels. So I say “Alexa, ask home to set volume to 25” which converts 25 into the volume (which happens to be 0.75).

Figure out what you need for the conversion and use that template. This is my alexa intent for this:

  "intent": "SetVolumeIntent",
  "slots": [
  {
    "name": "Level",
    "type": "Levels"
  }]

I made a slot with all the Levels I wanted to allow. I didn’t want my speaker to blow up so I use the alexa slot to limit the inputs instead of using AMAZON.NUMBER.

Basically you can use this principle for creating the temperature. You just need to find the attribute you are using and fill it in with the appropriate number. As I said before, you may need to convert the number you speak into the number that the attribute desires. For example, if your temperature attribute requires ºC and you say ºF, then you need to convert it before placing it in that attribute through the design_template.

Try this:

SetDownstairsTemp:
      action:
        service: climate.set_temperature
        data_template:
          entity_id: climate.downstairs
          temperature: {{ downtemp | float }}

Notice that the entity_id is in the data_template.

Hi Petro,

The above did not work for me either, I still got the same error. But looking at your post before that, I was able to get this to work:

SetDownstairsTemp:
  action:
    service: climate.set_temperature
    data_template:
      entity_id: climate.downstairs
      temperature: >-
        {% set n = downtemp|float %}
        {{ n }}

Thanks so much!

This worked for me using the Test feature on Amazon, but it does not work when I speak to my Echo Dot. It says there was a problem with the skill’s response and an error prints out from HomeAssistant stating that downtemp is undefined.

Any thoughts?

He, thanks a lot for input.

Got mine to work with:

  VolumeDenon:
    action:
      service: input_slider.select_value
      data_template:
        entity_id: input_slider.volume_setpoint      
        value: >
         {%-  set n = volume | int -%}
         {{ n }}

@nbroyer maybe you should remove the - in >- because i think you don’t like to set your temperature to minus degrees.

No problem, glad it worked for the both of you.

Nbroyer, what are you sending as a response? For something like this I would just have her response be “OK”, see my example:

SetDownstairsTemp:
  action:
    service: climate.set_temperature
    data_template:
      entity_id: climate.downstairs
      temperature: >-
        {% set n = downtemp|float %}
        {{ n }}
    speech:
      type: plaintext
      text: OK

Anything under the text attribute is what alexa says. I’m not sure if its needed but I always have her say ‘ok’.

I did try to simplify the response to just OK but still had the same problem. I also noticed I would get a similar problem using the Test feature occasionally. It seemed like there was a timeout issue. I just upgraded to 38.3 and it is working fine with my Echo Dot now, using the response “Okay, set downstairs temperature to {{downtemp}}”.

Thanks again for all your help!

Hi There, Would be really helpful if you are able to advise on your final script in the home assistant .yaml and what you ended up putting into the Amazon console in the intents/slots/utterance fields or a copy and paste of the json file I found in the beta interaction model tab in the amazon console, I’m really struggling to get this working. I can get echo to talk to HA and works in test but it wont actually report the temp back or change the temp. Many Thanks

It looks like some updates to HA have broken this for me. I’ve tried switching my intents: to intent_script: and my speech type from plaintext to plain, but I still get a Received Unknown Intent error. This is what I currently have, though, if it helps at all:

alexa:
  intent_script:
    BoilerTempIntent:
      speech:
        type: plain
        text: The wood boiler temperature is {{ states.sensor.wood_boiler_temp.state }} degrees
    MasterTempIntent:
      speech:
        type: plain
        text: The master temperature is {{ states.climate.master.attributes.current_temperature}} degrees
    DownTempIntent:
      speech:
        type: plain
        text: The downstairs temperature is {{ states.climate.downstairs.attributes.current_temperature}} degrees
    UpTempIntent:
      speech:
        type: plain
        text: The upstairs temperature is {{ states.climate.upstairs.attributes.current_temperature}} degrees
    SetDownstairsTemp:
      action:
        service: climate.set_temperature
        data_template:
          entity_id: climate.downstairs
          temperature: >
            {%- set n = downtemp|float -%}
            {{ n }}
      speech:
        type: plain
        text: Okay, set downstairs temperature to {{downtemp}}
    SetUpstairsTemp:
      action:
        service: climate.set_temperature
        data_template:
          entity_id: climate.upstairs
          temperature: >
            {%- set n = uptemp|float -%}
            {{ n }}
      speech:
        type: plain
        text: Okay, set upstairs temperature to {{uptemp}}
    SetMasterTemp:
      action:
        service: climate.set_temperature
        data_template:
          entity_id: climate.master
          temperature: >
            {%- set n = mastertemp|float -%}
            {{ n }}
      speech:
        type: plain
        text: Okay, set master temperature to {{mastertemp}}

Intents -
{
“intents”: [
{
“slots”: [],
“intent”: “BoilerTempIntent”
},
{
“slots”: [],
“intent”: “MasterTempIntent”
},
{
“slots”: [],
“intent”: “DownTempIntent”
},
{
“slots”: [],
“intent”: “UpTempIntent”
},
{
“slots”: [
{
“name”: “downtemp”,
“type”: “AMAZON.NUMBER”
}
],
“intent”: “SetDownstairsTemp”
},
{
“slots”: [
{
“name”: “uptemp”,
“type”: “AMAZON.NUMBER”
}
],
“intent”: “SetUpstairsTemp”
},
{
“slots”: [
{
“name”: “mastertemp”,
“type”: “AMAZON.NUMBER”
}
],
“intent”: “SetMasterTemp”
}
]
}

Utterances -

BoilerTempIntent What’s the boiler temp
BoilerTempIntent For the boiler temp

MasterTempIntent For the master temp

DownTempIntent For the downstairs temp

UpTempIntent For the upstairs temp

SetDownstairsTemp to set the downstairs temp to {downtemp}
SetUpstairsTemp to set the upstairs temp to {uptemp}
SetMasterTemp to set the master temp to {mastertemp}

That’s great thanks, gives me some more to try out, thanks for that.

No problem. Let me know if you get it working so I can try to fix mine, too. Thanks!

Hi, All working… that took a few hours and some!

This also helped;

I ended up using this script below in HA in !intent_script.yaml, I have different names for the intent (SetTemperature) and slot (temp), I also did use AMAZON.NUMBER in the slot type originally for my ‘temp’ (which worked) but changed it as I actually only want to select 15 to 25 degrees so created a custom slot type ‘temps’ and values 15 to 25 on each line. Its setting my zwave horstmann thermostat a treat. Also used a card but not worked that out yet.

 SetThermostat:
action:
  service: climate.set_temperature
  data_template:
    entity_id: climate.main_house
    temperature: '{{ temp | replace(" ", "_") }}'
speech:
  type: plain
  text: >
    Setting temperature to '{{ temp | replace(" ", "_") }}' degrees
card:
  type: simple
  title: Setting temperature to '{{ temp | replace(" ", "_") }}' degrees
  content: You have altered the house temperature of the entrance hall

And the Intent Schema in the Amazon Console was;

{
“intents”: [
{
“intent”: “AMAZON.CancelIntent”
},
{
“intent”: “AMAZON.HelpIntent”
},
{
“intent”: “AMAZON.StopIntent”
},
{
“slots”: [
{
“name”: “temp”,
“type”: “temps”
}
],
“intent”: “SetThermostat”
}
]
}

With utterances of;

SetThermostat set the main house temperature to {temp}
SetThermostat set the temperature to {temp}
SetThermostat set the house temperature to {temp}

Also have the temp being reported back under another skill at the moment but the intent HouseTemperature script for my sensor entity_id: sensor.main_thermostat_temperature was;

 HouseTemperature:
speech:
  type: plain
  text: >
    The main house temperature is {{ states.sensor.main_thermostat_temperature.state|round }} degrees

Intent Schema:

{
“intents”: [
{
“intent”: “HouseTemperature”
}
]
}

No Slots and Utterances as below;

HouseTemperature house temperature
HouseTemperature main house temperature

You will be well aware of all this info but I’ve listed it out for the benefit of anyone else who spends hours trying to work out how to get Alexa to change their climate entity setting from Alexa or have Alexa to report the status of a sensor! Ill be trying this to set other climate sensor states or entities set with values (media and so on at some point). I’m off to Bed!

Cheers

Glad you got it working! I finally got mine fixed, as well. My problem was that I had the intent_script line indented under alexa when it shouldn’t be.

I have a couple of intents that are not using slots that are working fine. However, I have one intent with one slot and Alexa gives me the message ‘This intent is not yet configured withing …’

The Amazon skill compiles and when I test it, it returns 'open' or 'close'.  

{
                    "name": "garage",
                    "slots": [
                        {
                            "name": "OpenClose",
                            "type": "AMAZON.SearchQuery"
                        }
                    ],
                    "samples": [
                        "to {OpenClose} the garage door",
                        "to {OpenClose} the garage",
                        "to {OpenClose} garage",
                        "to {OpenClose} sesame"
                    ]
                }

This is my intent:

 garage:
    speech:
      type: plaintext
      text:  >
        You asked me to {{OpenClose}} the garage

Any help would be appreciated.
Thanks!