Czech bidding zone (CZ) only — prices in CZK, Czech distribution tariffs.
Downloadable flow
Download node-red-tok.json and import it in Node-RED via Menu → Import. In the http request node, replace its_VASKLIC in the address with your key. The key in the path is the recommended way: the response goes through our cache. bearer authentication in the node works too (the address is then without /k/…), but the response is not stored in the cache and is slower.
The flow requests https://api.itexservices.cz/v1/k/its_VASKLIC/ted.json every 20 minutes (72 requests a day, which fits even the Free tier). For a consumption schedule, use schedule.json in the same way; for export limiting, use export.json.
Function in the flow
// output 1: current price, output 2: 1/0 cheap now
const d = msg.payload;
if (msg.statusCode !== 200 || !d || d.stav === "neplatny_klic") {
node.status({ fill: "red", shape: "ring", text: `error ${msg.statusCode}` });
return null;
}
node.status({ fill: "green", shape: "dot", text: `${d.cena_ted} CZK/kWh, ${d.uroven_ted}` });
return [{ payload: d.cena_ted }, { payload: d.levno_ted ? 1 : 0 }];Safe behavior during an API outage
The API may stop responding for a while, return an error or return stale data. Your home automation has to expect this — build it so that an outage breaks nothing:
- The relay stays in its last safe state. Without valid data, do not switch anything on because of a “cheap hour”. Return devices to the behavior the house would have without ITexSpot (boiler on a time schedule, inverter without export limiting, battery in normal mode).
- Fallback window. For loads that must run (boiler, charging), keep a fixed window in usually cheap hours, for example 1–5 am. When the data is not valid, run by that window.
- Detect invalid data. Always check the data status. In JSON it is
stav(ok,stara_data= stale data,limit,neplatny_klic= invalid key,nedostupne= unavailable), in the Loxone text outputstav_kod: 0 = OK, 1 = stale data, 401 key, 429 limit, 503 outage. Thenstari_min(age in minutes): the data changes three times a day, so overnight it is routinely up to about 16 hours old. A value above 1,800 minutes (30 h) means no new data is being produced. - A lost connection may not show in the values. Loxone and other systems keep the last value they read when the server is unreachable.
stari_min, however, grows with every successful request. When it stops changing, requests are not getting through. - On a 429 or 503 error, wait as long as the
Retry-Afterheader says and do not retry immediately.
// Shelly Gen2+ (script): relay by the ITexSpot schedule, fallback window on outage
let URL = "https://api.itexservices.cz/v1/k/its_YOURKEY/schedule.json?hodin=4";
let intervals = []; // [[start, end], …] in unix seconds
let validUntil = 0; // until when we trust the schedule
function fallbackWindow(h) { return h >= 1 && h < 5; }
function decide() {
let t = Date.now() / 1000;
let on = false;
if (t < validUntil) {
for (let i = 0; i < intervals.length; i++) {
if (t >= intervals[i][0] && t < intervals[i][1]) on = true;
}
} else {
on = fallbackWindow(new Date().getHours());
}
Shelly.call("Switch.Set", { id: 0, on: on });
}
function load() {
Shelly.call("HTTP.GET", { url: URL, timeout: 15 }, function (r, err) {
if (err !== 0 || !r || r.code !== 200) return; // keeps the last schedule
let d = JSON.parse(r.body);
if (d.stav !== "ok") return;
intervals = d.unix;
validUntil = Date.now() / 1000 + 24 * 3600;
});
}
load();
decide();
Timer.set(60 * 60 * 1000, true, load); // schedule every 1 h = 24 requests a day
Timer.set(60 * 1000, true, decide); // decided locally, no network needed