Expansion rules in sentences, why doesnt this work?

This trigger:

triggers:
  - command:
      - <what_is> [the] [current] outside temperature

Won’t fire an automation when the phrase ‘what is the outside temperature’ is spoken.

I thought <what_is> was a standard expansion rule from _common.yaml, so why doesn’t that phrase work?

1 Like

I’m clearly doing something wrong, with that sentence trigger, ALL my voice automations fail until I remove the offending sentence and do a (soft) restart of HA.

I get the following error in the logs:-

Unexpected error during intent recognition
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 1065, in recognize_intent
    := await conversation.async_handle_sentence_triggers(
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self.hass, user_input
        ^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/components/conversation/__init__.py", line 220, in async_handle_sentence_triggers
    return await default_agent.async_handle_sentence_triggers(user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/default_agent.py", line 1330, in async_handle_sentence_triggers
    if trigger_result := await self.async_recognize_sentence_trigger(user_input):
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/default_agent.py", line 1256, in async_recognize_sentence_trigger
    for result in recognize_all(user_input.text, self._trigger_intents):
                  ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/hassil/recognize.py", line 231, in recognize_all
    intent_sentence.compile(match_settings.expansion_rules)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/hassil/expression.py", line 150, in compile
    self._compile_expression(self, pattern_chunks, expansion_rules)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/hassil/expression.py", line 170, in _compile_expression
    self._compile_expression(item, pattern_chunks, rules)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/hassil/expression.py", line 189, in _compile_expression
    raise ValueError(rule_ref)
ValueError: RuleReference(rule_name='what_is')

so how do I use (a default) expansion rule in a sentence trigger ?

To get around the above problem I’ve basically copied the built in expansion as follows:-

triggers:
  - command:
      - (what is | what's | tell me) [the] [current] outside temperature

But there must be a way to use the built in ones ?