[
  {
    "id": "itexspot_tab",
    "type": "tab",
    "label": "ITexSpot",
    "info": "Cena elektřiny teď z ITexSpot API (beta). Klíč its_… vložte v uzlu http request (autentizace bearer). Návod: https://www.itexservices.cz/itexspot/node-red"
  },
  {
    "id": "itexspot_inject",
    "type": "inject",
    "z": "itexspot_tab",
    "name": "á 15 min",
    "props": [],
    "repeat": "900",
    "once": true,
    "onceDelay": "5",
    "topic": "",
    "x": 130,
    "y": 100,
    "wires": [["itexspot_http"]]
  },
  {
    "id": "itexspot_http",
    "type": "http request",
    "z": "itexspot_tab",
    "name": "ITexSpot ted.json",
    "method": "GET",
    "ret": "obj",
    "paytoqs": "ignore",
    "url": "https://www.itexservices.cz/api/spot/v1/ted.json",
    "tls": "",
    "persist": false,
    "proxy": "",
    "insecureHTTPParser": false,
    "authType": "bearer",
    "senderr": false,
    "headers": [],
    "x": 330,
    "y": 100,
    "wires": [["itexspot_fn"]]
  },
  {
    "id": "itexspot_fn",
    "type": "function",
    "z": "itexspot_tab",
    "name": "cena teď / levno teď",
    "func": "// výstup 1: cena teď, výstup 2: 1/0 levno teď\nconst d = msg.payload;\nif (msg.statusCode !== 200 || !d || d.stav === \"neplatny_klic\") {\n  node.status({ fill: \"red\", shape: \"ring\", text: `chyba ${msg.statusCode}` });\n  return null;\n}\nnode.status({ fill: \"green\", shape: \"dot\", text: `${d.cena_ted} Kč/kWh, ${d.uroven_ted}` });\nreturn [{ payload: d.cena_ted }, { payload: d.levno_ted ? 1 : 0 }];",
    "outputs": 2,
    "timeout": 0,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 550,
    "y": 100,
    "wires": [["itexspot_cena"], ["itexspot_levno"]]
  },
  {
    "id": "itexspot_cena",
    "type": "debug",
    "z": "itexspot_tab",
    "name": "cena teď",
    "active": true,
    "tosidebar": true,
    "complete": "payload",
    "x": 760,
    "y": 80,
    "wires": []
  },
  {
    "id": "itexspot_levno",
    "type": "debug",
    "z": "itexspot_tab",
    "name": "levno teď",
    "active": true,
    "tosidebar": true,
    "complete": "payload",
    "x": 760,
    "y": 120,
    "wires": []
  }
]
