bruxy70 / Garbage-Collection

🗑 Custom Home Assistant sensor for scheduling garbage collection (or other regularly re-occurring events - weekly on given days, semi-weekly or monthly)
MIT License
382 stars 90 forks source link

Feature Request: A state for next bin to be collected #425

Closed CaptInsano closed 2 years ago

CaptInsano commented 2 years ago

Before you submit a new bug report, please check that

Is your feature request related to a problem? Please describe.

I would like to set a conditional card to only show the next bin to be collected.

The current states in this addon allow me to show the the card when it is within a day of being collected but I would love more notice than that:

eg:

type: conditional
conditions:
  - entity: sensor.waste_bin
    state_not: '2'
card: 
  type: custom:garbage-collection-card
  entity: sensor.waste_bin
State
The state can be one of

Value   Meaning
0   Collection is today
1   Collection is tomorrow
2   Collection is later

Describe the solution you'd like

Would it be possible to create a new state "3" meaning this is the next bin to be collected?

Eg:

State
The state can be one of

Value   Meaning
0   Collection is today
1   Collection is tomorrow
2   Collection is later
3      Next bin to be collected

It would make this a much easier thing to accomplish!

Describe alternatives you've considered

I have tried to look at automations and helpers to set a helper toggle but I struggled

Additional context

Thanks so much for your work!

bruxy70 commented 2 years ago

You can create a group bin with all the bins in it. It will show the next one. Then, in the conditional card you can check if the days attribute is the same as the group. How about that?

CaptInsano commented 2 years ago

That seems like a complicated way to achieve the result, I will have to have a mess around as I do not fully understand what you are suggesting here!

Thanks so much for getting back to me!

bruxy70 commented 2 years ago

Not really complicated, probably less than what you suggest. Let me o slower.

When you configure the garbage collection helper, you choose the frequency. One of them is group that will then allow you to pick from other garbage collection helpers and show whichever comes next. That can be used to "merge" or combine two schedules, so for example If you have a winter and summer schedule, you can combine it to a single entity. So that is 90% of what you want.

So if you add all your garbage to a group, it will tell you that a collection is tomorrow, or today. But it would not tell you which one. So this is where the conditional card comes in. Each entity shows the number of days till the next collection. So if the number of days is the same as the number of says of the "master group", then this is the entity that is shown in the group, so it is the next one (and there could be more if there are more collections happening at the same day).