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
263 stars 51 forks source link

timeslots round to nearest 30 minute #133

Closed davidsgullick closed 6 months ago

davidsgullick commented 7 months ago

Describe the bug When using the naive-mpc-optimm it is encouraged to frequently call the function with new data using the endpoint and publish the results. However, when running with a freq of 30 minutes, the results in the Emhass table can sometimes show states starting in the future and not the modelled state for now.

To Reproduce config set at 30 minutes Pass data to the naive-mpc-optimm function at a time that would round down to the nearest half hour. For example 9:01 to 9:14 am. This will show in the table timeslots starting at 9:00am onwards. Do the same thing at 9:16 to 9:29 and the timeslots will start at 9:30.

Expected behavior I would expect the first timeslot to always include the current date and time. I think the first slot should be decided by a floor(CURRENT_TIME), not a round(CURRENT_TIME)

Screenshots If applicable, add screenshots to help explain your problem.

These screenshots were run one minute apart. The first at 08:14am the second at 08:15am. You can see the first timeslot dissapears in the table (and subsequent publishes to HA)

Screenshot 2023-11-24 at 08 14 34 Screenshot 2023-11-24 at 08 15 27

Home Assistant installation type

Your hardware

EMHASS installation type

Additional context

davidusb-geek commented 6 months ago

Use the parameter method_ts_round from the configuration file. You can set the method for timestamp rounding, options are: first, last and nearest. Don't you think that changing this parameter you may be able to obtain your derired behavior?

davidsgullick commented 6 months ago

Thanks very much. Yes thats exactly what I needed!