Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: power toggle won't work #339

Open
1 task done
cruzer619 opened this issue Dec 9, 2024 · 12 comments
Open
1 task done

[Bug]: power toggle won't work #339

cruzer619 opened this issue Dec 9, 2024 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@cruzer619
Copy link

cruzer619 commented Dec 9, 2024

What happened and in what context?

After upgrading to latest version of telegram-bot when printer is off but pi is still on. Power toggle no longer works. I've tried to uninstall and reinstall. and same result. Also when first starting the printer. And assuming the service starts. Printer online status notification sends every 30 secs. After I stop and restart service it will stop sometimes.

If needed, paste the relevant bot log contents here.


Current Moonraker telegram bot config
[bot]
server = localhost
power_device = Ender5
light_device = LED1

[progress_notification]
percent = 10


2024-12-09 01:38:35,438 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/info'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:36,455 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/info'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:37,467 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
2024-12-09 01:38:37,472 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/info'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:38,487 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/info'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:39,501 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
2024-12-09 01:38:39,505 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/info'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:40,519 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/info'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:41,536 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
2024-12-09 01:38:41,540 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/info'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:42,562 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/info'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:43,599 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/info'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:44,603 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
2024-12-09 01:38:44,622 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/info'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:45,645 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
2024-12-09 01:38:46,267 - klippy - ERROR - klippy.py:362 - Server error '503 Klippy Host not connected' for url 'http://localhost/printer/objects/list'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503
2024-12-09 01:38:47,435 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
trunk
2024-12-09 01:48:15,435 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
2024-12-09 01:48:17,435 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
2024-12-09 01:48:19,437 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
2024-12-09 01:48:21,437 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
2024-12-09 01:48:22,413 - main - ERROR - main.py:986 - Exception while handling an update:
Traceback (most recent call last):
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions
yield
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpx/_transports/default.py", line 394, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
raise exc from None
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request
response = await connection.handle_async_request(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpcore/_async/connection.py", line 101, in handle_async_request
raise exc
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpcore/_async/connection.py", line 78, in handle_async_request
stream = await self._connect(request)
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpcore/_async/connection.py", line 124, in _connect
stream = await self._network_backend.connect_tcp(**kwargs)
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpcore/_backends/auto.py", line 31, in connect_tcp
return await self._backend.connect_tcp(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpcore/_backends/anyio.py", line 122, in connect_tcp
stream._raw_socket.setsockopt(*option) # type: ignore[attr-defined] # pragma: no cover
File "/usr/lib/python3.9/contextlib.py", line 135, in exit
self.gen.throw(type, value, traceback)
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ConnectTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/request/_httpxrequest.py", line 293, in do_request
res = await self._client.request(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpx/_client.py", line 1540, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpx/_client.py", line 1629, in send
response = await self._send_handling_auth(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpx/_client.py", line 1657, in _send_handling_auth
response = await self._send_handling_redirects(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpx/_client.py", line 1694, in _send_handling_redirects
response = await self._send_single_request(request)
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpx/_client.py", line 1730, in _send_single_request
response = await transport.handle_async_request(request)
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpx/_transports/default.py", line 394, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/lib/python3.9/contextlib.py", line 135, in exit
self.gen.throw(type, value, traceback)
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/ext/_application.py", line 1319, in process_update
await coroutine
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/ext/_handlers/basehandler.py", line 158, in handle_update
return await self.callback(update, context)
File "/home/pi/moonraker-telegram-bot/bot/main.py", line 447, in power
await update.effective_message.get_bot().send_chat_action(chat_id=configWrap.secrets.chat_id, action=ChatAction.TYPING)
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/ext/_extbot.py", line 2520, in send_chat_action
return await super().send_chat_action(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/_bot.py", line 3443, in send_chat_action
return await self._post(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/_bot.py", line 617, in _post
return await self._do_post(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/ext/_extbot.py", line 351, in _do_post
return await super()._do_post(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/_bot.py", line 646, in _do_post
result = await request.post(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/request/_baserequest.py", line 202, in post
result = await self._request_wrapper(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/request/_baserequest.py", line 334, in _request_wrapper
code, payload = await self.do_request(
File "/home/pi/moonraker-telegram-bot-env/lib/python3.9/site-packages/telegram/request/_httpxrequest.py", line 310, in do_request
raise TimedOut from err
telegram.error.TimedOut: Timed out
2024-12-09 01:48:23,440 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}
trunk
2024-12-09 01:53:49,434 - websocket_helper - WARNING - websocket_helper.py:312 - Error received from websocket: {'code': 503, 'message': 'Klippy Host not connected'}

If needed, paste the relevant bot journal contents here.

No response

What branch does this occur on?

master

Reports only on latest master or development branches!

  • I have updated to latest development/master version before submitting the bug
@cruzer619 cruzer619 added the bug Something isn't working label Dec 9, 2024
@cruzer619
Copy link
Author

cruzer619 commented Dec 12, 2024

ok was able to fix the printer online status repeating every 30 secs. Referencing #326, I used kiauh alpha 6 to reinstall. I manually installed via git. So I'm good there, but "/power" function doesn't work unless I'm at my home computer to turn it on.
Screenshot 2024-12-11 164029
on 1.5.0 I was able to power on printer when it was in the off state. Will try to uninstall latest version and manually install previous version, unless there is an easy way to roll back.

Thanks

RC

@cruzer619
Copy link
Author

ok rolled back to 1.5.0 and now able to power on printer when its off. so using RP 4 with relay to turn on/off printer mainboard via moonraker.

@nlef nlef self-assigned this Dec 12, 2024
@nlef nlef added this to Bugs Dec 12, 2024
@github-project-automation github-project-automation bot moved this to Unsorted bug reports in Bugs Dec 12, 2024
@nlef
Copy link
Owner

nlef commented Dec 31, 2024

@cruzer619
Most likely you are using power devices that control klipper output_pin. In the latest versions of moonraker, when the klipper is in shutdown/error state, switching such power devices is impossible.
The API for controlling power devices has not changed in moonraker, the logic for working with it has not changed in the bot.
For convenience, I added the output of an error message in the reply message when controlling power devices from the bot in add8df3
It would be cool if you could test and indicate the errors that occur when working with power devices for you.

@nlef nlef moved this from Unsorted bug reports to Needs more input/logs/testing in Bugs Dec 31, 2024
@cruzer619
Copy link
Author

image
@nlef yes I am using GPIO pins to toggle relay on/off. ok just got home from out of state. Will give this a try and send error test message.

@cruzer619
Copy link
Author

cruzer619 commented Jan 2, 2025

telegram.log
Here is the latest telegram log. And going to leave installation at v2.0.0 for now.

@nlef
Copy link
Owner

nlef commented Jan 2, 2025

@cruzer619
judging by the attached log file, you are using a bot from the master branch. Unfortunately, you won't be able to test the commit I specified above. Could you add debug: true to the section bot in the bot config file, restart the bot, switch the power device and attach a new bot log?

@cruzer619
Copy link
Author

image
my bad.. I thought I grabbed development branch.. saw in notes you added "power device error"... so from this screen. I thought if I clicked on the green code button, and copied the url from there would git the develpment branch. or is there another way of doing it?

@cruzer619
Copy link
Author

cruzer619 commented Jan 2, 2025

telegram.log
Here is new log with bot => debug: true

update: just noticing with debug being on.. the power on dialog is showing up sometimes.. but doesn't power on printer.
also think I found the right syntax for git and branch download..
git clone --single-branch --branch <branchname> <remote-repo>
but won't update via git unless you say so.

@nlef
Copy link
Owner

nlef commented Jan 2, 2025

cd ~/moonraker-telegram-bot
git checkout development

also you could add primary_branch: development into moonraker config update_manager section for the bot. This will give the ability to update the bot from the dev branch from the web interface

@cruzer619
Copy link
Author

ok thanks will update and try again... but will need some sleep.. will try again in about 5 hours.. thanks.

@cruzer619
Copy link
Author

telegram.log
ok here is new log. I updated to development branch. turned off debug mode. I did like 5 power toggles and after about 3 min "5 power on dialogs" showed up. hit power on and printer turned on. but when I pressed power toggle again. about 5 times. no diaglog to turn off printer. so its not just to power it on. seems to be lack of some communication. as I tried status as well. and no dialog either with a pic.

@cruzer619
Copy link
Author

cruzer619 commented Jan 3, 2025

FYI I've started to print my ERCF v2 parts. Won't be able to test 'til the following day.

UPDATE: able to test whenever ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Needs more input/logs/testing
Development

No branches or pull requests

2 participants