getPlainValue multiple values
Closed this issue · 4 comments
Describe the bug
I try to get 4 values from iobroker with the getPlainValue request via a Python3 (3.9.2) script. As stated the request should be separated with a semicolon. The example on the other hand shows a comma plus additional blank. Nevertheless I tried all combos, semicolon and comma, with or without blank. Neither of these variantes gave me a result but various kinds of error.
To Reproduce
Steps to reproduce the behavior:
Using , or ; with blank:
http://192.168.1.150:8087/getPlainValue/octoprint.0.tools.bed.actualTemperature, octoprint.0.tools.bed.targetTemperature, octoprint.0.tools.tool0.actualTemperature, octoprint.0.tools.tool0.targetTemperature
produces
http.client.InvalidURL: URL can't contain control characters. '/getPlainValue/octoprint.0.tools.bed.actualTemperature, octoprint.0.tools.bed.targetTemperature, octoprint.0.tools.tool0.actualTemperature, octoprint.0.tools.tool0.targetTemperature' (found at least ' ')
And without blank:
http://192.168.1.150:8087/getPlainValue/octoprint.0.tools.bed.actualTemperature;octoprint.0.tools.bed.targetTemperature;octoprint.0.tools.tool0.actualTemperature;octoprint.0.tools.tool0.targetTemperature
produces
urllib.error.HTTPError: HTTP Error 500: Internal Server Error
Expected behavior
A single value can be retrieved without problems:
URL:
http://192.168.1.150:8087/getPlainValue/octoprint.0.tools.bed.actualTemperature
RSP:
<http.client.HTTPResponse object at 0x76198058>
DAT:
20.16
Screenshots & Logfiles
The above quotes were taken from a Putty terminal.
Versions:
- Adapter version: 2.6.2
- JS-Controller version: 4.0.15
- Node version: v12.22.10
- Operating system: Debian 11.2 "bullseye" on RasPi 3B+
Additional context
...
additional info:
I tried combinations of "," (comma) and ";" (semicolon) with and without trailing blank. Additionally I tried with and without preceding url base "http://.../getPlainValue/" from the 2nd request on.
I only had some result using "," (comma) without trailing blank and not repeating the url base:
http://192.168.1.150:8087/getPlainValue/octoprint.0.tools.bed.actualTemperature,octoprint.0.tools.bed.targetTemperature,octoprint.0.tools.tool0.actualTemperature,octoprint.0.tools.tool0.targetTemperature
Different from other request resulting in "Internal Server Error" I get a
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Printing out the result gives:
<http.client.HTTPResponse object at 0x76161e80>
b'20.47\n0\n20.5\n0'
So... there seem to be the requested values 20.47, 0, 20.5 and 0 present, separated by \n, enclosed in b'' This might be a JSON / decoder problem then?
Michael
Hi,
"getPlainValue" is not returning a JSON as per definition ... so the response is also no JSON (in no case! ALso not when just requesting a single value). This means multiple values are returned separated by line breaks in the order as given in the URL.
SO I think that your expectation is simply wrong regarding the returned data. YOu need to parse the response differently when you use "getPlainValue" at all
PS: the "b'...'" seems to come from your paython script because it is a normal string or such ... so the b' ' is not coming from the server!
And PPS: Yes the line with comma as seoarator and WITHOUT spaces is correct call wise