[SOLVED] String from HTTP sentence Sonoff

(Juan) #1

Hi there,

Is it possible to get a string from the http in order to get the following info?

Something like:

String Raw {http=""}

I do not get that it works…

(Harry) #2

Have you worked with refreshintervalinmilliseconds or Command?

What value does the item have?

(Vincent Regaud) #3
val String response = sendHttpGetRequest("")

But this is from a Sononf with tasmota firmware.
Have you heard of MQTT?

(Juan) #4

Yes, I know.
But I would like to get the POWER from http.

I want to pass this string:


I have this rule:

rule "Power Rele"
when Item sonoff06 changed to ON
String estado "estado" { http="<[]" }
logInfo("rule","Estado " + estado)

(Juan) #5

OK, it works.

Now I want to extract the field Power as a Number… to work with other rules

2018-07-12 15:22:11.613 [INFO ] [.eclipse.smarthome.model.script.rule] - Estado {"Status":{"Module":1,"FriendlyName":["Sonoff06"],"Topic":"sonoff06","ButtonTopic":"0","Power":1,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"ButtonRetain":0,"PowerRetain":0}}

(Vincent Regaud) #6
val String sonoffStatus = transform("JSONPATH", "$.POWER", response }

(Juan) #7

Thank you!!!