Closed lixxbox closed 8 months ago
There is a self.client.disconnect()
in the send_command
function. Not sure, if it is needed for something, but if I comment that out, it works.
Funny timing, I found this two days ago too haha, had fixed it but hadn't merged it. Just merged it so should be good now. The disconnect is indeed the issue, changed it so it disconnects when the object is destroyed. https://github.com/mattcar15/bambu-connect/commit/bcd83f375798d10954b98f48adfcf4180d7e0c0d
I'll leave the issue open so you can confirm too, lemme know
It's working now.
My example script throws the following error after the two send_commands have been called. I think the error is triggered by exiting the script and probably has more to do with how I (not) handle it.
Edit: Adding bambu_client.executeClient.disconnect()
at the bottom solves this.
But the light goes on and off now. ☺️ Thank you very much!
toggle: on
toggle: off
Exception ignored in: <function BambuClient.__del__ at 0x000001C523D3C680>
Traceback (most recent call last):
File "C:\Python311\Lib\site-packages\bambu_connect\BambuClient.py", line 17, in __del__
File "C:\Python311\Lib\site-packages\bambu_connect\ExecuteClient.py", line 24, in disconnect
File "C:\Python311\Lib\site-packages\paho\mqtt\client.py", line 1358, in disconnect
File "C:\Python311\Lib\site-packages\paho\mqtt\client.py", line 2853, in _send_disconnect
File "C:\Python311\Lib\site-packages\paho\mqtt\client.py", line 3016, in _packet_queue
File "C:\Python311\Lib\site-packages\paho\mqtt\client.py", line 1577, in loop_write
File "C:\Python311\Lib\site-packages\paho\mqtt\client.py", line 2464, in _packet_write
File "C:\Python311\Lib\site-packages\paho\mqtt\client.py", line 649, in _sock_send
File "C:\Python311\Lib\ssl.py", line 1210, in send
ssl.SSLError: Underlying socket connection gone (_ssl.c:2321)
If your Python script ends normally, Python's garbage collector will destroy the objects that are no longer needed and del should be called, which is where the disconnect happens. If you exit it (with ctrl+c) then this would be an expected error yeah
Hm okay, I did not quit with ctrl+c.
The script just ran bambu_client.executeClient.send_command(toggle_led("on"))
& bambu_client.executeClient.send_command(toggle_led("off"))
and quit itself.
So, it looks like del
was not called?
Can you share the script?
It's in the first post.
As a beginner in Python, I'm facing an issue with controlling a printer lamp.
Although I can successfully execute either the 'on' or 'off' command individually, it seems that only the first command in my code is working. If I rearrange the order of these commands, still only the first one gets executed.
I've verified that the payload is correct. Do you have any tips for me?