JonasJoKuJonas / homeassistant-WebUntis

Custom component to access data from Web Untis in Home Assistant
https://community.home-assistant.io/t/webuntis-timetable-in-ha/568273
MIT License
53 stars 12 forks source link

Error setting up entry #144

Closed hr1179 closed 1 month ago

hr1179 commented 1 month ago

The problem

When trying to add the device for my child (for my other child it works) I get following error. It's a bit strange as some days before it worked but I've deleted both devices and add new ones as first calendar was empty for both childs (see bug report of other users). For one device it worked after a reboot but for the other I have this error. Even if I recreate the device.

Version of Home Assistant?

2023.11.1

What type of installation are you running?

Home Assistant Container

Version of WebUntis

unkown

Last working WebUntis version

unknown

Traceback/Error logs

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 402, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/webuntis/init.py", line 56, in async_setup_entry await server.async_update() File "/config/custom_components/webuntis/init.py", line 206, in async_update await self._async_status_request() File "/config/custom_components/webuntis/init.py", line 285, in _async_status_request self.next_class = await self._hass.async_add_executor_job(self._next_class) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/webuntis/init.py", line 504, in _next_class if lesson.start > now and self.check_lesson(lesson): ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/webuntis/init.py", line 717, in check_lesson if not lesson.subjects: ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/webuntis/utils/misc.py", line 30, in get obj.dict[self.name] = result = self.fget(obj) ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/webuntis/objects.py", line 355, in subjects return self._session.subjects(from_cache=True).filter( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/webuntis/objects.py", line 163, in filter data=[self.filter({key: v})[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/webuntis/objects.py", line 163, in data=[self.filter(**{key: v})[0]


  File "/usr/local/lib/python3.11/site-packages/webuntis/objects.py", line 180, in __getitem__
    data = self._data[i]  # fails if there is no such item
           ~~~~~~~~~~^^^
IndexError: list index out of range

### Additional information

_No response_
f-zappa commented 1 month ago

Same error came up here after today's update, even without changing the configuration. I defined two instances, one for personal plan (this one works) and one for the class (this one fails).

f-zappa commented 1 month ago

in my case it might also be the school still configuring untis because they just started using it some weeks ago.

JonasJoKuJonas commented 1 month ago

@f-zappa can you send me your logs because the logs above are from bevor the update

f-zappa commented 1 month ago

@f-zappa can you send me your logs because the logs above are from bevor the update

Logger: homeassistant.config_entries
Quelle: config_entries.py:604
Erstmals aufgetreten: 11:36:44 (4 Vorkommnisse)
Zuletzt protokolliert: 11:46:56

Error setting up entry GESCHWAERZT for webuntis
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/webuntis/__init__.py", line 60, in async_setup_entry
    await server.async_update()
  File "/config/custom_components/webuntis/__init__.py", line 240, in async_update
    await self._async_status_request()
  File "/config/custom_components/webuntis/__init__.py", line 338, in _async_status_request
    self.next_class = await self._hass.async_add_executor_job(self._next_class)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/webuntis/__init__.py", line 526, in _next_class
    if lesson.start > now and self.check_lesson(lesson):
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/webuntis/__init__.py", line 749, in check_lesson
    if not getattr(lesson, "subjects", None) and not self.invalid_subjects:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/webuntis/utils/misc.py", line 30, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
                                           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/webuntis/objects.py", line 355, in subjects
    return self._session.subjects(from_cache=True).filter(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/webuntis/objects.py", line 163, in filter
    data=[self.filter(**{key: v})[0]
          ~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/usr/local/lib/python3.12/site-packages/webuntis/objects.py", line 180, in __getitem__
    data = self._data[i]  # fails if there is no such item
           ~~~~~~~~~~^^^
IndexError: list index out of range
JonasJoKuJonas commented 1 month ago

does it work now?

f-zappa commented 1 month ago

does it work now?

no .. but we didn't change anything yet !?

JonasJoKuJonas commented 1 month ago

does it work now?

no .. but we didn't change anything yet !?

in version 1.2.2!

f-zappa commented 1 month ago

does it work now?

no .. but we didn't change anything yet !?

in version 1.2.2!

looks still the same, but the error is only there when i have "Kein Fach" enabled.

Logger: homeassistant.config_entries
Quelle: config_entries.py:604
Erstmals aufgetreten: 12:52:59 (5 Vorkommnisse)
Zuletzt protokolliert: 13:05:45

Error setting up entry ??? for webuntis
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/webuntis/__init__.py", line 60, in async_setup_entry
    await server.async_update()
  File "/config/custom_components/webuntis/__init__.py", line 240, in async_update
    await self._async_status_request()
  File "/config/custom_components/webuntis/__init__.py", line 338, in _async_status_request
    self.next_class = await self._hass.async_add_executor_job(self._next_class)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/webuntis/__init__.py", line 526, in _next_class
    if lesson.start > now and self.check_lesson(lesson):
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/webuntis/__init__.py", line 764, in check_lesson
    if any(subject.name in self.filter_subjects for subject in lesson.subjects):
                                                               ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/webuntis/utils/misc.py", line 30, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
                                           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/webuntis/objects.py", line 355, in subjects
    return self._session.subjects(from_cache=True).filter(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/webuntis/objects.py", line 163, in filter
    data=[self.filter(**{key: v})[0]
          ~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/usr/local/lib/python3.12/site-packages/webuntis/objects.py", line 180, in __getitem__
    data = self._data[i]  # fails if there is no such item
           ~~~~~~~~~~^^^
IndexError: list index out of range
JonasJoKuJonas commented 1 month ago

It is a different error. But I know where to fix it

JonasJoKuJonas commented 1 month ago

@f-zappa can you test version v1.2.3

f-zappa commented 1 month ago

@f-zappa can you test version v1.2.3

sorry, I can't test this ... the event without "Fach" (aka Wandertag im Kletterpark) already took place last week and so it's not longer visible.

JonasJoKuJonas commented 1 month ago

same here 🤣 so we just have to wait

hr1179 commented 1 month ago

For me, it works now. Thanks a lot!!!