delphiki / hass-pronote

Pronote integration for Home Assistant
58 stars 9 forks source link

Erreurs avec 0.9.0 #30

Open vingerha opened 11 months ago

vingerha commented 11 months ago

Celle-ci était déjà là dans 0.7.0 J'ai reconfiguré les comptes L'erreur vient de la compte de mon file qui n'a pas de grades Compte demo (parent fanny) ná pas de soucis EDIT: j'ai vu tes changements dans coordinator et c'est app pareil que j'avais fait sur 070 local...curieux...je vais tester de plus

EDIT2: correction, comme dit avant, mon fils a recu un note mais sans grade.average (null) donc le float/re.sub échoue

EDIT3:, j'ai enlevé float/re.sub et ça marche .. je ne sais pas comment faire une if/then ici


Last logged: 06:58:47

Error adding entities for domain sensor with platform pronote
Error while setting up pronote platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1002, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 730, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 774, in _async_generate_attributes
    attr.update(self.extra_state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pronote/sensor.py", line 233, in extra_state_attributes
    'class_average': float(re.sub(',', '.', grade.average)),
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/re/__init__.py", line 185, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
delphiki commented 11 months ago

Oui, je pense qu'il va falloir tester unitairement tous les champs avant de faire des opérations dessus, car s'ils sont vides, ça plante

vingerha commented 11 months ago

Solution pour encore substituer point par virgule


'class_average': float(re.sub(',', '.', str(grade.average).replace('None','0,0'))),
vingerha commented 11 months ago

Plus simple (trial and error car je ne suis pas trops ajour avec python)


'class_average': str(grade.average).replace('.',','),
vingerha commented 11 months ago

je vais retirer mon PR puis ajouter ci-dessus et re-ajouter information/surveys, d'accord?

vingerha commented 11 months ago

Correction: il existe un autre PR.... je ne le refait pas ... je le laisse à @GaPhi

vingerha commented 11 months ago

Testé ton allternative dans 0.9.0 mais encore même soucis. Seul choses qui marche

'class_average': str(grade.average).replace('.',','),

Ja fait un PR ?