Receiving a TCP or HTTP notification

Hi,

I have an Axis IP camera which has an integrated PIR sensor. I can configure the camera to send a HTTP or TCP notification when it senses movement. I noticed Home Assistant has a HTTP sensor as well as TCP sensor. However the HTTP sensor expects JSON which the camera doesn’t post and the TCP sensor is for polling, not for receiving notifications on its own. Has anyone tried to get something like this to work?

This is what the camera says about notifications:

1 Like

You could create a script that you call via HTTP. I’m not sure that you’d be able to pass/receive arguments, but you could have the script notify you with a “motion sensed” message. Then turn on some lights based on time-of-day, etc.

Note: you can add conditions to the sequence of a script. The script continues as long as the condition is met.

Good idea, thanks. I don’t think I need to pass arguments anyway. Installing a WWW server just for this seems a bit excessive, but I guess there aren’t much of a choice.

Home Assistant has a built-in web server that responds to HTTP requests.

Check out the services dev tool (button at bottom of sidebar) to see examples of services you can run.

Anything you can do in an automation can be done via the API.

http://ip.of.hasss/api/services/script/SRCRIPTNAME?api_password=YOURPASSWORD

will call a script

1 Like

I’m also looking at integrating various Axis cameras with HASS and have been looking into the possible ways, @ih8gates seems to have some good suggestions. Hope this will work for us!

/R

So it would be possible to use any script in HASS directly without requiring JSON headers?

/R

I made a script and tried to call it with http://myhassip/api/services/script/test1?api_password=123456789 but I’m getting “405: Method Not Allowed”. Same message from curl and browser. The script is working through the services dev tool. Tried the following curl command per the example here:

curl -X GET \
-H "x-ha-access: YOUR_PASSWORD" \
-H "Content-Type: application/json" \
http://myhassip:8123/api/services/script/test1?api_password=123456789

Not sure if I’m doing this right though?

Ah. You need a POST, not a GET.

Oops. Changed GET to POST in the curl command and now it works. Axis doesn’t trigger the script though. It does accept the address and test says succesfull, so maybe it doesn’t just use POST after all. I’ll maybe do a packet capture later to confirm.

edit: Axis uses GET on its request, so it looks like this approach might not work. If all else fails, installing that web server should solve the problem.

If you find a solution please share it in here.

I saw that with latest release Hikvision got support for their event stream, Axis has got something similar, so would be interesting to see if it owould be possible to achieve a similar implementation.

/R

Hi

Not sure if you got this sorted in the end. We install Axis equipment and integrate with 3rd party systems. The VAPIX document maybe of some help to you. Axis VAPIX Events There is also other VAPIX documentation available at All VAPIX Documents

You can also have TCP notifications rather than HTTP, im fairly new to HA so im not sure what options are avaialble.

Hope the documents help

Thanks

I tried these:

  • HTTP API: you can read the PIR state from /axis-cgi/view/param.cgi?action=list&group=IOPort.I0.Input.Trig. However this would require polling and the PIR seems to activate for only a very short time so this will not work.
  • Axis scripting: couldn’t find a suitable command to do a HTTP GET.

So far the only thing I can think of that would work is to use 3rd party web server.

1 Like

Where cleaning up my mailbox and found this old thread and thought I would just post a link to my custom component that gives support for among other things Axis cameras with pir sensor.

/R

I’m interested running just a HASS script, fired by an action trigger from the Axis camera. Can I ask if you found a way to achieve this in the end?

We didn’t progress on this. I chose to get a proper implementation in place instead.

/R