Skip to content

Commit

Permalink
fix bad naming sensors - fix sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Giga77 committed Mar 25, 2024
1 parent f80adc5 commit 18bbc20
Show file tree
Hide file tree
Showing 7 changed files with 2,781 additions and 183 deletions.
30 changes: 16 additions & 14 deletions custom_components/ecole_directe/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,39 +103,41 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
homework["contenu"] = matiere["aFaire"]["contenu"]

_LOGGER.debug("homeworks_json:%s", homeworks_json)
self.data[f"homeworks{eleve.get_fullname_lower()}"] = homeworks_json
self.data[f"{eleve.get_fullname_lower()}_homeworks"] = (
homeworks_json
)
except Exception as ex:
_LOGGER.warning(
"Error getting homeworks from ecole directe: %s", ex
)
self.data[f"homeworks{eleve.get_fullname_lower()}"] = {}
self.data[f"{eleve.get_fullname_lower()}_homeworks"] = {}
if "NOTES" in eleve.modules:
try:
self.data[
f"grades{eleve.get_fullname_lower()}"
f"{eleve.get_fullname_lower()}_grades"
] = await self.hass.async_add_executor_job(
get_grades, session, eleve, year_data
)
self.compare_data(
previous_data,
f"grades{eleve.get_fullname_lower()}",
f"{eleve.get_fullname_lower()}_grades",
["date", "subject", "grade_out_of"],
"new_grade",
eleve,
format_grade,
)
except Exception as ex:
_LOGGER.warning("Error getting grades from ecole directe: %s", ex)
self.data[f"grades{eleve.get_fullname_lower()}"] = {}
# if "MESSAGERIE" in eleve.modules:
# try:
# self.data[
# "messages" + eleve.eleve_id
# ] = await self.hass.async_add_executor_job(
# get_messages, session, eleve, year_data
# )
# except Exception as ex:
# _LOGGER.warning("Error getting messages from ecole directe: %s", ex)
self.data[f"{eleve.get_fullname_lower()}_grades"] = {}
# if "MESSAGERIE" in eleve.modules:
# try:
# self.data[
# "messages" + eleve.eleve_id
# ] = await self.hass.async_add_executor_job(
# get_messages, session, eleve, year_data
# )
# except Exception as ex:
# _LOGGER.warning("Error getting messages from ecole directe: %s", ex)

return self.data

Expand Down
5 changes: 4 additions & 1 deletion custom_components/ecole_directe/ecole_directe_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
def format_homework(homework):
"""format homework"""
try:
contenu = base64.b64decode(homework.contenu).decode("utf-8")
if homework.contenu is not None:
contenu = base64.b64decode(homework.contenu).decode("utf-8")
else:
contenu = ""
return {
"date": homework.pour_le,
"subject": homework.matiere,
Expand Down
Loading

0 comments on commit 18bbc20

Please sign in to comment.