How to sync virtual /Hubitat) with real switch in Homekit

Hi,
I'm trying to run all my automations in Hubitat.
Since I cannot manage in hubitat my Bticino/Legrand switches but I can manage this system in Apple Homekit I decided to integrate the two systems via Homekit Integration.
I can now see al my lights and switches in Homekit but not in Hubitat due to the way homekit integration works.
So I created in Hunitat a virtual switch for every light or group in Homekit.
Now I see virtual switches in Apple Homekit.
I created some automations in homekit to turn on a real light when it's corresponding virtual switch is activated in Hubitat.
everything is ok.
But now I want an automation that turns on a virtual switch if a real light is turned on in Homekit.
So I created in homekit another automation that turns on a virtual switch is the real light is turned on.
Now I have a problem...
Sometimes state is correctly updated in boht systems and sometimes if I turn on a virtual switch in Hubitar the corresponding switch in homekit is not updated...
I think it's a sync problem because I have 4 automations for every switch.

  1. if real switch is on -> turn on virtual switch
  2. if real switch is off -> turn off virtual switch
  3. if virtual switch is on -> turn on real switch
  4. if virtual switch is off -> turn off real switch

As you can see if there is any sync latency on switch update you may have fake results...
Any idea in how to bypass this problem...?
Any other solution?
I'm sure there is a better way
Please Help :slight_smile:
Luca

I made some more testing and the problem is clearly in Hubitat.
The virtual switch state and the real one always update correctly according to homekit automations.
The problem is that Hubitat does not send always to homekit the virtual switch status.
Sometimes I switch off the virtual switch but in homekit is still on.
STRANGE BEHAVIOUR: To turn on a virtual switch: if I switch on, off and then on again it always update the statur correctly.
The same if I switch off, on and again off to tunr it off.
Maybe this can help hubitat programmers to understand the problem...

Can you let us know a bit more about your Homekit setup? What are you using as your Homekit hub (AppleTV, iPad, Mac....)? Also, if AppleTV or Mac, is it connected via wifi or ethernet?

Apple TV last model with network cable.

1 Like

Do you have any real lights in Hubitat that you can expose to HomeKit? If there is an issue on the Hubitat side (or Homekit), you should see the same problem. However, if that works correctly (status between Homekit and HE is in sync and you can control the device from either Hubitat or Apple Home), then there is something else going on.

He's got a redundant topic here:

which has some extra details of his 4 Apple Automations trying to get a real Apple HomeKit only appliance to sync.

2 Likes