[APP][Pro] Ubiquiti UniFi Network

This seems to work to retrieve if any guests are on the network:

const base = 'https://<CONTROLLER IP>/proxy/network/integration/v1/sites/<SITEID>/clients';
const filter = "access.type.eq('GUEST')";
const url = base + '?filter=' + filter
const headers = {
  'Accept': 'application/json',
  'X-API-Key': '<API KEY>'
};
const agent = new https.Agent({ rejectUnauthorized: false });

const res = await fetch(url, { method: 'GET', headers, agent });
const json = await res.json();

return json.totalCount != 0

When i block my childs ipad, it just roams to another AP. I have fixed names and ip adresses on the ipad and static mac adresses.
I cant find a solution

if i block the ipad via the unify app, it just works

Ha funny, I’m also looking for this. I need it a bit more specific though. First device connected to vlan, last device disconnected from vlan. Because I use Private pre-shared keys, so the wifi name is always the same.

What do you do with this code? Do you paste it in homey script? Or do you use some app for it?

I need to find a way to trigger on if someone is connected to my guest network or not. My guest network(seperate vlan).

Yes I run it every 5 minutes in a homeyscript card. Not the most resource efficient though. Still have to figure out if I can trigger it only on event occurance via webhooks or so. Too bad @ObelixNL seems to ignore this :person_shrugging: . For sure he knows more about this.

When you want to add functionality you are free to develop features for it. I am doing this in my free time without getting paid for it. I am very happy with some donations so I can buy UniFi devices to add support for it.

1 Like

Hey man, no worries your doing an amazing job already with the apps! I’m not really a coder, but will try to find some workarounds with the help of AI :stuck_out_tongue:

Can you send me a DM? I want to now if we can see the vlan in the event, I don’t think the vlan is expose in the event. Are you seeing some events in unifi?

There is a flow card ‘First device connected’ only this is for all devices on all networks.

Strange, I will look at it, Do you have an example flow?

Works on my network

I have created a test version with an extra tag ipAddress in the connected and disconnected card.

There is a condition card (And) to check if there are guests connected or not in the latest test version. Not tested because I don’t have a guest portal only isolated devices on the guest network.

haha i have the same flow.
I have a unify dreammachine pro. with multiple accesspoints. What do you use?

I will test it with the api directly, maybe its something else.

UniFi Cloud Gateway Max and multiple accesspoints and 16 or more port switches.

Thanks you for the guest support in the latest test version. Much appreciated !

I will try to test it later today or this week.

So I just tested v2.5.4, but I haven’t got any AND cards. Only unifi devices I added are listed.

Thats strange, are you sure you downloaden the test version? I do have the changes.

For me the test additions don’t seem to work though, but sinds my network is more complicated, I was interessted in if it would work for someone else.

Just double checked, I’m on v2.5.4 test but haven’t got any AND or THEN cards at all. Only IF cards. I already restarted both the unifi app and homey, but no luck. Last resort would be to uninstall and reinstall the unifi app but then I have to fix alot of flows :frowning:

Just a quick question, has anything changed recently?

I am getting 500 Internal Server Errors on
/api/app/com.ubnt.unifi/websocketstatus

{
“error”: “Cannot read properties of null (reading ‘isWebsocketConnected’)”,
“error_description”: “Cannot read properties of null (reading ‘isWebsocketConnected’)”,
“stack”: “Error: Cannot read properties of null (reading ‘isWebsocketConnected’)\\n    at Remote Process\\n”,
“statusCode”: null,
“statusName”: “Error”
}

and

/api/app/com.ubnt.unifi/getLastWebsocketMessageTime

{
“error”: “Cannot read properties of null (reading ‘getLastWebsocketMessageTime’)”,
“error_description”: “Cannot read properties of null (reading ‘getLastWebsocketMessageTime’)”,
“stack”: “Error: Cannot read properties of null (reading ‘getLastWebsocketMessageTime’)\\n    at Remote Process\\n”,
“statusCode”: null,
“statusName”: “Error”
}

When trying to access the settings page.

Currently running UDM SE Network 9.5.21 and Ubiquiti UniFi Network v2.5.4. Had the same problem with 2.5.2. Not sure why this is. Running Homey v12.8.0. Anyone encountered this before?

Hi @ObelixNL

I’ve just tested the latest one (2.5.4) with my USW-24-POE, powering off, neither power cycling (both cards) do not work for me.

I am trying to set up the Ubiquiti Unifi network homey-app.

While the protect-app does accept my credentials for a local user, net homey-network app does not.

I really do not know what to put in for „site:“. IP does mean the gatewayˋs IP-address , but what does „site“ mean exactly ?

At the end I want to switch PoE-ports on/off by time using this app