# "light toggle" does not work

**URL:** <https://klipper.discourse.group/t/light-toggle-does-not-work/13528>\
**Category:** General Discussion\
**Created:** [January 26, 2024, 6:46pm UTC](https://klipper.discourse.group/t/light-toggle-does-not-work/13528 "2024-01-26T18:46:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bybarbaros](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/bybarbaros/32/8853_2.png) [@bybarbaros](https://klipper.discourse.group/u/bybarbaros)\
**Post date:** [January 26, 2024, 6:46pm UTC](https://klipper.discourse.group/t/light-toggle-does-not-work/13528/1 "2024-01-26T18:46:25Z")

</div>

Friends. I want to run the light control macro. “on” and “off” buttons work. I can’t run “light toggle”. This may not be an obstacle in terms of usage. But I want to add a physical button to my printer and turn the lights on and off with a single button. I couldn’t find where I made a mistake. I need your help.  
 ![light_toggle](https://global.discourse-cdn.com/free1/uploads/klipper/original/2X/e/e94f7271ff8a18f63490179eb06c0735538dc2c8.png)  
[light\_control.txt](https://klipper.discourse.group/uploads/short-url/5GrP5jsyQCcLFMVYTBlCHaXGIjy.txt) (1.4 KB)

---

<div class="post-metadata">

**Author:** ![EddyMI3D](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/eddymi3d/32/1981_2.png) [@EddyMI3D](https://klipper.discourse.group/u/EddyMI3D)\
**Post date:** [January 26, 2024, 7:25pm UTC](https://klipper.discourse.group/t/light-toggle-does-not-work/13528/2 "2024-01-26T19:25:54Z")

</div>

For you was greeted with this text when you opened this thread:

* * *

[DELETE\_ME\_AFTER\_READING]  
This category is for posting **working macros only**. It is **not** intended for support or questions.  
[/DELETE\_ME\_AFTER\_READING]

* * *

I’ll move your thread.

---

<div class="post-metadata">

**Author:** ![bybarbaros](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/bybarbaros/32/8853_2.png) [@bybarbaros](https://klipper.discourse.group/u/bybarbaros)\
**Post date:** [January 27, 2024, 3:23am UTC](https://klipper.discourse.group/t/light-toggle-does-not-work/13528/3 "2024-01-27T03:23:32Z")

</div>

I am really sad. I couldn’t understand it because it’s not my native language. Thank you.

---

<div class="post-metadata">

**Author:** ![theophile](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/theophile/32/31_2.png) [@theophile](https://klipper.discourse.group/u/theophile)\
**Post date:** [January 28, 2024, 9:07pm UTC](https://klipper.discourse.group/t/light-toggle-does-not-work/13528/4 "2024-01-28T21:07:31Z")

</div>

The only thing I can think of to try would be something like this:

```auto
[gcode_macro lights_off]
gcode:
    SET_PIN PIN=caselight VALUE=0|int
 
[gcode_macro lights_on]
gcode:
    SET_PIN PIN=caselight VALUE=20|int
 
[gcode_macro lights_toggle]
gcode:
    {% if (printer["output_pin caselight"].value)|int == 20 %}
        lights_off
    {% else %}
        lights_on
    {% endif %}

```

---

<div class="post-metadata">

**Author:** ![bybarbaros](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/bybarbaros/32/8853_2.png) [@bybarbaros](https://klipper.discourse.group/u/bybarbaros)\
**Post date:** [January 28, 2024, 10:32pm UTC](https://klipper.discourse.group/t/light-toggle-does-not-work/13528/5 "2024-01-28T22:32:49Z")

</div>

theophile thanks. 🙏I somehow got it working today by chance. everything is okay right now. I will definitely try the arrangement you wrote. Thank you again for your help.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/klipper/original/1X/64419bf2aac6639e6ef5cef200dcd456b0a01ac3.png) [@system](https://klipper.discourse.group/u/system)\
**Post date:** [March 28, 2024, 10:33pm UTC](https://klipper.discourse.group/t/light-toggle-does-not-work/13528/6 "2024-03-28T22:33:39Z")

</div>

Closed on March 28, 2024, 10:33pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
