What did the user ask about?

I am trying to determine what the user is searching for. I have tried the items below.

{#% set q = (
  (intent_input if intent_input is defined else '') ~ ' ' ~
  (input.text if input is defined and input.text is defined else '') ~ ' ' ~
  (trigger.text if trigger is defined and trigger.text is defined else '') ~ ' ' ~
  (query if query is defined else '') ~ ' ' ~
  (message if message is defined else '')
) | lower %#}
{#% set q = (trigger.slots.text 
if trigger is defined 
and trigger.slots is defined 
and trigger.slots.text is defined else '') | lower %#}
{% set q = (
  intent_input
  | default(trigger.slots.text | default(trigger.text | default('')))
) | lower %}

My branching instructions

{# ############################################### #}
{# #### Air quality CO2                       #### #}
{# ############################################### #}
{% if 'co2' in q or 'carbon' in q  %}
CO2 / AIR QUALITY CONTEXT:
{{ states('sensor.llm_co2_context') }}
{% endif %}
{# ############################################### #}
{# #### Temperature                           #### #}
{# ############################################### #}
{% if 'temp' in q or 'temperature' in q or 'rain' in q %}
TEMPERATURE CONTEXT:
{{ states('sensor.llm_temp_context') }}
{% endif %}
{# ############################################### #}
{# #### Internet                              #### #}
{# ############################################### #}
{% if  'internet' in q  and 'speed' in q %}
NETWORK CONTEXT:
{{ states('sensor.llm_network_context') }}
{% endif %}
{# ############################################### #}

Sample Run

init_options:
  start_stage: intent
  end_stage: intent
  input:
    text: what is the co2 level
  pipeline: 01jvfc2ewj8d4m3n9p1gep5eja
  conversation_id: null
stage: done
run:
  pipeline: 01jvfc2ewj8d4m3n9p1gep5eja
  language: en
  conversation_id: 01KQZRBPP6RZKN7VM105GN4Z36
  runner_data:
    stt_binary_handler_id: null
    timeout: 300
events:
  - type: run-start
    data:
      pipeline: 01jvfc2ewj8d4m3n9p1gep5eja
      language: en
      conversation_id: 01KQZRBPP6RZKN7VM105GN4Z36
      runner_data:
        stt_binary_handler_id: null
        timeout: 300
    timestamp: "2026-05-06T23:00:55.623205+00:00"
  - type: intent-start
    data:
      engine: conversation.llama3_1_8b
      language: en
      intent_input: what is the co2 level
      conversation_id: 01KQZRBPP6RZKN7VM105GN4Z36
      device_id: null
      satellite_id: null
      prefer_local_intents: true
    timestamp: "2026-05-06T23:00:55.623289+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        role: assistant
        content: Bed
    timestamp: "2026-05-06T23:00:59.852092+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: room
    timestamp: "2026-05-06T23:01:00.007217+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: " CO"
    timestamp: "2026-05-06T23:01:00.165368+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: "2"
    timestamp: "2026-05-06T23:01:00.320834+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: " is"
    timestamp: "2026-05-06T23:01:00.475314+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: " "
    timestamp: "2026-05-06T23:01:00.630505+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: "666"
    timestamp: "2026-05-06T23:01:00.789138+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: "6"
    timestamp: "2026-05-06T23:01:00.945280+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: " ppm"
    timestamp: "2026-05-06T23:01:01.100358+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: ","
    timestamp: "2026-05-06T23:01:01.258797+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: " Kitchen"
    timestamp: "2026-05-06T23:01:01.413887+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: " CO"
    timestamp: "2026-05-06T23:01:01.572286+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: "2"
    timestamp: "2026-05-06T23:01:01.727171+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: " is"
    timestamp: "2026-05-06T23:01:01.882417+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: " "
    timestamp: "2026-05-06T23:01:02.037459+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: "188"
    timestamp: "2026-05-06T23:01:02.193046+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: "8"
    timestamp: "2026-05-06T23:01:02.347710+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: " ppm"
    timestamp: "2026-05-06T23:01:02.503053+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: .
    timestamp: "2026-05-06T23:01:02.658088+00:00"
  - type: intent-progress
    data:
      chat_log_delta:
        content: ""
    timestamp: "2026-05-06T23:01:02.813293+00:00"
  - type: intent-end
    data:
      processed_locally: false
      intent_output:
        response:
          speech:
            plain:
              speech: Bedroom CO2 is 6666 ppm, Kitchen CO2 is 1888 ppm.
              extra_data: null
          card: {}
          language: en
          response_type: action_done
          data:
            success: []
            failed: []
        conversation_id: 01KQZRBPP6RZKN7VM105GN4Z36
        continue_conversation: false
    timestamp: "2026-05-06T23:01:02.813763+00:00"
  - type: run-end
    data: null
    timestamp: "2026-05-06T23:01:02.813791+00:00"
started: 2026-05-06T23:00:55.623Z
intent:
  engine: conversation.llama3_1_8b
  language: en
  intent_input: what is the co2 level
  conversation_id: 01KQZRBPP6RZKN7VM105GN4Z36
  device_id: null
  satellite_id: null
  prefer_local_intents: true
  done: true
  processed_locally: false
  intent_output:
    response:
      speech:
        plain:
          speech: Bedroom CO2 is 6666 ppm, Kitchen CO2 is 1888 ppm.
          extra_data: null
      card: {}
      language: en
      response_type: action_done
      data:
        success: []
        failed: []
    conversation_id: 01KQZRBPP6RZKN7VM105GN4Z36
    continue_conversation: false
finished: 2026-05-06T23:01:02.813Z

Ok I'm not following.

First what are you trying to do? (long form explain it like I'm an idiot)

Second are you trying to use builtin assist speech to phrase or are you using an LLM.

(your materials say LLM)

Thanks @NathanCu. I was following the advice of an AI to build my local AI. It is good to step back and try to explain what I am trying to do.

When I am using voice assistant, I want to search for something what is the co2 level. I want home assistant to process locally, if possible. I am running an ollama not inside HA but on the same network. I want the "instructions" to the LLM to also have the CO2 values since my search has co2 in it. The instructions to the LLM should have the values from sensor.llm_co2_context.

I am trying to give the LLM all the information it needs so it doesn't need to talk with HA. I am also running the LLM on CPU only without a GPU. Memory is sort-of limited 16GB total for all the system.

Oh and I want to embedded a comment into the LLM. Something like this for debugging purposes.

#{% value of user search request %}

Is that enough of an explanation?

better - first - LLMs WILL lead you down the wrong path. HA is exactly the wrong kind of workload (changes fast) to search for in an LLM.

If you're going do voice you have two choices - Assist text to phrase, or LLM.

If TTP then you must build sentence triggers the triggers use the trigger syntax to try to trigger when a certain phrase matches and pass the 'slots' into a scriptl

(which is what half of your script tries)

If LLM then you need a tool with a good description that tells the LLM what it's looking at. (any of the scripts in my Friday's party are a good example of an LLM script, Good description, good fields and returns clear information with instructions to the llm)

so in your what is the co 2 level question where is the data from?

1 Like