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

PR - Emploi du temps avec EDT #9

Merged
merged 17 commits into from
May 14, 2024
Merged

PR - Emploi du temps avec EDT #9

merged 17 commits into from
May 14, 2024

Conversation

DanBendavid
Copy link
Contributor

Ajout des objets Associé a Emploi du temps
LESSONS_TO_DISPLAY = 15

EDLesson,
get_lessons (...... edt_date_start, edt_date_end)
format_lesson
EDLessonsSensor

DanBendavid added 11 commits May 5, 2024 23:46
	modified:   custom_components/ecole_directe/ecole_directe_formatter.py
	modified:   custom_components/ecole_directe/ecole_directe_helper.py
	modified:   custom_components/ecole_directe/sensor.py
	modified:   custom_components/ecole_directe/sensor.py
	modified:   custom_components/ecole_directe/sensor.py
	modified:   custom_components/ecole_directe/coordinator.py
	modified:   custom_components/ecole_directe/ecole_directe_helper.py
	modified:   custom_components/ecole_directe/sensor.py
@DanBendavid
Copy link
Contributor Author

Mon fork sur la version 0.25 fonctionne sur les Notes et les Devoir. L'EDT indique cette Error getting Lessons from ecole directe: Error with URL:[https://api.ecoledirecte.com/v3/eleves/2204/emploidutemps.awp?verbe=get&v=4.55.0]: b'Oups une erreur est survenue ...: \r\n522'

@Giga77 Giga77 self-assigned this May 10, 2024
Copy link
Collaborator

@Giga77 Giga77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarde les commentaires que j'ai laissé

@@ -72,6 +74,10 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
else:
year_data = f"{str(current_year)}-{str(current_year + 1)}"

#EDT BODY
edt_date_start = "2024-05-02"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ici, il ne faut pas avoir la date en dur

] = await self.hass.async_add_executor_job(
get_lessons, session.token, eleve, edt_date_start, edt_date_end
)
#self.compare_data(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour l'emploi du temps pas besoin de comparer
Je ne vois pas l'utilité, chaque jour va forcément être différent.

"""get lessons"""
json_resp = get_response(
token,
f"{APIURL}/eleves/{eleve.eleve_id}/emploidutemps.awp?verbe=get&v={APIVERSION}",
Copy link
Collaborator

@Giga77 Giga77 May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l'url ici n'est pas bonne :
{APIURL}/E/{eleve.eleve_id}/emploidutemps.awp

source : https://github.com/EduWireApps/ecoledirecte-api-docs

@@ -9,4 +9,5 @@
# default values for options
DEFAULT_REFRESH_INTERVAL = 30
GRADES_TO_DISPLAY = 15
LESSONS_TO_DISPLAY = 15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ce n'est pas utilisé, tu peux le supprimer

@@ -83,3 +83,37 @@ def format_grade(grade) -> dict:
except Exception as ex:
_LOGGER.warning("Error: %s - format_grade: %s", ex, grade)
return {}


def format_lesson(lesson) -> dict:
Copy link
Collaborator

@Giga77 Giga77 May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adapte avec la fonction Pronote (pour utiliser les cartes Pronotes):

def format_lesson(lesson, lunch_break_time):
    return {
        'start_at': lesson.start,
        'end_at': lesson.end,
        'start_time': lesson.start.strftime("%H:%M"),
        'end_time': lesson.end.strftime("%H:%M"),
        'lesson': format_displayed_lesson(lesson),
        'classroom': lesson.classroom,
        'canceled': lesson.canceled,
        'status': lesson.status,
        'background_color': lesson.background_color,
        'teacher_name': lesson.teacher_name,
        'teacher_names': lesson.teacher_names,
        'classrooms': lesson.classrooms,
        'outing': lesson.outing,
        'memo': lesson.memo,
        'group_name': lesson.group_name,
        'group_names': lesson.group_names,
        'exempted': lesson.exempted,
        'virtual_classrooms': lesson.virtual_classrooms,
        'num': lesson.num,
        'detention': lesson.detention,
        'test': lesson.test,
        'is_morning': lesson.start.time() < lunch_break_time,
        'is_afternoon': lesson.start.time() >= lunch_break_time,
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'avais deja pris en compte le lovelace pour certaines données. Pas 100% d'equivalence.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui, je m'en doute.
Mais si on veut utiliser les cartes Pronotes, il nous faut les attributs, même s'ils sont vides.

	modified:   custom_components/ecole_directe/ecole_directe_helper.py
	modified:   custom_components/ecole_directe/sensor.py
@Giga77
Copy link
Collaborator

Giga77 commented May 12, 2024

Pourquoi as-tu fermé la PR ?

@DanBendavid DanBendavid reopened this May 12, 2024
@DanBendavid
Copy link
Contributor Author

J'ai voulu reprendre à partir de la 0.26. Je n'ai pas encore fait le formatage.

@Giga77
Copy link
Collaborator

Giga77 commented May 12, 2024

Pour ça, tu fais une PR de ma version 2.6 vers ton fork. Automatiquement cette PR sera mise à jour.

@Giga77
Copy link
Collaborator

Giga77 commented May 14, 2024

J'approuve et je finis le dév, merci

@Giga77 Giga77 merged commit 6b51edd into hacf-fr:main May 14, 2024
4 checks passed
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.

2 participants