Skip to content

Implement night mode support and improve startup sequence - #33

Draft
penguineer wants to merge 4 commits into
masterfrom
nightmode
Draft

Implement night mode support and improve startup sequence#33
penguineer wants to merge 4 commits into
masterfrom
nightmode

Conversation

@penguineer

Copy link
Copy Markdown
Member

This pull request adds a "nightmode" feature to the LED control service, allowing the LEDs to be turned off at night except for a brief period after a state change. The implementation introduces new MQTT topic handling, state tracking, and timing logic to manage visibility during nightmode. It also improves startup and shutdown behavior for the LEDs.

Fixes #32

Nightmode feature and MQTT integration:

  • Added support for a new MQTT topic (MQTT_NIGHTMODE_TOPIC) to enable or disable nightmode via MQTT messages. When nightmode is active, LEDs remain off except for a short visibility window after a state change. [1] [2]
  • Updated the MQTT message callback to handle both the ampel state topic and the new nightmode topic, and to manage the requested LED state and visibility timer accordingly. [1] [2]

Nightmode state management and timing:

  • Introduced global variables to track nightmode status, requested LED state, and a monotonic timer for brief visibility during nightmode. Added a helper function to get the current monotonic time. [1] [2]
  • Implemented the apply_physical_state function to control LED output based on nightmode and timer state, ensuring LEDs are only shown briefly in nightmode.
  • In the main loop, added logic to turn off LEDs automatically when the nightmode visibility timer expires.

Startup and shutdown improvements:

  • Added a startup sequence to briefly show each LED color for one second when the service starts.
  • Ensured LEDs are turned off on service shutdown for safety.

@penguineer penguineer self-assigned this Aug 27, 2026
@penguineer
penguineer marked this pull request as draft August 27, 2026 14:20
@penguineer

Copy link
Copy Markdown
Member Author

Somehow with this solution the status is not regained after rebooting wittgenstein or restarting the service. This worked before on master.

Needs further investigation.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Honor global Nightmode in ledcontrol

1 participant