Reply
New Member
Posts: 7
Registered: ‎11-04-2016
Kudos: 2

Re: Unifi Protect API or Motion alerts hit API?

I would prefer to not play around on the cloud key OS to get the events from Unifi protect... But maybe it is possible to reuse some of the Web-API work from other unifi adhered open source projects. I think ubnt did not reinvent the wheel for protect.

 

I use the iobroker.unifi adapter (https://github.com/jens-maus/ioBroker.unifi) to get information on the WiFi clients, especially known smartphone clients to decide if somebody of the family is around the house.

 

Best would be to integrate also the Unifi Protect API into this adapter. Since I'm still waiting to receive my new cloud key gen2, I can not start to play around with it. But maybe somebody else could at least take a look at the authentication...

New Member
Posts: 7
Registered: ‎11-04-2016
Kudos: 2

Re: Unifi Protect API or Motion alerts hit API?

Just tried with node-unifi to authenticate againt unifi protect and it seems to work. Next will be to integrate some basic API functions.

 

If somebody likes to try: https://github.com/jens-maus/node-unifi

New Member
Posts: 2
Registered: ‎02-26-2018

Re: Unifi Protect API or Motion alerts hit API?

+1 on API (CK fire an API call) / MQTT

 

I like to receive proper events in HomeAssistant. Allthough I Iike the efforts above, I preffer to keep my CK2+ clean and don't wan't to add modifications. Polling API is nice, but I prefer to have realtime events :-)

 

 

New Member
Posts: 1
Registered: 3 weeks ago

Re: Unifi Protect API or Motion alerts hit API?

+1 on API / MQTT

 

Just echoing above... a simple way to integrate with my home automation system would be wonderful!

New Member
Posts: 33
Registered: ‎10-16-2016
Kudos: 613

Re: Unifi Protect API or Motion alerts hit API?

+1 on API / MQTT

New Member
Posts: 1
Registered: ‎04-18-2018

Re: Unifi Protect API or Motion alerts hit API?

[ Edited ]

@terafin Hi, I've finally gotten my CKG2+ but the daemon doesn't seem to start. Would like to open an issue on your github but it's not available.
The script however does run when executing it manually

/usr/local/bin/unifi-protect-mqtt.sh

Status:

root@ck-plus:/usr/lib/unifi# systemctl is-active unifi-protect-mqtt
activating
root@ck-plus:/usr/lib/unifi# systemctl status unifi-protect-mqtt
● unifi-protect-mqtt.service - Unifi Protect Motion Detection to MQTT
   Loaded: loaded (/etc/systemd/system/unifi-protect-mqtt.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) since Sat 2019-02-09 13:06:41 CET; 194ms ago
  Process: 2506 ExecStart=/usr/local/bin/unifi-protect-mqtt.sh (code=exited, status=0/SUCCESS)
 Main PID: 2506 (code=exited, status=0/SUCCESS)
      CPU: 8ms

Feb 09 13:06:41 ck-plus systemd[1]: unifi-protect-mqtt.service: Consumed 8ms CPU time

I cannot see it running with an px -aux either.


Any ideas?

 

EDIT

And solved, had to change the username to unifi-protect, created a pull request for that one.

root@ck-plus:/usr/local/bin# systemctl status unifi-protect-mqtt
● unifi-protect-mqtt.service - Unifi Protect Motion Detection to MQTT
   Loaded: loaded (/etc/systemd/system/unifi-protect-mqtt.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-02-09 13:49:35 CET; 7s ago
 Main PID: 6794 (unifi-protect-m)
   Memory: 408.0K
      CPU: 10ms
   CGroup: /system.slice/unifi-protect-mqtt.service
           ├─6794 /bin/bash /usr/local/bin/unifi-protect-mqtt.sh
           └─6795 inotifywait -e modify /srv/unifi-protect/logs/events.cameras.log

 

One other question though, does this survive a firmware upgrade? 

 

EDIT2

It does not... Requires reinstall after firmware upgrade.

Reply