node-red-contrib-afya-week-calendar 0.2.0

Node-RED weekly time switch with states: paint states 0–15 (e.g. temperatures) or simple ON/OFF on a week calendar (drag, move, copy, stretch – like Outlook) and get the state number, its value, name or true/false by the time of day in your time zone. Ran

npm install node-red-contrib-afya-week-calendar

node-red-contrib-afya-week-calendar

npm license: MIT

Node-RED weekly time switch with states. Paint the week on a calendar – drag, move, copy and stretch blocks like in Outlook – and the node sends the current state whenever the time of day in your time zone moves into another one.

  • 2 states (0 = OFF, 1 = ON) – a plain on/off switch: true / false, 1 / 0.
  • Up to 16 states (0–15) with a name and a value each – e.g. heating 0 = 22 °C, 1 = 22.5 °C, 2 = 23.5 °C. One node sends the temperature itself – no more several on/off calendars plus a function picking the highest one.
  • Optional random ± offset of every change (presence simulation), active periods (from … to, also every year), a live current time in the node's time zone, labels in English or Polish.

English · Polski


English

Install

cd ~/.node-red
npm install node-red-contrib-afya-week-calendar

Requires Node-RED ≥ 3.0 and Node.js ≥ 18. The node appears in the AFYA palette group as week calendar. Examples: Import → Examples → node-red-contrib-afya-week-calendar (see also Example: heating).

States

State 0 is basal – all time that is not painted. States 1–15 are painted on the week and never overlap. Every state has a name and a value (number, text, true/false or JSON), set in Settings → States or with + on the toolbar. Painting over another state asks:

  • Cut at their edges – the new state only fills the free time, the others stay;
  • Paint over them – the new state replaces them inside the painted range.

The answer can be remembered until the dialog is closed.

Painting the week

Gesture What it does
Pick a state on the toolbar (keys 0–9) only blocks of that state can be moved / edited, the others are dimmed
Drag on the grid paint the state – drag sideways to paint several days at once
Click on an empty place dialog: exact times, state, more days, overnight (22:00 → 06:00)
Drag a block move it, also to another day · hold Shift = copy
Top / bottom edge of a block stretch it
Click a block edit times and state, copy to other days, delete
Ctrl / ⌘ + click on a block cut out one grid step (split it in two)
× on a block delete it
State 0, or hold Alt erase by dragging; a click deletes a block
Day name copy / paste a day, copy it to Mon–Fri, Sat–Sun or every day, clear it
Ctrl / ⌘ + Z, Ctrl / ⌘ + Shift + Z undo / redo

The grid snaps to 5, 10, 15, 30 or 60 minutes. While drawing, the time and length are shown at the cursor. Every state has its own pastel colour. The red line is now, the current block is highlighted and under the grid you see Now 10:30 · 22.5 °C · 1 h 30 min left.

Copying to other nodes

  • Export – the week, the states and the settings as JSON, or the week as plain text, with a Copy button.

  • Import – paste an export, pick another week calendar node from the list, or just type (=N = state N, nothing = state 1):

    mon-fri 05:30-07:30=2, 07:30-12:00, 12:00-19:00=2
    sat, sun 08:00-23:00
    weekend 22:00-02:00        # overnight – continues on the next day
    

    Day names in English or Polish (pn, wt, śr …), groups daily, weekdays, weekend.

  • Copying the node itself (Ctrl+C / Ctrl+V) copies its week too.

Settings

Field Description
Current time Read only, at the top of the dialog: the time ticking live on the clock of the Node-RED server, in the time zone the node works with, with its UTC offset and source (Settings / server). Warns when the server clock is off.
Labels Language of the labels and messages: system language (Polish only on a Polish system, English for every other language), English or Polski. Only texts change – fields, values and msg properties stay the same.
States Name and value of every state, add / remove the last one.
Time zone Empty = the time zone of the Node-RED server. Docker usually runs in UTC – the dialog warns you and offers your browser's zone (e.g. Europe/Warsaw). Summer/winter time is handled.
Randomize ± minutes Every change moves by a random amount up to ± this – different every day, the same after a restart, different in every node. Changes close to each other move less, so their order never changes and a short period never disappears. In the grid: hatched = random range, thin bar = the real times this week.
Active always, or only from … to … – one or more periods, both dates inclusive, an empty date = open end, every year repeats it yearly (also across the new year, e.g. 1 Dec – 31 Mar). Outside the periods the node is in state 0.
Payload true / false or "on" / "off" (only with 2 states), the state number, the value of the state, the name of the state, or all of them as an object { level, value, name, state }.
Topic Optional msg.topic.
Send the state after deploy Sends the current state once after deploy / restart.
Variable global or flow context variable with the state (readable from any flow).

Input

msg Effect
anything answers with the current state (the message is passed on)
level = N manual state N (0–15) until the schedule itself changes next time (like a thermostat)
payload = "on" / "off" / "toggle" manual state 1 / 0 until the next scheduled change
payload = "auto" back to the schedule
payload = "disable" / "enable", or msg.enable = false / true switch the node off (state 0) and on again – until redeploy
schedule new week until redeploy: the export (JSON or text), { mon: ["07:00-09:00=2"], … } or 7 lists of [startMinute, endMinute, state]

Output

Sent on every change (checked at every full minute), after deploy (optional) and as an answer to every input message. Use whichever you need – msg.payload as chosen, and msg.calendar always has the number, the value and the name:

{
  "payload": 23.5,
  "topic": "heating/calendar/kitchen",
  "calendar": {
    "level": 2, "name": "23.5 °C", "value": 23.5, "state": true, "reason": "schedule",
    "scheduled": true, "scheduledLevel": 2, "enabled": true, "active": true,
    "next": { "level": 1, "name": "22.5 °C", "value": 22.5, "state": true,
              "date": "2026-11-28", "time": "19:00", "label": "19:00", "inMinutes": 495 },
    "periodChange": null, "timezone": "Europe/Warsaw", "localTime": "2026-11-28 10:45", "randomize": 0
  }
}

reason: schedule, override (manual), disabled or inactive (outside the active periods). The context variable holds the same object plus value (what the node sends), stateValue and timestamp.

Status

At the dot: current time · state · how long it still lasts, e.g. 10:44 · 23.5 °C · 8 h 16 min left, 10:44 · OFF · 2 h left, 10:44 · ON (manual) · 1 h left, 10:44 · inactive · from 2026-12-01, 10:44 · disabled · OFF.

Example: heating with states

Why. The classic way needs 2 on/off calendars per room (one per temperature), a sync delay, a function picking the highest active temperature and a tick every 15 s. With states it is one calendar per room: 0 = basal temperature, 1, 2 … = higher temperatures, and the value of a state is the temperature – the calendar sends a ready temperature and states never overlap. Thermostats run on batteries and every command wakes them up, so the example sends a command only when the target changes (a few times a day).

What is inside. 4 × week calendar (Payload: value of the state, variable flow.heat_<room>) → one function Heating – MQTT with a table of rooms (ROOMS) → 1 command / s → MQTT out. The function retries at most 3 times (after 5, 15, 60 min) and only when a thermostat itself reports another value; the 15-minute bathroom boost (remote or inject) is ended by a timer. No tick, no change nodes. Set your broker in MQTT broker and the devices in ROOMS (radiator-1 … 4, remote-1). The same flow with Polish labels: Import → Examples → AFYA Week Calendar – ogrzewanie na stanach (PL).

Flow JSON – copy and import (Ctrl+I)
[
  {"id":"b86daf445e5b541d","type":"comment","name":"Heating with states – an AFYA calendar per room sends the temperature, one function drives the thermostats","info":"WHY THIS WAY\n• Before: 2 on/off week calendars per room (one per temperature) + a 0.5 s sync delay + a function picking the highest active temperature + a tick every 15 s.\n• Now: ONE calendar per room with states – 0 = basal temperature, 1, 2 … = higher temperatures. The value of a state is the temperature, so the calendar sends a ready temperature and states never overlap (no \"who wins\").\n• Thermostats run on batteries – every command wakes them up. So the function sends a command ONLY when the target temperature changes (a few times a day), retries at most 3 times (after 5, 15, 60 min) and only when the thermostat itself reports another value, and the bathroom boost is ended by a timer – no tick, no change nodes.\n\nWHAT IS INSIDE\n• 4 × AFYA week calendar (Payload: value of the state, variable flow.heat_<room>)\n• 1 function \"Heating – MQTT\" with a table of rooms (ROOMS) – put your devices here\n• thermostat reports (mqtt in), bathroom remote + boost / cancel injects, 1 command / s limiter, MQTT out\n\nSet your broker in \"MQTT broker\".","x":470,"y":30,"wires":[]},
  {"id":"9a2f40f99333169b","type":"afya-week-calendar","name":"Kitchen + living room – heating","x":230,"y":90,"wires":[["c4241e64121ef3c8"]],"schedule":[[[330,450,2],[450,720,1],[720,1140,2],[1140,1320,1]],[[330,450,2],[450,720,1],[720,1140,2],[1140,1320,1]],[[330,450,2],[450,720,1],[720,1140,2],[1140,1320,1]],[[330,450,2],[450,720,1],[720,1140,2],[1140,1320,1]],[[330,450,2],[450,720,1],[720,1140,2],[1140,1320,1]],[[330,1140,2],[1140,1320,1]],[[330,1140,2],[1140,1320,1]]],"snap":15,"states":[{"name":"22 °C","value":"22","vt":"num"},{"name":"22.5 °C","value":"22.5","vt":"num"},{"name":"23.5 °C","value":"23.5","vt":"num"}],"timezone":"Europe/Warsaw","randomize":0,"periodMode":"always","periods":[],"outputType":"value","topic":"heating/calendar/kitchen","sendOnStart":true,"lang":"auto","variableName":"heat_kitchen","scope":"flow"},
  {"id":"631a677193377742","type":"mqtt in","name":"radiator – kitchen + living room","x":230,"y":140,"wires":[["c4241e64121ef3c8"]],"topic":"zigbee2mqtt/radiator-1","qos":"0","datatype":"json","broker":"32df765dc1e7e5ff","nl":false,"rap":false,"rh":0,"inputs":0},
  {"id":"358f0488bf7c275c","type":"afya-week-calendar","name":"Kids room – heating","x":230,"y":210,"wires":[["c4241e64121ef3c8"]],"schedule":[[[330,450,2],[720,1140,1]],[[330,450,2],[720,1140,1]],[[330,450,2],[720,1140,1]],[[330,450,2],[720,1140,1]],[[330,450,2],[720,1140,1]],[[330,570,2],[570,1140,1]],[[330,570,2],[570,1140,1]]],"snap":15,"states":[{"name":"22 °C","value":"22","vt":"num"},{"name":"22.5 °C","value":"22.5","vt":"num"},{"name":"23 °C","value":"23","vt":"num"}],"timezone":"Europe/Warsaw","randomize":0,"periodMode":"always","periods":[],"outputType":"value","topic":"heating/calendar/kids","sendOnStart":true,"lang":"auto","variableName":"heat_kids","scope":"flow"},
  {"id":"c0de31263c6383e1","type":"mqtt in","name":"radiator – kids room","x":230,"y":260,"wires":[["c4241e64121ef3c8"]],"topic":"zigbee2mqtt/radiator-2","qos":"0","datatype":"json","broker":"32df765dc1e7e5ff","nl":false,"rap":false,"rh":0,"inputs":0},
  {"id":"7d6c94221e3fa0d6","type":"afya-week-calendar","name":"Bedroom – heating","x":230,"y":330,"wires":[["c4241e64121ef3c8"]],"schedule":[[[330,450,2],[720,1140,1]],[[330,450,2],[720,1140,1]],[[330,450,2],[720,1140,1]],[[330,450,2],[720,1140,1]],[[330,450,2],[720,1140,1]],[[330,570,2],[570,1140,1]],[[330,570,2],[570,1140,1]]],"snap":15,"states":[{"name":"22 °C","value":"22","vt":"num"},{"name":"23 °C","value":"23","vt":"num"},{"name":"23.5 °C","value":"23.5","vt":"num"}],"timezone":"Europe/Warsaw","randomize":0,"periodMode":"always","periods":[],"outputType":"value","topic":"heating/calendar/bedroom","sendOnStart":true,"lang":"auto","variableName":"heat_bedroom","scope":"flow"},
  {"id":"a6e5997e016588e1","type":"mqtt in","name":"radiator – bedroom","x":230,"y":380,"wires":[["c4241e64121ef3c8"]],"topic":"zigbee2mqtt/radiator-3","qos":"0","datatype":"json","broker":"32df765dc1e7e5ff","nl":false,"rap":false,"rh":0,"inputs":0},
  {"id":"f7c97ce07fee1039","type":"afya-week-calendar","name":"Bathroom – heating","x":230,"y":450,"wires":[["c4241e64121ef3c8"]],"schedule":[[[330,570,2],[720,1080,1],[1080,1320,2]],[[330,570,2],[720,1080,1],[1080,1320,2]],[[330,570,2],[720,1080,1],[1080,1320,2]],[[330,570,2],[720,1080,1],[1080,1320,2]],[[330,570,2],[720,1080,1],[1080,1320,2]],[[330,570,2],[570,1080,1],[1080,1320,2]],[[330,570,2],[570,1080,1],[1080,1320,2]]],"snap":15,"states":[{"name":"22 °C","value":"22","vt":"num"},{"name":"23.5 °C","value":"23.5","vt":"num"},{"name":"36 °C","value":"36","vt":"num"}],"timezone":"Europe/Warsaw","randomize":0,"periodMode":"always","periods":[],"outputType":"value","topic":"heating/calendar/bathroom","sendOnStart":true,"lang":"auto","variableName":"heat_bathroom","scope":"flow"},
  {"id":"c369afda804f41b2","type":"mqtt in","name":"radiator – bathroom","x":230,"y":500,"wires":[["c4241e64121ef3c8"]],"topic":"zigbee2mqtt/radiator-4","qos":"0","datatype":"json","broker":"32df765dc1e7e5ff","nl":false,"rap":false,"rh":0,"inputs":0},
  {"id":"91972f61cd0654bb","type":"mqtt in","name":"remote – bathroom","x":230,"y":570,"wires":[["c4241e64121ef3c8"]],"topic":"zigbee2mqtt/remote-1","qos":"0","datatype":"json","broker":"32df765dc1e7e5ff","nl":false,"rap":true,"rh":2,"inputs":0},
  {"id":"acefe20f1c476616","type":"inject","name":"Boost bathroom 15 min","x":250,"y":620,"wires":[["c4241e64121ef3c8"]],"props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"heating/boost/bathroom","payload":"","payloadType":"date"},
  {"id":"6e23aa7198200b7c","type":"inject","name":"Cancel boost","x":250,"y":670,"wires":[["c4241e64121ef3c8"]],"props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"heating/cancel/bathroom","payload":"","payloadType":"date"},
  {"id":"c4241e64121ef3c8","type":"function","name":"Heating – MQTT","x":600,"y":400,"wires":[["855a6e62d851a7b8"]],"func":"// One function for the whole house. Every AFYA week calendar sends the temperature of its room\n// (Payload: value of the state) and keeps it in flow.<calendar>. Here only BOOST and MQTT.\n// A thermostat gets a command ONLY when its target changes – no tick, batteries last.\nconst ROOMS = {\n    kitchen: { device: 'radiator-1', calendar: 'heat_kitchen' },\n    kids: { device: 'radiator-2', calendar: 'heat_kids' },\n    bedroom: { device: 'radiator-3', calendar: 'heat_bedroom' },\n    bathroom: { device: 'radiator-4', calendar: 'heat_bathroom', maxTemperature: 36,\n        boostTemperature: 36, boostMinutes: 15, remote: 'zigbee2mqtt/remote-1' },\n};\nconst RETRY = [5, 15, 60]; // minutes – resend only when the thermostat reports another value, then give up\n\nconst t = msg.topic || '';\nconst p = msg.payload;\nconst key = Object.keys(ROOMS).find((k) => {\n    const r = ROOMS[k];\n    return t === 'heating/calendar/' + k || t === 'heating/boost/' + k || t === 'heating/cancel/' + k ||\n        t === 'zigbee2mqtt/' + r.device || (r.remote && t === r.remote);\n});\nif (!key) return null;\nconst room = ROOMS[key];\nconst ctx = context.get(key) || { sent: {}, state: {}, boostUntil: 0 };\n\nconst startBoost = () => {\n    ctx.boostUntil = Date.now() + room.boostMinutes * 60000;\n    // end of the boost: wake up once, exactly when it is over\n    setTimeout(() => {\n        const out = update();\n        if (out.length) node.send([out]);\n    }, room.boostMinutes * 60000 + 1000);\n};\nif (room.remote && t === room.remote) {\n    if (msg.retain || !p || p.action !== 'toggle') return null;\n    startBoost();\n} else if (t === 'heating/boost/' + key) startBoost();\nelse if (t === 'heating/cancel/' + key) ctx.boostUntil = 0;\nelse if (t === 'zigbee2mqtt/' + room.device && p && typeof p === 'object') ctx.state = { ...ctx.state, ...p };\ncontext.set(key, ctx);\n\nfunction update() {\n    const now = Date.now();\n    const c = context.get(key) || ctx;\n    if (c.boostUntil && c.boostUntil <= now) c.boostUntil = 0;\n    const cal = flow.get(room.calendar); // { value: 22.5, name: '22.5 °C', level: 1, next: {…}, … }\n    if (typeof cal?.value !== 'number') return []; // the calendar has not started yet\n    const target = c.boostUntil ? room.boostTemperature : cal.value;\n    const desired = { preset: 'manual', ...(room.maxTemperature ? { max_temperature: room.maxTemperature } : {}),\n        current_heating_setpoint: target };\n    const out = [];\n    for (const [k, v] of Object.entries(desired)) {\n        const prev = c.sent[k];\n        const reported = c.state[k];\n        let send = !prev || prev.value !== v; // a new target\n        if (!send && reported !== undefined && reported !== v && prev.tries < RETRY.length &&\n            now - prev.at >= RETRY[prev.tries] * 60000) send = true; // the thermostat did not take it – retry\n        if (send) {\n            out.push({ topic: 'zigbee2mqtt/' + room.device + '/set', payload: { [k]: v }, retain: false });\n            c.sent[k] = { value: v, at: now, tries: prev && prev.value === v ? prev.tries + 1 : 0 };\n        }\n    }\n    context.set(key, c);\n    const targets = { ...(context.get('targets') || {}), [key]: target + (c.boostUntil ? ' BOOST' : '') };\n    context.set('targets', targets);\n    node.status({ fill: Object.values(targets).some((x) => String(x).includes('BOOST')) ? 'yellow' : 'green', shape: 'dot',\n        text: Object.entries(targets).map(([k, v]) => k + ' ' + v).join(' · ') });\n    return out;\n}\n\nconst out = update();\nreturn out.length ? [out] : null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[]},
  {"id":"855a6e62d851a7b8","type":"delay","name":"1 command / s","x":840,"y":400,"wires":[["624781c212d432ff","e4713f0b99188314"]],"pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1},
  {"id":"624781c212d432ff","type":"mqtt out","name":"Thermostats /set","x":1080,"y":370,"wires":[],"topic":"","qos":"1","retain":"false","broker":"32df765dc1e7e5ff"},
  {"id":"e4713f0b99188314","type":"debug","name":"Thermostat commands","x":1090,"y":430,"wires":[],"active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full"},
  {"id":"32df765dc1e7e5ff","type":"mqtt-broker","name":"MQTT broker","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}
]

Polski

Tygodniowy zegar sterujący ze stanami. Malujesz tydzień na kalendarzu – przeciągasz, przesuwasz, kopiujesz i rozciągasz bloki jak w Outlooku (i jak w grafiku kręgielni) – a węzeł wysyła aktualny stan za każdym razem, gdy godzina w Twojej strefie czasowej przechodzi w inny stan.

  • 2 stany (0 = OFF, 1 = ON) – zwykły włącznik: true / false, 1 / 0.
  • Do 16 stanów (0–15), każdy z nazwą i wartością – np. ogrzewanie 0 = 22 °C, 1 = 22.5 °C, 2 = 23.5 °C. Jeden węzeł sam wysyła temperaturę – bez kilku kalendarzy true/false i funkcji wybierającej najwyższą.

Instalacja

cd ~/.node-red
npm install node-red-contrib-afya-week-calendar

Wymaga Node-RED ≥ 3.0 i Node.js ≥ 18. Węzeł week calendar jest w grupie palety AFYA.

Stany

Stan 0 jest bazowy – to cały niezamalowany czas. Stany 1–15 malujesz na tygodniu, nie mogą się nakładać. Każdy ma nazwę i wartość (liczba, tekst, true/false, JSON) – w Ustawienia → Stany albo przyciskiem + na pasku. Malowanie na innym stanie pyta: przyciąć do jego granic (nowy stan wypełni tylko wolny czas) czy nanieść na niego (nowy stan go zastąpi w malowanym zakresie); wybór można zapamiętać do zamknięcia okna.

Malowanie

  • wybierz stan na pasku (klawisze 0–9) – przesuwasz i edytujesz tylko jego bloki, pozostałe są przygaszone,
  • przeciągnij po siatce – maluj; w bok – kilka dni naraz,
  • klik w puste miejsce – dokładne godziny, stan, więcej dni, przez północ (22:00 → 06:00),
  • przeciągnij blok – przesuń (też na inny dzień), z Shift – kopiuj,
  • górna / dolna krawędź – rozciągnij, klik w blok – edycja, × – usuń,
  • Ctrl / ⌘ + klik – wytnij jeden krok siatki, stan 0 albo Alt – gumka,
  • nazwa dnia – kopiuj / wklej dzień, kopiuj na pn–pt, weekend, każdy dzień, wyczyść,
  • Ctrl / ⌘ + Z – cofnij, Ctrl / ⌘ + Shift + Z – ponów.

Każdy stan ma swój pastelowy kolor. Czerwona linia to teraz, bieżący blok jest podświetlony, a pod siatką widać Teraz 10:30 · 22.5 °C · zostało 1 h 30 min.

Ustawienia

  • Bieżący czas – na górze okna, tylko do odczytu: czas z zegara serwera Node-RED (tyka co sekundę) w strefie, w której węzeł działa, z przesunięciem UTC i źródłem strefy; ostrzega, gdy zegar serwera się spóźnia lub śpieszy.
  • Etykiety – język opisów i komunikatów: język systemu (polski tylko w polskim systemie, w każdym innym angielski), English albo Polski. Zmieniają się tylko teksty – pola, wartości i właściwości msg zostają takie same.
  • Stany – nazwa i wartość każdego stanu, dodaj / usuń ostatni.
  • Strefa czasowa – puste = strefa serwera Node-RED. Docker zwykle działa w UTC – okno to pokazuje i podpowiada strefę przeglądarki (np. Europe/Warsaw); czas letni/zimowy jest obsłużony.
  • Losowanie ± minut – każda zmiana przesuwa się losowo o maks. ± tyle minut, codziennie inaczej (symulacja obecności), po restarcie tak samo, w każdym węźle inaczej; kolejność zmian się nie zmienia i krótki okres nie znika.
  • Okres działania – zawsze albo od … do … (włącznie, puste = bez końca, co roku – też przez Nowy Rok, np. sezon grzewczy 1 XII – 31 III). Poza okresem węzeł jest w stanie 0.
  • Payload – true / false lub "on" / "off" (tylko przy 2 stanach), numer stanu, wartość stanu, nazwa stanu albo wszystko naraz jako obiekt { level, value, name, state }; Temat; wysyłka stanu po deployu; Zmienna – global / flow ze stanem.

Wejście i wyjście

Dowolna wiadomość – aktualny stan; msg.level = N – ręcznie stan N do najbliższej zmiany w grafiku; on / off / toggle; auto – powrót do grafiku; enable / disable (lub msg.enable); msg.schedule – nowy tydzień do redeployu.

Wyjście przy każdej zmianie (sprawdzane co pełną minutę): msg.payload wg ustawienia, a msg.calendar zawsze ma level (numer), value (wartość) i name (nazwę) – korzystasz z tego, czego potrzebujesz. Status przy kropce: godzina · stan · ile jeszcze, np. 10:44 · 23.5 °C · zostało 8 h 16 min.

Przykład: ogrzewanie na stanach

Dlaczego. Klasycznie potrzeba 2 kalendarzy włącz/wyłącz na pokój (po jednym na temperaturę), opóźnienia do synchronizacji, funkcji wybierającej najwyższą temperaturę i ticka co 15 s. Ze stanami to jeden kalendarz na pokój: 0 = temperatura bazowa, 1, 2 … = wyższe temperatury, wartość stanu to temperatura – kalendarz wysyła gotową temperaturę, a stany się nie nakładają. Termostaty są na baterie i każde polecenie je budzi, więc przykład wysyła polecenie tylko przy zmianie docelowej temperatury (kilka razy dziennie).

Co jest w środku. 4 × week calendar (Payload: wartość stanu, zmienna flow.heat_<pokój>) → jedna funkcja Ogrzewanie – MQTT z tabelką pokoi (ROOMS) → 1 polecenie / s → MQTT out. Ponawia najwyżej 3 razy (po 5, 15, 60 min) i tylko gdy termostat sam zgłosi inną wartość; 15-minutowe dogrzewanie łazienki (pilot albo inject) kończy timer. Bez ticka i bez węzłów change. W Node-RED: Import → Examples → AFYA Week Calendar – ogrzewanie na stanach (PL) (wersja angielska: heating with states (EN), różnią się tylko opisy). Ustaw swój broker w Broker MQTT i urządzenia w ROOMS.


Marcin Chuć · MIT

Node Info

Version: 0.2.0
Updated 8 hours ago
License: MIT
Rating: not yet rated

Categories

Actions

Rate:

Downloads

0 in the last week

Nodes

  • afya-week-calendar

Keywords

  • node-red
  • afya
  • week
  • calendar
  • schedule
  • scheduler
  • timer
  • time switch
  • timeswitch
  • weekly
  • time zone
  • random
  • presence simulation
  • heating
  • thermostat
  • states
  • lights

Maintainers