Art-of-WiFi / UniFi-API-browser

Tool to browse data exposed by Ubiquiti's UniFi Controller API
MIT License
1.1k stars 150 forks source link

Guest Authed on captive portal? #112

Closed bradgillap closed 1 month ago

bradgillap commented 1 month ago

Hello,

Does the API allow for finding out how many guests passed through the captive portal or sorting that by month?

Thanks.

malle-pietje commented 1 month ago

The most reliable source for this is to go through the output of list_events() and process events with the same key as in the example:

    {
        "is_admin": true,
        "msg": "Guest[8e:59:66:55:aa:f8] is authorized by Admin[local_admin_user] for 20160 minutes",
        "time": 1725461317957,
        "datetime": "2024-09-04T14:48:37Z",
        "minutes": "20160",
        "site_id": "56ee74bce4zzzzzzzza62a0ea",
        "admin": "Admin[local_admin_user]",
        "subsystem": "wlan",
        "guest": "8e:59:66:55:aa:f8",
        "_id": "66d87345zzzzzzzz7741ac4628",
        "is_negative": false,
        "key": "EVT_AD_GuestAuthorizedFor"
    },
bradgillap commented 1 month ago

Thank you,

I see what you mean now. There are a few things I can count, and group on here.

So now I just need to learn php. lol. I'll ask a buddy for some help but that gets me closer to my objective with this.

"datetime": "2024-09-04T21:18:27Z", "ssid": "hidden ssid", "guest": "hidden-mac-address", "site_id": "hidden-site-id",

{
        "msg": "Guest[hidden-mac-address] has connected to AP[hidden-mac-address] with SSID \"hidden ssid\" on \"channel 40(na)\"",
        "ap_model": "U7HD",
        "channel": "40",
        "ap_displayName": "hidden display name",
        "subsystem": "wlan",
        "ssid": "hidden ssid",
        "ap": "hidden-mac-address",
        "radio": "na",
        "hostname": "hidden-hostname",
        "ap_name": "hidden ap name",
        "time": 1725484707677,
        "datetime": "2024-09-04T21:18:27Z",
        "site_id": "hidden-site-id",
        "guest": "hidden-mac-address",
        "_id": "hidden",
        "is_negative": false,
        "key": "EVT_WG_Connected"
    },

Thanks again.

malle-pietje commented 1 month ago

You’re welcome! 👍