iSpy and HASS integration

I have both iSpy and HASS running and i would like HASS to send a notification when iSpy detects motion.
iSpy can trigger all kind of actions, like call URL, execute file and send email. It looks like all the ingredients are there, but i don’t know where to start.
Any ideas how to accomplish this?

I guess rest api will be easiest way

I set up a script to run for a motion alert and a different script for alert stop.
The scripts make an API call to home assistant like this:

curl -X POST ^
-H “Content-Type: application/json” ^
-d “{"state": "true"}” ^
https://myURL/api/states/binary_sensor.garage_motion_detected

Then, I have an automation that runs when that state changes:

- alias: GarageMotionDetected
  trigger:
    platform: state
    entity_id: binary_sensor.garage_motion_detected
    from: 'false'
    to: 'true'
  action:
    - service: notify.ios_tr7p
      data: 
        message: "garage motion detected!"
        data:
          push:
            sound: US-EN-Alexa-Motion-In-Basement.wav

Actually you do not need that Binary sensor. You could use http sensor. https://home-assistant.io/components/binary_sensor.http/
It will automatically appear in your gui

Thanks @treno and @Lapatoc
I think you guys got me started. Will report back the results soon

Hi,

I try to do the same thing but it’s not clear to me where I have to put this script and how to call for it in iSpy.
Can you help me?

EW

the iSpy interface is super confusing and I have to dig for it every time.

It doesn’t matter where you put your script file. I put mine in a directory called c:\batch\

in the i-spy inteface
right-click your camera image and choose edit
click the alerts tab
Make sure Alerts are enabled
in the Actions box choose “Execute File” from the menu and choose Add
Select your file from the file browser

Thank you for this part!
Now I made the .bat file:

echo on
curl -X POST -H "x-ha-access: PW" ^
  -H "Content-Type: application/json" ^
  -d '{"state": "true"}' ^
  http://URL:PORT/api/states/binary_sensor.eksters
PAUSE

When I run the file I got this error back:

curl: (3) [globbing] unmatched close brace/bracket in column 5
{"message": "Invalid JSON specified"}

This is in the HA log:

2017-09-07 18:13:53 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web.py", line 306, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/ban.py", line 58, in ban_middleware_handler
    return (yield from handler(request))
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 424, in handle
    result = yield from result
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/api.py", line 311, in post
    data = json.loads(body) if body else None
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

EW

GOT IT:

curl -X POST -H “x-ha-access: PW” ^
-H “Content-Type: application/json” ^
-d “{"state": "true"}” ^
http://IP/PORT/api/states/binary_sensor.eksters