weymann / OH3-SolarForecast-Drops

Development Drops for openHAB binding SolarForecast
4 stars 0 forks source link

getPower action not working #4

Closed hal295 closed 4 months ago

hal295 commented 4 months ago

Hi, I am running your great binding on OH4.2, installed from Marketplace. Using Solcast service with two sc-planes. And I am having trouble with getPower action used in rule:

"Script execution of rule with UID 'solcast-1' failed: An error occurred during the script execution: Could not invoke method: org.openhab.binding.solarforecast.internal.actions.SolarForecastActions.getPower(org.openhab.core.thing.binding.ThingActions,java.time.Instant,java.lang.String[]) on instance: null in solcast".

val solarforecastActions = getActions("solarforecast","solarforecast:sc-site:homeSite")     // this is definitely OK 
val granularityInMinutes = 30
var observedDateTime = LocalDateTime.now
val endDT = observedDateTime.plusDays(1)
endDT = endDT.minusMinutes(30)

var influx_content = ""
while (observedDateTime.isBefore(endDT)) {
     val powerAvg = solarforecastActions.getPower(observedDateTime).toString().replace(' kW', '')
     influx_content = influx_content + "solcast_power_estimate   value=" + powerAvg + " " + epoch +"\n"
     observedDateTime = observedDateTime.plusMinutes(granularityInMinutes)
}

I was using same code on OH3 and it works. I am using very similar script with getDay action with no problem on OH4.2. Can you help me pls? Thanks.

hal295 commented 4 months ago

Fixed! Problem was in using LocalDateTime instead of Instant. I found this in changelog Version 1.0-rc. https://community.openhab.org/t/solar-forecast-pv/137681?page=4#version-10-rc-3