Skip to content

Allow use of toggle switch instead of momentary push button to change light state - #19

Open
jjsat wants to merge 1 commit into
thomst08:masterfrom
jjsat:toggle_switch
Open

jjsat wants to merge 1 commit into
thomst08:masterfrom
jjsat:toggle_switch

Conversation

@jjsat

@jjsat jjsat commented Sep 13, 2026

Copy link
Copy Markdown

This change adds the option of using a toggle switch to control the light state. It can be selected whether the light follows the switch state (light on = switch on) or if the logic should be inverted.

Also adds a new custom gcode that toggles the current light state in addition to the existing on/off commands.

Motivation for this change is the use of a enclosure with a door switch that can automatically turn on the light when the door is opened and turn it off again when closing the door. It is still possible to override this behaviour and toggle the light state at will with the light bulb button in the web UI.

… State of light then depends on switch on/off (direct or inverted logic selectable).
@thomst08

Copy link
Copy Markdown
Owner

Hmmmm, interesting idea... I like what you have here.
Let me setup a test for it and make sure everything is working as expected.
Looking at the code, everything seems fine, so I don't see any major issues.

Good work :)
I'll let you know if I find any issues. Please give me a moment, I am a bit pressed for time so it might take me a little while to get to this.

@jjsat

jjsat commented Sep 14, 2026

Copy link
Copy Markdown
Author

As an additional info: the reason for adding the TOGGLE gcode is that I wanted to easily switch the light using OctoDash. So I added a button there that executes the gcode ( https://github.com/jjsat/OctoDash/tree/light_switch ). It can also be just added into the action bar as a custom action.
image
Otherwise this change would not be necessary for the toggle button support.

Thanks for taking the time to review.

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