Trigger HomeKit scenes from HA

Hi,

Is there a way to call a script (scene) which is on HomeKit, from Home Assistant.
If not, is there a way to store the current light states to a new HA scene?

1 Like

Hello!

Why not the other way? I mean run scripts on HomeKit that are written on Home Assistant.
You have two separated things: HomeKit and Home Assistant right? Or HA is making homebridge to your HomeKit?

I have HassIo, running with the Homekit component. I don’t use HomeBridge anymore since.
But I use Siri a lot, and that won’t work for calling HA scenes.
So the scenes I use with Siri are in Homekit.

But for some automations (like dimming lights while watching movies) I want the lights to come back to the default state (the scene in HomeKit)

Have you found a solution to this? There is an option in the Homekit component to include ‘scenes’ but it’s not working for me.

That’s the other way around; you’ll expose the HA-Scenes to HomeKit. :wink:

I don’t think you can expose scenes from Home Assistant to HomeKit, but you can create scripts in HA that run scenes. You can then expose those scripts to HomeKit (a workaround to expose HA scenes to HomeKit).

You can show HomeKit lights, switches etc. in HA with HomeKit controller support. Although it looks like it doesn’t support importing HomeKit scenes. Maybe there could be a workaround to include scenes, I’m not sure.

I tried to do this in the past but have ended up creating all scripts, scenes etc. in Home Assistant, then exposing all of those to HomeKit (see my previous post about a workaround to exposing HA scenes to HomeKit by running them via scripts).

For me this has been the best way of using Siri/HomeKit along with Home Assistant.

excellent. I will give it a try. But Im not sure where to start. How do I write a script that communicates with Homekit / the Homekit Controller? Still learning the ropes.

Here’s an example of a script that runs a scene in Home Assistant, and below it how it would be exposed to HomeKit:

script:
  bedtime_scene:
    alias: "Bedtime"
    sequence:
      - service: scene.turn_on
        entity_id: scene.bedtime


homekit:
  auto_start: true
  filter:
    include_entities:
      - script.bedtime_scene

You would put this in configuration.yaml, unless you've separated your .yaml files for scripts, scenes, etc. into separate ones.

This is exactly what I needed, thank you!

Well, now I’m stumped again. I have the following in my yaml file, but upon rebooting, I get an error on the overview screen that says : Invalid Config The following components and platforms could not be set up: script

The scene in Homekit I am trying to access is called “Editing” for when I edit on my computer. What am I doing wrong?

script:
Editing_scene:
alias: “Editing”
sequence:
- service: scene.turn_on
entity_id: scene.editing

homekit:
auto_start: true
filter:
include_entities:
- script.Editing_scene

  • PS, spacing seems to be correct in the yaml file but it is not showing up correctly here.

Try changing Editing_scene: to editing_scene: (all lowercase). The only place you can use Title Case/UPPERCASE in .yaml is in the names and aliases of your entities (in your case alias: Editing should be fine).

Also, it looks like you have smart quotes around Editing for the alias, try to use regular straight single or double quotes ( ’ or " ), or don’t use them at all for names.


Once you’ve pasted your code here on the forum select it and click the button </> to keep the formatting (see the top of this or any post post about formatting)

Hi there, basically it worked for me too. However, homekit interprets the scenes as a switch for me. Is that the same with you?

Yes, they appear in the Home app as switches for me too.

This is an old thread, but I thought I might add my experience to the mix. I went through the same struggle as others, trying to figure out how best to handle scenes with a mix of HomeKit and HA devices. What worked best for me was creating a script (rather than a scene) in HA, and then exposing it to HomeKit. As others have mentioned, it is interpreted as a switch. I then added that “switch” to an actual HomeKit scene. Sometimes by itself, and sometimes with other HomeKit devices. Now I can say “Hey Siri, Movie Night” and it will turn on the “switch” as part of the Movie Night HomeKit scene, which will then run the HA script.

3 Likes

I am not sure when this was added, but I was able to add a Home Assistant scene entity to my configuration.yaml file and call the Scene on Siri.

Example entry:

homekit:
  filter:
    include_entities:
      - scene.movie_time # Movie time
2 Likes

Old post but i can’t to use the scenes from HA to scenes in HomeKit, only as switch… this is annoying there is any solution for this?
Thanks

@loop2 did you ever find a solution to this? At the moment my scenes are exposed as switches too.

There is no solution. That is how they are exposed. Create a new HomeKit scene that turns on that switch.

1 Like

I found a workaround: create an extra helper switch in Home Assistant, expose that to Homekit.
Setup an automation in Homekit that whenever the HA switch gets toggled, a scene gets triggered.

Its a workaround but Homekit seems to pick up these changes quite quickly.