Skip to content

relay(all): boot & sync refactoring#2654

Merged
mcspr merged 34 commits intodevfrom
relay-flags
Nov 28, 2025
Merged

relay(all): boot & sync refactoring#2654
mcspr merged 34 commits intodevfrom
relay-flags

Conversation

@mcspr
Copy link
Collaborator

@mcspr mcspr commented Nov 26, 2025

  • support sync mode at boot and in timers. boot mode also introduces separate ON & OFF delays specifically for handling sync mode in bulk w/o accessing individual relay settings
  • boot sync ID configuration to control which relay drives synchronization behaviour during boot
    by default, last relay boot'ed is used for status.
  • properly retain hw gpio relay status when rebooting & deal with sync cases. fallback to normal setup when dealing with mixed relay provider configurations. currently, only hw gpio flagged as 'retain'ing
  • relays now keep all status transition timers in a shared pool. mqtt disconnect, pulse & on / off delay cannot overlap
  • some api calls try to avoid relays that were not boot'ed yet processing must happen at least once for it to begin working. internal api tracks 'first time' relay status is set. whenever any other call happens internally, it may override the initial one with something else
  • various clean-ups in public & private api reuse. for one, internals now prefer internal (sic) funcs to at least optimize out id < .size() check when it is already known / parsed that id < .size()

- support sync mode at boot, apply based on specific ID change
  default to the last relay ID for setting status
  (set as build flag / setting otherwise)
- retain hw gpio relay status when rebooting
- relays keep timers in a shared pool
  mqtt disconnect, pulse & on / off delay cannot overlap
- some api calls try to avoid relays that were not boot'ed yet
  processing must happen at least once for it to begin working
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the relay boot and synchronization system to introduce shared timer management, improved boot sequence handling, and enhanced sync mode capabilities. The changes aim to unify timer handling across different relay operations and improve relay state retention across reboots.

  • Introduces a shared timer pool (BulkTimer) that manages MQTT disconnect, pulse, and on/off delay timers to prevent overlapping operations
  • Adds sync mode ID configuration to control which relay drives synchronization behavior during boot
  • Implements relay status retention for GPIO-based relays across reboots using hardware state

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
code/espurna/thermostat.cpp Simplified relayStatus() call by removing explicit forward and group report parameters
code/espurna/relay.h Updated API signatures, removed overloaded functions, added relayTimer() and improved documentation
code/espurna/relay.cpp Major refactoring including timer pool implementation, boot sequence changes, sync logic improvements, and relay activation tracking
code/espurna/config/general.h Added RELAY_SYNC_ID, RELAY_DELAY_ON, and RELAY_DELAY_OFF configuration options
code/espurna/config/defaults.h Updated relay delay defaults to use global RELAY_DELAY_ON/OFF settings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI commented Nov 26, 2025

@mcspr I've opened a new pull request, #2655, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

previously retrieving 'last relay #'
amends de8cb76
clean up cancelation logic & fix notifier

also be more diligent when discovering sync func
prefer using sync mask for delayed timers, but keep id for pulse
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mcspr mcspr merged commit 9fe8d9c into dev Nov 28, 2025
6 checks passed
@mcspr mcspr deleted the relay-flags branch November 28, 2025 19:47
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.

3 participants