davidusb-geek / emhass

emhass: Energy Management for Home Assistant, is a Python module designed to optimize your home energy interfacing with Home Assistant.
MIT License
260 stars 51 forks source link

Feature Request - Add a new input parameter to naive-mpc-optim to say deferrable load must be scheduled now #280

Closed danielclau closed 4 weeks ago

danielclau commented 1 month ago

Now that a lot of people does optimisation much more frequently than once a day, I was thinking how this could be improved without having to majorly rewrite EMHASS.

As the mpc-optim rest call does not keep state of previous runs, it does not know that a previous run has scheduled a deferrable to run now and the next call can schedule the deferrable to run at a later time (still within the window). If the mpc-optim job is run frequently, it can cause a deferrable load to start-stop frequently which is not healthy on things like compressors.

An idea would be to allow another parameter to be sent to EMHASS which tells EMHASS the deferrable is currently running so keep it running. EMHASS just has to put that in timeslot 0 and in successive timeslots till the job is finished. It could also send how much hows is left in that particular deferrable as EMHASS doesn’t keep state. This would be easy for us to send from HA as its easy to find out of the deferrable > 0W and when it last started. As an added bonus, this could be used to signify a job has completed for the day and not try to schedule it later.

eg. 4 hour job not started def_remainder_time = [4]

4 hour job midway def_remainder_time = [2]

4 hour job completed def_remainder_time = [0]

If this requires too much rewrite, then just a simple flag stating whether the job is currently running and we use existing p_def_total_hours to send remaining hours left.

def_running = [1]

davidusb-geek commented 1 month ago

Yes this can be a nice improvement. I will transfer this to the main EMHASS repo. However, for the second part of your request this is already possible. The use can dynamically update and pass the def_total_hours parameter at runtime so that for MPC you can take into account the reamainder # of hours

It could also send how much hows is left in that particular deferrable as EMHASS doesn’t keep state. This would be easy for us to send from HA as its easy to find out of the deferrable > 0W and when it last started. As an added bonus, this could be used to signify a job has completed for the day and not try to schedule it later.

davidusb-geek commented 4 weeks ago

This was added in the just published release. You can use the def_current_state aprameter at runtime to indicate that a deferrable load is currently scheduled/in-operation. Just set this to True/Flase for each of your deferrable loads. Closing this as completed but reopen if needed