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);
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.
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
in test, looking good for now.
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





