Emoncms Demand Shaper module

The demandshaper background job demandshaper_run.php doesn’t seem to be able to reschedule Nordpool Spot portion correctly, but instead it always sets the schedule in OpenEVSE from 4 am to 8 am. What is curious is that this 4am to 8am matches with the Run period and Complete by settings?!

If I go to the web page, it correctly calculates the schedule and sets it on OpenEVSE, but the next day it again reverts to 4-8 am.

Any idea where to start investigating this? Is it the scheduler2.php that is responsible for this?

UPDATE:
The core reason why this happens is somehow related to the fact that there isn’t always 24h price data available for the future, but in the morning for example, you see that there is no data available for the following night. This leads the scheduler to assume prices after midnight are 0, so it always selects the last 4 hours, so from 4 to 8. Somewhere in program logic we should not allow these “empty” hours to be included in the calculation.

This hasn’t always been like this, the previous code did work correctly and this issue only started after the “big” refactoring that introduced multiple sources, etc.

UPDATE2: PR submitted at Fix Nordpool Spot scheduling by jpalo · Pull Request #65 · emoncms/demandshaper · GitHub