Skip to content

Commit

Permalink
avoid error if session doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Giga77 committed Mar 28, 2024
1 parent 135f3fe commit 8db01d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion custom_components/ecole_directe/ecole_directe_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
_LOGGER = logging.getLogger(__name__)

APIURL = "https://api.ecoledirecte.com/v3"
APIVERSION = "4.53.0"
APIVERSION = "4.53.4"


def encode_body(dictionnary, is_recursive=False):
Expand Down
18 changes: 9 additions & 9 deletions custom_components/ecole_directe/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ async def async_setup_entry(
]

sensors = []

for eleve in coordinator.data["session"].eleves:
sensors.append(EDChildSensor(coordinator, eleve))
if "CAHIER_DE_TEXTES" in eleve.modules:
sensors.append(EDHomeworksSensor(coordinator, eleve))
if "NOTES" in eleve.modules:
sensors.append(EDGradesSensor(coordinator, eleve))

async_add_entities(sensors, False)
if "session" in coordinator.data and "eleves" in coordinator.data["session"]:
for eleve in coordinator.data["session"].eleves:
sensors.append(EDChildSensor(coordinator, eleve))
if "CAHIER_DE_TEXTES" in eleve.modules:
sensors.append(EDHomeworksSensor(coordinator, eleve))
if "NOTES" in eleve.modules:
sensors.append(EDGradesSensor(coordinator, eleve))

async_add_entities(sensors, False)


class EDGenericSensor(CoordinatorEntity, SensorEntity):
Expand Down

0 comments on commit 8db01d5

Please sign in to comment.