UISP/Ubiquity Network Monitoring

Hey y’all - I’m very new to coding and starlark and all that. I want to push an app to my brand new Tidbyt to show current status of my small ubiquity UISP network. Anyone have a chance to maybe look at my code and have an idea of how this would preform with the API? I didn’t see an API call to give me client count for example but I had AI write the code to count the number of clients returned. The error this code returns is:

% pixlet serve UCRM_Client_Count.star
2023/10/03 19:40:42 listening at
2023/10/03 19:40:42 error loading applet: failed to load applet: starlark.ExecFile: UCRM_Client_Count.star:21:8: got illegal token, want primary expression

My code:

load(“http.star”, “http”)
load(“render.star”, “render”)


UISP_API_BASE_URL = “UISP Cloud Access Portal

Your API Token


def fetch_active_clients():
headers = {
“x-auth-token”: UISP_API_TOKEN,
url = UISP_API_BASE_URL + “/clients”
response = http.get(url, headers=headers)

# Check for non-200 status code
if response.status_code != 200:
    return None, "Error reaching UISP: " + str(response.status_code)

# Attempt to parse the response as JSON
    return response.json(), None
except Exception as e:
    return None, "JSON decoding error: " + str(e)

def main(config):
data, error = fetch_active_clients()

if error:
    return render.Root(
        child = render.Text(error)

# Assuming the data is a list of clients, count the number of active clients
active_client_count = len([client for client in data if client.get('isActive')])

# Display the count on Tidbyt
return render.Root(
    child = render.Text(str(active_client_count) + " Active Clients")

TIA for any help!

you can’t use try/except in starlark. Your AI doesn’t know this.

1 Like

I understand that. I asked for it to study up and said to use starlark. Any chance you or someone else would help me or send me in the right direction ?

Is the above code not in starlark?