Thanks i read the documentation, now is better but i still have problems.
this is my custom intent i used
language: "it"
intents:
ImpostaSveglia:
data:
- sentences:
- "Imposta una sveglia alle {ore} e {minuti}"
- "Metti una sveglia per le {ore}:{minuti}"
- "Programma una sveglia alle {ore} e {minuti}"
- "Metti la sveglia per le {ore} e {minuti}"
- "Svegliami alle {ore}:{minuti}"
- "Svegliami alle {ore} e {minuti}"
lists:
ore:
range:
type: "number"
from: 0
to: 23
minuti:
range:
type: "number"
from: 0
to: 59
this is my intent_script
intent_script:
ImpostaSveglia:
action:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.sveglia
data:
time: >
{% set ore = (intent.get("ore", 7) | int) %}
{% set minuti = (intent.get("minuti", 0) | int) %}
{{ '{:02d}:{:02d}'.format(ore, minuti) }}
- service: automation.turn_on
target:
entity_id: automation.sveglia_con_input_datetime
speech:
text: >
Sveglia impostata per le {{ intent.get("ore", 7) }}:{{ '{:02d}'.format(intent.get("minuti", 0) | int) }}.
and i have this error in log when i try to give the command to assist
Registratore: homeassistant.components.conversation.default_agent
Fonte: components/conversation/default_agent.py:456
Integrazione: Conversazione (documentazione, problemi)
Prima occorrenza: 06:20:59 (6 occorrenze)
Ultimo accesso: 07:14:16
Unexpected intent error
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 643, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2756, in _render_with_context
return template.render(**kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 1295, in render
self.environment.handle_exception()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 942, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
TypeError: argument of type 'Context' is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 416, in async_prepare_call_from_config
render = template.render_complex(config[conf], variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 260, in render_complex
render_complex(key, variables, limited, parse_result): render_complex(
~~~~~~~~~~~~~~^
item, variables, limited, parse_result
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 266, in render_complex
return value.async_render(variables, limited=limited, parse_result=parse_result)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 645, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: argument of type 'Context' is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/intent.py", line 145, in async_handle
result = await handler.async_handle(intent)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/intent_script/__init__.py", line 243, in async_handle
action_res = await action.async_run(slots, intent_obj.context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1808, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 528, in _async_step
self._handle_exception(
~~~~~~~~~~~~~~~~~~~~~~^
ex, continue_on_error, self._log_exceptions or log_exceptions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 558, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 735, in _async_call_service_step
params = service.async_prepare_call_from_config(
self._hass, self._action, self._variables
)
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 423, in async_prepare_call_from_config
raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: TypeError: argument of type 'Context' is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/conversation/default_agent.py", line 456, in _async_process_intent_result
intent_response = await intent.async_handle(
^^^^^^^^^^^^^^^^^^^^^^^^^^
...<10 lines>...
)
^
File "/usr/src/homeassistant/homeassistant/helpers/intent.py", line 153, in async_handle
raise IntentUnexpectedError(f"Error handling {intent_type}") from err
homeassistant.helpers.intent.IntentUnexpectedError: Error handling ImpostaSveglia
the problem is that i cannot let the sistem use the variables Hour and minutes and give to intent script