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

getPlainValue without quotes #38

Open
TeNNo2k5 opened this issue Jun 7, 2020 · 11 comments
Open

getPlainValue without quotes #38

TeNNo2k5 opened this issue Jun 7, 2020 · 11 comments

Comments

@TeNNo2k5
Copy link

TeNNo2k5 commented Jun 7, 2020

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

@Apollon77
Copy link
Contributor

Please show exact examples.

@TeNNo2k5
Copy link
Author

TeNNo2k5 commented Jun 7, 2020

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" } }

@Apollon77
Copy link
Contributor

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.

@TeNNo2k5
Copy link
Author

TeNNo2k5 commented Jun 7, 2020

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? :)

@Goersch
Copy link

Goersch commented Jul 18, 2020

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.

@Apollon77
Copy link
Contributor

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

@Goersch
Copy link

Goersch commented Jul 19, 2020

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 :)

@drhideg
Copy link

drhideg commented Aug 22, 2020

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.

@Apollon77
Copy link
Contributor

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.

@peterfido
Copy link

peterfido commented Dec 23, 2021

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.

@Apollon77
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants