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

calendar for canteen lunches #69

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mgrfilipmarek
Copy link
Collaborator

@mgrfilipmarek mgrfilipmarek commented Dec 17, 2024

This is the first (prototype) of edupage canteen calendar with lunches loaded if available. We can add and adjust loaded data in the next steps or after some feedback. For example allergens, rating or weight.

@mgrfilipmarek mgrfilipmarek linked an issue Dec 17, 2024 that may be closed by this pull request
@rine77 rine77 self-assigned this Dec 17, 2024
@rine77
Copy link
Owner

rine77 commented Dec 17, 2024

Thanks!

some points:

  • we should make canteen menu optional, so e.g. if there is no module in school edupage instance, than there is no entity for it. Do you think it's possible?
  • when I test this branch I dont have any grade sensors anymore and student_name is None in notifications sensor (it crashes unidecode) and also calendar is no more functional. Even if remove integration and reinstall.
  • I dont have lots of spare time atm due to real life work but I see you are getting deeper into the rabbit hole day by day :) thanks man

@mgrfilipmarek
Copy link
Collaborator Author

  • Im afraid we don`t have the information from edupage-api if lunches module is on/off
  • do you see any error in your log? (coming from custom_components/homeassistantedupage/homeassistant_edupage.py, line 134)

@rine77
Copy link
Owner

rine77 commented Dec 17, 2024

  • "failed to fetch timetable:" word "timetable" is to be removed cause the try/except block handled all data. Maybe we should try/except all steps alone, but in this case its because of the missing data of get_lunched():

2024-12-17 13:42:30.120 ERROR (MainThread) [custom_components.homeassistant_edupage] INIT Failed to fetch timetable: EDUPAGE error updating get_lunches() data for 2024-12-17: list index out of range

  • next error is because unidecode tries to access a None object:

2024-12-17 14:22:45.286 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up homeassistantedupage platform for sensor
Traceback (most recent call last):
File "/home/rine/Projekte/homeassistantedupage/.venv/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 366, in _async_setup_platform
await asyncio.shield(awaitable)
File "/home/rine/Projekte/homeassistantedupage/custom_components/homeassistantedupage/sensor.py", line 45, in async_setup_entry
notify = EduPageNotificationSensor(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rine/Projekte/homeassistantedupage/custom_components/homeassistantedupage/sensor.py", line 121, in init
self.student_name = unidecode(student_name).replace(' ', '').lower()
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rine/Projekte/homeassistantedupage/.venv/lib/python3.12/site-packages/unidecode/init.py", line 60, in unidecode_expect_ascii
bytestring = string.encode('ASCII')
^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'encode'

@mgrfilipmarek
Copy link
Collaborator Author

  • We can return None if there is an exception in get_lunches(self, date): method. But Im not sure if this is proper way to go as Im new in python and also cannot really reproduce. What do you think?

  • Regarding unidecode error - I dont see a point why this happened as unidecode was not added or changed in this PR.

@rine77
Copy link
Owner

rine77 commented Dec 17, 2024

  • the get_lunch problem should be handled in init.py by catching the error with try/except and only create lunch sensor if there is data
  • the unicode error happens because the student_name is of Type None, this must be catched

@mgrfilipmarek
Copy link
Collaborator Author

Regarding "unidecode" issue - I guess its related to this bug #70 and should be solved separately. Would someone be able to overtake that pls?

@rine77
Copy link
Owner

rine77 commented Dec 18, 2024

I'd go for it but have 2 full range offsite working days and will not be back before friday.

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

Successfully merging this pull request may close these issues.

[feature_request] lunch as calendar entries
2 participants