Git Product home page Git Product logo

klipper-ws281x_led_status's People

Contributors

11chrisadams11 avatar pycvalade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

klipper-ws281x_led_status's Issues

Moonraker power api not working.

Versions

moonraker: v0.7.1-876-g87dba2f
Klipper-WS281x_LED_Status: master, 715991aed1a3cbdbbc4c8926028d11e644ad51f8

Description

I ran the klipper_ledstrip.py from the command line. It exits with this traceback:

Traceback (most recent call last):
  File "/home/pi/Klipper-WS281x_LED_Status/./klipper_ledstrip.py", line 167, in <module>
    run()
  File "/home/pi/Klipper-WS281x_LED_Status/./klipper_ledstrip.py", line 110, in run
    if moonraker_api.power_status(moonraker_settings) == 'on':
  File "/home/pi/Klipper-WS281x_LED_Status/moonraker_api.py", line 28, in power_status
    return json.loads(ret.text)['result']['devices'][0]['status']
KeyError: 'result'

Navigating to http://<printer_ip>:7125/machine/device_power/devices gives me a 404 (in json format, thanks, moonraker). That api call looks correct from the docs. Other api calls work (like http://<printer_ip>:7125/printer/objects/query?heater_bed&extruder&display_status).

I don't have any power control in my klipper config. I think that may be the reason I am getting different results?

Let me know if I can provide any other info.

Workaround

I made these changes to get it running here:

diff --git a/klipper_ledstrip.py b/klipper_ledstrip.py
index a8d90fc..8ee21f6 100755
--- a/klipper_ledstrip.py
+++ b/klipper_ledstrip.py
@@ -107,7 +107,7 @@ def run():

             if printer_state_ == 'complete':
                 base_temps = []
-                if moonraker_api.power_status(moonraker_settings) == 'on':
+                if completion_settings['shutdown_when_complete'] and moonraker_api.power_status(moonraker_settings) == 'on':
                     shutdown_counter += 1
                     if completion_settings['shutdown_when_complete'] and shutdown_counter > 9:
                         shutdown_counter = 0

And in the config:

diff --git a/settings.conf b/settings.conf
index 82b68cd..cf3abe5 100644
--- a/settings.conf
+++ b/settings.conf
@@ -9,7 +9,7 @@ strip_settings:
   idle_timeout     : 300     # Time in seconds before LEDs turn off when on same state

 completion_settings:
-  shutdown_when_complete  : True
+  shutdown_when_complete  : False
   bed_temp_for_shutdown   : 50
   hotend_temp_for_shutdown: 40

Either the moonraker_api.py should be catching and handling the exception, or that api shouldn't be called at all if shutdown_if_complete is false. I understand why you might have added that feature here. But it honestly doesn't fit in with LED control. It might be better to just separate it into a separate project (I sure wish moonraker had a plugin system like octoprint to manage this kind of thing for me, but that is off-topic).

Thanks for all the work. I just got it running 5 mins ago, and I am happy to see it lighting up again after being off since I installed moonraker. I haven't set up the service yet, just running the command through ssh right now.

sk6812

hello, can you please tell me how to use it with a sk6812 strip. thank you

Minor typo

Hi

Firstly, thanks for putting this together, it is REALLY appreciated!

Minor, very minor, typo in your instructions I thought I'd let you know about. You have "chmod 744 ./klipper-ledstrip.py" but it should be "chmod 744 ./klipper_ledstrip.py"

Edit: Had asked a couple of questions as well but then found the Reddit thread so moved questions to there as it seemed a better place to ask.

Script behavior…

First of all Thank you! You made it possible to use NeoPixel with Klipper, that’s awesome.

I’m not quite sure if I’m getting this right.
My LEDs are on Pin 10.
When starting the script all LEDs are white. Starting the print job they stay white.
Every 5 minutes or so they change to the expected behavior an showing a green progress bar for about 2 seconds and then changing back to full white.

also when using the macros, the selected mode just stays for 1 or 2 seconds and then it changes to all white again.

Stopping the script and just use the macros, ON, WHITE and PURPLE are working, as well as useing the values in bash.

what am I missing?
Thanks for sour help.

Permission Denied ???

I´m abaut to install LED Status on klipper, i reached git clone [email protected]:11chrisadams11/Klipper-WS281x_LED_Status.git
Cloning into 'Klipper-WS281x_LED_Status'...

I get this error.

The authenticity of host 'github.com (140.82.121.3)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'github.com,140.82.121.3' (ECDSA) to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I cannot see the file on your resposity on Git.

BR Tom

settings.conf not found

Script isnt working ... it only shows

with open('settings.conf', 'r') as settings_file: FileNotFoundError: [Errno 2] No such file or directory: 'settings.conf'

or

with open('settings_sample.conf', 'r') as sample_settings_file: FileNotFoundError: [Errno 2] No such file or directory: 'settings_sample.conf'

All files stored in Klipper-WS28x_LED_Status

Direction for use correction. You cant cd in a .git

Clone code to Raspberry Pi running Klipper and Moonraker cd /home/pi git clone https://github.com/11chrisadams11/Klipper-WS281x_LED_Status.git cd Klipper-WS281x_LED_Status.git

Constant blinking and errors trying to run commands

So I just got this installed and everything went off without a issue. But now my Led strap constantly turn off, flash white, off, back to the predefined setting, i.e. Idle colors, off, full white, off, idle color. I saw a reddit post from 2 years ago saying this issue was solved in an update.

I also copied the scripts to be able to use macros to turn off the leds, make them white, or make them purple. When running the command, the console returns 'Error running command ...'

I'm at a loss of what to try. I've rebooted, ensured the service is setup correctly, verified config files. Any tips or suggestions?

Startup script not working on mailsailOS/raspbian 10

When attempting to restart the service, I get the following errors. When I run the klipper_ledstrip.py command, the LED strip response as expected.

`pi@sv01-mainsailos:/Klipper-WS281x_LED_Status $ sudo /etc/init.d/ledstrip status
/etc/init.d/ledstrip: 1: /etc/init.d/ledstrip: [Unit]: not found
/etc/init.d/ledstrip: 2: /etc/init.d/ledstrip: Python: not found
/etc/init.d/ledstrip: 5: /etc/init.d/ledstrip: [Service]: not found
/etc/init.d/ledstrip: 15: /etc/init.d/ledstrip: [Install]: not found
pi@sv01-mainsailos:
/Klipper-WS281x_LED_Status $ sudo service ledstrip status
● ledstrip.service
Loaded: loaded (/etc/init.d/ledstrip; generated)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
pi@sv01-mainsailos:/Klipper-WS281x_LED_Status $ sudo service ledstrip stop
pi@sv01-mainsailos:
/Klipper-WS281x_LED_Status $ sudo service ledstrip start
Job for ledstrip.service failed because the control process exited with error code.
See "systemctl status ledstrip.service" and "journalctl -xe" for details.
pi@sv01-mainsailos:~/Klipper-WS281x_LED_Status $ systemctl status ledstrip.service
● ledstrip.service
Loaded: loaded (/etc/init.d/ledstrip; generated)
Active: failed (Result: exit-code) since Sun 2022-08-28 11:30:40 PDT; 7s ago
Docs: man:systemd-sysv-generator(8)
Process: 28112 ExecStart=/etc/init.d/ledstrip start (code=exited, status=203/EXEC)

Aug 28 11:30:40 sv01-mainsailos systemd[1]: Starting ledstrip.service...
Aug 28 11:30:40 sv01-mainsailos systemd[28112]: ledstrip.service: Failed to execute command: Exec format error
Aug 28 11:30:40 sv01-mainsailos systemd[28112]: ledstrip.service: Failed at step EXEC spawning /etc/init.d/ledstrip: Exec format error
Aug 28 11:30:40 sv01-mainsailos systemd[1]: ledstrip.service: Control process exited, code=exited, status=203/EXEC
Aug 28 11:30:40 sv01-mainsailos systemd[1]: ledstrip.service: Failed with result 'exit-code'.
Aug 28 11:30:40 sv01-mainsailos systemd[1]: Failed to start ledstrip.service.
-- Subject: A start job for unit ledstrip.service has begun execution
-- Defined-By: systemd
-- Support: https://www.debian.org/support

-- A start job for unit ledstrip.service has begun execution.

-- The job identifier is 2008.
Aug 28 11:30:40 sv01-mainsailos systemd[28112]: ledstrip.service: Failed to execute command: Exec format error
Aug 28 11:30:40 sv01-mainsailos systemd[28112]: ledstrip.service: Failed at step EXEC spawning /etc/init.d/ledstrip: Exec format error
-- Subject: Process /etc/init.d/ledstrip could not be executed
-- Defined-By: systemd
-- Support: https://www.debian.org/support

-- The process /etc/init.d/ledstrip could not be executed and failed.

-- The error number returned by this process is ERRNO.
Aug 28 11:30:40 sv01-mainsailos systemd[1]: ledstrip.service: Control process exited, code=exited, status=203/EXEC
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: https://www.debian.org/support

-- An ExecStart= process belonging to unit ledstrip.service has exited.

-- The process' exit code is 'exited' and its exit status is 203.
Aug 28 11:30:40 sv01-mainsailos systemd[1]: ledstrip.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support

-- The unit ledstrip.service has entered the 'failed' state with result 'exit-code'.
Aug 28 11:30:40 sv01-mainsailos systemd[1]: Failed to start ledstrip.service.
-- Subject: A start job for unit ledstrip.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support

-- A start job for unit ledstrip.service has finished with a failure.

-- The job identifier is 2008 and the job result is failed.
`

-- ledstrip.service --
`cat /etc/init.d/ledstrip
[Unit]
Description=Simplified Python Klipper LED Strip Service
After=syslog.target

[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/Klipper-WS281x_LED_Status/
ExecStart=/home/pi/Klipper-WS281x_LED_Status/klipper_ledstrip.py
StandardOutput=syslog
StandardError=syslog
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target
`

Noob question - How to call/start the script before a print?

Hi,

thank you for developing this, really great and works like a charm!
But I have a bit of issues in starting the script before a print.

My idea was to start the script via a GCode shell command which I add to the start code of the slicer.
Here a snip form my printer.cfg:

[gcode_shell_command led_off]
command: sudo /home/pi/klipper_ledstrip.py 0 0 0
timeout: 2.
verbose: True

[gcode_shell_command led_white]
command: sudo /home/pi/klipper_ledstrip.py 255 255 255
timeout: 2.
verbose: True

[gcode_shell_command status_led]
command: sudo /home/pi/klipper_ledstrip.py
timeout: 2.
verbose: True

[gcode_macro LED_OFF]
gcode:
RUN_SHELL_COMMAND CMD=led_off

[gcode_macro LED_WHITE]
gcode:
RUN_SHELL_COMMAND CMD=led_white

[gcode_macro STATUS_LED]
gcode:
RUN_SHELL_COMMAND CMD=status_led

You note that I had to add sudo, which is per se not allowed for gcode shell command, but nevertheless LED_OFF and LED_WHITE is working with this setup.
As soon as I run STATUS_LED the script gets loaded and led's are displaying standby but immediately Klipper shuts down with

Errno 1 Operation not permitted
19:23:49
// Klipper state: Shutdown
19:23:49
!! Internal error on command:"RUN_SHELL_COMMAND"
19:23:49
!! Internal error on command:"STATUS_LED"

Surely I am doing something wrong but like to understand​ what that would be and how to recify.

If I start the script via ssh everything runs fine using same command.

Sorry to misuse this; this is most probably not an issue with the script but with me not understanding what's actually going on....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.