OH 2.4.0 SNAPSHOT
Why does my “!== null” test not skip the NULL string elements?
rule "Test Thing Status"
when
Item testRule changed
then
var String output = ""
var String filter = "$..[?(@.statusInfo.status=='OFFLINE')]"
val allThings = sendHttpGetRequest("http://localhost:8080/rest/things")
val thingStatus = allThings.split('"statusInfo"')
thingStatus.forEach[thing |
if (thing != "[{")
{
output = transform("JSONPATH", filter, '{"statusInfo"'+thing)
if (output !== null)
{
logInfo("test","Test Thing Status - Output: {}", output)
}
}
]
end
Log output:
2018-10-05 14:50:21.134 [INFO ] [pse.smarthome.model.script.test] - Test Thing Status - Output: NULL
2018-10-05 14:50:21.166 [INFO ] [pse.smarthome.model.script.test] - Test Thing Status - Output: {statusInfo={status=OFFLINE, statusDetail=COMMUNICATION_ERROR, description=No route to host (Host unreachable)}, editable=true, label=Bedroom Chromecast...