I currently use the excellent SecuritySpy on a spare MacMini for my home CCTV system. I have tried ZoneMinder but just find it a pain and unreliable. SS is very reliable and have used for it a year so. My HA is running on a Pi.
Although SS doesn’t have any plugins for HA (it does for Indigo) it does some basic scripting functionality using AppleScript. For example you can tell the app to turn on motion recording by using the script:
Tell Application "SecuritySpy"
set motion camera number 0
end tell
This has to be done locally on the SS MacMini. This would be great to do when when I leave home rather than relying on the inbuilt static schedules in SS. I don’t know much about OSX, does anyone have an idea how I can do this?
I send commands to my Macs from Home Assistant, Google Assistant, Alexa etc. for a few things, and the app I use is Keyboard Maestro.
In Keyboard Maestro I create a macro (which you can build workflows in a similar way to Automator, or just run scripts).
In Keyboard Maestro it will give a script (AppleScript, Shell Script, whatever you like) to run that macro from another source (in my case Home Assistant running on a RPi3).
In Home Assistant here’s an example of the code to run a script on my Mac mini (Reboot) and on my iMac (Backup Home Assistant)
Very interested in this but having trouble getting it working. Are you using the public web trigger shared trigger? When I’ve tried pasting the link it gives me, nothing seems to happen. Do you have to open up ports to let KM communicate outside your network? Thanks.
In Keyboard Maestro’s preferences I went to Web Server and filled in some login details (note, it says if you use HTTPS you change the port number and +1).
For the macro trigger it doesn’t matter what you select, as you select script below. Then copy the code for the macro (32 digit code) and paste that into your yaml code in Home Assistant
setup a bash script and call it via a shell command. look here for apple script and bash scripting examples:
#!/bin/bash
osascript <<EOD
tell application "Google Chrome"
activate
end tell
tell application "System Events"
key down {command}
key down {shift}
keystroke "f"
key up {shift}
key up {command}
end tell
EOD
echo "Google Chrome is now open in Kiosk Mode"
@jono I’m trying to do this but can’t get it to work. Where do I put the code? All in the “configuration.yaml” or do you also use “script.yaml”? Also, how do you set up a shell_command in hass.io (witch I use)?
As well as the shell command you need a script to call/run the shell command from the frontend of Home Assistant, Alexa, Home Assistant etc.
I have separate yaml files for scripts. shell commands etc. but if you just have a separate scripts.yaml then put the script part in there, and the shell command part in configuration.yaml.
So it should be something like this:
So I have been playing with this to get HA to redirect my cameras’ PTZ at sunrise and sunset. So far I have only began familiarizing myself with Keyboard Maestro (thanks for the hint - its a powerful app!). Anyhow, I am at the point where I am trying to integrate this into my HA config.yaml, but I am not clear on a couple of things;
1: What Username:Password configuration should I be putting in the curl script; my macbooks credentials or those for the Keyboard Maestro trigger site?
In Keyboard Maestro > Preferences > Web Server this is the username and password that you need to use (if you haven’t added anything then add something there).
2. For the trigger you select Remote Trigger and by default it's set to 'this Mac only', meaning it will only run on that Mac. If you want it to run on multiple Macs when you run the trigger then change it to shared.
Click on the Copy button next to the trigger URL and that will copy what you need to use in Home Assistant.
Here’s an example of what you’d need to trigger it at sunrise or sunset
So Jono, I wanted to let you know. It all works fine now. The exterior link via the trigger server was doing nothing, so I went back to the localhost option - works fine now.
As an alternative to Keyboard Maestro, I found the adnanh/webhook tool. It is a small web server you can run on your Mac that will listen for http requests and run predefined shell commands (so could be anything, including AppleScript).
If you’re a nerd like me and enjoy using foss, check it out. If you’re more comfortable with using a nice user interface, I’d recommend you stick with Keyboard Maestro