Solar Forecast PV

I understand what you say. But I seem to have the case where the binding thinks that my north facing solar plane was getting sun on it, even when the sun was physically below the ridge line of the roof. (note: winter in northern hemisphere)

I see your point. Think I’ve a similar situation, one pv plane facing north-east the other total opposite south-west The picture with comparison NE vs SW is below.
I’ve the luxury to compare the forecast against my inverter measures.

There’s no way in yellow mark in the morning that my SW plane is getting direct sunlight.
But I get the measures from my inverter and it’s producing.
There’s no way in red mark in the late evening that my NE plane is getting direct sunlight.
Again the measures from inverter shows production.

I think this has to do with diffuse sunlight which hits your pv plane rather than direct sunlight. Maybe @Forecast.Solar who owns forecast.solar service and is member of the forum can elaborate on that.

Have you found a solution for this problem?

What do you mean with solution?

As you can see from picture in previous post pretty much aligns with the forecast. If it doesn’t you’ve the possibility to tweak your forecast with advanced parameters like

  • damp factor
  • horizon

If it still doesn’t match the bindings will not do any corrections on the data provided by Solcast or forecast.solar

Sorry that I didn’t describe the problem in more detail.
I refer to a post 87 from June 2023:

Error in my log file:

> Script execution of rule with UID '037_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 037_Solcast

Rule:

val solarforecastActions = getActions("solarforecast","solarforecast:sc-site:homeSite")

        // get power forecast in 1 hour
        var hourPlusOnePowerState = solarforecastActions.getPower(LocalDateTime.now.plusHours(1))
        //logInfo("SF Tests","Hour+1 power state: "+ hourPlusOnePowerState.toString)
        if (hourPlusOnePowerState instanceof Number) { SolcastHourPlusOnePowerState.sendCommand(hourPlusOnePowerState as Number) }

It worked for me too and suddenly stopped after an update.
Is anyone able to help me?

Thanks for the details,

correct, Actions have changed during the review process so lets solve them step by step

First

Script execution of rule with UID ‘037_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 037_Solcast

Please assure solarforecastActions isn’t null, Maybe you’ve to restart your system with clean-cache

Second
You’ve to provide an Instant timestamp to get power

var hourPlusOnePowerState = solarforecastActions.getPower(ZonedDateTime.now.plusHours(1).toInstant)

After these changes it’s going to work

I have an issue with my JS rules. The following code:

        const solareForecastActions = actions.get('solarforecast', 'solarforecast:fs-site:homeSite');
        const forecastTomorrow = solareForecastActions.getDay(time.LocalDate.now().plusDays(1));
        items.getItem('SolarForecast_Energy_Tomorrow')?.postUpdate(forecastTomorrow);

leads to the following error:

2024-06-21 21:37:29.308 [WARN ] [e.automation.internal.RuleEngineImpl] - Failed to execute action: 1(Error: Failed to execute rule Solar-Forecast–Calculate-for-tomorrow-591b3a30-b1ff-41b9-980c-64281c026d29: TypeError: invokeMember (getDay) on org.openhab.binding.solarforecast.internal.actions.SolarForecastActions@16de93f failed due to: Cannot convert ‘[object Object]’(language: JavaScript, type: LocalDate) to Java type ‘java.time.LocalDate’: Value must have date and time information.: TypeError: invokeMember (getDay) on org.openhab.binding.solarforecast.internal.actions.SolarForecastActions@16de93f failed due to: Cannot convert ‘[object Object]’(language: JavaScript, type: LocalDate) to Java type ‘java.time.LocalDate’: Value must have date and time information.

So basically

Cannot convert ‘[object Object]’(language: JavaScript, type: LocalDate) to Java type ‘java.time.LocalDate’: Value must have date and time information.:

What can I do to make it work?

Just checked with DSL and looks fine with LocalDate.now.plusDays(1).

    val tomorrow = solcastActions.getDay(LocalDate.now.plusDays(1))
    logInfo("EMS PRED Tomorrow","{}",tomorrow)

What is time.LocalDate in your rule below?

Yeah, the examples are with DSL, I was not able to find a working example with JS based rules.
I assumed that time.LocalDate is the equivalent to the Java LocalDate, but it seems like this is not the case.

Other methods work fine in my JS rules like

const forecastPower = solareForecastActions.getPower(time.Instant.now().plusSeconds(60 * 60 * i));

Right, same name but these are different objects! Looked at javascript binding and LocalDate doesn’t fit. While testing I faced some basic problems calculating the correct date.

This works on my side using js:

forecastTomorrow = solareForecastActions.getDay(time.convert(time.ZonedDateTime.now().plusDays(1)).toDate());

Thanks, that did the trick. What works now is this:

const forecastTomorrow = solareForecastActions.getDay(time.convert(time.ZonedDateTime.now().plusDays(1)).toDate());
items.getItem('SolarForecast_Energy_Tomorrow')?.postUpdate(forecastTomorrow.toString());

Although I have no idea on how I should’ve figured out this myself.

Don’t worry, DateTime is a very sensitive topic => DateTime Conversion (openHAB 3.x)

Let me try to break it down

tomorrowDateTime = time.ZonedDateTime.now().plusDays(1); // tomorrow as js-joda
tomorrowDate = time.convert(tomorrowDateTime).toDate(); // convert to javascript date
forecastTomorrow = solareForecastActions.getDay(tomorrowDate);
  • time. is referring to js-joda library like described in javascript binding
  • tomorrowDateTime is exactly one day ahead as joda object
  • tomorrowDate is the conversion from js-joda to javascript date
  • use this tomorrowDate to query forecast for next day
1 Like

Hi.
For me the following code stopped working after upgrading to 4.2:

val solarforecastActions = getActions("solarforecast","solarforecast:fs-plane:0e8335fb8a:c056ab1541")
val forecastTomorrow = solarforecastActions.getDay(LocalDate.now.plusDays(1));

…my log just says:

 The method getDay(LocalDate) is undefined for the type ThingActions

When reading your conversation above (and also the examples in the binding documentation) I think that this should work, right? Is this something that changed in 4.2 (worked fine when running 4.0)?

edit: I think you can ignore this questions. Seems the binding wasn’t even installed any more, must have disappeared in the OH upgrade for some reason?

Hard to say because to be bloody honest I don’t know exactly how the upgrade process works. But I know OH4.2 is the first official release containing the solarforecast binding. So either you placed a jar in addons folder or you installed it via Marketplace before.
I propose to double check - delete jar from addons folder if it’s in and check Marketplace installations and remove. After check/cleanup install official approved binding.

Yep, you’re right, I had an old jar in there (according to the name made for 3.4). Guess OH 4.2 simply did ignore it as being too old. Simply deleted the file now, everything seems to work fine also after that. Thanks!

1 Like