node-red-contrib-ha-ladder 0.1.0

Ladder logic for Node-RED with Home Assistant entities as I/Q (fork of @redplc/node-red-redplc)

npm install node-red-contrib-ha-ladder

node-red-contrib-ha-ladder

English · Português

Ladder logic (IEC 61131-3 style) for Node-RED, using Home Assistant entities as digital inputs/outputs.

Palette: ha-ladder / ha-ladder-sys.


Attribution / Based on redPlc

This package is a fork/adaptation of the excellent redPlc work:

Most of the ladder logic (scan, rail, contact/coil modes, function, counter, timer, flipflop, move, math, scale, compare, M/MA memory) comes from redPlc.
This fork mainly changes I/O: instead of GPIO / I / Q, contact/coil talk to HA entities.

If you use ladder in Node-RED, please also support the upstream project: redplc/redplc.


Author

Ricardo Gomes
Website: https://ricardogomes.eu
If this saved you time/pain: https://buymeacoffee.com/ricard0g0mes


English

What changes vs redPlc

redPlc HA Ladder
I / Q via GPIO modules HA entities on contact / coil
import / export Not needed for digital HA I/O
Addresses like M0.0 as external I/O entity_id such as light.luz_escritorio
redPlc colors/icons Own colors + Font Awesome icons (hal-*)

Internal memory (M, T, C, FF, …) is kept for intermediate ladder bits.

Requirements

Install

Option A — Home Assistant Node-RED addon

  1. Copy the package folder to:
    /addon_configs/<slug>_nodered/node_modules/node-red-contrib-ha-ladder
    
    (or your addon’s node_modules path)
  2. Restart the Node-RED addon
  3. In the palette: categories ha-ladder and ha-ladder-sys

Option B — npm (when published)

cd ~/.node-red
npm install node-red-contrib-ha-ladder

Restart Node-RED.

Option C — from this repo

git clone https://github.com/ricard0g0mes/node-red-contrib-ha-ladder.git
cd ~/.node-red
npm install /path/to/node-red-contrib-ha-ladder

Nodes (summary)

System (ha-ladder-sys)

Palette Node Role
hal-scan Scan inject Scan cycle (PLC-style)
hal-boot On start Pulse on startup
hal-1st First scan First cycle
hal-rail Rail Left/right rail
hal-M / hal-MA Memory Boolean / analog memory

Ladder (ha-ladder)

Palette Node Role
hal-in Contact Input: HA entity or memory
hal-out Coil Output: HA entity or memory
hal-fn Function AND/OR/XOR/NOT/triggers…
hal-cnt Counter Counter
hal-tmr Timer Timer
hal-ff Flipflop SR/RS/L/T
hal-mov Move Copy values
hal-math Math Arithmetic
hal-scl Scale Scale
hal-cmp Compare Comparisons

Contact / Coil with Home Assistant

Contact (hal-in)

  • Source ha: pick HA Server + entity_id
    • “On-like” states: on, home, open, unlocked, playing, true, 1
    • event.*: treats event state change as a pulse
  • Source mem: ladder memory (M, …) like redPlc
  • Operations: NO / NC / P (rising) / N (falling)

Coil (hal-out)

  • Source ha: calls HA services (turn_on / turn_off, or lock/cover by domain)
  • Source mem: writes a memory bit
  • Modes: Store, Set, Reset, etc. (from redPlc)

State reads: HA websocket client cache or global.homeassistant.
Writes: callService on the same client. No Supervisor hacks.

Minimal example

Goal: input_boolean.… → light.…

  1. hal-scan → hal-rail (left)
  2. hal-in (contact) → source ha, entity input_boolean.maquina_lavar_loica_em_ciclo
  3. hal-out (coil) → source ha, entity light.luz_escritorio, Store mode
  4. Deploy; ensure the HA Server is Connected

Typical flow: scan → rail → contact → coil.

Notes / limitations

  • Contact is synchronous in the scan: needs state already cached. If the HA server is not connected, the contact stays “mute”.
  • Not a replacement for complex HA automations; digital ladder + memory, with HA as I/O.
  • Visuals differ from redPlc on purpose (colors + Font Awesome) so the palette is not confusing.

License

Apache-2.0 — see LICENSE.
Original redPlc copyright: Derya Y. / Ocean — see commits and file headers.
HA Ladder modifications: Ricardo Gomes, 2026.

Links


Português

O que muda face ao redPlc

redPlc HA Ladder
I / Q via módulos GPIO Entidades HA no contact / coil
import / export Não necessários para I/O digital HA
Endereços M0.0 como I/O externo entity_id tipo light.luz_escritorio
Cores/ícones redPlc Cores próprias + ícones Font Awesome (hal-*)

Memória interna (M, T, C, FF, …) mantém-se para bits intermédios do ladder.

Requisitos

Instalação

Opção A — Home Assistant Node-RED addon

  1. Copia a pasta do pacote para:
    /addon_configs/<slug>_nodered/node_modules/node-red-contrib-ha-ladder
    
    (ou o path node_modules do teu addon)
  2. Restart do addon Node-RED
  3. Na palette: categorias ha-ladder e ha-ladder-sys

Opção B — npm (quando publicado)

cd ~/.node-red
npm install node-red-contrib-ha-ladder

Reinicia o Node-RED.

Opção C — a partir deste repo

git clone https://github.com/ricard0g0mes/node-red-contrib-ha-ladder.git
cd ~/.node-red
npm install /caminho/para/node-red-contrib-ha-ladder

Nodes (resumo)

Sistema (ha-ladder-sys)

Palette Node Função
hal-scan Scan inject Ciclo de scan (como PLC)
hal-boot On start Pulso no arranque
hal-1st First scan Primeiro ciclo
hal-rail Rail Barra esquerda/direita
hal-M / hal-MA Memory Memória booleana / analógica

Ladder (ha-ladder)

Palette Node Função
hal-in Contact Entrada: entidade HA ou memória
hal-out Coil Saída: entidade HA ou memória
hal-fn Function AND/OR/XOR/NOT/triggers…
hal-cnt Counter Contador
hal-tmr Timer Temporizador
hal-ff Flipflop SR/RS/L/T
hal-mov Move Cópia de valores
hal-math Math Aritmética
hal-scl Scale Escala
hal-cmp Compare Comparações

Contact / Coil com Home Assistant

Contact (hal-in)

  • Source ha: escolhe o HA Server + entity_id
    • Estados “on-like”: on, home, open, unlocked, playing, true, 1
    • event.*: trata mudança de estado do evento como pulso
  • Source mem: memória ladder (M, …) como no redPlc
  • Operações: NO / NC / P (rising) / N (falling)

Coil (hal-out)

  • Source ha: chama serviços HA (turn_on / turn_off, ou lock/cover conforme domínio)
  • Source mem: escreve bit de memória
  • Modos: Store, Set, Reset, etc. (herdados do redPlc)

Leitura de estado: cache do cliente websocket HA ou global.homeassistant.
Escrita: callService do mesmo cliente. Sem hacks ao Supervisor.

Exemplo mínimo

Objectivo: input_boolean.… → light.…

  1. hal-scan → hal-rail (esquerda)
  2. hal-in (contact) → source ha, entity input_boolean.maquina_lavar_loica_em_ciclo
  3. hal-out (coil) → source ha, entity light.luz_escritorio, modo Store
  4. Deploy; garante que o HA Server está Connected

Fluxo típico: scan → rail → contact → coil.

Notas / limitações

  • Contact é síncrono no scan: precisa de estado já em cache. Se o server HA não estiver ligado, o contact fica “mudo”.
  • Não substitui automações HA complexas; é ladder digital + memória, com HA como I/O.
  • Visual diferente do redPlc de propósito (cores + Font Awesome), para não confundir na palette.

Licença

Apache-2.0 — ver LICENSE.
Copyright original redPlc: Derya Y. / Ocean — ver commits e cabeçalhos nos ficheiros.
Modificações HA Ladder: Ricardo Gomes, 2026.

Links

Node Info

Version: 0.1.0
Updated 1 day ago
License: Apache-2.0
Rating: not yet rated

Categories

Actions

Rate:

Downloads

0 in the last week

Nodes

  • ha-ladder-contact
  • ha-ladder-coil
  • ha-ladder-function
  • ha-ladder-counter
  • ha-ladder-timer
  • ha-ladder-flipflop
  • ha-ladder-move
  • ha-ladder-math
  • ha-ladder-scale
  • ha-ladder-compare
  • ha-ladder-sys-inject
  • ha-ladder-sys-onstart
  • ha-ladder-sys-firstscan
  • ha-ladder-sys-rail
  • ha-ladder-m-memory
  • ha-ladder-ma-memory

Keywords

  • node-red
  • home-assistant
  • ladder
  • plc
  • iec-61131
  • ha-ladder

Maintainers

Contributors

  • Derya Y. / Ocean