Skip to content

Add Interlock Mode - #463

Open
gui9394 wants to merge 1 commit into
romasku:mainfrom
gui9394:add-interlock-mode
Open

Add Interlock Mode#463
gui9394 wants to merge 1 commit into
romasku:mainfrom
gui9394:add-interlock-mode

Conversation

@gui9394

@gui9394 gui9394 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces an Interlock Mode (mutually exclusive switch mode) for multi-channel switches (devices with 2 or more relay channels).

When active, it ensures only one relay channel is active at a time. If another channel is commanded to turn on, the previously active channel is turned off first, followed by a configurable delay (in milliseconds) before the requested channel is activated.

Key Changes

1. Firmware Logic (src/zigbee/relay_cluster.c, relay_cluster.h)

  • Implemented basic interlock checks inside relay_cluster_on.
  • Added asynchronous task scheduling via hal_tasks_schedule to implement the delay without blocking the CPU.
  • Added a pending_on state tracking variable to handle race conditions under rapid sequential toggling, canceling pending relay activations when a different channel is selected.
  • Forced immediate OFF reports (hal_zigbee_send_report_attr) when a pending channel activation is canceled, keeping the controller's UI in sync with the hardware.
  • Deferred ZCL report_handler execution outside of ZCL message processing callbacks to prevent report packet drops inside command handlers.

2. Zigbee Custom Attributes (src/zigbee/consts.h, basic_cluster.c, basic_cluster.h)

  • Added 0xFF03 (ZCL_ATTR_BASIC_INTERLOCK_MODE) - Boolean.
  • Added 0xFF04 (ZCL_ATTR_BASIC_INTERLOCK_DELAY) - Uint16 (in milliseconds).
  • Enabled NVM persistence.

3. Integrations & Generators

  • Zigbee2MQTT: Updated converter templates (switch_custom.js.jinja) to automatically expose interlockMode and interlockDelay on devices with 2+ relays.
  • ZHA: Added ZHA quirk mapping support in zha_quirk.py.jinja.
  • HOMEd: Extended make_homed_extension.py.

@falkenhawk

Copy link
Copy Markdown

@gui9394 thank you. I am soo looking forward to see this included in the main build. @andrei-lazarov 🙏 I need it in order not to kill my kichen hood turbine, which never must be supplied with live over more that 1 speed at a time.

May I test the build somehow on a 4ch Avatto ZWSM16-4-ZIGBEE? I guess the definitions need to be adjusted to cover that module?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants