Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in check_fix_rrule (AttributeError: 'str' object has no attribute 'items') #36

Open
liegri opened this issue Oct 16, 2021 · 2 comments

Comments

@liegri
Copy link

liegri commented Oct 16, 2021

Hi,

I just wanted to try this integration, but sadly I'm getting the following error repeatedly.

Log:

2021-10-16 17:29:19 ERROR (MainThread) [custom_components.ics.sensor] 
============= ICS Integration Error ================
2021-10-16 17:29:19 ERROR (MainThread) [custom_components.ics.sensor] unfortunately ICS hit an error, please open a ticket at
2021-10-16 17:29:19 ERROR (MainThread) [custom_components.ics.sensor] https://github.com/KoljaWindeler/ics/issues
2021-10-16 17:29:19 ERROR (MainThread) [custom_components.ics.sensor] and paste the following output:
2021-10-16 17:29:19 ERROR (MainThread) [custom_components.ics.sensor] Traceback (most recent call last):
  File "/config/custom_components/ics/sensor.py", line 173, in get_data
    _LOGGER.debug(f"fixed {self.check_fix_rrule(cal)} RRule dates")
  File "/config/custom_components/ics/sensor.py", line 152, in check_fix_rrule
    if("UNTIL" in event["RRULE"]):
  File "/usr/local/lib/python3.9/site-packages/icalendar/caselessdict.py", line 91, in __eq__
    return self is other or dict(self.items()) == dict(other.items())
AttributeError: 'str' object has no attribute 'items'

Integration details:

  • Installed version: 0.6.1
  • Installation method: HACS
  • Configuration method: Trough UI
  • Using an ics from Google calendar

HASS details:

  • Core Version: core-2021.9.4
  • Installation type: Home Assistant OS on RasPi

Let me know if I can provide you with any further details.

I hope you can fix this issue soon, thank you in advance :)

@liegri
Copy link
Author

liegri commented Oct 16, 2021

After some debugging I found out that event["RRULE"] was an array for one of my calendar events.

This quick and very dirty fix is now working for me (changes at == START OF FIX ==):

# inside custom_components/isc/sensor.py, check_fix_rrule
for event in calendar.walk('vevent'):
    if("RRULE" in event):
        # == START OF FIX ==
        if(isinstance(event["RRULE"], list):
            event["RRULE"] = event["RRULE"][0]
        # == END OF FIX ==
        if("UNTIL" in event["RRULE"]):
            # ...

Sadly (as of right now) I have no idea how this can be handled correctly, otherwise I would have created a PR.
But maybe my findings help you solve the bug.

@KoljaWindeler
Copy link
Owner

Hmm this seems to be an issue with the underlaying iCalendar .. would you open your ticket there? Also: I'd totally accept that pull request. ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants