HTTP binding in OpenHAB to query JSON

Tags: #<Tag:0x00007f6e0e201bf0> #<Tag:0x00007f6e0e201ab0>

I’ve been playing around with OpenHAB and trying to follow the instructions to use the HTTP binding to read a JSON output from my solar panel micro-inverter gateway. But I can’t seem to get it working.

The url is unauthenticated and returns JSON

“wattHoursToday”: 9410,
“wattHoursSevenDays”: 75272,
“wattHoursLifetime”: 578396,
“wattsNow”: 854

I’ve followed the GitHub instructions for the HTTP binding and use the caching facility. I’ve updated the config, items and sitemap files and created three JavaScript files to parse the JSON object as described in the guide. The amended files are:

Configuration - openhab.cfg

Items - oem.items
/* Solar Enphase */
String enphase_current “Solar Power (Current)” { http="<[LocalSolarOutputCache:10000:JS(getSolarCurrent.js)]" }
String enphase_day “Solar Power (Day)” { http="<[LocalSolarOutputCache:10000:JS(getSolarDay.js)]" }
String enphase_week “Solar Power (Week)” { http="<[LocalSolarOutputCache:10000:JS(getSolarWeek.js)]" }

Sitemap - oem.sitemap
Frame label=“enPhase Solar” {
Text item=enphase_current icon="energy"
Text item=enphase_day icon="energy"
Text item=enphase_week icon=“energy”

…and the three JSON files look like

getSolarCurrent.js - JSON.parse(input).wattsNow;
getSolarDay.js - JSON.parse(input).wattHoursToday;
getSolarWeek.js - JSON.parse(input).wattHoursSevenDays;

The EmonPi webpage doesn’t show any values