nietog
(Gustavo Nieto García)
January 10, 2021, 8:25pm
1
Hello fiends,
I have just migrated to OPENHAB 3 , and I’m trying to get the power value of my Efergy sensor through the http binding (through the new UI). The value I’m trying to get is contained in this response of a URL:
[{“cid”:“PWER”,“data”:[{“1610309338000”:188 }],“sid”:“824212”,“units”:“W”,“age”:2}]
Specifically, I want to get the value 188
Can anyone give me a hand on how to do it through http binding configuration on UI?
Thanks!
opus
(Jürgen Baginski)
January 14, 2021, 8:22pm
2
That looks like JSON format, the JSONPATH transformation should help.
nietog:
“1610309338000”
Is this string, before the 188 , always the same?
nietog
(Gustavo Nieto García)
January 15, 2021, 9:52pm
4
nietog:
1610309338000
No, this number changes in every query…
nietog
(Gustavo Nieto García)
January 17, 2021, 10:58pm
5
Thanks Jürgen, hafniumzinc, the problem is that the string before the value I want to get changes in every query (as it’s a kind of time value)
[{“cid”:“PWER”,“data”:[{“1610309338000 ”:188 }],“sid”:“824212”,“units”:“W”,“age”:2}]
opus
(Jürgen Baginski)
January 18, 2021, 5:20am
6
If it’s a time value, can you precompute it?
nietog
(Gustavo Nieto García)
January 30, 2021, 10:26pm
7
Thanks Jürgen but I’m not an expert on programming, nor JSON, even nor Openhab!
The .js script I had in Openhab2 to get this value was:
JSON.parse(input)[0].data[0][Object.keys(JSON.parse(input)[0].data[0])[0]]
The question is how this translates into the value I have to set into the field “State Transformation” in the Openhab 3 graphic interface…
Thanks!