Script check Uptime

Hi,
I’m writing a script that check the type of connection enabled and then the relative uptime.

Seems to be easy but it doesn’t work. Some idea?
Thakns

let WANPPPConnection1 = declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Enable”, {value: 1}).value[0];
if (WANPPPConnection1 == “true”) {
let WANPPPConnection1UpTime = declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Uptime”, {value: 1}).value[0];
if (WANPPPConnection1UpTime > 0) {
declare(“Tags.Ok”, null, {value: true});
}
}

Two different issues going on. First, you are comparing a string to a boolean. While this can be made to work through forced type coercion, its far better to use explicit comparison. The second and bigger issue is you are telling GenieACS to use stale data for its comparison.

const now = Date.now();
let WANPPPConnection1 = declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Enable", {value: now}).value[0];
if (WANPPPConnection1) {
    let WANPPPConnection1UpTime = declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Uptime", {value: now}).value[0];
    if (WANPPPConnection1UpTime > 0) {
        declare("Tags.Ok", null, {value: true});
    }
}

…Stale data, understood.
So how do I know if the line is up? Which parameter should I use?

Use the code above. I fixed all the issues and fresh data will be pulled back.