Using Actions to control your Macbook via BetterTouchTool

This guide is for people with HA and macbooks with BetterTouchTool installed.
You can use your iphone or Apple Watch to control your MacBook in any other way want. Mine’s set up for basic media controls including PlayPause, Volume up/down, and having Spotify start playing either of my 2 most used playlists.

In BTT:
Settings > Web Server > Enable BetterTouchTool Web Server.
Choose which port you want to use. This is the BTT documention for using the web server
Create a named trigger and assign an action.
eg. name: MacPlayPause with Assigned Action: PlayPause.
BTT has a lot of options for actions, including Apple Script, Shell Script and Javascript, so you can do whatever you want.

In HA configuration.yaml:

shell_command:
  macbook_playpause: 'curl http://192.168.1.##:PORT/trigger_named/?trigger_name=MacPlayPause'

Just make sure the trigger_name matches exactly with your named trigger.

In automations:

- alias: action_ios_macbook_playpause
  trigger:
    - platform: event
      event_type: ios.action_fired
      event_data:
        actionName: 'Mac PlayPause'
  action:
    - service: shell_command.macbook_playpause

Finally, in the ios Companion app > App configuration > Integrations > Actions
Create a new action with the name identical to your automation actionName. Set the text, icon & colours. Save it, exit, and you’re done.

5 Likes

I use BTT, but never thought about using it through HASS. I mostly used unified remote with Tasker (though I just saw there’s the Unified Remote integration, so perhaps Tasker is ready to be cut from some of it?).

In any case, with those two, it seems like a lot of control of stuff on PCs (MacOS, Windows, Linux) is possible from HASS.

So really neat, thanks for sharing!

Yep, the unified remote integration works well, but has a limitation of controlling just an unique computer. I’m working to improve this.

Hi thanks for this
Got it working
Sending apple scripts
To airfoil
To connect and disconnect my airplay speakers
And now have them motion controlled vir home assistant; to follow have music from Spotify follow me round the house

This is awesome. BTT + the new built in ‘Shortcuts’ App in Monterey make this really powerful.
I was wondering if there was a way to do this without BTT via the Mac Home Assistant Companion app, which delivers notifications and reports sensors. Potentially more secure/extensible.