kotope / aio_energy_management

Home Assistant All-In-One Energy Management integration
MIT License
14 stars 0 forks source link

Cleanup too aggressive #9

Closed xoferz closed 3 weeks ago

xoferz commented 3 weeks ago

When new Nordpool prices are published and starting_today is false the hours are removed from today even if they have not yet arrived.

For instance, I have a following sensor:

    - nordpool_entity: sensor.nordpool
      unique_id: nordpool_cheapest_2h_nonconsecutive
      name: "Cheapest 2h non-consecutive"
      first_hour: 0
      last_hour: 22
      starting_today: false
      number_of_hours: 2
      sequential: False
      failsafe_starting_hour: 22  

One of the hours was today - 25/09 at 15:00-16:00 This hour was removed from calendar when the prices for tomorrow, 26/09 were published. Screenshot 2024-09-25 at 14 40 30 (it is 14:50 now -- 15:00 has still not arrived and it has vanished) Only events in the past should be cleaned up from calendar. I would prefer to even keep past events for today for visuals.

kotope commented 3 weeks ago

Is this with the latest 0.2.0 release? I did make some changes of the expiration logic since it failed with entso-e and certain configuration. So if with latest release I might have done some regression accidentally.

Will look into this.

xoferz commented 3 weeks ago

0.1.1

kotope commented 3 weeks ago

0.1.1

Ok, could you try with latest 0.2.0? This issue is most probably fixed already. Just tried to reproduce this using unit testing and couldn't get this to happen. Will try the same unittest with 0.1.1 to see if it fails on that release.

kotope commented 3 weeks ago

Couldn't reproduce this issue either with 0.1.1.

Would you mind sharing some more info? I'd like to know the timezone you're in and the Nord Pool regional data used.

kotope commented 3 weeks ago
Screenshot 2024-09-25 at 15 53 22

I've got kind of similar setup on my dev env currently. "My next day hours" is still coming up later today and already tomorrow hours are ready for tomorrow, no cleanup is made for that entity. This is with latest 0.2.0 though.

xoferz commented 3 weeks ago

Are they "starting_today: false"? I do not really understand the implications of true/false here anyway :-)

kotope commented 3 weeks ago

Are they "starting_today: false"? I do not really understand the implications of true/false here anyway :-)

Yes, starting_today is false on that sensor.

starting_today should be marked true if the cheapest hours should be calculated partially for the same day already. E.g in cases where you want to run find hours during night like between 22-06.

kotope commented 3 weeks ago

Found an issue with a help of another user. It looks like Home Assistant restart (or integration) reload will cleanup too quickly.

I will resolve the issue as soon as possible.

kotope commented 3 weeks ago

This should now be fixed on 0.2.1 assuming that the root cause for this is the reboot of Home Assistant or reloading integration.

If you still experience data loss, please re-open the issue and I'll keep on digging.

Thank you @xoferz for your bug report!

xoferz commented 3 weeks ago

Yes, HA reload might have well been a factor. Will test.