[APP][Pro] Solar Forecasts (SolCast + Forecast.Solar)

conditions are easier to program then triggers, so I made it into condition (untested)

with homeyscript

let settings = await Homey.apps.getAppSettings({ id: 'com.solcast' });
let solcast = settings.solcast_raw;
if (typeof solcast === 'string') solcast = JSON.parse(solcast);

let cutoffTime = "14:00";
let threshold = 5;

let [h, m] = cutoffTime.split(":").map(Number);
let cutoff = new Date();
cutoff.setHours(h, m, 0, 0);

let remaining = solcast.forecasts
  .filter(f => new Date(f.period_end) <= cutoff)
  .reduce((acc, f) => acc + f.pv_estimate / 2, 0);

console.log(`Remaining before ${cutoffTime}: ${remaining.toFixed(2)} kWh`);
console.log("Below threshold?", remaining < threshold);

Okay, I have now made it like this.

@Pieterv123

Unfortunately, it’s not working properly yet. I just created a test flow. Remaining today = 2.84. kWh_PV_Required = 7.526. So both conditions are true. However, as you can see, the card with the cutoff time is false. Solcast reports production until 19:30 today. So the cutoff time card would be less than expected today. I’m happy with the AND card. Because I can use the same function again in my flow to improve forced charging. But at the moment, it’s not working as expected.

So obviously the upper condition is false according to your screen shot (yellow bar and yellow point at the false branche).
You can check the value by moving the mouse over the value as long as the flow is in test mode.
Example


So check the test outcome again. Probably you find the error, or you can provide more details.

For the moment I think it is not correct and I have no idea on fixing it.

Indeed, but it should be true.

Suggestion: ask for help in the developer forum, not ChatGPT.

2 Likes

you can test the latest version with a hopefully working trigger.
Condition has not been changed (yet)

Trigger tested. Looks like it’s working. If you can also make the condition work would be great. A number of conditions are then not necessary in my flow.

I will try to fix it this weekend

you can try the latest version with (hopefully) fixed condition card

1 Like

in test, looking good for now.

Hi, The prediction with Solcast of the day is always empty? Anybody knows why?

Try to put your midnight update after 02AM

Where do you set this up?

@Arko_Goossens Maybe with a flow?

Something like,

IF time is 2:00

THEN Fetch midnight update

Or something like this. I don’t use this app.

Correct

Zoiets:

Hi, having api rates exceeded error since a few days. Even if the api calls are very low (2).

The information which is shown is of 2 days ago. Runnen the latest version of the app and homey software

Anybody having the same issues/knows how to solve this?

Regards