node-red-contrib-afya-lullaby 0.2.0

Node-RED dimmer helper: changes a value from X to Y in Z seconds – dim the light to fall asleep or brighten it for a slow wake-up.

npm install node-red-contrib-afya-lullaby

node-red-contrib-afya-lullaby

npm license: MIT

Node-RED dimmer helper: changes a value from X to Y in Z seconds. Made for my children, who like falling asleep with the light on – it dims the light slowly. It also works the other way round, as a slow wake-up light.

English · Polski


English

The node does not control a lamp itself – it calculates the value. Use msg.payload.value for your light.

Install

cd ~/.node-red
npm install node-red-contrib-afya-lullaby

Requires Node-RED ≥ 3.0 and Node.js ≥ 18. The node appears in the AFYA palette group as lullaby.

Configuration

Field Description
Start value Value at the beginning (e.g. 100).
Stop value Value at the end (e.g. 0). Start > stop: dimming; start < stop: brightening.
Step Change per step (integer > 0).
Time Total time in seconds (20 min = 1200).
Variable Context variable with the current state – global (readable from any flow) or flow.
Name Optional label.

Input

  • any message – start (ignored while running),
  • msg.payload = "stop" or "kill" – stop at the current value.

Start from the current value (msg.payload)

Turn on Start from the number in msg.payload and send the current value as a number, e.g. the brightness of the lamp – the change starts from there instead of the configured start value:

  • above the stop value – dimming, below – brightening; equal – the node sends end at once,
  • text, objects and timestamps (a default inject) keep the configured start value,
  • Time from there: always the time above, or same speed – with 100 → 0 in 20 min, 50 → 0 takes 10 min.

Handy e.g. for a home theatre: dim from the brightness the lights have when the film starts. If the brightness comes in another property (e.g. msg.payload.brightness), move it to msg.payload with a change node first.

Output

{ "value": 57, "state": "counting", "direction": "down", "timestamp": 1764057600000 }

state: counting while running, end with the final (stop) value.

The context variable additionally holds startValue, stopValue, startTime, stopTime and can have state = killed or stopped (redeploy).

Example flow: https://flows.nodered.org/flow/ce2fe16f73fc82e2760eaaadf28991b9

Upgrading to 0.1.0

The node was registered under a wrong key in package.json (afya-panic-button) – fixed, both packages can now be installed side by side. Older nodes get the context variable when you open and save them. See change.log.


Polski

Zmienia wartość od X do Y w czasie Z sekund. Stworzony dla moich dzieci, które lubią zasypiać przy zapalonym świetle – powoli je wygasza. Działa też w drugą stronę, jako budzenie światłem.

Węzeł nie steruje lampą – tylko liczy wartość. Użyj msg.payload.value.

Instalacja

cd ~/.node-red
npm install node-red-contrib-afya-lullaby

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

Użycie

  • Start value / Stop value – od czego do czego (start > stop: gaszenie, start < stop: rozjaśnianie),
  • Step – zmiana na krok, Time – czas w sekundach (20 min = 1200),
  • Variable – zmienna global lub flow z bieżącym stanem (dostępna z innych flow),
  • dowolna wiadomość uruchamia, msg.payload = "stop" lub "kill" przerywa,
  • Start from the number in msg.payload – liczba w msg.payload (np. obecna jasność lampy) staje się wartością startową; kierunek wynika z niej, a Time from there decyduje, czy czas jest zawsze ten sam, czy prędkość (krótszy zakres – krócej). Tekst, obiekt i znacznik czasu z inject nie zmieniają startu.

Na wyjściu: { value, state, direction, timestamp }, state: counting lub end.


Marcin Chuć · MIT

Node Info

Version: 0.2.0
Updated 1 day ago
License: MIT
Rating: 5.0 1

Categories

Actions

Rate:

Downloads

21 in the last week

Nodes

  • afya-lullaby

Keywords

  • node-red
  • afya
  • lullaby
  • dimmer
  • timer
  • fade
  • light
  • fall asleep
  • wake up
  • sunrise
  • children

Maintainers