- Platform information:
- Hardware: IBM Thinkpad - i5/8gbRAM/128gb SSD
- OS: Debian
- Java Runtime Environment: openjdk 11.0.10
- openHAB version: 3.0.1
- Issue of the topic: Hi all. Thank you in advance for any help. I am trying to pull in data from Amber Electric in Australia using their API. I have managed to get the JSON string into openhab, but I am having trouble transforming it into usable data. I think there is a problem with the syntax in the transform function, but I cannot work out exactly how to fix it. The item “AmberString” ends up with the entire JSON inside it. I believe it might also be possible to select which data is needed by searching on the “channelType” value, but I cannot quite figure this one out either. Any help is appreciated. Thanks again.
My Rule DSL.
var String JSON_Current = executeCommandLine(Duration.ofSeconds(5), "/home/luke/scripts/amber.sh")
val String duration = transform("JSONPATH", "$.0.duration", JSON_Current)
logInfo("AmberAPI", duration)
AmberString.postUpdate(duration)
The JSON string that comes in.
[
{
"type": "CurrentInterval",
"date": "2022-04-03",
"duration": 30,
"startTime": "2022-04-03T11:30:01Z",
"endTime": "2022-04-03T12:00:00Z",
"nemTime": "2022-04-03T22:00:00+10:00",
"perKwh": 49.26995,
"renewables": 25.355,
"spotPerKwh": 27.79159,
"channelType": "general",
"spikeStatus": "none",
"descriptor": "neutral",
"estimate": true
},
{
"type": "CurrentInterval",
"date": "2022-04-03",
"duration": 30,
"startTime": "2022-04-03T11:30:01Z",
"endTime": "2022-04-03T12:00:00Z",
"nemTime": "2022-04-03T22:00:00+10:00",
"perKwh": 40.78895,
"renewables": 25.355,
"spotPerKwh": 27.79159,
"channelType": "controlledLoad",
"spikeStatus": "none",
"descriptor": "high",
"estimate": true
},
{
"type": "CurrentInterval",
"date": "2022-04-03",
"duration": 30,
"startTime": "2022-04-03T11:30:01Z",
"endTime": "2022-04-03T12:00:00Z",
"nemTime": "2022-04-03T22:00:00+10:00",
"perKwh": -68.22956,
"renewables": 25.355,
"spotPerKwh": 27.79159,
"channelType": "feedIn",
"spikeStatus": "none",
"descriptor": "high",
"estimate": true
}
]