#custom intents - fan speed / percentage

1 messages · Page 1 of 1 (latest)

lime yew
#

I clearly suck at writing custom intents as I've tried everything and have spend hours searching but no one else that I've been able to find has solved this.
Here is my intent_script: (in configuration.yaml)
```
intent_script:
SetFanSpeed:
speech:
text: "Setting the fan speed to {{ percentage }}%."
action:
- service: fan.set_percentage
data:
entity_id: "{{ entity_id if entity_id is not none else area_id }}"
percentage: "{{ percentage }}"
```
sentences: (in config/custom_sentences/en/SetFanSpeed.yaml)

```
intents:
SetFanSpeed:
data:
- sentences:
- "Set the fan in {area} to {percentage} percent"
- "Adjust the fan in {area} to {percentage} percent"
- "Make the fan speed in {area} {percentage} percent"
slots:
area:
type: area
percentage:
type: number

  - sentences:
      - "Set {entity} speed to {percentage} percent"
      - "Adjust {entity} to {percentage} percent"
      - "Make {entity} speed {percentage} percent"
    slots:
      entity:
        type: entity
        domain: fan
      percentage:
        type: number

```

These cause intents to not even work and in the log I get a bunch of errors.. seems very similar to other intents/scripts..

Any suggestions? (even tried getting ChatGPT to help and it never solves it..)

radiant cliff
#

please wrap these in triple backticks so it is more legible 🙂

#
like this 
#

also, sentence files and intent scripts go in two different areas. The sentence files go into /config/custom_sentences/en, intent scripts go into configuration.yml, you can also do config mappings for that to load your intent scripts from a different directory, that's detailed more in the HA docs 🙂

lime yew
#

yep.. I have that.. sorry.

radiant cliff
#

may also help to list the errors here

lime yew
#

Errors:

```
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/conversation/http.py", line 211, in websocket_hass_agent_debug
elif intent_result := await agent.async_recognize_intent(user_input):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/conversation/default_agent.py", line 318, in async_recognize_intent
result = await self.hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<7 lines>...
)
^
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/conversation/default_agent.py", line 626, in _recognize
for result in recognize_all(
~~~~~~~~~~~~~^
user_input.text,
^^^^^^^^^^^^^^^^
...<3 lines>...
allow_unmatched_entities=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
):
^

```

#

and
```

File "/usr/local/lib/python3.13/site-packages/hassil/recognize.py", line 269, in recognize_all
yield from _process_match_contexts(
...<5 lines>...
)
File "/usr/local/lib/python3.13/site-packages/hassil/recognize.py", line 299, in _process_match_contexts
for maybe_match_context in match_contexts:
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/hassil/string_matcher.py", line 443, in match_expression
for item_context in match_expression(
~~~~~~~~~~~~~~~~^
settings, group_context, item
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/hassil/string_matcher.py", line 458, in match_expression
raise MissingListError(f"Missing slot list {{{list_ref.list_name}}}")
hassil.errors.MissingListError: Missing slot list {entity}

```

radiant cliff
#

hm not sure if type is needed, or at least I haven't used that one. Here's an example where I use remote entities:

language: "en"
intents:
  LaunchAppOnAndroidTv:
    data:
      - sentences:
          - "(launch|open) {app}"
        requires_context:
          area:
            slot: true
      - sentences:
          - "(launch|open) {app} on <name>"
        requires_context:
          domain: "remote"
lists:
  app:
    values:
      - "moonlight"
      - "twitch"
      - "twitch streaming"
      - "plex"
      - "disney plus"
      - "netflix"
      - "crunchyroll"
      - "youtube"
      - "youtube tv"
      - "hulu"
      - "prime video"
      - "paramount plus"
#

if you use <name> and use requires_context, name will restrict that name slot to be an entity from the specified domain

#

so in your case, "fan"

#

then you can just use the name slot to get the name of the entity