UNPKG

@gravypower/node-red-franklinwh

Version:

Node-RED node to control FranklinWH gateway

29 lines (25 loc) 829 B
const apiHandler = require('../../../api-handler'); module.exports = function(RED) { function FranklinWHGetGridStatusNode(config) { RED.nodes.createNode(this, config); const node = this; const server = RED.nodes.getNode(config.server); if (!server) { node.error("No credentials configured"); return; } node.on("input", async function (msg, send, done) { await apiHandler.executeWithRetry( node, server, async (api) => { return { online: await api.isGridOnline() }; }, msg, send, done ); }); } RED.nodes.registerType("franklinwh-get-grid-status", FranklinWHGetGridStatusNode); }