Share how you are using the new "ask a question" functionality

@KE55ARD basic question, but is the volume up on it?

I’m still having issues as well, using the blueprint and the above code from Didgeridrew.

My ESP32-box prints the question text on screen and waits for my response but only once out of many tries have I actually heard the TTS (volume is up). This morning whilst the question text was on-screen I said the wake word and then suddenly the TTS was read out… but again it seemed to get stuck waiting for my response yet not doing anything when I said yes or no.

Tonight I’ll try it with my Voice PE which just arrived, maybe the ESP32 -box is struggling for some reason (it’s running the default firmware from the ESPhome github repo).

1 Like

I am trying to figure out this “ask a question” functionality however it’s not working as I am expecting it to so I was hoping someone might be able to help out. Up to this point I had 2 different automations to trigger a conversation. One that provided a daily weather update and a second one that provided a five day weather forecast. I was thinking I could combine them now by having the “ask a question” functionality ask if I would like to hear the five day weather forecast after hearing the daily weather forecast.

The problem is that the automation runs but I never hear the daily weather conversation and even though the “ask a question” does ask me if I want to hear the five day weather forecast and I say “yes” it never responds to the “yes” and always goes down the default path of “no”. I am stumped as to why the daily weather conversation never speaks and it goes directly to the default. I should mention that looking at the trace it appears to provide the correct daily weather info it just never verbally responds with it.

Here is the code:

alias: Daily Weather Info Conversation 2
description: ""
triggers:
  - trigger: conversation
    command:
      - Good morning
      - Daily info
      - What's the weather
      - What's the weather for today
      - Weather
conditions: []
actions:
  - set_conversation_response: >-
      Good {{ states.sensor.time_of_day.state }}. It is {{
      states.sensor.current_time.state }}. Today is {{ now().strftime( '%A, %B
      %d, %Y') }}. The current temperature is {{
      states.sensor.home_temperature.state | int(default=0) }} degrees
      Fahrenheit and feels like {{ states.sensor.home_realfeel_temperature.state
      | int(default=0) }}. It is currently {{ states.weather.home.state }}. The
      forecast for today is {{
      state_attr('sensor.ksmq_twice_daily_weather_forecast','forecast')[0].detailed_description
      }} For tonight, {{
      state_attr('sensor.ksmq_twice_daily_weather_forecast','forecast')[1].detailed_description
      }}. The low temperature for today is {{
      states.sensor.home_realfeel_temperature_min_day_0.state | int(default=0)
      }} degrees Fahrenheit with a high of {{
      states.sensor.home_realfeel_temperature_max_day_0.state | int(default=0)
      }}. The humidity level is {{
      states.sensor.aqara_temperature_humidity_sensor_humidity.state |
      int(default=0) }} percent. The atmospheric pressure yesterday was {{
      states('input_text.yesterday_pressure') | float(0) }}. The atmospheric
      pressure today is {{
      states.sensor.aqara_temperature_humidity_sensor_pressure.state }}. That is
      a difference of {{ states.sensor.pressure_calculation.state | float }}.
      The pressure level is {{ states.sensor.home_pressure_tendency.state }}. {{
      states.sensor.grass_pollen_text.state }}. {{
      states.sensor.mold_pollen_text.state }}. {{
      states.sensor.ragweed_pollen_text.state }}. {{
      states.sensor.tree_pollen_text.state }}. {{
      states('sensor.sun_rise_time_text') }}, {{
      states('sensor.sun_set_time_text') }}. 

      {{ ['Have a wonderful day!', 'It''s a beautiful day, go enjoy it!', 'Go
      have a great day!', 'Today''s going to be great day go have some fun!',
      'What a wonderful day today''s going to be!', 'It''s going to be a
      terrific day, don''t you think?'] | random }} 
  - action: assist_satellite.ask_question
    metadata: {}
    data:
      question: Would you like to hear the extended weather forecast?
      preannounce: false
      answers:
        - id: "yes"
          sentences:
            - Sure
            - Please
            - Yes [please]
            - Definitly
            - ok
        - id: "no"
          sentences:
            - No [thank you]
            - not now
      entity_id: assist_satellite.seeed_respeaker_satellite2_assist_satellite
    response_variable: answer
  - choose:
      - conditions:
          - condition: template
            value_template: "value_template: \"{{ answer.id == 'yes' }}\""
        sequence:
          - sequence:
              - action: script.extended_weather_forecast
                metadata: {}
                data: {}
    default:
      - action: assist_satellite.announce
        metadata: {}
        data:
          message: >-
            Sounds good. When you are ready just ask for the extended weather
            forecast
          preannounce: true
        target:
          entity_id: assist_satellite.seeed_respeaker_satellite2_assist_satellite
mode: single

That’s not going to work…

ugh, I totally missed that but would that have any impact on the first part of the conversation not responding verbally?

**edit - I corrected the value_template and looking at the trace it seems it did recognize my response of “yes” however neither the 1st part of the automation (daily weather) nor the 2nd part (five day forecast) were spoken verbally.

No, probably not…

The first thing I would do would be to convert all the state object methods to use the states() function. Any of those could kill the template rendering.

Next, double check the quotes marks in the last bit.

I have been using these automations for months now as conversation automations. They work flawlessly as separate automations. I was just hoping I could combine them now but for some reason neither gets spoken when combined like this.

One other thing to try would be to add a delay between the original conversation response and the ask action. Sometimes you can get a collision between two speaking actions that are called in too close succession.

I was finally able to get back to this, unfortunately I tried a delay of 5 seconds, 30 seconds and 1 minute and again after looking at the trace I can see that it seems to execute correctly but never verbally speaks the results back.

Greetings and salutations-

I thought I’d share this script as an example of how to break down complicated requests into simpler parts. The script gets called by an automation triggered by someone stating “Make Temperature Adjustment” or something like that. The Automation sends the assist entity that is receiving the request.

Once the script is called, it asks what change the user would like to make to the thermostats/temperature. I have 4 possible categories of responses: 1) a change to the thermostat mode (Nest thermostats have two modes - eco temperatures or normal temperatures), 2) setting the target temperature, 3) a “make it colder” command that lowers the temperature by 2 degrees F, and (4) a “make it warmer” command that raises the temperature by 2 degrees F.

If the user responds by stating one of the mode change sentences, then the script determines if the user wants eco mode on or normal mode on. If the user wants to set target temperature, then a follow up question asks the user for the specific target temperature and applies that target (as long as the number is between 64 & 86). The make it warmer and make it colder options each call another script that handles those actions.

Each action has a different announcement to inform the user what HA did or did not do. The script stops once an action set is completed, so I added a final announcement that will only execute if HA didn’t understand the user’s responses.

I know that some will say that it is easier to just have the user make a single request to HA, but I’ve found that (some of) my family has difficulty stringing long requests. So breaking it down may make it easier for them. I just wanted to test this out.

I have been waiting a loooooooooooong time for some platform to incorporate this functionality (amazon, smartthings, hubitat, google, and apple - all nada). Kudos to the HA team for doing it, and doing it right. It works extremely well.

Anyway, here’s the code:

sequence:
  - action: assist_satellite.ask_question
    metadata: {}
    data:
      preannounce: true
      question: How do you want to adjust the thermostats?
      answers:
        - id: mode
          sentences:
            - turn {mode_change}
        - id: temper
          sentences:
            - set target temperature
        - id: cooler
          sentences:
            - make it (colder|cooler)
            - (reduce|lower) the temperature
            - it is too (warm|hot)
        - id: warmer
          sentences:
            - make it (warmer|hotter)
            - (raise|increase) the temperature
            - it is too (chilly|cold|cool)
      entity_id: "{{the_sat}}"
    response_variable: answer
    alias: ASK How do you want to adjust the thermostats
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ answer.id == 'mode' }}"
            alias: Answer was turn on/off Eco/Normal Mode
        sequence:
          - alias: Apply Requested Mode
            if:
              - condition: template
                value_template: >-
                  {{ ['eco mode off','off eco mode','normal temps on','on normal
                  temps','on normal temperature','on normal mode','normal mode
                  on']|contains(answer.slots.mode_change) }}
                alias: Test for Normal Mode
            then:
              - action: input_button.press
                data: {}
                enabled: true
                target:
                  entity_id: input_button.normal_temps
              - action: assist_satellite.announce
                metadata: {}
                data:
                  message: The thermostats are applying the normal temperatures.
                  preannounce: false
                target:
                  entity_id: "{{ the_sat }}"
            else:
              - alias: Test for Eco Mode
                if:
                  - condition: template
                    value_template: >-
                      {{ ['on eco mode','eco mode on','on eco temps','eco temps
                      on','on eco setting','eco setting
                      on']|contains(answer.slots.mode_change) }}
                then:
                  - action: input_button.press
                    data: {}
                    enabled: true
                    target:
                      entity_id: input_button.eco_mode_on
                  - action: assist_satellite.announce
                    metadata: {}
                    data:
                      message: The thermostats are applying eco mode temperatures.
                      preannounce: false
                    target:
                      entity_id: "{{ the_sat }}"
                else:
                  - action: assist_satellite.announce
                    metadata: {}
                    data:
                      message: >-
                        I did not understand that. Try asking one of the 5
                        following commands:  1, turn eco on, 2, turn normal mode
                        on, 3, set target temperature, 4, make it warmer, or, 5,
                        make it colder.
                      preannounce: false
                    target:
                      entity_id: "{{ the_sat }}"
                    alias: No Comprende Senor
          - stop: End Choice
        alias: Normal / Eco Modes
      - conditions:
          - condition: template
            value_template: "{{ answer.id == 'temper' }}"
            alias: Answer was Set Target Temps
        sequence:
          - alias: ASK for target temperature.
            action: assist_satellite.ask_question
            metadata: {}
            data:
              preannounce: true
              question: Tell me the new target temperature.  Just the number please.
              answers:
                - id: degree
                  sentences:
                    - "{newTarget}"
              entity_id: "{{the_sat}}"
            response_variable: answer
          - alias: If requested temp is valid, apply to current target
            if:
              - condition: and
                conditions:
                  - condition: template
                    value_template: "{{ (answer.slots.newTarget|int) < ('86'|int) }}"
                  - condition: template
                    value_template: "{{ (answer.slots.newTarget|int) > ('64'|int) }}"
            then:
              - action: input_number.set_value
                metadata: {}
                data:
                  value: "{{ answer.slots.newTarget | int }}"
                target:
                  entity_id: >-
                    {{ iif (states('input_select.mode_list') ==
                    'Sleepytime','input_number.sleepytime_target_temp','input_number.day_target_temp')
                    }}
              - action: assist_satellite.announce
                metadata: {}
                data:
                  message: The target termperature is now {{ answer.slots.newTarget }}.
                  preannounce: false
                target:
                  entity_id: "{{ the_sat }}"
            else:
              - action: assist_satellite.announce
                metadata: {}
                data:
                  preannounce: false
                  message: >-
                    Nice try, bozo.  You are only allowed to set a target
                    temperature between 65 and 85 degrees.
                target:
                  entity_id: "{{ the_sat }}"
          - stop: End Choice
        alias: Set Target Temperature
      - conditions:
          - condition: template
            value_template: "{{ answer.id == 'cooler' }}"
            alias: Answer was Make it Colder
        sequence:
          - action: script.reduce_temp_2_degrees
            metadata: {}
            data: {}
          - action: assist_satellite.announce
            metadata: {}
            data:
              message: >-
                I reduced the target temperature by 2 degrees.  It will cool
                down in a few minutes.
              preannounce: false
            target:
              entity_id: "{{ the_sat }}"
          - stop: End Choice
        alias: Make it Colder
      - conditions:
          - condition: template
            value_template: "{{ answer.id == 'warmer' }}"
            alias: Make it Warmer
        sequence:
          - action: script.reduce_temp_2_degrees
            metadata: {}
            data: {}
          - action: assist_satellite.announce
            metadata: {}
            data:
              message: >-
                I increased the target temperature by 2 degrees.  You'll warm up
                soon.
              preannounce: false
            target:
              entity_id: "{{ the_sat }}"
          - stop: End Choice
        alias: Answer was Make it Warmer
  - alias: No Comprende Senor
    action: assist_satellite.announce
    metadata: {}
    data:
      message: >-
        I did not understand that, you meatbag. Next time try telling me one of
        the 5 following commands:  1, turn eco on, 2, turn normal mode on, 3,
        set target temperature, 4, make it warmer, or, 5, make it colder.
      preannounce: false
    target:
      entity_id: "{{ the_sat }}"
fields:
  the_sat:
    selector:
      entity: {}
    name: the_sat
    description: The HA Satellite
    required: true
    default: assist_satellite.ha_voice_1_assist_satellite
alias: Ask Question - Temp Change
description: ""

3 Likes