Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code refactoring - scheduling by automation

See original GitHub issue

I plan to do a major rewrite of the integration, that will hopefully make this whole thing simpler and more flexible.

Over I added a number of exceptions to the holiday handling. The “holidays” feature was not meant to be the main function of the integration, but as there are many different ways to handle these, it grew quickly. As a result, it made the integration quite complicated, both for the configuration as well as the logic. And even then, there are more and more requests for handling different exceptions. So, I decided for a completely different approach.

I will pre-generate the collection schedule for year ahead (as I do for the calendar anyhow), as well as a list of holidays. But it will not automatically skip collections or move it to another day.

Instead, I will create two services - to remove_date and add_date to the calendar, allowing to adopt any logic anyone wants, including skipping specific dates, adding new ones etc. I also plan to add a new empty frequency where you can add the schedule by the automation based on whatever logic you want (e.g. take it from a list).

The schedule will be refreshed once a day (or you could trigger it by service) - after the refresh it will create an event. Then, you can have automation triggered by this event to handle the exceptions. At the end, it will search for the next collection date according to the new schedule. And I am thinking to create few blueprints to handle the basic exceptions, similar to what is done now by the automation (and with that, you will be able to create your own and share with the others).

I will also probably move completely to the config-flow configuration, as this is where HA is apparently moving anyhow.

I will use this issue to link all other related issues and I will close those. Feel free to discuss this below.

What do you think?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

rob51i03commented, Sep 13, 2021

I can’t comment on the “how”, but the “what” seems to be all positive. I’m a huge fan of your component and this change can only make it better. It’s impossible to pre-empt all the different ways this component can be used, so adding the freedom you are suggesting to manipulate the calendar sounds like a real win, making the component more flexible and yet easier to maintain.

My only question is whether such a major code refactoring would require any existing garbage collection entities to be deleted and re-added? Not a show-stopper for me but it might affect any plans to add more entities in the interim.

Thank you for continuing to invest your considerable thought and effort into this custom component.

bruxy70commented, Jan 12, 2022

I created a couple of blueprints. You can check them out. I will be now creating a separate integration for holidays, then create more blueprints to fully replace this functionality, and then make these parameters obsolete, and eventually remove them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code Refactoring: What You Need to Know About It
Understanding Code Refactoring: A Tester's Perspective. The term 'Refactoring' is mainly used to indicate required code cleanup/redesign.
Read more >
Automated scheduling for clone‐based refactoring using a ...
Refactoring is a widely accepted technique to improve the software quality by restructuring its design without changing its behavior.
Read more >
Automated scheduling for clone-based ... - ResearchGate
We first detect code clones that are suitable for refactoring and generate the most beneficial refactoring schedule to remove them.
Read more >
What is Code Refactoring? How Refactoring Resolves ...
Refactor during regularly-scheduled intervals. This doesn't have to mean dedicating a whole day to it, but rather add it in to your routine...
Read more >
Automated scheduling for clone-based ... - ACM Digital Library
Automated scheduling for clone-based refactoring using a competent GA · Approximation algorithms analysis · Scheduling algorithms · Online algorithms · Online ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found