Using HA Assist "lists:-values:-in" text in response sentence

Hi,
How do I add the device “in” list value into the “intent_script:-speech:-text:” response?
In this case (a specific example then the full code blocks follow):

lists:
  oil_heater:
    values:
      - in: ...

Into the:

intent_script:
    speech: 
      text: "Temperature changed to {{ temp_degrees }} degrees"

My example attempt:

intent_script:
    speech: 
      text: "The {{ oil_heater }} Temperature changed to {{ temp_degrees }} degrees"

of course returns the:

lists:
  oil_heater:
    values:
      - out: ...

So how do I code the “intent_script:-speech:-text:” to include the specific “lists:-oil_heater:-values:-in” from my intents sentence?

My full (pertinent) code:

In configuration.yaml

intent_script:
  SetTemperature:
    action:
      service: "number.set_value"
      data:
        entity_id: "{{ oil_heater }}"
        value: "{{ temp_degrees }}"
    speech: 
      text: "Temperature changed to {{ temp_degrees }} degrees"

in /homeassistant/custom_sentences/en/temperatures_.yaml

language: "en"
intents:
  SetTemperature:
    data:
      - sentences:
          - "(set|change) {oil_heater} to {temp_degrees} [degrees]"
lists:
  oil_heater:
    values:
      - in: "office"
        out: number.irdecode1office_select_heater1_temp_42_95_f
      - in: "bedroom"
        out: number.irdecode2front_bdrm_select_heater2_temp_42_95_f
      - in: "living room"
        out: number.irdecode3livingrm_select_heater3_temp_42_95_f
      - in: "dining room"
        out: number.irdecode4diningrm_select_heater4_temp_42_95_f
  temp_degrees:
    range:
      from: 42
      to: 80

I finally got the syntax correct to use a list and push the value into the response, here’s my test setup:

/config/voice-respond.yaml

Test:
    speech:
        text: "Test successful {{ tlist }}"

/homeassistant/custom_sentences/en/voice-listen.yaml

language: "en"
intents:
    Test:
        data:
            - sentences:
                - "Control test"
                - "Actual test {tlist}"
lists:
    tlist:
        values:
            - "alpha"
            - "beta"
            - "gamma"

/homeassistant/custom_sentences/en/_custom.yaml
Did not create for this test

1 Like

The in values aren’t available, unfortunately, since there (currently) can only be one value for an intent slot. I’ll see if there’s another way to pass this in.

Thanks. I’m still looking at ways to accomplish this though so far unsuccessfully.

1 Like

Posted earlier, realized I was wrong. Now I’m trying again…

If I understand correctly, you want HA to accept a sentence with a list variable in it, and then use that list as an In value to convert to a number via an item-specific Out value, then take an action based on both the Out value and the original In value.

The only way I can imagine doing that with the current system is to encode a value in your number function. I would suggest doing that by changing from ‘degrees F’ to ‘1000 + degrees F’. Then in your action you can pick out the leading digit which represents your location (giving you 9 options without having to handle leading zeros), and then get your degrees F by removing that lead digit.

While I haven’t tested this myself, that means something like:

  oil_heater:
    values:
      - in: "office"
        out: {{number.irdecode1office_select_heater1_temp_42_95_f + 1000}}
      - in: "bedroom"
        out: {{number.irdecode2front_bdrm_select_heater2_temp_42_95_f + 2000}}
      - in: "living room"
        out: {{number.irdecode3livingrm_select_heater3_temp_42_95_f + 3000}}
      - in: "dining room"
        out: {{number.irdecode4diningrm_select_heater4_temp_42_95_f + 4000}}

Forgive the intrusion. Note: I am not a programmer. Though your reply was not addressed to me (op), I gave your code block a try; I replaced my code block with yours and got the error pop-up: “Unexpected error during intent recognition”.
What I’m trying to do is have the response TTS reply using both the List “in” and “out” values.
For example using the following list item:

lists:
  oil_heater:
    - in: "office"
      out: number.irdecode1office_select_heater1_temp_42_95_f

Then have the TTS response say something like: “The office temperature changed to 75 degrees”
Though the following does not work, hopefully it explains what I’m trying to do:

intent_script:
  SetHeaterTemperature:
    action:
      service: "number.set_value"
      data:
        entity_id: "{{ oil_heater }}"
        value: "{{ temp_degrees }}"
    speech: 
      text: "The {{ oil_heater }} Temperature changed to {{ temp_degrees }} degrees"

Where oil-heater returns office instead of spelling out the list/out code.
The code that works for me at the moment cannot include the oil-heater -in- value as in

    speech: 
      text: "Temperature changed to {{ temp_degrees }} degrees"

Thank you for testing… though I’m obviously a bit disappointed I didn’t have a brilliant insight that resolved the original request! I’m going to hack away at it and see if I can make something else work, eventually I’ll want to do this for my own setup anyway.

edit:

You know, you CAN use two lists in the same input… so you could have a list for your devices and a list for the value you want to pass to them. And I’ve tested this myself and it works perfectly. If you’re trying to pull current values from those devices, you’d do so in the response.

Hi,

Thanks for the follow-up. Nice find. It might come in handy sometime.

Only thing is that though using two lists works to get it to first say the room then the temperature but only if I say the room name twice in the intents-sentences.
Something like: “office office to 55 degrees”

In /homeassistant/configuration.yaml

intent_script:
  SetHeaterTemperature:
    action:
      service: "number.set_value"
      data:
        entity_id: "{{ oil_heater }}"
        value: "{{ temp_degrees }}"
    speech: 
      text: "{{ room_location }} Temperature changed to {{ temp_degrees }} degrees"

In /homeassistant/custom_sentences/en/temperatures_.yaml

language: "en"
intents:
  SetHeaterTemperature:
    data:
      - sentences:
          - "([set]|[change]) {oil_heater} {room_location} [temperature] to {temp_degrees} [degrees]"
lists:
  oil_heater:
    values:
      - in: "office"
        out: number.irdecode1office_select_heater1_temp_42_95_f
  room_location:
    values:
      - in: "office"
        out: "office"
  temp_degrees:
    range:
      from: 42
      to: 80

This works but I have to remember the number of the heater that goes in a room.

In /homeassistant/configuration.yaml

intent_script:
  SetHeaterTemperature:
    action:
      service: "number.set_value"
      data:
        entity_id: "{{ oil_heater }}"
        value: "{{ temp_degrees }}"
    speech: 
      text: "{{ room_location }} temperature changed to {{ temp_degrees }} degrees" 

In /homeassistant/custom_sentences/en/temperatures_.yaml

lists:
  room_location: 
    values:
      - in: "office"
        out: "office"
      - in: "bedroom"
        out: "bedroom"
      - in: "living room"
        out: "living room"
      - in: "dining room"
        out: "dining room"
  oil_heater:
    values:
      - in: "heater one"
        out: number.irdecode1office_select_heater1_temp_42_95_f
      - in: "heater two"
        out: number.irdecode2front_bdrm_select_heater2_temp_42_95_f
      - in: "heater three"
        out: number.irdecode3livingrm_select_heater3_temp_42_95_f
      - in: "heater four"
        out: number.irdecode4diningrm_select_heater4_temp_42_95_f
  temp_degrees:
    range:
      from: 42
      to: 80