hass-pronote icon indicating copy to clipboard operation
hass-pronote copied to clipboard

Erreurs avec 0.9.0

Open vingerha opened this issue 2 years ago • 6 comments

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'

vingerha avatar Sep 22 '23 05:09 vingerha

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

delphiki avatar Sep 22 '23 07:09 delphiki

Solution pour encore substituer point par virgule

'class_average': float(re.sub(',', '.', str(grade.average).replace('None','0,0'))),

vingerha avatar Sep 22 '23 07:09 vingerha

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

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

vingerha avatar Sep 22 '23 07:09 vingerha

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

vingerha avatar Sep 22 '23 07:09 vingerha

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

vingerha avatar Sep 22 '23 07:09 vingerha

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 ?

vingerha avatar Oct 06 '23 05:10 vingerha