How to activate a hubitat virtual switch within homebridge?

I've got homebridge running on a raspberri pi and I have the unifi protect plugin installed, along with the hubitat/maker api plugin. My first initial goal is to capture the "doorbell press" event from my unifi doorbell and get a sonos announcement. I can see the doorbell press in homebridge and I can activate the hubitat virtual switch via the homebridge dashboard and its status syncs across from hubitat. So I can easily setup a TTS event when the virtual switch is turned on. How to I tie the doorbell press event in homebridge to the virtual switch in homebridge? Do I have to setup homekit somewhere? I have little experience with Apple as I'm an android guy, so homebridge/homekit is new to me. I'm assuming Alexa could be used as a go between with a routine? I'd really like there to be a local method, and I feel like there is one that I just don't know about. Or maybe there's even a way to do it in homebridge and I just don't know what I don't know. Thanks!

If you don't have HomeKit setup on an Apple device you could use the homebridge-alexa plugin in HomeBridge and link the devices through Alexa.

You would still need to setup an account to link your Amazon Alexa to Homebridge. This can be done at:

This account will be used when you enable the skill in the Alexa App.

Thank you. I do suppose that would work, and might even be simpler, keeping it outside of habitat entirely. I have a Sonos One with Alexa built in that could easily make the announcement. It sure would be nice to trip that virtual switch in habitat though. Local execution and the ability to respond to that button press with basically anything, from any speaker. It looks like it could be achieved with Node-Red running on a pi...?

Well I guess you could trip the hubitat switch via alexa with this setup also, so the only downside would be the cloud component and potential execution delays.

I use Node-Red, but not for Alexa so someone else will have to advise.

I haven't ever used node-red, but it looks like there's a homebridge plugin so that a node-red flow could be written to "turn on switch A when this happens". Since homebridge knows of the hubitat virtual switch, it appears it could be done without Alexa in the mix.

That would be a better solution, then you could keep everything local.

Haven't seen a third-party or non-Apple way to do HomeKit Automations. That's essentially what you need to do. In HomeKit (you need an Apple device to set this up - Mac the can run MacOS Mojave or later, or an iOS device) you build a HomeKit Automation so when the device in HomeKit activates, it turns on the Hubitat virtual switch. If it's momentary only that you need, then you can just set the virtual switch in Hubitat to turn off after 1 second.

To build Automations, Apple requires one of the following - An always on iPad that can run the latest iOS, or an Apple TV 4 or later (this is what I use) or and Apple HomePod. One of these (whichever you choose) will act as a type of HomeKit hub, and it also allows remote access. There's one additional use, is that is there's a compatible Bluetooth device nearby, it can be controlled by the Apple "hub". I do this for my Yale door lock on the back door which has the HomeKit module (bluetooth) in it. Works perfectly.

HomeKit and its automations are local.


I tested this with a couple of virtual switches I created with a HomeBridge plugin and Hubitat along with the node-red-contrib-homebridge-automation pallet and it is possible to control them in Node-Red without HomeKit.

Screen Shot 2020-10-09 at 6.10.20 PM

Interesting. My understanding was the OP wanted to have the action of a HomeKit device control a virtual switch in Hubitat. Is that what you’ve done here and I’m just not understanding, or are you talking about the opposite, where you triggered something in HE and that controlled the HomeKit device?

It works both ways.


That’s pretty significant then. First time I’ve heard of anything that could do that outside of HomeKit. Very cool.


Thanks for testing! This works beautifully. So with this method, you can use any homebridge accessory event to control a habitat device. I am using it with the homebridge unifi protect plugin to get a doorbell announcement from my unifi doorbell. Doorbell button pressed -> homebridge event -> node-red->activate hubitat virtual switch->rule machine->sonos announcement. Its virtually instant since its all local. It takes a little bit of doing, but I was already running homebridge on a pi so it wasn't much really. If I had experience in Node-red it would've been a piece of cake, but it took me a bit to figure out how to send the proper payload to the hubitat switch. Thanks again.

Should we make a more general post about this? It seems like kind of a big deal that there's already a method in place to link hubitat and homebridge without requiring homekit and an apple device.

That’s not a bad idea. This functionality could definitely benefit those who have devices that can’t be directly integrated into Hubitat.

Isn't it much simpler and easier just to setup a virtual momentary switch in Hubitat, and send that switch over to HomeKit (via Homebridge) and then when they "turn it on" in the IPad (or Homepod/Siri), it goes back to Hubitat which triggers an automation?

If you reread the OP he doesn’t have HomeKit.

Buying an iPad and immersing yourself in a new platform that is severely limited when compared to android does not sound simpler and easier to me. :wink: This solution works in a very specific use case where the only currently available device integration is via homebridge and there's no access to homekit or any IOS device.

My apologies.
You're right, I didn't fully comprehend what he was asking.

1 Like

No worries, it’s all good. :blush: