Custom Component - AXIS Camera Events

My Axis Camera (Companion Cube LW) does not support ONVIF, so using the current Axis component does not work for me. In order to still get some support out of it, I leverage their HTTP(s) notification action inside their Events functionality to have the camera push custom defined events from the camera to HomeAssistant.

This allows me to trigger events in HomeAssistant from my camera without needing ONVIF.

Setup (Axis):

Go to the “Events” section of your Camera’s UI, and create a Recipient called HomeAssistant configured as HTTP (or HTTPs depending on how your HASS instance is set up):
image

Configure your Action rule to whatever criteria you desire, and specify the Action to send a Notification to the Recipient we created above.

In the “Custom Parameters” field, define the following mandatory parameters:

  • api_password=<YOUR HASS API PASSWORD>
  • name=<WHAT YOU WANT YOUR CAMERA TO BE CALLED IN HASS>
  • type=<WHAT TYPE OF EVENT YOU WANT TO SEND>

You can also add any of the optional parameters: time, ip, short_mac, mac, preset_number, preset_name, termperature, video_source, pan_coordinate, tilt_coordinate

Axis has a long list of modifiers in their help docs that let you send device-specific information like IP address, etc.

Once the rule is configured in Axis, drop axis_event.py in your custom_components folder and add “axis_event:” to your configuration.yaml

If configured correctly, when the rule is triggered on your Axis camera, it will fire off an event in HomeAssistant: axis_event.<hostname>.<type>

You can then use the events to trigger your automation in HomeAssistant. I personally set it up to notify me when the Camera notices motion.

Hope you guys enjoy it!

Sample Automation: (Sample camera parameters: name=living_room, type=motion)
https://gist.github.com/iamtpage/78b7c34536f6b660da9d674195c9b356

3 Likes

Great work!

Gonna have a closer look next week when I’m back at home. Didn’t know that could be done so easily.

I definitely want to see this as a complement in the Axis component.

Thanks, take a look when you can. I didn’t want to settle for the fact that I paid ~$200 for an IP camera and NOT be able to integrate into HomeAssistant somehow. Right now it just does custom events, I might look into some of the URLs and see if I can trigger a recording through crafting the right URL + Digest Auth

You should be able to trigger recording through the Axis components service

You have a link to examples or documentation? I can’t seem to find anything

Check under device services. If it’s not what you’re after then we have a discrepancy

Looks good to me. Haven’t tried it out though. Will you integrate it?

Any chance this will get integrated in the official Axis component? I find it extremely useful.

The originator did start on something but then nothing has happened, someone will need to polish it up. I think it fills a gap in the component, but I do not have time to look at it myself.

In case somebody gets a ‘Device name not specified’ error in HA, maybe ‘hostname’ was used (like in the Action Rule Setup screenshot) instead of ‘name’.

Thanks iamtpage for sharing your work. I just implemented this on my M7001. Took a bit to figure out as M7001 only goes up to firmware 5.4 which has a slightly different action rule setup page (customer parameters is just one line for your variables).

so i had to use the following format to put in the 3 custom parameters;

api_password=[password];name=[camera name];type=[event name]

(notices the ; i used to separate the parameters with no space)

Also, the event_type you use to trigger HA automation is [parameter name]_[parameter type] from above.

took me little debugging to figure that out but everything else worked as described.

It looks like custom components require folders and the component file named as the component type as of .88 - any feedback on how to name this in my custom components folder?