Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

alexqndr

macrumors regular
Original poster
Mar 18, 2018
211
179
London
I am struggling to create an automation within HomeKit and I'd like to know if I maybe have to get into HomeBridge or HomeAssistant.

The automation is relatively simple: i'd like my mac to run a bash or apple script when the scene Good Night activates, or when two different accessories turn off.

Is there a way to achieve this within HomeKit? Scripting and SSH seem disabled in HomeKit automations. Maybe through Homebridge? I've tried through the Eve app and Home+ but can't see anything helpful at the moment.
 

waw74

macrumors 601
May 27, 2008
4,699
966
I'm thinking homebridge + homebridge-ssh is the answer here.

just make a device that sends the ssh command when you turn it on, and then include the device in your good night scene.


it also looks like that if you go into the shortcuts app, make a new home automation, and then turn that into a shortcut, you can run an SSH script but... you can only trigger those based on a device changing state. So you might still need homebridge-dummy to create a dummy switch that you could use to trigger the automation. Or if you have a device that is only controlled at bedtime, you could use that.
You could also write a shortcut that triggers when LampA turns off, and then checks if LampB is also off before executing the SSH command. depending on how you control things, you might need a second automation that triggers when LampB turns off, and checks LampA.
 

alexqndr

macrumors regular
Original poster
Mar 18, 2018
211
179
London
I'm thinking homebridge + homebridge-ssh is the answer here.

just make a device that sends the ssh command when you turn it on, and then include the device in your good night scene.


it also looks like that if you go into the shortcuts app, make a new home automation, and then turn that into a shortcut, you can run an SSH script but... you can only trigger those based on a device changing state. So you might still need homebridge-dummy to create a dummy switch that you could use to trigger the automation. Or if you have a device that is only controlled at bedtime, you could use that.
You could also write a shortcut that triggers when LampA turns off, and then checks if LampB is also off before executing the SSH command. depending on how you control things, you might need a second automation that triggers when LampB turns off, and checks LampA.

Thanks. Is HomeBridge good with scripting and automation? Or should I consider HomeAssistant too? Before diving in such a demanding package I want to be sure that it will give me enough flexibility. I am already leaning toward HomeBridge as I am an HomeKit aficionado and appreciate the advertised ease of use of HomeBridge. But I am happy to consider the alternatives.
 

waw74

macrumors 601
May 27, 2008
4,699
966
homebridge is a translator, nothing more
it translates non-homekit things into homekit's "language", Allowing non-homekit things to "speak HomeKit" and be added to the home app. any scripting or automation is done in the home app, shortcuts, or 3rd party apps like eve.

*there are a few slightly hack-y (I don't necessarily mean that in a bad context) homebridge plugins that will do things like add timers, but it basically adds 2 devices to the home app, a switch that when turned on will start a timer for a pre-set length, and when that timer runs out, it "flashes" a motion sensor. but you then have to configure what to do when that motion sensor triggers in the home app. Or homebridge-alexa which well let you add any devices in homebridge to your Alexa home, devices in your HomeKit home that don't go through homebrige won't be exposed by that plugin. Or another similar that lets you control homebridge devices using a web browser.

homeassitant is home automation software, so it has scripting and such. They have also coded homebridge's function into it. So you can add homeassitant devices to the home app.
Ideally you'd add native HomeKit stuff directly into home assistant, so you could perform more advanced scripting with all of your devices. You would leave all your native devices added directly to HomeKit, and not use HA's translator. Those devices would then take commands from both HA and the home app.

I've also seen node-RED mentioned as an alternative for more advanced scripting, but I'm not that familiar.


I use a program called homeseer, I do have to use homebridge and a plugin to get the devices I want into HomeKit.
I've been using it for about 20 years, Might not be the choice I would make with the other options today, it still works great, just a little pricy.

I've got z-wave light switches, LED tape controllers, motorized shades, door sensors, and temp/humid/motion sensors. All of those go into homeseer and then through homebridge into home
I"ve also got Hue bulbs, which are into HomeKit natively, and into home seer through a plugin. Any change from one form of control shows up in the other. (I ask Siri to turn the light on, I can see it turn on in homeseer)

I've also got a couple dummy devices in homeseer, like a switch that says if I'm home or not, and a home "alarm". the alarm doesn't alert anything, it's more of a switch to set the state of my house.

how things are controlled/automated depends on what makes sense, or the capabilities of the controller

scenes are pretty much all done in home

--the home/away switch is triggered by basic location based automations in the home app

-- I have a light behind the TV, and use home app to turn that on, since I can't see the state of my TV in Homeseer

the rest of my automations are done in homeseer, since it's interface is much easier to deal with, and I can get more complex if I need to.

--I have an automation setup in homeseer that will turn on a couple lights for the cat if I'm away and it's after sunset. (not really possible in HomeKit, since HomeKit needs a trigger, and not just the state of devices)


so basically I use homekit/Siri for basic control of lights and scenes, any automations or things that require a bit of logic happen in homeseer. having all devices available in both makes that possible.
 

alexqndr

macrumors regular
Original poster
Mar 18, 2018
211
179
London
@waw74 Thanks for the extensive response, you provided me with some valuable information. However after digging a bit into the options you have listed, I am questioning which platform to pick up.

The following is the general picture I've gathered by doing some research. Please correct me if I am wrong. I have highlighted the information I haven't researched yet. Keep in mind that my evaluations are subjective.
  • HomeBridge
    • Pros:
      • relative ease of use
      • preserves base network and HomeKit integrity
      • being less complex and extensible than HA or Node-Red, it brings less vulnerabilities and reduced attack surface from the outside
    • Cons:
      • does not release one from all the limitations of HomeKit and Shortcuts.app automations
      • cannot act as an HomeKit hub in place of an iPad or an HomePod?
      • if HomeBridge disconnects or it's permanently damaged, I'd loose my entire HomeKit set-up?
  • HomeAssistant
    • Pros:
      • can act as a HomeKit hub in place of a iPad or an Homepod?
      • can act as as an Aqara or Hue hub?
      • preserves base network and HomeKit integrity
      • easily extensible with tons of plugins non-HomeKit accessories
    • Cons:
      • steep learning curve
      • code 'based' scripting
      • large attack surface due to it's codebase complexity
      • substantial risk of failure and unreliability due to codebase complexity
      • If the HA disconnects or it's permanently damaged, I'd loose my entire HomeKit set-up?
  • Node-Red
    • Pros:
      • slick scripting GUI, similar to Keyboard Maestro and Alfred Workflows, which I really like
      • can run on top of HomeAssistant as a plugin?
      • if Node-Red disconnects or it's permanently damaged, I'd loose my entire HomeKit set-up?
    • Cons:
      • niche software targeted to hyper tech savvy people. As a fringe platform, support in the long term can be at question and its community might not be as lively and helpful as the alternatives.
      • cannot act as an HomeKit hub in place of an iPad or an HomePod?
      • cannot act as as an Aqara or Hue hub?
I assume it's helpful to list my potential use cases. Below are some automations that I'd like to implement in the future. Are these achievable in HomeBridge with Dummy Switches?
  • use Vivaldi browser Philips Hue integrations with LIFX lights. In other words, hack the LIFX lights to appear as Hue lights to specific applications on MacOS or others
  • trigger HomeKit automations at the end of a specific Calendar.app event or when a notification on MacOS/iOS it's triggered
  • trigger HomeKit automations based on Focus (MacOS/iOS) state
  • deploy Aqara Zigbee devices without their original hub (I am aware I'd have to purchase and install a USB Zigbee stick to try this)
  • run Apple Scripts or Terminal commands in MacOS at scene changes or device state mutations
  • run HomeKit scenes when MacOS environment changes. I partially do this already with KeyBoard maestro and Shortcuts.app integrations, but it's quite clunky and it requires to create redundant automations in both apps. I assume I could simply send a script to HA, HB or Node-Red to trigger the above, instead of recurring to workarounds.
  • trigger a scene with pressure/vibration sensors
  • remote into the HUB web portal from an external connection
  • have Siri announce a message and/or change the lights when I receive an email from a specific sender
  • and more...
Having said that, I feel like it would be best to approach the advanced automation blackhole gradually. So I wouldn't mind if the platform I choose has some limitations, but it allows me to get up and going quicker than the alternatives. I am afraid of jumping on something complex, and bail out because of learning fatigue or by compromising my Smart Home Ecosystem.

Right now I feel like HomeAssistant might be my best option, as — with the information I have — it seems it would allow me to start minimal by adding a HomeKit bridge and learn more complex automations at my own pace. On the other hand I really like the way Node-Red is designed, as it allows to craft automations with a flow based GUI. Despite that, I am concerned it might turn out to be the most complex platform, and scare me off with an aggressively steep learning curve.

TL;DR
In conclusion, if HomeAssistant is able to act as a HomeKit hub and run Node-Red as an add-on, I'd be far less hesitant. If not, I could run HA along Node-Red with Docker on a same RaspBerry 4 B.

My Pi has only 2GB of RAM, which I am not sure if it would slow down the system. And above all, I would do this only if the chances of conflict, errors and delays by running two platforms would be minimal. If the risk of this hub Frankenstein panicking is elevated, I'd probably just go with Node-Red.

Lastly, HomeBridge would be the safest options if it can run most of my automation wish-list with dummy switches.

Hope my indecisiveness is not obnoxious. I prefer to ponder on this carefully before committing, so I can do it with peace of mind. Many thanks for donating your expertise.
 

waw74

macrumors 601
May 27, 2008
4,699
966
nothing can act as a homehub except a HPod or aTV (or iPad).
And just to clarify, since the word "hub" is used a lot... A home hub is used to access your devices when you're outside your home network, and to handle any automations that happen when you're not home. a Home will work without them, but automations can be spotty.

if homebridge (or home assistant) stop working, only the devices from that instance of homebridge will go "no response". It might cause some slowdown, and some annoying notifications from Siri when you're giving commands, but when homebridge re-starts they should start working again. BUT... if homebridge starts, and for some reason your config is messed up causing some devices to go missing out of homebridge, It's very probable that those devices, and all their settings, will be removed from your home. But no matter what happens with homebrige, your native devices will be fine, as will devices from other bridges. It's also possible now to run each plugin as a child bridge, meaning any problems will be contained to to that one plugin, and the rest should continue to work fine.
Having just had a Node update issue borking Homebridge and one of my plugins, I can confirm my (native) Hue lights continued to work just fine.


you can already trigger automations in the shortcut app based on focus changes. and add HomeKit scenes or device to that automation.
there are also triggers for mail received with filters for sender and subject.
but with iOS 15, shortcuts has added a lot of notifications and confirmations for things that are automatically triggered, so YMMV

for pressure/vibration sensors, check out the eve app, It's just a second front end for HomeKit, it has some more advanced options for triggering events, plus you can add conditions to automations. These will all still run from your home hub like the ones created in the home app.

for remoting in, most things will have a web interface, you can either (less secure) open a port on your router to access them remotely, or (more secure) setup a VPN sever on your home network, and connect to that, then access the webpages through the VPN. For either of these, you'll probably want to use a dynamic DNS service, so you can point your browser or VPN client to alexqndrs-house.dnsservice.com, no-ip.com is a decent choice for this.

the 2GB of ram should be fine, homebridge doesn't use much resources, unless it's running cameras.
 

alexqndr

macrumors regular
Original poster
Mar 18, 2018
211
179
London
nothing can act as a homehub except a HPod or aTV (or iPad).
And just to clarify, since the word "hub" is used a lot... A home hub is used to access your devices when you're outside your home network, and to handle any automations that happen when you're not home. a Home will work without them, but automations can be spotty.

if homebridge (or home assistant) stop working, only the devices from that instance of homebridge will go "no response". It might cause some slowdown, and some annoying notifications from Siri when you're giving commands, but when homebridge re-starts they should start working again. BUT... if homebridge starts, and for some reason your config is messed up causing some devices to go missing out of homebridge, It's very probable that those devices, and all their settings, will be removed from your home. But no matter what happens with homebrige, your native devices will be fine, as will devices from other bridges. It's also possible now to run each plugin as a child bridge, meaning any problems will be contained to to that one plugin, and the rest should continue to work fine.
Having just had a Node update issue borking Homebridge and one of my plugins, I can confirm my (native) Hue lights continued to work just fine.


you can already trigger automations in the shortcut app based on focus changes. and add HomeKit scenes or device to that automation.
there are also triggers for mail received with filters for sender and subject.
but with iOS 15, shortcuts has added a lot of notifications and confirmations for things that are automatically triggered, so YMMV

for pressure/vibration sensors, check out the eve app, It's just a second front end for HomeKit, it has some more advanced options for triggering events, plus you can add conditions to automations. These will all still run from your home hub like the ones created in the home app.

for remoting in, most things will have a web interface, you can either (less secure) open a port on your router to access them remotely, or (more secure) setup a VPN sever on your home network, and connect to that, then access the webpages through the VPN. For either of these, you'll probably want to use a dynamic DNS service, so you can point your browser or VPN client to alexqndrs-house.dnsservice.com, no-ip.com is a decent choice for this.

the 2GB of ram should be fine, homebridge doesn't use much resources, unless it's running cameras.

Thanks for this, after doing some more research I am confident to commit to HomeAssistant. The fact that Node-Red can be used as a simple add-on nudged me on. I will start with a HomeKit bridge plugin and take it from there. Next steps will be integrating MacOS with my scenes and creating more advanced automations with Node-Red add-on.

I appreciate that you can do most of what I've listed with HomeKit + other apps, but I find it very annoying to have to jump through a million different apps to get my automations running. Additionally, I feel like scripting is being heavily choked by Apple, and that's the main thing I am interested about. HomeAssistant will be a bit more complex at the beginning, but I feel it will save me some headaches down the line. Hopefully the extra effort will enable me to take full control of the automations, and tinker some cool stuff out of it.
 
Last edited:

chown33

Moderator
Staff member
Aug 9, 2009
10,800
8,533
A sea of green
For all the cases where you asked:
If the SOFTWARE disconnects or it's permanently damaged, I'd lose my entire HomeKit set-up?

Whatever you're running, and wherever its running (Pi, etc.), you should have a reliable backup strategy in place. You should probably even practice recovering from one of the backups occasionally.

A good backup will let you recover from updates that don't work, as well as from hardware failures, software misconfigurations, etc. The key in many cases is to make a backup before doing some risky action.

If it were me, I'd make the backup, restore it to new media (like a new SD card for the Pi), then do the update or reconfig on the newly made replica. That way you'll confirm that the backup worked, that the recovery process works, and the original unadulterated media is safe because it isn't even being used.
 

alexqndr

macrumors regular
Original poster
Mar 18, 2018
211
179
London
For all the cases where you asked:


Whatever you're running, and wherever its running (Pi, etc.), you should have a reliable backup strategy in place. You should probably even practice recovering from one of the backups occasionally.

A good backup will let you recover from updates that don't work, as well as from hardware failures, software misconfigurations, etc. The key in many cases is to make a backup before doing some risky action.

If it were me, I'd make the backup, restore it to new media (like a new SD card for the Pi), then do the update or reconfig on the newly made replica. That way you'll confirm that the backup worked, that the recovery process works, and the original unadulterated media is safe because it isn't even being used.

That sounds like a very good strategy. Is is possible to keep an automated backup of a Pi, HA or HB? Rsync to Dropbox/iCloud maybe?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.