Get arraylist with status from item

  • Platform information:
    • Hardware: rasp4
    • OS: openhabian
    • openHAB version: 3.3
  • how i get all values from actual day beginnen at 0:00 clock in a arraylist.

Hi, i have live data from my solarplant. Binding is okay and working. I want to send the data from today via array(list) and mqtt to an esp32 with epaper display… i need 720 datapoints (2min resolution -24 houres) .

Question is: Is it possible to get all points from beginning of a day from persistence?
I want an arrayfor euch day and send it… if i habe to restart the esp32 i will send all data again.

The rest is fine. I will send the data inside of a rule

Thanks a lot.

Have a lok onto the API Explorer on MainUi.
Using that one you can get the stored values for a persisted item in JSON format. The needed http code can be copied from the respective subpage.
Note that your persistence would need to be setup for 2 minute steps in advance, the above request can return data only in the persisted steps.

Thanks a lot… looks good

in the rule I’m calling
var String value = sendHttpGetRequest(“url”);

Here is the solution for all who are interessted:

// 00:00 as StartTime
var String myDate = String::format("%1$tY-%1$tm-%1$td", now() )
val myStartDate = ZonedDateTime.parse(myDate+"T00:00:00.000Z").withZoneSameInstant(ZoneId.systemDefault()).toInstant.toEpochMilli

//  catch the data
var String url =  "http://xxx.xxx.xxx.xxx:8080/rest/persistence/items/SolarEdge_Production?starttime="+myDate+"T00%3A00%3A00.000Z"
var String value = sendHttpGetRequest(url)
 
var String sentext = ""
var i = 0
var myStartTime = myStartDate
 
while (i < 720) 
{  
  if(i > 0)
    sentext +=","
    
    var result = transform("JSONPATH","$.data[?(@.time=='" + myStartTime.toString + "')].state",value)
    
    if(result.toString == "NULL")
      sentext += "0.0"
     else
       sentext += result
    
    //  jump 2 minutes
    myStartTime += 120000
    
    i += 1
}

logInfo("",sentext)
2 Likes

One last question - the timestamp from the API is GMT and not my timezone, right ? the are to early (-2houres) and not my local time. i was wondering why my solarplant starts so eraly (5 O’clock and not 7 like in my normal app.
I have also a problem with the solaredge binding… this is why i’m asking… The binding is online but - send any data also with a delay ( so its NOT live, like it should be)