Unusual automation using my Mac Keyboard

I was also thinking about this some more, and came up with a less elegant method which doesn’t require SSH.

  1. Turn on your Mac’s internal web server (loads of instructions on Google, I use MAMP for work so I used that).

  2. I use the same shell script to launch a Mac app (or an applescript to press ‘enter’ in OP’s case). This script is named ‘launchapp.sh’

#!/bin/sh
export DYLD_LIBRARY_PATH=""

osascript -e 'tell application "NewBlockParty" to activate'

Save it somewhere, I just put in a folder named mac-scripts in MAMP’s htdocs folder.

  1. Put a tiny PHP script named launchapp.php in the MAMP htdocs folder:
<?php
$start_app = exec('/Applications/MAMP/htdocs/mac-scripts/launchapp.sh');

You may need to give this script permissions (chmod 755).

  1. Now you can use a command line switch in HA to launch your script:
- platform: command_line
  switches:
    new_block_party_playlist:
      friendly_name: New Block Party
      command_on: "curl -sS http://192.168.0.3:8888/mac-scripts/launchapp.php"
1 Like