delphiki/hass-pronote

initialisation

Closed this issue · 17 comments

Hello,
I connect 3 pronote to my home assistant.
It works a few minute, then :
image

all sensors are unavailable.
nothing in logs

Thank's

same here, i registered with qrcode, and after changing nickname and wake up offset it's stuck in initialisation

homeassistant log :

2023-10-24 07:24:26.250 ERROR (MainThread) [custom_components.pronote.coordinator] Unexpected error fetching CHHAY--DURIS Ethan (via compte parent) data: ('Decryption failed while trying to un pad. (probably bad decryption key/iv)', 'exception happened during login -> probably bad username/password')
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pronotepy/pronoteAPI.py", line 327, in aes_decrypt
    return Padding.unpad(cipher.decrypt(data), 16)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/Crypto/Util/Padding.py", line 95, in unpad
    raise ValueError("PKCS#7 padding is incorrect.")
ValueError: PKCS#7 padding is incorrect.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pronote/coordinator.py", line 104, in _async_update_data
    client = await self.hass.async_add_executor_job(get_pronote_client, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pronote/pronote_helper.py", line 13, in get_pronote_client
    return get_client_from_qr_code(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pronote/pronote_helper.py", line 70, in get_client_from_qr_code
    client = (pronotepy.ParentClient if data['account_type'] == 'parent' else pronotepy.Client).token_login(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 154, in token_login
    return cls(pronote_url, username, password, mode="token", uuid=uuid)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 695, in __init__
    super().__init__(pronote_url, username, password, ent, mode, uuid)
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 390, in __init__
    super().__init__(pronote_url, username, password, ent, mode, uuid)
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 104, in __init__
    self.logged_in = self._login()
                     ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 207, in _login
    dec = e.aes_decrypt(bytes.fromhex(challenge))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/pronoteAPI.py", line 329, in aes_decrypt
    raise CryptoError(
pronotepy.exceptions.CryptoError: ('Decryption failed while trying to un pad. (probably bad decryption key/iv)', 'exception happened during login -> probably bad username/password')
2023-10-24 07:26:55.749 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/pronote/__init__.py", line 67, in update_listener
    await hass.config_entries.async_reload(entry.entry_id)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1268, in async_reload
    unload_result = await self.async_unload(entry_id)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1251, in async_unload
    raise OperationNotAllowed(
homeassistant.config_entries.OperationNotAllowed: The config entry CHHAY--DURIS Ethan (via compte parent) (pronote) with entry_id 6f655164ca41a86e5b0dad6c2ab42822 cannot be unloaded because it is not in a recoverable state (ConfigEntryState.SETUP_IN_PROGRESS)

QR code registration too

more info :
Unexpected error fetching CHHAY--DURIS Ethan (via compte parent) data: Unknown error from pronote: 5 | Votre adresse IP est provisoirement suspendue ! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/pronote/coordinator.py", line 104, in _async_update_data client = await self.hass.async_add_executor_job(get_pronote_client, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/pronote/pronote_helper.py", line 13, in get_pronote_client return get_client_from_qr_code(data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/pronote/pronote_helper.py", line 70, in get_client_from_qr_code client = (pronotepy.ParentClient if data['account_type'] == 'parent' else pronotepy.Client).token_login( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 154, in token_login return cls(pronote_url, username, password, mode="token", uuid=uuid) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 695, in __init__ super().__init__(pronote_url, username, password, ent, mode, uuid) File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 390, in __init__ super().__init__(pronote_url, username, password, ent, mode, uuid) File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 81, in __init__ self.attributes, self.func_options = self.communication.initialise() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pronotepy/pronoteAPI.py", line 100, in initialise initial_response = self.post( ^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pronotepy/pronoteAPI.py", line 181, in post raise PronoteAPIError( pronotepy.exceptions.PronoteAPIError: Unknown error from pronote: 5 | Votre adresse IP est provisoirement suspendue !

Unexpected error fetching CHHAY--DURIS Ethan (via compte parent) data: Your IP address is suspended. Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/pronote/coordinator.py", line 104, in _async_update_data client = await self.hass.async_add_executor_job(get_pronote_client, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/pronote/pronote_helper.py", line 13, in get_pronote_client return get_client_from_qr_code(data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/pronote/pronote_helper.py", line 70, in get_client_from_qr_code client = (pronotepy.ParentClient if data['account_type'] == 'parent' else pronotepy.Client).token_login( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 154, in token_login return cls(pronote_url, username, password, mode="token", uuid=uuid) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 695, in __init__ super().__init__(pronote_url, username, password, ent, mode, uuid) File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 390, in __init__ super().__init__(pronote_url, username, password, ent, mode, uuid) File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 81, in __init__ self.attributes, self.func_options = self.communication.initialise() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pronotepy/pronoteAPI.py", line 76, in initialise self.attributes = self._parse_html(get_response.content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pronotepy/pronoteAPI.py", line 261, in _parse_html raise PronoteAPIError("Your IP address is suspended.") pronotepy.exceptions.PronoteAPIError: Your IP address is suspended.

Même erreur par ici, peut être un souci de délai de rafraichissement trop élevé ?

Même erreur par ici, peut être un souci de délai de rafraichissement trop élevé ?

Je pense que le problème vient du soucis initial d'authentification (apres x authentifications échouées ban temporaire de l'ip) pour éviter les problèmes de brute force

Je n'ai pas le souci d'IP mais de token Ical pour ma part
Error getting ical_url from pronote: Pronote did not return ICal token
2023-10-24 15:02:34.333 DEBUG (MainThread) [custom_components.pronote.coordinator] Finished fetching xxxxxx Robin (via compte parent) data in 2.135 seconds
Du coup même si la récupération des données semble OK ça se bloque en initialisation

Même problème ici avec 2 comptes sur 2 pronotes de la meme ENT mais 2 etablissements différents.

Les 2 comptes ont été initialisés acec la méthode QRCode, au début l'initialisation se passe correctement pour les 2 comptes et des données correctes sont bien remontées depuis pronote (double check avec l'appli web pronote). Au bout de quelques heures l'etat suivant apparait :

Capture d’écran 2023-10-25 à 22 16 23

et les logs affichent respectivement pour chaque compte

2023-10-25 22:18:03.005 ERROR (MainThread) [custom_components.pronote.coordinator] Unexpected error fetching COMPTE2 (via compte parent) data: Your IP address is suspended.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pronote/coordinator.py", line 104, in _async_update_data
    client = await self.hass.async_add_executor_job(get_pronote_client, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pronote/pronote_helper.py", line 13, in get_pronote_client
    return get_client_from_qr_code(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pronote/pronote_helper.py", line 70, in get_client_from_qr_code
    client = (pronotepy.ParentClient if data['account_type'] == 'parent' else pronotepy.Client).token_login(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 154, in token_login
    return cls(pronote_url, username, password, mode="token", uuid=uuid)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 695, in __init__
    super().__init__(pronote_url, username, password, ent, mode, uuid)
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 390, in __init__
    super().__init__(pronote_url, username, password, ent, mode, uuid)
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 81, in __init__
    self.attributes, self.func_options = self.communication.initialise()
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/pronoteAPI.py", line 76, in initialise
    self.attributes = self._parse_html(get_response.content)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/pronoteAPI.py", line 261, in _parse_html
    raise PronoteAPIError("Your IP address is suspended.")
pronotepy.exceptions.PronoteAPIError: Your IP address is suspended.
2023-10-25 22:18:08.190 ERROR (MainThread) [custom_components.pronote.coordinator] Unexpected error fetching COMPTE1 (via compte parent) data: Your IP address is suspended.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pronote/coordinator.py", line 104, in _async_update_data
    client = await self.hass.async_add_executor_job(get_pronote_client, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pronote/pronote_helper.py", line 13, in get_pronote_client
    return get_client_from_qr_code(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pronote/pronote_helper.py", line 70, in get_client_from_qr_code
    client = (pronotepy.ParentClient if data['account_type'] == 'parent' else pronotepy.Client).token_login(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 154, in token_login
    return cls(pronote_url, username, password, mode="token", uuid=uuid)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 695, in __init__
    super().__init__(pronote_url, username, password, ent, mode, uuid)
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 390, in __init__
    super().__init__(pronote_url, username, password, ent, mode, uuid)
  File "/usr/local/lib/python3.11/site-packages/pronotepy/clients.py", line 81, in __init__
    self.attributes, self.func_options = self.communication.initialise()
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/pronoteAPI.py", line 76, in initialise
    self.attributes = self._parse_html(get_response.content)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pronotepy/pronoteAPI.py", line 261, in _parse_html
    raise PronoteAPIError("Your IP address is suspended.")
pronotepy.exceptions.PronoteAPIError: Your IP address is suspended.

des nouvelles ?

c'et bientôt la rentrée et l'intégration est inutilisable ....

Merci par avance

je pense que le problème vient du jeton créé par le QR code qui expire, c'est vraiment casse pied car cette intégration est vraiment cool

Apres 15 minutes, ça revient en initialisation .... et les sensor sont indispo

Exactement la même chose chez moi. Je viens de découvrir l'intégration, effectivement ça serait bien de trouver un workaround mais je n'ai pas les compétences.

Après avoir creusé, j'ai trouvé le fil de discussion sur hacf : https://forum.hacf.fr/t/integration-pronote-0-13-1-cours-devoirs-notes-etc/24682

vinergha mentionne que la version 11 fonctionne, j'ai donc en attendant rollback à cette version et ça tient.
image

delphiki dit faire une pause pendant les vacances et il est au courant :
image

si vous avez accès via user/mdp, a priori ça fonctionne, perso je n'arrive pas car ça passe par edu et malgré mes tentative j'ai un problème d'authentification

Hello,

La dernière version (0.13.2) devrait corriger le souci.
Si le souci persiste, essayez de supprimer puis ré-ajouter les entrées. 👍

je teste

merci !

pour le moment :
passage de la 11 à la 13.2 : OK
sensors : correctement initialisés
modification de config et rechargement de l'intégration : OK
refresh des données au bout de 15 minutes: OK

13.2 Ok pour un enfant. Le deuxième ne s'initialise pas plus . J'ai tenté suppression ajout, réinstall de l'intégration. Le prénom à des accents ça peut jouer? (Pénélope)
unsupported operand type(s) for: 'NoneType' and 'datetime.timedelta'
Lors de l'ajout j'ai fait les deux enfants avec le même QR code / code secret. ça peut être utile de le savoir ptet?

(en fait il ne s'initialise plus, car ça à fonctionné toute la soirée hier. Mes enfants étaient épatés :) )

la 13.2 corrige bien le problème d'initialisation. Merci beaucoup.
maintenant, nouveau problème qui a l'air lié à ce bug : #52
Je clos cette issue.