First of all, I am new to HA, so please be indulgent on any mistakes I could make in terms of vocabulary.
My initial need was to run actions from HomeKit scenes. For exemple, when I said “Hey Siri, good nights” to turn off all lights and do other things.
I first created a scene in HA, but the UI to manage and edit scenes is frustrating : the scene is run each time you click on it to edit…
So I created a script to do all actions I needed to do. And then, I created a HomeKit bridge exposing my scripts in HomeKit as a switch.
The problem : it doesn’t work at all.
I can see my switch in AppleHome. When I turn it on, nothing is done, and then it come back to off (as expected I think).
The scripts associated is never ran in HA…
What I am missing ?
I could not find anything on that matter online.
I’ve experienced the same thing with scripts exposed to HK. I got around it by creating an input_boolean helper and exposing that to HK. So, HK just flips the toggle and then an automation in HA watches for that and runs all my good night actions.
So you have 1 helper that activate 1 automation, and in your automation you have the actions ?
Does the helper goes back to off automatically right after activation ?
Correct me if I’m wrong : the advantage of script vs doing it in automation is that I can reuse my script elsewhere ?
Yup. I have a helper called “Good Night Switch”. I have a lot of automations that trigger off of that for various things.
My main “good night” automation triggers off that helper and then calls a script to shut down the house. Then I have a TOD sensor that flips on at 5:30 am and flips the good night switch off again. I could flip it off as soon as my automation runs (operate like a momentary button), but I use the good night switch as a condition to change lights and such in the middle of the night.
I have scripts exposed through HomeKit Bridge and they have been working fine for a year or so. Is there any information in the script’s Traces? Or any info in the Logs?
In my case, both were clean. I could see the scripts getting executed most of the time, but HK would show strange statuses (On when the script completed 5+ minutes ago) and other strange behavior. It was only constrained to scripts though. Other domains acted fine.
I can’t say I’ve paid much attention to the script entity’s status in HomeKit. Like OP, I have a HomeKit scene which triggers the script. I hit the scene and it works flawlessly. I just checked now and the script entity turned on briefly (executed) then turned off. All expected.
Quite weird that your issues were just happening with scripts, but not other entities.
For OP, just to double check: your HomeKit scene is set to turn your script on (not off)? I know I have setup scenes and added devices, but forgotten to set their state before.
Yeah. I thought about opening a bug ticket for it. At the time, I was kinda meh on using HK for anything, so I didn’t really care, I just found a workaround. Maybe I’ll test it again and see what happens.