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

Calendar broken on 4.7.7 #398

Closed nicksmith53 closed 2 years ago

nicksmith53 commented 2 years ago

Before you submit a new bug report, please check that

Describe the bug

After update from 4.7.6 to 4.7.7 collection days no longer show on the calendar. The sensors appear to still be working correctly.

Appears to be caused by 50c62a0958026a2658893f413846982f97d8c8b1

Calendar.py still references the old function https://github.com/bruxy70/Garbage-Collection/blob/master/custom_components/garbage_collection/calendar.py#L104

Configuration

{
  "home_assistant": {
    "installation_type": "Home Assistant Container",
    "version": "2022.5.4",
    "dev": false,
    "hassio": false,
    "virtualenv": false,
    "python_version": "3.9.9",
    "docker": true,
    "arch": "x86_64",
    "timezone": "America/New_York",
    "os_name": "Linux",
    "os_version": "5.3.18-150300.59.63-default",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "version": "1.24.5",
      "requirements": [
        "aiogithubapi>=21.11.0"
      ]
    },
    "holidays": {
      "version": "1.7.4",
      "requirements": [
        "python-dateutil>=2.8.2",
        "holidays>=0.13"
      ]
    },
    "garbage_collection": {
      "version": "4.7.7",
      "requirements": [
        "python-dateutil>=2.8.2"
      ]
    }
  },
  "integration_manifest": {
    "domain": "garbage_collection",
    "name": "Garbage Collection",
    "version": "4.7.7",
    "documentation": "https://github.com/bruxy70/Garbage-Collection/",
    "issue_tracker": "https://github.com/bruxy70/Garbage-Collection/issues",
    "iot_class": "calculated",
    "dependencies": [],
    "config_flow": true,
    "codeowners": [
      "@bruxy70"
    ],
    "requirements": [
      "python-dateutil>=2.8.2"
    ],
    "is_built_in": false
  },
  "data": {
    "entity_id": "sensor.trash_day",
    "state": 2,
    "attributes": {
      "next_date": "2022-05-20T00:00:00-04:00",
      "days": 2,
      "last_collection": "2022-04-28T19:54:28.653760-04:00",
      "last_updated": "2022-05-18T00:20:57.080307-04:00",
      "device_class": "garbage_collection__schedule"
    },
    "config_entry": {
      "entry_id": "1efe2b2eb1de2289be22ade72b9401d0",
      "version": 5,
      "domain": "garbage_collection",
      "title": "Trash Day",
      "data": {
        "unique_id": "2bdb0a29-4fbd-44b0-a7c0-9958f973cd39",
        "frequency": "weekly",
        "collection_days": [
          "fri"
        ],
        "first_month": "jan",
        "last_month": "dec",
        "icon_normal": "mdi:trash-can",
        "icon_today": "mdi:delete-circle",
        "icon_tomorrow": "mdi:delete-restore",
        "manual_update": true,
        "verbose_state": false,
        "hidden": false
      },
      "options": {},
      "pref_disable_new_entities": false,
      "pref_disable_polling": false,
      "source": "import",
      "unique_id": null,
      "disabled_by": null
    }
  }
}

Debug logs

2022-05-18 00:37:12 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 222, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 219, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 337, in get
    calendar_event_list = await entity.async_get_events(
  File "/config/custom_components/garbage_collection/calendar.py", line 54, in async_get_events
    return await self.hass.data[DOMAIN][CALENDAR_PLATFORM].async_get_events(
  File "/config/custom_components/garbage_collection/calendar.py", line 104, in async_get_events
    start = await garbage_collection.async_next_date(start_date, True)
AttributeError: 'WeeklyCollection' object has no attribute 'async_next_date'