Exception when trying to /on /off the printer
fabiuzzo77 opened this issue · 5 comments
fabiuzzo77 commented
Hi,
when trying to swtich on/off the printer it does't work, I see in the logs:
2021-10-25 20:58:47,201 - octoprint.plugins.telegram.listener - INFO - Got a command: 'SwitchOff' with parameter: '' in chat 305823880
2021-10-25 20:58:47,202 - octoprint.plugins.telegram.listener - ERROR - Exception caught! 'SwitchOff'
Traceback (most recent call last):
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_telegram/__init__.py", line 97, in loop
self.processMessage(message)
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_telegram/__init__.py", line 176, in processMessage
self.handleCallbackQuery(message)
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_telegram/__init__.py", line 186, in handleCallbackQuery
self.handleTextMessage(message["callback_query"], chat_id, from_id)
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_telegram/__init__.py", line 631, in handleTextMessage
if self.main.isCommandAllowed(chat_id, from_id, command):
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/__init__.py", line 1737, in wrapper
return f(*args, **kwargs)
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_telegram/__init__.py", line 2532, in isCommandAllowed
if self.chats[chat_id]["commands"][command]:
KeyError: 'SwitchOff'
I have PSU Control plugin, I use a wifi plug with a webhook to control the power supply.
Can you help?
I'm running on Python3 with octo 0.17 and version 1.6.5 of Telegram Notification
Thanks!
giloser commented
Hi I'sure can try but I gonna need more of the logs
Thanks
fabiuzzo77 commented
Thanks!
021-10-25 20:58:19,250 - octoprint.plugins.telegram - DEBUG - self.tmsg = <octoprint_telegram.telegramNotifications.TMSG object at 0xa95ead50>
2021-10-25 20:58:42,873 - octoprint.plugins.telegram.listener - DEBUG - listener: sending request with offset 755124733...
2021-10-25 20:58:43,460 - octoprint.plugins.telegram.listener - DEBUG - Updating update_offset from 755124733 to 755124734
2021-10-25 20:58:43,461 - octoprint.plugins.telegram.listener - DEBUG - MESSAGE: {'update_id': 755124733, 'callback_query': {'id': '1313503563679928567', 'from': {'id': 305823880, 'is_bot': False, 'first_name': 'Fabio', 'last_name': 'XXX', 'language_code': 'it'}, 'message': {'message_id': 4913, 'from': {'id': 1405953844, 'is_bot': True, 'first_name': 'Ender 3 OctoBot', 'username': 'End3v2_bot'}, 'chat': {'id': 305823880, 'first_name': 'Fabio', 'last_name': 'XXX', 'type': 'private'}, 'date': 1635188169, 'text': '❓ Turn off the Printer?', 'reply_markup': {'inline_keyboard': [[{'text': '✅ Yes', 'callback_data': 'SwitchOff'}, {'text': '❌ No', 'callback_data': 'No'}]]}}, 'chat_instance': '7825497000268026092', 'data': 'No'}}
2021-10-25 20:58:43,461 - octoprint.plugins.telegram.listener - DEBUG - Not changing update_offset - otherwise would reduce it from 755124734 to 755124734
2021-10-25 20:58:43,462 - octoprint.plugins.telegram.listener - INFO - Got a command: 'No' with parameter: '' in chat 305823880
2021-10-25 20:58:43,463 - octoprint.plugins.telegram - DEBUG - Sending a message UPDATE: Maybe next time. chatID= 305823880
2021-10-25 20:58:43,463 - octoprint.plugins.telegram - DEBUG - SENDING UPDATE: {'text': 'Maybe next time.', 'message_id': 4913, 'chat_id': 305823880}
2021-10-25 20:58:43,754 - octoprint.plugins.telegram - DEBUG - REQUEST RES: {'ok': True, 'result': {'message_id': 4913, 'from': {'id': 1405953844, 'is_bot': True, 'first_name': 'Ender 3 OctoBot', 'username': 'End3v2_bot'}, 'chat': {'id': 305823880, 'first_name': 'Fabio', 'last_name': 'XXX', 'type': 'private'}, 'date': 1635188169, 'edit_date': 1635188323, 'text': 'Maybe next time.'}}
2021-10-25 20:58:43,756 - octoprint.plugins.telegram.listener - DEBUG - listener: sending request with offset 755124734...
2021-10-25 20:58:45,524 - octoprint.plugins.telegram.listener - DEBUG - Updating update_offset from 755124734 to 755124735
2021-10-25 20:58:45,525 - octoprint.plugins.telegram.listener - DEBUG - MESSAGE: {'update_id': 755124734, 'message': {'message_id': 4914, 'from': {'id': 305823880, 'is_bot': False, 'first_name': 'Fabio', 'last_name': 'XXX', 'language_code': 'it'}, 'chat': {'id': 305823880, 'first_name': 'Fabio', 'last_name': 'XXX', 'type': 'private'}, 'date': 1635188325, 'text': '/off', 'entities': [{'offset': 0, 'length': 4, 'type': 'bot_command'}]}}
2021-10-25 20:58:45,525 - octoprint.plugins.telegram.listener - DEBUG - Not changing update_offset - otherwise would reduce it from 755124735 to 755124735
2021-10-25 20:58:45,527 - octoprint.plugins.telegram.listener - INFO - Got a command: '/off' with parameter: '' in chat 305823880
2021-10-25 20:58:45,555 - octoprint.plugins.telegram - DEBUG - start _send_msg
2021-10-25 20:58:45,556 - octoprint.plugins.telegram - DEBUG - log instead log sending message
2021-10-25 20:58:45,556 - octoprint.plugins.telegram - DEBUG - data so far: {'disable_web_page_preview': True, 'reply_markup': '{"inline_keyboard": [[{"text": "\\u2705 Yes", "callback_data": "SwitchOff"}, {"text": "\\u274c No", "callback_data": "No"}]]}', 'chat_id': '305823880', 'disable_notification': False}
2021-10-25 20:58:45,556 - octoprint.plugins.telegram - DEBUG - Sending without image.. 305823880
2021-10-25 20:58:45,905 - octoprint.plugins.telegram - DEBUG - Sending finished. 200
2021-10-25 20:58:45,908 - octoprint.plugins.telegram.listener - DEBUG - listener: sending request with offset 755124735...
2021-10-25 20:58:47,199 - octoprint.plugins.telegram.listener - DEBUG - Updating update_offset from 755124735 to 755124736
2021-10-25 20:58:47,199 - octoprint.plugins.telegram.listener - DEBUG - MESSAGE: {'update_id': 755124735, 'callback_query': {'id': '1313503564197130387', 'from': {'id': 305823880, 'is_bot': False, 'first_name': 'Fabio', 'last_name': 'XXX', 'language_code': 'it'}, 'message': {'message_id': 4915, 'from': {'id': 1405953844, 'is_bot': True, 'first_name': 'Ender 3 OctoBot', 'username': 'End3v2_bot'}, 'chat': {'id': 305823880, 'first_name': 'Fabio', 'last_name': 'XXX', 'type': 'private'}, 'date': 1635188325, 'text': '❓ Turn off the Printer?', 'reply_markup': {'inline_keyboard': [[{'text': '✅ Yes', 'callback_data': 'SwitchOff'}, {'text': '❌ No', 'callback_data': 'No'}]]}}, 'chat_instance': '7825497000268026092', 'data': 'SwitchOff'}}
2021-10-25 20:58:47,200 - octoprint.plugins.telegram.listener - DEBUG - Not changing update_offset - otherwise would reduce it from 755124736 to 755124736
2021-10-25 20:58:47,201 - octoprint.plugins.telegram.listener - INFO - Got a command: 'SwitchOff' with parameter: '' in chat 305823880
2021-10-25 20:58:47,202 - octoprint.plugins.telegram.listener - ERROR - Exception caught! 'SwitchOff'
Traceback (most recent call last):
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_telegram/__init__.py", line 97, in loop
self.processMessage(message)
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_telegram/__init__.py", line 176, in processMessage
self.handleCallbackQuery(message)
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_telegram/__init__.py", line 186, in handleCallbackQuery
self.handleTextMessage(message["callback_query"], chat_id, from_id)
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_telegram/__init__.py", line 631, in handleTextMessage
if self.main.isCommandAllowed(chat_id, from_id, command):
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/__init__.py", line 1737, in wrapper
return f(*args, **kwargs)
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_telegram/__init__.py", line 2532, in isCommandAllowed
if self.chats[chat_id]["commands"][command]:
KeyError: 'SwitchOff'
2021-10-25 20:58:47,203 - octoprint.plugins.telegram.listener - DEBUG - listener: sending request with offset 755124736...
2021-10-25 20:58:59,374 - octoprint.plugins.telegram - DEBUG - Testing token 1111111111:AAAaaaaaAaAAaAAAaa111-AA11A111AaaAA
giloser commented
Hi
did you give you right for the switchoff or switchon function?
fabiuzzo77 commented
What did you mean exacly? With pi user I've created a bash script that calls a webhook to switch PSU, so execution rights are granted to pi
giloser commented