The APCACCESS is a little bit broken and reports network errors the whole time. I started to play arround with the apcaccess output on the console and build a flow to extract the information and turn them into objects with a function node. Hope i helped somebody with that.
-
-
Save Dud3z/fc403e2cd768cc1d8cbe58e99f941eed to your computer and use it in GitHub Desktop.
Get data from APCUPSD
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
[{"id":"9943bf81dd01ebe6","type":"exec","z":"97f8641c.552078","command":"sudo apcaccess status -u","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":1650,"y":160,"wires":[["c5e21d8231c01359"],[],[]]},{"id":"05b154bbf98b3ae5","type":"inject","z":"97f8641c.552078","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":1420,"y":160,"wires":[["9943bf81dd01ebe6"]]},{"id":"c5e21d8231c01359","type":"function","z":"97f8641c.552078","name":"","func":"const lines = msg.payload.split(\"\\n\");\nlet result = {};\n\nfor (let i = 0; i < lines.length ; i++) {\n const line = lines[i].trim();\n if(!line) continue;\n let parts = line.split(\":\");\n if(parts.length != 2) continue;\n let key = parts[0].trim();\n let val = parts[1].trim();\n if(key != \"SER\" && isNumeric(val)) val = Number(val)\n result[key] = val;\n}\n\nmsg.payload = result;\nreturn msg;\n\nfunction isNumeric(n) {\n return !isNaN(parseFloat(n)) && isFinite(n);\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1880,"y":140,"wires":[["26f9cb02d64e46be"]]},{"id":"26f9cb02d64e46be","type":"debug","z":"97f8641c.552078","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":2050,"y":140,"wires":[]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment