Created
August 2, 2024 00:07
-
-
Save WietseWind/7a16f18ef5ecb02ce1c20e4895cc9ce9 to your computer and use it in GitHub Desktop.
Shelly 1 PM Mini Gen 3 - PRTG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Access: http://{ip}/script/1/prtg | |
HTTPServer.registerEndpoint('prtg', function (request, response) { | |
response.headers = [ | |
['content-type', 'application/json'] | |
] | |
const em = Shelly.getComponentStatus('switch', 0) | |
const ip = Shelly.getComponentStatus('input', 0) | |
response.body = JSON.stringify({ | |
prtg: { | |
result: [ | |
{ | |
Channel: "Voltage", | |
Value: em.voltage, | |
CustomUnit: "V", | |
Float: 1, | |
DecimalMode: 3 | |
}, | |
{ | |
Channel: "Frequency", | |
Value: em.freq, | |
CustomUnit: "Hz", | |
Float: 1, | |
DecimalMode: 3 | |
}, | |
{ | |
Channel: "Current", | |
Value: em.current, | |
CustomUnit: "A", | |
Float: 1, | |
DecimalMode: 3 | |
}, | |
{ | |
Channel: "Total Energy", | |
Value: em.aenergy.total, | |
CustomUnit: "Wh", | |
Float: 1, | |
DecimalMode: 3 | |
}, | |
{ | |
Channel: "Output", | |
Value: em.output ? 1 : 0, | |
CustomUnit: "ON" | |
}, | |
{ | |
Channel: "Switch", | |
Value: ip.state ? 1 : 0, | |
CustomUnit: "Pos" | |
}, | |
] | |
} | |
}) | |
response.code = 200 | |
response.send() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment