Set default list/ slot value in intent or intent script

I want to control the air conditioning with two options in sentence: temperature and hvac_mode. The issue is that when the sentence only specifies the temperature, the hvac_mode doesn’t have a default value, causing Assist to be unable to understand the action or service call.

I couldn’t find anything in the documentation lists options or intent with these choices.

Does anyone have suggestions on how to fix this without having to create two separate intents for just temperature / temperature and hvac_mode ?

Intent:

language: vi
intents:
  DieuKhienDieuHoa:
    data:
      - sentences:
       // This'll make Unexpected error during intent recognition or Received invalid slot info for DieuKhienDieuHoa
          - "Set [temp] climate at {temp}"      
       // This work well with intend script below  
          - "Set [temp] climate at {temp}  with mode {hvac_mode} "   /
lists:
 temp:
    range:
      from: 16
      to: 30
  hvac_mode:
    values:
      - in: "lạnh"
        out: "cool"
      - in: "nóng"
        out: "heat"

Intent script

DieuKhienDieuHoa:
    action:
      service: climate.set_temperature
      target:
        entity_id: climate.dieu_hoa_labo
      data:
        temperature: "{{temp}}"
        hvac_mode:  "{{hvac_mode}}"  
    speech:
      text: >-
        Climate mode {hvac_mode}} with {{ temp }}   

Create another Intent script just for the temperature

  DieuKhienDieuHoa:
    data:
      - sentences:
          - "Set [temp] climate at {temp}  with mode {hvac_mode} "
  DieuKhienDieuHoa_t:
    data:
      - sentences:
          - "Set [temp] climate at {temp}"

something like that

Initially, the script does not receive the expected variable when the temperature-only option is used

1 Like

Right now, I’m creating two custom sentences/intents and two intent scripts for this to work: First for just temperature and the others for both temperature and hvac mode.This is fine.

However, when there are more than two variables ( ex: fan speed, timer,area…). it gets more complicated—especially if some variables are missing when the sentence is called, as I have to account for each scenario individually.

So that, I want the variables to have default values so that when any variable is missing, it automatically uses that value, which would significantly reduce complexity. Hope that have template for that or it’ll support in the furture

Unfortunately, even the built-in offers do not have such flexibility. There is a strict binding to the original form of the phrase so that Hassil can process the request.
Until now, we have to turn on each device with a separate command.

If in the future it will be possible to use logical selection in the body of the script and make checks for the presence of variables, perhaps this could solve your problem.

1 Like

Thanks for sharing the Hassil link. The examples there are more detailed and clearer than those in the HA Developer Docs. Now, I’m combining the extended OpenAI integration with Home Assistant conversations to minimize misunderstandings.
Hopefully, it will be updated in the future to make it more localized and convenient.