ioBroker.simple-api icon indicating copy to clipboard operation
ioBroker.simple-api copied to clipboard

getPlainValue without quotes

Open TeNNo2k5 opened this issue 4 years ago • 11 comments

Hi,

When you query the browser with getPlainValue/stateID some results are displayed in quotes, it does not depend on the datatype, I can only assume that if a stateID contains a space these results are displayed in quotes.

My suggestion would be to display generally without quotes if possible, or to provide an additional HTTP Get request that displays the output without quotes.

The background for the request is that I fill a datapoint with HTML data using a script to display it on my magic mirror using an iframe, this works great but the output is spoiled by the quotes.

Greetings TeNNo2k5

TeNNo2k5 avatar Jun 07 '20 12:06 TeNNo2k5

Please show exact examples.

Apollon77 avatar Jun 07 '20 13:06 Apollon77

Hi Apollon77,

Output example with quotes:

gpv1

{ "from": "system.adapter.javascript.0", "ts": 1521495357813, "user": "system.user.admin", "common": { "name": "javascript.0.cmd", "role": "javascript", "type": "mixed" }, "native": {}, "acl": { "object": 1636, "owner": "system.user.admin", "ownerGroup": "system.group.administrator", "state": 1636 }, "_id": "javascript.0.cmd", "type": "state" }

Output example without quotes:

gpv2

{ "common": { "name": "CpuTemp", "role": "state", "type": "mixed", "custom": { "sql.0": { "enabled": true, "changesOnly": false, "debounce": 0, "maxLength": 10, "retention": "15811200", "changesRelogInterval": 0, "changesMinDelta": 0, "storageType": "", "aliasId": "" }, "influxdb.0": { "enabled": true, "changesOnly": true, "debounce": 0, "maxLength": 10, "retention": "31536000", "changesRelogInterval": 0, "changesMinDelta": 0, "storageType": "", "aliasId": "" } } }, "native": {}, "type": "state", "from": "system.adapter.javascript.0", "user": "system.user.admin", "ts": 1562789243620, "_id": "javascript.0.CpuTemp", "acl": { "object": 1636, "state": 1636, "owner": "system.user.admin", "ownerGroup": "system.group.administrator" } }

TeNNo2k5 avatar Jun 07 '20 14:06 TeNNo2k5

The simple-api adapter provides api ways and so the value is returned based on its data type!!

44 Is a number and the other one is a string. So response is as expected.

Apollon77 avatar Jun 07 '20 14:06 Apollon77

Ok then it was an understanding mistake with the data types and the processing by the simple-api adapter on my part.

But is there no hope for me that maybe an additional function could be implemented to output strings without quotes via HTTP Get request? :)

TeNNo2k5 avatar Jun 07 '20 15:06 TeNNo2k5

I have the same problem - I created a large HTML formated table in an object and tried to use getPlainText. Due to the quotes the page is not shown correct. So I would also appreciate an extension.

Goersch avatar Jul 18 '20 20:07 Goersch

But why you not use "JSON.parse" with the response and then handle it as you need it in your client side code?

Apollon77 avatar Jul 19 '20 14:07 Apollon77

There is no client side code :) - my idea is/was to create a html page with the javascript adapter store it in an object and use getPlainText to show the page in a browser. This doesn‘t work because of the added quotes.

In my case: I found a different solution today :)

Goersch avatar Jul 19 '20 16:07 Goersch

Same issue here with get/getBulk/getPlainValue. If value is 0 then i got it with qoutes, otherwise only the value as number. Data comes from tuya adapter.

drhideg avatar Aug 22 '20 09:08 drhideg

If it comes as „0“ then the value in fact is a string - and then also the object in the tuya Adapter should be a string value. So this is „to be expected“ as well. String is not a number.

Apollon77 avatar Aug 22 '20 19:08 Apollon77

Hallo,

ich habe mir jetzt einen Bilderrahmen als Display geholt, welches sich Werte stumpf über eine URL holen kann. Dargestellt werden soll eine Temperatur. Blöd, dass bei runden Zahlen die Kommastelle fehlt und statt einem Dezimalkomma ein Dezimalpunkt genommen wird. Auch kann ich kein Grad-Zeichen hintendran hängen.

Das geht alles, wenn ich den Wert als String ausgebe. Aber dann sind da Anführungszeichen vor und hinter dem Wert. Diese sollten optional abgeschaltet werden können.

peterfido avatar Dec 23 '21 05:12 peterfido

Ich glaube Ihr versteht den Adapter falsch ... Das ist eine API und kein "Fertig für eine Visualisierungs-Anzeige Frontend Datenlieferand". Ihr kommt um irgendeine Logik die Daten aufbereitet nicht drum herum - oder man muss hier einiges erweitern. Nachkommastellen bei einer ".0" Zahl denke bekommst Du auch mit String nicht

Apollon77 avatar Dec 23 '21 07:12 Apollon77