Trigger HomeKit scenes from HA

homekit
Tags: #<Tag:0x00007f47faeb6fb0>

#1

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?


#2

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?


#3

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)


#4

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.


#5

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


#6

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).


#7

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.


#8

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.


#9

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.

#10

This is exactly what I needed, thank you!


#11

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.

#12

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)