Repository: mampfes/hacs_waste_collection_schedule

Issue:
[Bug]: Issue with static calendar "last Monday of the month" schedule
### I Have A Problem With:

Sensor configuration

### What's Your Problem

Everything used to work fine until a few weeks ago. I have 3 static calendars:
- mixed waste is picked up every Monday
- plastic is picked up first Monday of the month
- paper is picked up last Monday of the month

I have 3 sources and 3 sensors configured, and as I've mentioned, everything used to work fine.

However, recently, the paper schedule became the same as the plastic schedule, it's showing first Mondays of the month (and not last). So it looks like plastic and paper are picked up on the same day.

e.g. currently (2023-04-03) the next paper pickup should show 2024-04-29 and not 2024-05-06.

Does anyone have an idea what might have changed to cause this, or a suggestion for a fix?

![image](https://github.com/mampfes/hacs_waste_collection_schedule/assets/1048531/95284844-e720-4127-8521-6d53ce3c0d19)
![image](https://github.com/mampfes/hacs_waste_collection_schedule/assets/1048531/b36a161c-4459-46ce-8c2f-73a2830d648d)
![image](https://github.com/mampfes/hacs_waste_collection_schedule/assets/1048531/41811cab-4896-4577-a1b6-2fbcd958a7c2)
![image](https://github.com/mampfes/hacs_waste_collection_schedule/assets/1048531/61c97ea2-da2d-4131-9b5b-fae313f96f88)


### Source (if relevant)

static

### Logs

```Shell
no relevant logs
```


### Relevant Configuration

```YAML
waste_collection_schedule:
  sources:
    - name: static
      calendar_title: "Garbage Pickup"
      args:
        type: Garbage
        frequency: WEEKLY
        weekdays: MO
    - name: static
      calendar_title: "Plastic Pickup"
      args:
        type: Plastic
        frequency: MONTHLY
        weekdays: { MO: 1 }
    - name: static
      calendar_title: "Paper Pickup"
      args:
        type: Paper
        frequency: MONTHLY
        weekdays: { MO: -1 }

sensor:
  - platform: waste_collection_schedule
    name: "Next Garbage Pickup"
    source_index: 0
    details_format: upcoming
    add_days_to: true
    value_template: "{{ value.daysTo }} days"
    types:
      - Garbage
  - platform: waste_collection_schedule
    name: "Next Plastic Pickup"
    source_index: 1
    details_format: upcoming
    add_days_to: true
    value_template: "{{ value.daysTo }} days"
    types:
      - Plastic
  - platform: waste_collection_schedule
    name: "Next Paper Pickup"
    source_index: 2
    details_format: upcoming
    add_days_to: true
    value_template: "{{ value.daysTo }} days"
    types:
      - Paper
```


### Checklist Source Error

- [ ] Use the example parameters for your source (often available in the documentation) (don't forget to restart Home Assistant after changing the configuration)
- [ ] Checked that the website of your service provider is still working
- [ ] Tested my attributes on the service provider website (if possible)
- [X] I have tested with the latest version of the integration (master) (for HACS in the 3 dot menu of the integration click on "Redownload" and choose master as version)

### Checklist Sensor Error

- [ ] Checked in the Home Assistant Calendar tab if the event names match the types names (if types argument is used)

### Required

- [X] I have searched past (closed AND opened) issues to see if this bug has already been reported, and it hasn't been.
- [X] I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.


Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/static.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/static.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/static.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/static.py
@@ -79,7 +79,7 @@ def __init__(
                 [
                     self.add_weekday(
                         weekday,
-                        int(number) if number is not None and number == "" else 1,
+                        int(number) if number is not None and number != "" else 1,
                     )
                     for weekday, number in weekdays.items()
                 ]


Test patch: