I’m on OpenHab4 and want to pull daily consumption and total generation values from my Kaco NX.
By calling:
http://192.168.0.177:8484/getdevdata.cgi?device=2&sn=10.0NX312009307&HTTP/1.0\r\1\r\1
a JSON is returned containing:
{“flg”:1,“tim”:“20240206094132”,“tmp”:406,“fac”:4997,“pac”:42,“sac”:42,“qac”:0,“eto”:88017,“etd”:0,“hto”:5330,“pf”:100,“wan”:0,“err”:0,“vac”:[2299,2305,2323],“iac”:[5,5,5],“vpv”:[1677,1872],“ipv”:[15,17],“str”:}
etd is today’s generated kWh, eto is the overall kWh generation.
I’ve set up a rule in order to make every 15 seconds the http call against my Kaco, the rule is executed as expected but I don’t get out any values, any idea why it’s not working ?
import java.util.concurrent.locks.ReentrantLock
import java.util.concurrent.locks.Lock
var ReentrantLock lock = new ReentrantLock()
rule “KacoWR”
when
Time cron “0/15 * * * * ?” // every 15s
then
lock.lock()
try {
// etd= daily production eto=overall production
// HTTP-Call durchführen und Antwort speichern
val response = sendHttpGetRequest(“http://192.168.0.177:8484/getdevdata.cgi?device=2&sn=10.0NX312009307&HTTP/1.0\\r\\1\\r\\1”)
// Parse der Antwort, um die Variablen zu extrahieren
val etd = Integer::parseInt(transform("JSONPATH", "$.etd", response))
val eto = Integer::parseInt(transform("JSONPATH", "$.eto", response))
} finally {
lock.unlock()
}
end
Remarks:
- etd and eto items are defined as numbers
- display layout looks like this:
sitemap watch label=“Watch” {
…
}
Frame label=“Gesamt/Year/Max” {
Text item=eto label=“PV Gesamt [%.2f kWh]” icon=“energy”
Text item=etd label=“Erzeugung heute [%.2f kWh]” icon=“energy” valuecolor=[<30=“red”,<50=“yellow”,>=50=“green”]
…
}
}