Yes or no response from Assist, how to

Hi, I was wondering if someone could help with the following. I’m trying to code some variable responses (yes/no) based an Assist query. For example, I have a doors & windows group, where I have set up a simple custom sentence and response to ask if any of the windows or doors are open. At the moment, it will just say ‘The doors and windows are [state]’ (open or closed), but I’d like to change it so it says either ‘Yes, the doors & windows are open’, or 'The doors & windows are closed.

Here’s the code I have so far. How could this be changed to give a variable response? I did try looking through the default sentences and responses on github, but couldn’t get anything to work.

custom_sentence:

# Example config/custom_sentences/en/device_status_and_operation.yaml
language: "en"
intents:
  DoorsWindows:
    data:
      - sentences:
          - "(Are|Is) [there] (any|any of the|any) (windows|doors) [and|or] [windows|doors] open"

response:

# Doors & Windows
intent_script:
  DoorsWindows:
    speech:
      text:  "The doors and windows are {{states('sensor.doors_windows_state')}}"

You may have already figured this one out, if not I would replace

{{states('sensor.doors_windows_state')}}

with

{{ (states('sensor.doors_windows_state') == "open") | iif( 'Yes', 'No') }}
2 Likes

Thanks Aaron, I’ll give this a try :slight_smile:

Hi again, thanks for the tempting tip. Unfortunately, I couldn’t get the example you sent to work, but this one works a treat :slight_smile:

{{ is_state('sensor.doors_windows_state', 'open') | iif('Yes, the doors and windows are open', 'No, the doors and windows are closed') }}