Home Assistant
  • Home Assistant is a smart things hub for everything. For people asking for homekit support Home Assistant is the way to go.

    I would love to be able to use SS with Home Assistant.

    Here is a list of support systems. https://www.home-assistant.io/components/#camera

    I tried using - https://www.home-assistant.io/components/camera.generic/ and https://www.home-assistant.io/components/camera.mjpeg/

    Issue here was the fact I am using H.246 and I don't want to stop using it.

    Ben, am I able to stream from SS to Home Assistant?

    Side note... Home Assistant is amazing and has a great community. I know if you built a plugin for it you would sell a heaps of SS to the community! You would also then have the benefit of all the other amazing thing people could do with SS using Home Assistant!!
  • I just discovered with sub stream is, so I got it working but all the above still applies!!
  • You know you want to Ben..
  • This is interesting, we will have a look at the possibility of a SecuritySpy plugin for Home Assistant, I think that would be a good idea.

    The "Generic MJPEG IP Camera" plugin seems to be the best one to use currently. The MJPEG URL to supply would be something like this:

    http://ss-server-address:8000/++video?cameraNum=0

    (see the SecuritySpy Web Server Specification document for a full description of the ++video request.

    You can obtain the correct camera number from the Camera Info window in SecuritySpy - if you don't currently have this column displayed, click the header bar where you see the column names, and you will get a pop-up menu that allows you to add the Camera Number column.
  • I agree, from what I've seen on the web so far there would be a great demand for something like this. The NEST solution is Clould based and insanely expensive. I genuinely think that a home server solution which could integrate with Google Home and Homekit would be very popular.
  • I am working with Home Assistant to develop a series of switches that arm and disarm individual cameras. The benefit will be to enable the switches to be used with other automatons or scripts within Home Assistant. Here is the yaml I am using in my Home Assistant configuration.yaml.

    switch:
    - platform: command_line
    switches:
    camera_arm:
    command_on: '/usr/bin/curl -k "http://{ip}:8000/++ssControlMotionCapture?cameraNum=3&arm=1&auth={authkey}"'
    command_off: '/usr/bin/curl -k "http://{ip}:8000/++ssControlMotionCapture?cameraNum=3&arm=0&auth={authkey}"'
    command_state: '/usr/bin/curl -k --silent "http://{ip}:8000/++cameramodes?cameraNum=3&auth={authkey}" | grep -oP "(?<=M:).*"'<br /> value_template: '{{ value == "ARMED" }}'

    where {ip} = my camera IP address and {authkey} = my authentication. Ignore the not sure why that keeps popping up value_template is a separate line in the yaml.

    I suspect my error is in the syntax of the grep command because when I use curl on the command line in terminal to fetch the state of the camera it returns

    C:DISARMED
    M:DISARMED
    A:DISARMED

    however, as soon as I add the grep command it fails. If I can get this working I should be able to control this camera's motion capture, notifications, etc.. with switches in Home Assistant.
  • Anyone else have any experience with integrating security spy with home assistant. I am close, but do not have it working successfully yet.
  • Hi jjbanker
    This: {authkey} will not work in a command_line switch. Either you will have to type the full Auth Key or you will have to put the whole line in the secrets file with the typed auth key and then just do something like:
    command_on: !secret cam1_on
    command_off: !secret cam1_off
    command_state: !secret cam1_state

    Your value template is fine and so is you grep command. I use exactly the same and it works.
  • I'd like to get my SS install working with HA too. I'm curious about ben's aug 23rd post. Is this method known to work, or is this just speculation?

    Has anyone made any more progress on this?
  • Things I've done with SS/HASS.

    Cameras display in the HASS dashboard.
    PIR sensors (or any sensors or event changes) in HASS trigger SS recordings.
    Telegram notifications with camera screenshots when an event is triggered.

    I can probably do a write up if people are interested?
  • Thanks for the info Boxgrove, pretty self explanatory. I'll tweak my setup based on your info.
  • Ben mentioned in an earlier post that using the "++video request" method would be the best approach for pulling live video into HA today. It seems to work well, but is there a way to get only the video feed, without the "live" title and links to "main page", "captured files" and "cant view?" ?
  • Hi @bonfireva the ++video request is for the MJPEG live video stream itself. So there is no associated HTML page with titles etc. It sounds like you are referring to the "live" request, which gets you an HTML page with the titles and other text that you describe, containing the video image.

    This "live" page comes from an HTML template, which you can edit to remove the stuff you don't want. Please see Customising SecuritySpy’s Web Interface.
  • Thanks Ben, that's exactly what I was looking for. And you are correct, I was trying to use the new iFrame card in Home Assistant to display live video using the live request feature.
  • Ben, any update on a plugin for Home Assistant?
  • Has anyone had more luck integrating with Home Assistant?
  • I am sure security spy will eventually become a standard integration in home assistant, but I suspect this is pretty low in priority, especially since there are ways to make it work today with some configuring. The security spy server is just as easy to use as setting up cameras are in home assistant. Its actually not that hard, just takes a little tinkering to integrate the two together. See comments from Boxgrove above, Boxgrove was kind enough to share some of his config files. If you are using home assistant you should be familiar with yaml and how to create switches, automations, saving backups, etc..

    I run home assistant in a virtual machine on an old computer, 2012 Macmini in my case, so I just save a snapshot of my working virtual machine before I start tinkering and if I crash home assistant or break my configuration, I just restore my vm from the snap shot and its back up and running.
  • So spending some time with Home Assistant (HA), as I need a better way to control automations vs spending additional$$ for expensive web relays, when I have existing relays in place. Over the years, I've collected switches from TP-Link, Leviton, Eco Plugs, EweLink, and now leaning more towards Shelly relays. I'm finding it hard to find good outdoor motion sensors that tie to HA, so I'm on a quest to learn Node-Red and incorporate SS into HA.

    Thanks Boxgrove for the github files. I'm running my instance of HA on a Raspberry Pi, as I've got my Mac Pro running SS & Plex management, so I'm trying to reverse the thought process between the two platforms.

    My primary goal is when a motion is detected by a camera, then I'd like to 1) Determine if it's night time and 2) If Yes, send a command to turn on the lights associated with that camera and potentially another. Basically, using my cameras a glorified Motion Sensors, but hoping over time the AI interface that Ben has written will help minimize false positives from the occasional wasp or other insect, and thereby scare off potential intruders. My secondary goal, I plan to dissect my alarm system panel, whereby an actual breach of an alarm contact will trigger All Cameras, All Lights (internal/external), and anything else that makes sense that my current alarm system doesn't cover or wants to gouge me on the cost of the service. My current alarm system is an IControl Hub that uses Z-Wave modules and already has a siren and central station monitoring. I'm hoping to figure out how to sniff out the Z-Wave messaging and use HA to drive the other switches/automations.

    Any ideas or ways to simplify this would be appreciated. I agree with the others on this thread, that tying together existing IoT devices with SS is a good thing for Ben and the future of SS for all of us.
  • Hey tlutrick, this is all possible currently with Applescripts. I am using a ISY UDI944i automation system for our house. It is highly customizable with IF, ELSE, COMMANDS. I have AppleScript that read motion from SS to trigger the ISY system. Works flawless.
    Also I have the Streamdeck XL for a physical controller. I posted this solution in a earlier thread. give it a search.
  • tlutrick I use combination of Apple scripts from SS to webhooks on the Pi running HASS

    I’ll share config tomorrow but basically when motion is detected on SS, it sent a curl command to a URL on the Pi (the webhook) which acts as a trigger in an automation. You can then use a condition if it’s night (maybe using the sun sensor component) and then turn on the light as normal.


    EDIT: right this will be very quick and dirty but hopefully you can follow... This is an automation I use to detect motion on a SS camera to flash a light an LED strip in my office. Formatting will probably be screwed up, but if you can't get it working give me a few days and I'll try and get it on GitHub or something.

    make a security spy script: mine is called driveway_ss_trigger_1 - pay attention to that (remove square brackets below) and set that to be an action on motion detection.

    [do shell script "curl -d \"\" \"http://HASS_IP:8123/api/webhook/driveway_ss_trigger_1\""]

    Then my automation in Home Assistant looks like:

    - alias: SS Trigger Driveway Desk Flash
    id: ss_trigger_driveway_desk_flash
    trigger:
    - platform: webhook
    webhook_id: driveway_ss_trigger_1. ### this needs to match up to what the curl command points to

    condition: ### this just links to the occupancy sensor in my office to make sure it doesn't fire when I'm not there
    condition: state
    entity_id: binary_sensor.0x00158d0002c5888c_occupancy
    state: 'on'

    action:
    - service: script.driveway_motion #this runs a script that flashes the LED's
    - service: automation.turn_off
    entity_id: automation.ss_trigger_driveway_desk_flash
    - delay:
    minutes: 1
    - service: automation.turn_on
    entity_id: automation.ss_trigger_driveway_desk_flash

    Now you're probably wondering why I turn the automation off for a minute and then back on again... I have the driveway_motion script set up so it first captures the current state of the LED strips to a scene (I have a few different colour modes) flashes them red to indicate motion detected and then returns to it's previous state. So for example if I had them set to blue before motion is detected, they would flash red and then return to blue.

    What I found is that if motion was detected a 2nd time when the red flashes were happening, the script would capture the red flashes as the previous state and keep them turned on. Having the automation turn off for a minute gives the LEDs an opportunity to return to their previous state.

    If you're interested - script.drive_motion is....

    driveway_motion:
    sequence:
    - service: scene.create
    data_template:
    scene_id: before
    snapshot_entities:
    - light.wled_desk
    - service: light.turn_on
    data:
    entity_id: light.wled_desk
    transition: 3
    brightness: 127
    rgb_color: [255, 0, 0]
    effect: Solid ### just realise they don't actually flash here they just turn red, ha!
    - delay:
    seconds: 10
    - service: scene.turn_on
    data:
    entity_id: scene.before

    N.B you can also run multiple curl commands in one apple script - mine actually fires "driveway_ss_trigger_1" and "driveway_ss_trigger". One is a telegram notification with a capture screenshot, and the other is the desk flashing. I have them as two separate automations so I can turn them on and off independently.

    Now this is all probably a lot easier with NodeRED.... but I've always used yaml and it works for me.
  • BoxGrove, this is awesome and appreciate the help. I was on vaca and missed your post. Digging in now
  • BoxGrove,

    Been a terrible week. I've run into significant problems with my HA instance. AT&T had to replace my modem and the new BGW210-700 modem blocks port 443 and screwed up my access, so I spent most of the time troubleshooting the fiasco they created, but now I'm finally good...

    Ok, so I'm working through your scripts (thank you btw) and not following the creation of the entities. I'm still working through this

  • BoxGrove,

    You are FREAKING AWESOME!!! Took me a bit to decipher the syntax and get it working, but I'm rolling now. It is better than expected. DrZzzz's had a YouTube video on Sonoff integrations for local control that allowed me to turn on some other switches with the motion, and it works great. Gave me a better understanding for my ECOPlugs, Leviton switches, TP-Link Switches, etc... Going to move on to MQTT next and look to integrate some of my Shelly 1 switches.

    I'm still having to run my HA instance in HTTP, since I can't figure out a workaround for the whole AT&T Port 443 blocking issue. If I turn on my ssl_certificate and ssl_key, then I can access it remotely via HTTPS, and thereby security, but I can't get HTTP to work. I know I'm doing some rookie mistake, but I'll have to keep tinkering with other options to figure it out. I turned on two part authentication for some added security for now, though I don't know how much that helps. I spent 2 weeks screwing around with HTTP issues, with no joy, and your AWESOME instruction took me just 2 days to get some cool automations going.

    Thanks for the guidance and assist, and I encourage others on here to think about Home Assistant. Very Cool stuff and I've only scratched the surface. Look for me on the HA & GitHub pages as SolarCzar (changing my login to reflect my huge 20kW solar array hobby).

    Later guys
  • Oh, and Ben you're AWESOME as well for the ability to push the webhook scripting and improved AI on motion detection. Makes for a very nice integration now. Much happier and full of ideas on how to better automate my home. Thanks
  • No worries at all mate. Glad you could get it working. I’ve spend so much time messing trying to get it working so glad it’s been helpfully for someone else.

    I’ve noticed you can arm and disarm SS captures
    through shell commands so my next job is to set up automations that arm and disarm motion capture (useful for when I’m on the driveway washing the car, or in the garden). I’ll probably automate with a Wi-fi or RF button by the front door that turns off motion capture for X amount of time. (So I don’t forget to turn it back on)

    Home assistant really is so powerful if you’re willing to take the time to learn and tinker. I found that the AI motion capture on security spy was so much better than the motion sensors I was using through home assistant that had so many false positives.

    I just noticed in my trigger code above there is a random full stop after the webook ID - that shouldn’t be there and hope it didn’t cause too many problems.

    If I’ve got time I’ll shove al that code into a github, one of the most frustrating things with Yaml is the formatting and indentation so hopefully can save someone some headaches somewhere
  • Boxgrove & Ben,

    So I'm noticing that the curl commands aren't executing all the time. I'll test for example the command...

    do shell script "curl -d \"\" \"http://192.168.1.79:8123/api/webhook/driveway_ss_trigger_1\""

    which executes an automation in Home Asst and runs fine. I execute it again (from the script editor play button) and it doesn't work. I don't know how to verify that curl commands are going out and being received, but I'm trying to learn. Let me know if you guys can think of something off the top of your head for me to try.

    I got so excited from the initial setup from Boxgrove, that I started adding some more Shelly 1 switches to control more lights to tie to Motion from the cameras. I started noticing that one of my automations related to the garage cameras were really slow. I could walk 20' before the routine would run. That's when I started testing and finding that some routines aren't running all the time.

    Let me know if you have some ideas where/how to test this? Thanks again
  • It might be worth enabling debug logs on Home Assistant to see what it does when receiving web hooks:
    https://www.home-assistant.io/integrations/logger/
  • Just a side note, you may not need to escape all the quotes from your example. Mine looks like this in an Apple Script and it works ok (those are two single quotes after -d):

    do shell script "curl -d '' http://192.168.1.10:8123/api/webhook/kiosk_doorcam_motion"
  • So I've got 4 separate script files..

    do shell script "curl -d \"\" \"http://192.168.1.79:8123/api/webhook/driveway_ss_trigger_1""
    do shell script "curl -d \"\" \"http://192.168.1.79:8123/api/webhook/front_porch_ss_trigger_1""
    do shell script "curl -d \"\" \"http://192.168.1.79:8123/api/webhook/back_porch_ss_trigger_1""
    do shell script "curl -d \"\" \"http://192.168.1.79:8123/api/webhook/garage_ss_trigger_1""

    , but only the garage script actually runs. I've executed the automations within HA and they function correctly, but the webhook ID doesn't seem to be coming through except for the one mentioned. The scripts are identical except for their name, and I did try as paul2020 suggested to change the quote aspects, but with no joy.

    One note, from within Script Editor, I can "play" the garage script and it functions, whereas the others will not. To me, this indicates that the curl command

    I turned on logger: in my configuration.yaml file and it brought my HA to a crawl with too many entries. I changed it to...

    logger:
    default: warning
    logs:
    homeassistant.components.automations: debug
    homeassistant.components.webhook: debug
    homeassistant.components.switch: debug

    and this is all it posts...

    2020-07-14 23:23:44 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for driveway_ss_trigger_1
    2020-07-14 23:27:40 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for front_porch_ss_trigger_1
    2020-07-14 23:35:37 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for garage_ss_trigger_1

    notice that the garage_ss_trigger_1 is not a line item, yet it functions perfectly. Thoughts anyone?
  • So I went into Terminal on Mac and entered the curl command, and it executed. Went back into File Editor on HA and found this line in the debug for the appropriate time stamp...

    2020-07-15 00:46:20 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for driveway_ss_trigger_1

    So if I'm thinking about this correctly, the curl command is getting to HA. HA is recognizing the webhook, but it is not executing. I can manually execute the automation in the Configuration and it works. here is the excerpt from the automations.yaml file...
    ```
    - id: '1593209500332'
    alias: ss_driveway_motion
    description: Activate lights on SS driveway camera motion
    trigger:
    - platform: webhook
    webhook_id: driveway_ss_trigger_1
    condition:
    - after: sunset
    before: sunrise
    condition: sun
    - condition: state
    entity_id: switch.shelly_shsw_1_115f00
    state: 'off'
    action:
    - device_id: e6629ba0af684d6890b50f41079b5a4d
    domain: switch
    entity_id: switch.shelly_shsw_1_115f00
    type: turn_on
    - delay: 00:10:00
    - device_id: e6629ba0af684d6890b50f41079b5a4d
    domain: switch
    entity_id: switch.shelly_shsw_1_115f00
    type: turn_off
    ```

    What am I missing?
  • So I won't know until dark if it's working, but some guys on the HA forum indicated that my condition for when it's dark to turn on a light was wrong and should be...

    condition:
    condition: state
    entity_id: sun.sun
    state: 'below_horizon'

    We'll check it out tonight, but wanted to reply back to anyone reading this...
  • Ok, another update. The activity is working (Yeah Baby!!!!), but I'm noticing that the amount of time to recognize the motion and then activate the lights is longer than I hoped. I observed that I walked almost 25 feet on my driveway before the light switched on. I thought it was still HA, but I confirmed that the signaling to the Shelly 1 switch is staying local and really quick. When I execute the Apple Script manually on the Mac Pro that acts as the server for SS, it's really fast. So the time from the script activating to the lights turning on is less than 1-2 seconds

    So it's the time from when the motion detection begins, the AI determines it's a person or vehicle (which works great and cuts down false positives enough to make this viable), and sends the Action script. For recording video, it works great. So without sounding ungrateful, how can I improve the timing on this for the switch relay? I like that the lights would not be set off by every insect that flies in front of the camera, but I also don't want to walk completely through the detection area before the lights turn on. Everything is currently set with defaults that Ben wrote.

    Thoughts?
  • I just installed Home-assistant on the same MacOS server as SecuritySpy. I was able to get a notification to work by using this tutorial as a basis: https://www.nabucasa.com/config/webhooks/#triggering-automation-with-a-webhook

    Start at "Triggering Automation with a Webhook. Once you've enable the web hook, select HTTP POST without parameters and replace the sample url with the one from home-assistant. One caveat is that I'm using the Home Assistant Cloud service. It might work differently without it. The service is $5/month at the time of this post.

    I was thinking it would be nice if Security Spy was one of the integration services, but I'm not sure that would help in this situation. Besides, it's not that much work to do the setup.

Howdy, Stranger!

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