- Platform information:
- Hardware: Raspberry Pi 3 Model B Rev 1.2
- OS: Raspbian GNU/Linux 9 (stretch)
- Issue of the topic: No issue: I need to understand the difference of the updateInterval in http.cfg and the one in the ITEM
Hello, I did a http binding to MeteoBlue to retrieve the sunshine forecast. Meteoblue allows me max 24 data feeds per day (max one per hour).
http.cfg:
meteoBlueCache.url=http://my.meteoblue.com/packages/basic-day_clouds-1h?name=Pucon&lat=-39.2822&lon=-71.9543&asl=236&tz=America%2FSantiago&apikey=xyzungeloest&temperature=C&windspeed=ms-1&winddirection=degree&precipitationamount=mm&timeformat=iso8601&format=json
meteoBlueCache.updateInterval=3600000
Note for other OH members: never use accents, Pucón is not allowed so I had to use Pucon. I spent a full day day of my short life for a ridiculous ó !!
Items:
String jMeteoBlue "Meteo [%s]" { http="<[meteoBlueCache:3600000:REGEX((.*))]" }
String sUpdateTime "mg uTime [%s]" { http="<[meteoBlueCache:3600000:JSONPATH($.metadata.modelrun_updatetime_utc)]" }
My question is here, what is the difference between the updateInterval in the http.cfg file and on the Item http="<[meteoBlueCache:3600000:… The http.cfg reads each updateInterval into the cache buffer and the Item reads from the cache without accessing the URL again?
I need to be sure: If I have many ITEMS accessing my Cache this is no extra traffic or other URL access?
Extra infos:
I’m parsing from MeteoBlue the sunshine time for the next day. I have a off-grid PV on Battery and I need to know how much electricity I can spend today depending on how much Sun I will have tomorrow. If the battery is very low and there is no sun coming I can start a generator.
The parsing of the MeteoBlue.JSON is done on a rule. I’m happy to share the code. It seems to work fine but if if someone helps me to optimize the code it would be great.
/*---------------------------------------------------------------------------------
;
; Read SunShine info
;
----------------------------------------------------------------------------------*/
rule "get sunshine"
when
Item jMeteoBlue changed
or Item POWERDHT changed // only for testing
then
if( jMeteoBlue.state != NULL ) {
var String jMeteo = jMeteoBlue.state.toString
var String sStart = transform( "JSONPATH", "$.data_day.indexto1hvalues_start[0]", jMeteo )
var String sEnd = transform( "JSONPATH", "$.data_day.indexto1hvalues_end[0]", jMeteo )
var int nStart = Float::parseFloat( sStart ).intValue
var int nEnd = Float::parseFloat( sEnd ).intValue
// logInfo( "SUN", "start " + nStart )
// logInfo( "SUN", "end " + nEnd )
var String sSun
var int nSunMinute = 0
var String jSon
//var int cnt =0
var int nSun
while( nStart < nEnd ) {
jSon = "$.data_1h.sunshinetime["
jSon += nStart
jSon += "]"
logInfo( "SUN", jSon );
nStart = nStart + 1
sSun = transform( "JSONPATH", jSon, jMeteo )
//logInfo( "SUN", "sSun " + sSun )
nSun = Float::parseFloat( sSun ).intValue
nSunMinute += nSun
}
vMeteoBlue.postUpdate( nSunMinute )
}
else vMeteoBlue.postUpdate( -1 )
end
I’m also parsing from MeteoGroup and checking the accuracy of both providers. Maybe I do an average. No many weather forecast provide the Sunshine data.
thanks !!