Get JSON value in Vis

Antworten
PlumBum
Beiträge: 1
Registriert: 17.02.2018, 23:51

Get JSON value in Vis

Beitrag von PlumBum » 17.02.2018, 23:55

how do i get an value from an JSON string to display in an text field

if i select an object id then i get the whole Json string i want just one value

bondrogeen
starter
Beiträge: 58
Registriert: 10.04.2015, 18:46

Re: Get JSON value in Vis

Beitrag von bondrogeen » 21.03.2018, 12:23

Disassemble the string using ioBroker.javascript and create a separate variable

Karl_999
professional
Beiträge: 121
Registriert: 21.11.2017, 22:09

Re: Get JSON value in Vis

Beitrag von Karl_999 » 01.04.2018, 17:36

Some days ago I had the same question viewtopic.php?f=20&t=13136&p=138325 (in German)
My solution is based on the systeminfo adapter as described in https://www.npmjs.com/package/iobroker.systeminfo using the filter

Code: Alles auswählen

nodes[?(@.name == 'mynames')][name,lastcontact,status,loadavg]
This searches in a list (of nodes) for the entry with node.name='mynames' and extracts from that entry the properties name, lastcontact, status and loadavg.
In case you would like to have names instead of numbered variables you might define the variable name as

Code: Alles auswählen

MyVariable.[name,lastcontact,status,loadavg]
HTH

tomganleylee
Beiträge: 1
Registriert: 03.05.2018, 17:40

Re: Get JSON value in Vis

Beitrag von tomganleylee » 03.05.2018, 17:43

Hi,
This has been a really useful thread for me however i am still a little stuck:

I have some mqtt data coming in in JSON format the data looks like this: {"Cistern":1,"Capacity":1160}

ive installed the Systeminfo and tried adding the json to the _data.json file however i cant seem to get it to come out as a varable to use in the vis.

would you be able to guide me in what steps i need to take?

Many thanks

Tom

Karl_999
professional
Beiträge: 121
Registriert: 21.11.2017, 22:09

Re: Get JSON value in Vis

Beitrag von Karl_999 » 21.06.2018, 10:05

tomganleylee hat geschrieben:
03.05.2018, 17:43
I have some mqtt data coming in in JSON format the data looks like this: {"Cistern":1,"Capacity":1160}
Not fully sure, as I have no example to test. But from my understanding it should work when using

Code: Alles auswählen

[Cistern, Capacity]
both as RegExp/Filter and as names.

I mostly approach such a task in steps:
- Check the full page you are reading (no filter, ...). So you can see whether the source is correct
- Try to reduce by using expressions and filters

Antworten