Hey there, I just recently installed HA onto my NAS to create a complex light automation that just wasn’t possible in HomeKit. I’ve created the automation itself no problem, but now I want to create a „button“ or „switch“ that starts and ends the automation (it could be set up as a script as well). I want this button to be exposed to HomeKit, but I can’t seem to figure out a way to make a „virtual“ button that starts my automation. I’m not familiar with YAML and have used only the HA GUI so far. Glad if anyone can help
I am not a Homekit user, so there may be some other method specific to that integration, but the basic answer is to use one of the following:
Input Boolean/Toggle/“Virtual Switch”
Both can be created in Settings > Devices and Services > Helpers
Usually this question is answered simply by create a button on Lovelace and set its click action to run service and run your automation or script… But you said
I want to trigger this in home kit.
make a toggle helper (input_boolean)… make it a trigger for your automation and in the automation, turn it off when the automation completes. The input boolean (basically a virtual switch) then gets exposed to whatever…
Then you can ask Siri to do your thing…
Yes, that makes sense in theory, which is what I want to do. I can’t figure out how to make the input Boolean the trigger for my automation. What do I select in the list?
An automation run manually is a script. Rather reverse things: Make a script that both your automation and button can use. Semantically it’s a lot better.
show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: automation.trigger
data:
skip_condition: true
target:
entity_id: automation.daily_weather_forecst_at_07_45
icon: mdi:weather-cloudy-alert
hold_action:
action: none
name: Weather Forecast
show_state: false
icon_height: 33px
entity: automation.automation_42
No problem I have also created a script that does the same thing. How do I select the button as the trigger though?
Im not familiar with yaml. Where should I enter these commands?
Navigate via settings to your integration page and select the tab “Helpers”
Add a helper with the blue button
Select switch
And then make a automation with the boolean switch
This is not made in yaml, but since it is the only way to exchange automations/lovelace configurations I just exported it, so you can import it (don’t see any other way…)
Every automation/page/scene has the option ’ edit in yaml’ or ’ show code’ …
I normally don’t put screen shot…but here you go:
(noted the top line ’ Show Code Editior’ ??
![:thinking: :thinking:](https://community.home-assistant.io/images/emoji/twitter/thinking.png?v=10)
You can just call the script directly with the button and in your automation you’ll call the same script under your actions.
Finally! Thank you all for your help I figured out what my error was. I wasn’t able to select the On/Off state in the mobile view, but on desktop it worked like a charm! I thought those attributes weren’t able to be selected that way at first. Works very well now with one script and two automations