So, my question is how to define a custom intent to press a button since the built-in intents (HassTurnOn …) does not include HassPress ?
I’m not sure you can, because a button press is an event, not a switch. Your voice command would have to address whatever the button does.
1 Like
A few moments later
After doing some homework, I have learnt some basic about intent_script from the reddit fellows. You can create a custom intent e.g. “HassPressButton” in configuration.yaml like:
intent_script:
HassPressButton:
speech:
text: "Sure—pressing {{ domain[0] }} of {{ name }} now."
slots:
domain:
type: domain
domain:
- input_button
- button
name:
type: text
action:
- service: "{{ domain[0] }}.press"
# this assume the target entity id follow convention of the name
target:
entity_id: "{{ domain[0] }}.{{ name | lower | replace(' ', '_') | replace('-', '_') }}"
This works as an add-on (or maybe I should pull a request there?) for firing button event for Assist developed by our fellow: GitHub - michelle-avery/openai-compatible-conversation: A copy of Home Assistant's built-in OpenAI Conversation Agent, with support for changing the base url.
good night
