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

customize tasmota http request timeout value #142

Closed
togeis opened this issue Apr 11, 2021 · 6 comments · Fixed by #158
Closed

customize tasmota http request timeout value #142

togeis opened this issue Apr 11, 2021 · 6 comments · Fixed by #158
Labels
enhancement New feature or request solved workaround documented or fix applied
Milestone

Comments

@togeis
Copy link

togeis commented Apr 11, 2021

Hi,
i have the problem, that my tasmota device sometimes needs more than 3sec to react for a webrequest.

time curl "http://192.168.178.91/cm?user=admin&password=&cmnd=Status 0"
{"Status":{"Module":0,"FriendlyName":["LED Drucker","Gosund Steckdose 6"],"Topic":"LEDDrucker","ButtonTopic":"0","Power":2,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}}
real	0m0.062s
user	0m0.002s
sys	0m0.005s

time curl "http://192.168.178.91/cm?user=admin&password=&cmnd=Status 0"
{"Status":{"Module":0,"FriendlyName":["LED Drucker","Gosund Steckdose 6"],"Topic":"LEDDrucker","ButtonTopic":"0","Power":2,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}}
real	0m4.825s     <<--- response > 3sec
user	0m0.002s
sys	0m0.004s

I use Tasmota 8.2.0

So i see in the plugin logs the following:

[2021-04-11 18:06:19,442] ERROR: Invalid ip or unknown error connecting to 192.168.178.91.
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_tasmota/__init__.py", line 498, in check_status
    webresponse = requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": plug["password"], "cmnd": "Status 0"}, timeout=3)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
ReadTimeout: HTTPConnectionPool(host='192.168.178.91', port=80): Read timed out. (read timeout=3)

Can you implement a input box to set a custom timeout value? Maybe a dropdown box with values from 3-10Sec ?

Thx&regards
togeis

@jneilliii jneilliii added the enhancement New feature or request label Apr 11, 2021
@jneilliii
Copy link
Owner

I had added that lower timeout fairly recently. I have no issue with either making it configurable, or possibly just increasing the value to something higher like 10 seconds? The only reason I added the timeout is because a request would go forever without it and in cases where a device wasn't responding it would just create a memory leak in the plugin.

@togeis
Copy link
Author

togeis commented Apr 14, 2021

making the timeout configurable would be great. Thx 👍

@jneilliii jneilliii added this to the 1.0.4 milestone Apr 14, 2021
jneilliii added a commit that referenced this issue Apr 20, 2021
@jneilliii
Copy link
Owner

I've enabled a configurable option in the above commit. If you want to test out and confirm you can change the plugin's release channel in OctoPrint's Software Update settings to Release Candidate and update when prompted.

@jneilliii jneilliii added the solved workaround documented or fix applied label Apr 20, 2021
@togeis
Copy link
Author

togeis commented Apr 20, 2021

thx for implementing. I have installed 1.0.4rc1 but there is no option for the timeout. I see in git, that you have changed it in the "rc" branch, but its not changed in the tagged 1.0.4rc1 code.

@jneilliii
Copy link
Owner

My bad, I pushed the changes to my rc branch but forgot to create the release. You should be able to force check for updates and get an update notice now.

@togeis
Copy link
Author

togeis commented Apr 21, 2021

Test was successful. Thx for implementation.

@togeis togeis closed this as completed Apr 21, 2021
@jneilliii jneilliii mentioned this issue Jul 31, 2021
jneilliii added a commit that referenced this issue Jul 31, 2021
* fix bug with M150 command not having I parameter causing the command to get lost in the queue, #143
* make request timeout configurable in settings, #142
* add numeric StatusSTS messages for chk values, #150
* account for energy data with multiple relay device, #155
* M118 support for LED commands for more real-time control based on what's happening on the printer (ie waiting for heat up). The function is similar to the M150 support but you will need to use the command `M118 TASMOTA_M150 I192.168.0.105 R### G### B### W### P###`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request solved workaround documented or fix applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants