Cockpit - UPS monitoring

I’m currently trying to integrate UPS monitoring into my Cockpit dashboard, but I’ve hit a bit of a wall. I want to be able to track power status and battery levels directly from the UI, but the data isn’t showing up as expected.

I’ve already created the following configuration files:

homeserver:/usr/share/cockpit/ups-eaton # cat index.html 
<!DOCTYPE html>
<html>
<head>
    <script src="../base1/cockpit.js"></script>
    <link href="../base1/cockpit.css" rel="stylesheet">
</head>
<body style="padding: 20px;">
    <h2>Monitor UPS Eaton 5E</h2>
    <hr>
    <pre id="output" style="background: #222; color: #0f0; padding: 15px; border-radius: 5px;">Czekam na dane...</pre>
    <script src="ups.js"></script>
</body>
</html>
homeserver:/usr/share/cockpit/ups-eaton # cat manifest.json 
{
    "version": "1.0",
    "display": {
        "title": "UPS Eaton",
        "icon": "battery-full"
    }
}
homeserver:/usr/share/cockpit/ups-eaton # cat ups.js 
const out = document.getElementById("output");
const refresh = () => {
    cockpit.spawn(["/usr/bin/upsc", "UPS@localhost"])
        .done(data => { out.innerText = data; })
        .fail(err => { out.innerText = "Błąd: " + err.message; });
};
cockpit.transport.wait(refresh);
setInterval(refresh, 5000);

Despite setting these up, it’s not working.

Ładowanie danych z NUT… → Loading data from NUT…

Does anyone see a syntax error or a missing permissions step?

First thing I’ve noticed is different message on the screenshot and the code “Ładowanie danych z NUT…” vs “Czekam na dane…” suggesting this is not the same code. [?!?]
Anyway…

Did you see NethServer users cockpit plugin?
I’m sure with couple tweaks will work or at least will give you some ideas how to run your own version.

I’ll try that. How can I best restore Cockpit to factory defaults?

Go back to snapshot?

I would strongly suggest to use virtual machine for testing / developing purposes. It saves a lot of time. You just simply clone the working template and mess with that. Something goes wrong, simply delete and start again.