MQTT or web hooks
  • Please implement MQTT or web hooks into your software, for motion events, arming or disarming cameras or starting or stopping recording. I implemented both into an app over the last weekend. It’s trivial. And would make your software so much more powerful.
  • Thanks for the suggestion, it's a good idea and has been requested a few times by other users, so we'll definitely look into adding one or the other of these functions in a future update.

    To clarify, with your webhook suggestion, do you mean that SecuritySpy should implement a new Action (i.e. to be triggered by motion detection) to make an HTTP request (GET or POST) to a custom URL?
  • MQTT would be awesome feature, would make integration easier for sure e.g. home assistant, node-red.
  • Thirded!
  • +1 Would also like the ability to send a command for triggering actions , such as turning off notifications temporarily via homebridge, etc.
  • In the latest version of SecuritySpy it's easy to issue an HTTP request (GET, POST etc.) as an action, using the "run shell script" action (see Preferences -> Cameras -> Actions.

    Likewise, it's possible to send an HTTP request to SecuritySpy to do various things such as set a schedule or a temporary override (e.g. to disarm Action mode and stop notifications) - this is described in our Web Server Specifications document.

    MQTT support specifically may come in the future, but it's not clear at the moment whether this would benefit enough users for the development cost to be worthwhile.
  • and this command line MQTT tool-thing ( ) may well cover that.

    I think the missing bit is macro expansion in the run shell script command string. if there was macro expansion for the values available for the applescript run:

    "Three parameters are passed to these scripts:

    The camera number
    The camera name
    The reason for the trigger, which is a comma-separated list of the following reasons:

    the sheep is gold. the goose is cooked. the lozenge is luminous. the night is over. tah-dah. etc.
  • +1 from me as well, but similar to my request in another thread about the event stream -- please please please PLEASE give me a coordinates for a bounding box for where the motion was detected in the video frame!

    I'd love to see this show up in the live streams on the iOS app and on OSX as well, as I would like to help figure out why the AI is detecting vehicles in rain/snow. Presently I just have the iOS app up with a ssh session overlaid on it so I can try to see what it's seeing, but without a bounding box it's just guessing.
  • Hi @aandrew, OK, in the latest beta version of SecuritySpy (currently 5.2.2b5) I have added a new "MOTION" event to the event stream, which provides the coordinates of the bounding box of the motion (x, y, width, height - origin top left). This is also now documented on the SecuritySpy Web Server Specification page. Please let me know what you think.
  • 20200301103405 1269 9 MOTION 114 31 88 66
    20200301103405 1270 9 MOTION 114 31 88 66
    20200301103405 1271 9 MOTION 120 31 88 66
    20200301103405 1272 9 MOTION 126 24 88 66
    20200301103405 1273 9 MOTION 132 24 88 66
    20200301103405 1274 9 MOTION 136 24 88 66
    20200301103405 1275 9 MOTION 148 24 88 66
    20200301103405 1276 9 MOTION 142 24 110 66
    20200301103405 1277 9 MOTION 164 24 88 66
    20200301103406 1278 9 MOTION 164 16 88 66
    20200301103406 1279 9 CLASSIFY HUMAN 2 VEHICLE 100
    20200301103406 1280 9 TRIGGER_M 256
    20200301103406 1281 9 TRIGGER_A 256

    This is amazing, thank you very much, this is exactly the kind of thing I'm looking for! I can parse this and get ffmpeg to draw a bounding box on the incoming RTSP stream and overlay the classifications as well.
  • gee that's quite cool. thanks Ben
  • Thanks Ben! This is very useful. I am controlling the camera actions via a StreamdeckXL. Great hardware. I am sending the command through a website button and all is working well.
    The button has an option to "Access in background", which will not work because I believe the command needs to return a status ok "OK". If I have it launch the browser, it works.
    Is there a way to amend a status to the command, so that it is not necessary?
  • I will try to trigger an applescript from the controller
  • Hey Ben,
    when running from the script editor:

    do shell script "curl http://@/++setSchedule?cameraNum=0&schedule=1&override=3&mode=CA"

    I get "OK" response, but it is not triggering the command, any ideas?

    I have also tried:
    do shell script "curl http:///++setSchedule?cameraNum=0&schedule=1&override=3&mode=CA&auth=xxxxxxxxx"

    "unauthorized", I quadruple checked the base64 encoding.

    sorry for the ignorance

  • Hi @CVH - firstly could you please try this with the latest 5.2.2 version of SecuritySpy if you haven't updated already.

    As for the auth parameter, this should be the username:password string, Base64-encoded. Make sure you are using the correct address, port and auth string. Also make sure the web account you are using actually has permission to set the mode of the particular camera you are trying to set here (e.g. try settings its permission level to Administrator and seeing if that resolves the issue).
  • Thanks Ben, 5.2.2 is working as expected.
  • Great to hear that!
  • I've been playing a bit with this -- I have noticed that (especially at night) I see a LOT of

    MOTION 0 0 0 0

    events. This isn't triggering anything, but I'm curious why/what is causing the system to think there is a 0x0 box with motion occurring in it?

    BTW just a note for anyone else who struggled with it: I have a nice one-liner for dumping this data at the shell and filtering while it's being done:

    wget -q0 - 'http://server/+++eventStream?version=3&auth=AUTH_HERE' | unbuffer -p sed -e 's/^M/^M^L/g' | grep -e ' [9X] '

    "unbuffer" is a utility which does what it says on the tin (allows you to stream the data as it comes in rather than receive it in blocks). The sed line converts CR-only to CRLF which makes displaying the data more useful, and then the grep is of course just the filter I have (only interested in NULL and events from camera 9 in this case). By far the most difficult part of all that was the unbuffer command. I haven't been successful in getting sed to do it on its own, nor in getting a similar command (unbuffer/stdbuf/setbuf/etc.) to work in OSX, although right as I type this I learned about setting the environment variable NSUnbufferedIO=YES, but that is untested by me.
  • It shouldn't be possible to get a MOTION event without a valid rectangle - I will look into this and get back to you.
  • Just a note: 5.2.4b7 I'm still seeing "MOTION 0 0 0 0", although it seems limited to one of my cameras now.
  • Hi @aandrew, this should now be fixed in the 5.2.4b8 beta version of SecuritySpy. Can you confirm?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!