[PROJECT] Driver for Unifi Protect Controllers

So I received a SuperLink and Environment sensor I managed to get ordered. First glances:

  1. The Protect API (even though I was already on EA) needed an update on my Unifi Controller.
  2. The SuperLink adopted without any fanfare.
  3. The Environment sensor tried NOT to be adopted. I had to reset it 3 times before it finally adopted successfully. Even then it took quite a while and in all cases it was not identified correctly in the app BEFORE adopting (said it was Unknown) but it shows afterwards.

Now for my drivers... The SuperLink is automatically recognized as a bridge. This means it has no real functions at all in the driver. Which is not really far from the truth here as the only thing you can do within the Unifi interfaces (app or controller) is turn on/off the LED on it. Not something I think I will make driver changes for.
The Environmental sensor was ALSO automatically recognized, as a Sensor. Up until now there have not been any other sensors so it was all based around what my UP Sense device did/could do. The Environmental sensor is very similar but has a COUPLE less features that the current driver allows you to control within Preferences. All the data seems to come back fine. So I am not sure if I need to do much for this one at this time.

The trouble here is that as more sensors are identified (as people send me data samples as I do I cannot afford to buy any more) there may be the need to break out the types of sensor, and thus create a bunch of different child device drivers. Obviously, I have LOTS of experience with that from my Network driver... but I was happy this one stayed smaller. I know what data fields to look at to distinguish them, so when the time comes I will have an idea how to break them apart. But until then, all I can say is HOORAH! SuperLink and Environmental sensors work!

2 Likes

Updated Version(s):

  • UnifiProtectAPI.groovy = 0.2.63
  • UnifiProtectChild-Sensor.groovy = 0.1.10

Change(s):

  • Fix for isRtspEnabled possible error if the streams the value is contained in are null.
  • Change to the login array handling.
  • A large number of additional data handling has been added as the result of significant numbers of changes from the Unifi API side. Most of these are being added as State Variables because their value is not known yet. However, there is a "smokeStatus" that is now showing up as well as implications for a glass break (only settings at this time, no data, unlike the smoke).
  • Sensor child driver had attributes added for smoke and a placeholder attribute for glass breakage. The smoke is only a string attribute at this time and does not use the Hubitat capability for a smoke detector because I have not yet seen any data on it (mine reports a null value) to know how it should be converted to what Hubitat's capability expects. But, it is laying the ground work at least and will show a value if it comes in.

Hello, I’ve had some issues with motion detection. It always seems to work for a couple of days then stops doing anything. I always notice that web sockets is closed when it stops working.

Is this a websockets issue? Is there a way to keep web sockets open? Am I biting off on the wrong thing?

The WebSocket will open/close "naturally" over time (it will spam the log with it if you have Trace logging on). In the parent device can you check the State Variable for "Web Socket Status" and whether there are any "Web Socket Failures"? If it has failed 5 times in a row then it will be disabled and you SHOULD have been able to reset it by running a manual Login (selecting the Login command). Except I just found a flaw in the Login where it was not writing the correct name of the variable... so it was resetting one that most of the rest of the code was not looking at... In the meantime, Save Preferences will reset it properly.

I have a new version coming soon but it only had data handling additions. I fixed the variable just now but want to test it for a bit to make sure it is good again.

Updated Version(s):

  • UnifiProtectAPI.groovy = 0.2.64

Change(s):

  • Fix for WebSocket failures variable not being reset properly when it should be upon Login and other methods. This could cause the WebSocket to stop operating after it hit the failure limit (5) without it being reset upon Login like it was supposed to.
  • Additional data handling for new variables being returned by the API.