Unifi Video Automation triggers


#1

Is it just me or are there no automation triggers for the unifi video platform?

Unifi Video can send email/push notification alerts on motion for example. Is this possible within the current API? I read somewhere it used to work but doesn’t any more?


#2

Nope, I’ve got the same problem, would like motion to trigger outdoor lights.


#3

This would be an excellent feature for triggering events based on camera motion detection, recording, etc.


#4

I used to have a sensor with each UniFi camera that indicated its mode, either idle or recording…with motion recording, that could be made to work as a trigger. Bonus points for being able to mask off areas to which you don’t want to pay attention. But I haven’t seen that in a while now.


#5

That’s the problem, the mode doesn’t change from idle. :frowning:


#6

Any news on this one?


#7

I would love to see this feature as well.


#8

Anyone figured out a way to do this? Would be very nice.


#9

Just about to invest in some Unifi cameras and the NVR. Would love to be able to trigger my outside lights via the CCTV…anyone get anywhere?


#10

Also want to one up this. Hopefully with Ubiquiti’s new involvement in HASS this will be coming soon.


#11

I came up with a python script that I run as a shell_command when a motion detector (z-wave) is tripped, but I think that’s the reverse direction from what you’re looking for.


#12

I was looking into this and I found that Unifi Video writes to a log file in /var/log/unifi-video/motion.log

If we could have a script to tail this file in realtime and then push motion events to MQTT it could work?

example:

1529103489.838 2018-06-15 18:58:09.838/EDT: INFO   Camera[F0xxxxxxxxxx] type:start event:4065 clock:3601035892 (Front Door) in ApplicationEvtBus-14
1529103519.809 2018-06-15 18:58:39.809/EDT: INFO   Camera[F0xxxxxxxxxx] type:stop event:4065 clock:3601065845 (Front Door) in ApplicationEvtBus-17
1529103562.699 2018-06-15 18:59:22.699/EDT: INFO   Camera[F0xxxxxxxxxx] type:start event:4066 clock:3601108687 (Front Door) in ApplicationEvtBus-7
1529103623.339 2018-06-15 19:00:23.339/EDT: INFO   Camera[F0xxxxxxxxxx] type:stop event:4066 clock:3601169338 (Front Door) in ApplicationEvtBus-7
1529103747.788 2018-06-15 19:02:27.788/EDT: INFO   Camera[F0xxxxxxxxxx] type:start event:4067 clock:3601293800 (Front Door) in ApplicationEvtBus-2
1529103789.536 2018-06-15 19:03:09.536/EDT: INFO   Camera[F0xxxxxxxxxx] type:stop event:4067 clock:3601335598 (Front Door) in ApplicationEvtBus-3

#13

This looks even better to modify, I’ll give it a go and see if I can get it working with unifi video


#14

Ok, I’ve gotten something to work but might need some more enhancements…


#15

How did you set it up in the home assistant to properly catch the publish and handle the notifications?


#16

d3vilb0y, Just follow the mqtt binary sensor component guide.

I spent about an hour playing with this last night and it works awesome! Did a little automation that when my driveway camera detects motion to turn on the porch light.
cameramotion

Thank you mzac for your work on this. Been waiting for something like this for like a year. LOL, just bought some esp8266 chips and PIR sensors to build my own motion detector unit, but couldn’t figure out a pretty way to set it up on the outside of my house that my wife would be ok with. Now I don’t have to.


Full integration of Ubiquiti Unifi Video
#17

Wow awesome!!


#18

Awesome work by you! I only had to make a couple modifications to get it to work for me. First off I installed it on one of the ubiquiti pre-configured UVC-NVR’s which is using an older version of debian so i couldn’t do the systemctl script, but rather did the init script for automatic start at boot. I also am using cloudmqtt as an mqtt broker so I had to add some variables of port, username, and password to the mqtt script. Other than those changes though your instructions were perfect for me.

Haha also found that once it got darker the porch light turning off actually caused another motion event, which in turn caused the light to come back on and it was an infinite loop of on and off. So i created a couple timers. 1st when there is motion triggering the light to come on it also starts a timer of 2 minutes. Once that timer goes from active to idle it triggers another automation to start another 5 second timer, and turn off the light. In my original automation that is turning on the light when it detects motion there is a condition that the 5 second timer can’t be active. This keeps it from automatically coming back on when the light switches off. Really an excellent little system and helps utilize these awesome unifi camera’s full potential.

p.s. I do recommend going into your camera settings and changing the motion sensitivity to a lower setting, and extending the length of time that motion has to be present before triggering an event. Found that dust, and fast flying moth’s were constantly setting off my motion detection.


#19

Got it working now, the debian package of mosquitto_pub is not yet able to specify version as in the ubuntu version (when you try and runt he integrated broker), got disconnected the whole time. so instead i went for the cloudmqtt, cheers for mentioning it Camwise!


#20

Thanks @mzac ! Anyone get this working for more than 1 camera? I have it working for 1 but I have 3 others I’d like it to work for and it doesn’t seem to parse for the other ones…