Integrate Unifi Access into Ignition Maker Edition

Hey folks,

I’m working on getting familiar with Ignition and trying to integrate my Unifi into it. Right now I want to create a dashboard for the Access portion of Unifi as a way to view and control my doors. I only have two fob readers for two separate doors.

I understand that Unifi has an API for this, and I have set that up. I’m having difficulty with the configuration in Ignition Maker. Using LLMs to sort of plod my way through this, I’m not a programmer by any means but I can understand how the code works.

Has anyone else accomplished this and can provide some guidance on how they did it?

Thanks

Assuming that it's an HTTP/REST API of some kind, the general advice is to create a project library script that wraps the API.

Follow a form something like this:


__client = system.net.httpClient()
__baseUrl = "https://unifi.com/myApi/"

__token = "12345"

def __performAuthenticatedRequest(endpoint, params):
    return __client.post(__baseUrl + endpoint, params, headers = {"Authorization": "Bearer %s" % __token})

def doSomethingUseful(params):
    return __performAuthenticatedRequest("useful/api/endpoint").json

But that's very broad strokes. I would start by identifying

  1. The API endpoint(s) you need to use
  2. Exactly what information/control you want to expose (in Perspective, presumably?)

Those two pieces of information would help us provide more concrete advice.

I'll also note to be very careful with this. LLMs do not have sufficiently useful knowledge of Ignition, so they will happily lead you up any number of blind alleys. With careful prompting they can be useful substitutes, but they'll (for instance) almost always try to import Python standard library stuff rather than Ignition's system functions or Java libraries. The latter is preferred for stability and performance reasons in Ignition's Jython environment, but the codebases LLMs are trained on are almost exclusively CPython.

2 Likes