Node-red TASMOTA OTA proxy

Node-red TASMOTA OTA proxy

[
    {
        "id": "7a1f2f6b.2f82e",
        "type": "http in",
        "z": "c7f7cbb6.9992c8",
        "name": "",
        "url": "/sonoff",
        "method": "get",
        "swaggerDoc": "",
        "x": 150,
        "y": 1020,
        "wires": [
            [
                "74c3ccd3.c67794"
            ]
        ]
    },
    {
        "id": "26df0774.223c58",
        "type": "http response",
        "z": "c7f7cbb6.9992c8",
        "name": "",
        "x": 750,
        "y": 1020,
        "wires": []
    },
    {
        "id": "d485cd38.338af",
        "type": "function",
        "z": "c7f7cbb6.9992c8",
        "name": "download",
        "func": "context.global.https.get(msg.payload, function(res) { \n  var d = [];\n  res.on('data', function(c) {\n    d.push(c);\n  })\n  res.on('end', function(c) {\n    msg.payload = Buffer.concat(d);\n    node.send(msg);\n  })\n})\n\nreturn;",
        "outputs": 1,
        "noerr": 0,
        "x": 560,
        "y": 1020,
        "wires": [
            [
                "26df0774.223c58"
            ]
        ]
    },
    {
        "id": "74c3ccd3.c67794",
        "type": "function",
        "z": "c7f7cbb6.9992c8",
        "name": "get latest",
        "func": "var options = {\n  hostname: 'api.github.com',\n  path: '/repos/arendst/Sonoff-MQTT-OTA-Arduino/releases/latest',\n  headers: {\n    'User-Agent': 'node-red'\n  }\n};\n\ncontext.global.https.get(options, function(res) { \n  var d = [];\n  res.on('data', function(c) {\n    d.push(c);\n  })\n  res.on('end', function(c) {\n    msg.payload = JSON.parse(Buffer.concat(d)).assets[0].browser_download_url;\n    node.send(msg);\n  })\n})\n\nreturn;",
        "outputs": 1,
        "noerr": 0,
        "x": 360,
        "y": 1020,
        "wires": [
            [
                "d485cd38.338af"
            ]
        ]
    }
]
wiktorschmidt

Flow Info

created 5 months, 2 weeks ago

Node Types

Core
  • function (x2)
  • http in (x1)
  • http response (x1)

Tags

  • sonoff
  • TASMOTA
  • OTA
  • proxy
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option