Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erreur lors de l'initialisation #79

Open
sebcaps opened this issue Dec 22, 2023 · 3 comments
Open

Erreur lors de l'initialisation #79

sebcaps opened this issue Dec 22, 2023 · 3 comments

Comments

@sebcaps
Copy link

sebcaps commented Dec 22, 2023

Lors de la mise à jour vers la version 0.9.0 (utilisation de l'api V4 pour le moment).

Logger: custom_components.rte_ecowatt
Source: helpers/update_coordinator.py:300
Integration: My EcoWatt by RTE ([documentation](https://github.com/kamaradclimber/rte-ecowatt), [issues](https://github.com/kamaradclimber/rte-ecowatt/issues))
First occurred: 18:22:50 (1 occurrences)
Last logged: 18:22:50

Unexpected error fetching ecowatt api data: the JSON object must be str, bytes or bytearray, not list
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 256, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/rte_ecowatt/__init__.py", line 189, in update_method
    signals = json.loads(body)["signals"]
              ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not list

Idem #77 , mais ne disparait pas ;-)
HA 2023.12.3

@kamaradclimber
Copy link
Owner

Bonjour,

merci du rapport de bug. Lorsque ce genre d'erreur arrive de façon répétée, il devrait y avoir un fichier .storage/rte_ecowatt contenant des informations utiles.
Par exemple:

{
  "version": 1,
  "minor_version": 1,
  "key": "rte_ecowatt",
  "data": {
    "last_update": "2023-11-29T19:23:43.857468",
    "body": "{\"signals\":[{\"GenerationFichier\":\"2023-11-28T23:00:00+01:00\",\"jour\":\"2023-11-29T00:00:00+01:00\",\"dvalue\":1,\"message\":\"Pas d\\u2019alerte.\",\"values\":[{\"pas\":0,\"hvalue\":1},{\"pas\":1,\"hvalue\":1},{\"pas\":2,\"hvalue\":1},{\"pas\":3,\"hvalue\":1},{\"pas\":4,\"hvalue\":1},{\"pas\":5,\"hvalue\":1},{\"pas\":6,\"hvalue\":1},{\"pas\":7,\"hvalue\":1},{\"pas\":8,\"hvalue\":1},{\"pas\":9,\"hvalue\":1},{\"pas\":10,\"hvalue\":1},{\"pas\":11,\"hvalue\":1},{\"pas\":12,\"hvalue\":1},{\"pas\":13,\"hvalue\":1},{\"pas\":14,\"hvalue\":1},{\"pas\":15,\"hvalue\":1},{\"pas\":16,\"hvalue\":1},{\"pas\":17,\"hvalue\":1},{\"pas\":18,\"hvalue\":1},{\"pas\":19,\"hvalue\":1},{\"pas\":20,\"hvalue\":1},{\"pas\":21,\"hvalue\":1},{\"pas\":22,\"hvalue\":1},{\"pas\":23,\"hvalue\":1}]},{\"GenerationFichier\":\"2023-11-28T23:00:00+01:00\",\"jour\":\"2023-11-30T00:00:00+01:00\",\"dvalue\":1,\"message\":\"Pas d\\u2019alerte.\",\"values\":[{\"pas\":0,\"hvalue\":1},{\"pas\":1,\"hvalue\":1},{\"pas\":2,\"hvalue\":1},{\"pas\":3,\"hvalue\":1},{\"pas\":4,\"hvalue\":1},{\"pas\":5,\"hvalue\":1},{\"pas\":6,\"hvalue\":1},{\"pas\":7,\"hvalue\":1},{\"pas\":8,\"hvalue\":1},{\"pas\":9,\"hvalue\":1},{\"pas\":10,\"hvalue\":1},{\"pas\":11,\"hvalue\":1},{\"pas\":12,\"hvalue\":1},{\"pas\":13,\"hvalue\":1},{\"pas\":14,\"hvalue\":1},{\"pas\":15,\"hvalue\":1},{\"pas\":16,\"hvalue\":1},{\"pas\":17,\"hvalue\":1},{\"pas\":18,\"hvalue\":1},{\"pas\":19,\"hvalue\":1},{\"pas\":20,\"hvalue\":1},{\"pas\":21,\"hvalue\":1},{\"pas\":22,\"hvalue\":1},{\"pas\":23,\"hvalue\":1}]},{\"GenerationFichier\":\"2023-11-28T23:00:00+01:00\",\"jour\":\"2023-12-01T00:00:00+01:00\",\"dvalue\":1,\"message\":\"Pas d\\u2019alerte.\",\"values\":[{\"pas\":0,\"hvalue\":1},{\"pas\":1,\"hvalue\":1},{\"pas\":2,\"hvalue\":1},{\"pas\":3,\"hvalue\":1},{\"pas\":4,\"hvalue\":1},{\"pas\":5,\"hvalue\":1},{\"pas\":6,\"hvalue\":1},{\"pas\":7,\"hvalue\":1},{\"pas\":8,\"hvalue\":1},{\"pas\":9,\"hvalue\":1},{\"pas\":10,\"hvalue\":1},{\"pas\":11,\"hvalue\":1},{\"pas\":12,\"hvalue\":1},{\"pas\":13,\"hvalue\":1},{\"pas\":14,\"hvalue\":1},{\"pas\":15,\"hvalue\":1},{\"pas\":16,\"hvalue\":1},{\"pas\":17,\"hvalue\":1},{\"pas\":18,\"hvalue\":1},{\"pas\":19,\"hvalue\":1},{\"pas\":20,\"hvalue\":1},{\"pas\":21,\"hvalue\":1},{\"pas\":22,\"hvalue\":1},{\"pas\":23,\"hvalue\":1}]},{\"GenerationFichier\":\"2023-11-28T23:00:00+01:00\",\"jour\":\"2023-12-02T00:00:00+01:00\",\"dvalue\":1,\"message\":\"Pas d\\u2019alerte.\",\"values\":[{\"pas\":0,\"hvalue\":1},{\"pas\":1,\"hvalue\":1},{\"pas\":2,\"hvalue\":1},{\"pas\":3,\"hvalue\":1},{\"pas\":4,\"hvalue\":1},{\"pas\":5,\"hvalue\":1},{\"pas\":6,\"hvalue\":1},{\"pas\":7,\"hvalue\":1},{\"pas\":8,\"hvalue\":1},{\"pas\":9,\"hvalue\":1},{\"pas\":10,\"hvalue\":1},{\"pas\":11,\"hvalue\":1},{\"pas\":12,\"hvalue\":1},{\"pas\":13,\"hvalue\":1},{\"pas\":14,\"hvalue\":1},{\"pas\":15,\"hvalue\":1},{\"pas\":16,\"hvalue\":1},{\"pas\":17,\"hvalue\":1},{\"pas\":18,\"hvalue\":1},{\"pas\":19,\"hvalue\":1},{\"pas\":20,\"hvalue\":1},{\"pas\":21,\"hvalue\":1},{\"pas\":22,\"hvalue\":1},{\"pas\":23,\"hvalue\":1}]}]}"
  }
}

Peux-tu me l'envoyer?

@sebcaps
Copy link
Author

sebcaps commented Dec 31, 2023

Salut,
Ci dessous contenu du fichier, générant l'erreur (PS, je suis passé en apiV5 : pas mieux)
Hope it helps

{
  "version": 1,
  "minor_version": 1,
  "key": "rte_ecowatt",
  "data": {
    "last_update": "2023-12-31T16:21:26.917296",
    "body": [
      {
        "GenerationFichier": "2023-12-30T23:00:00+01:00",
        "jour": "2023-12-31T00:00:00+01:00",
        "dvalue": 1,
        "message": "Pas d’alerte.",
        "values": [
          {
            "pas": 0,
            "hvalue": 1
          },
          {
            "pas": 1,
            "hvalue": 1
          },
          {
            "pas": 2,
            "hvalue": 1
          },
          {
            "pas": 3,
            "hvalue": 1
          },
          {
            "pas": 4,
            "hvalue": 1
          },
          {
            "pas": 5,
            "hvalue": 1
          },
          {
            "pas": 6,
            "hvalue": 1
          },
          {
            "pas": 7,
            "hvalue": 1
          },
          {
            "pas": 8,
            "hvalue": 1
          },
          {
            "pas": 9,
            "hvalue": 1
          },
          {
            "pas": 10,
            "hvalue": 1
          },
          {
            "pas": 11,
            "hvalue": 1
          },
          {
            "pas": 12,
            "hvalue": 1
          },
          {
            "pas": 13,
            "hvalue": 1
          },
          {
            "pas": 14,
            "hvalue": 1
          },
          {
            "pas": 15,
            "hvalue": 1
          },
          {
            "pas": 16,
            "hvalue": 1
          },
          {
            "pas": 17,
            "hvalue": 1
          },
          {
            "pas": 18,
            "hvalue": 1
          },
          {
            "pas": 19,
            "hvalue": 1
          },
          {
            "pas": 20,
            "hvalue": 1
          },
          {
            "pas": 21,
            "hvalue": 1
          },
          {
            "pas": 22,
            "hvalue": 1
          },
          {
            "pas": 23,
            "hvalue": 1
          }
        ],
        "date": "2023-12-31",
        "datetime": "2023-12-31T00:00:00+01:00"
      },
      {
        "GenerationFichier": "2023-12-30T23:00:00+01:00",
        "jour": "2024-01-01T00:00:00+01:00",
        "dvalue": 1,
        "message": "Pas d’alerte.",
        "values": [
          {
            "pas": 0,
            "hvalue": 1
          },
          {
            "pas": 1,
            "hvalue": 1
          },
          {
            "pas": 2,
            "hvalue": 1
          },
          {
            "pas": 3,
            "hvalue": 1
          },
          {
            "pas": 4,
            "hvalue": 1
          },
          {
            "pas": 5,
            "hvalue": 1
          },
          {
            "pas": 6,
            "hvalue": 1
          },
          {
            "pas": 7,
            "hvalue": 1
          },
          {
            "pas": 8,
            "hvalue": 1
          },
          {
            "pas": 9,
            "hvalue": 1
          },
          {
            "pas": 10,
            "hvalue": 1
          },
          {
            "pas": 11,
            "hvalue": 1
          },
          {
            "pas": 12,
            "hvalue": 1
          },
          {
            "pas": 13,
            "hvalue": 1
          },
          {
            "pas": 14,
            "hvalue": 1
          },
          {
            "pas": 15,
            "hvalue": 1
          },
          {
            "pas": 16,
            "hvalue": 1
          },
          {
            "pas": 17,
            "hvalue": 1
          },
          {
            "pas": 18,
            "hvalue": 1
          },
          {
            "pas": 19,
            "hvalue": 1
          },
          {
            "pas": 20,
            "hvalue": 1
          },
          {
            "pas": 21,
            "hvalue": 1
          },
          {
            "pas": 22,
            "hvalue": 1
          },
          {
            "pas": 23,
            "hvalue": 1
          }
        ],
        "date": "2024-01-01",
        "datetime": "2024-01-01T00:00:00+01:00"
      },
      {
        "GenerationFichier": "2023-12-30T23:00:00+01:00",
        "jour": "2024-01-02T00:00:00+01:00",
        "dvalue": 1,
        "message": "Pas d’alerte.",
        "values": [
          {
            "pas": 0,
            "hvalue": 1
          },
          {
            "pas": 1,
            "hvalue": 1
          },
          {
            "pas": 2,
            "hvalue": 1
          },
          {
            "pas": 3,
            "hvalue": 1
          },
          {
            "pas": 4,
            "hvalue": 1
          },
          {
            "pas": 5,
            "hvalue": 1
          },
          {
            "pas": 6,
            "hvalue": 1
          },
          {
            "pas": 7,
            "hvalue": 1
          },
          {
            "pas": 8,
            "hvalue": 1
          },
          {
            "pas": 9,
            "hvalue": 1
          },
          {
            "pas": 10,
            "hvalue": 1
          },
          {
            "pas": 11,
            "hvalue": 1
          },
          {
            "pas": 12,
            "hvalue": 1
          },
          {
            "pas": 13,
            "hvalue": 1
          },
          {
            "pas": 14,
            "hvalue": 1
          },
          {
            "pas": 15,
            "hvalue": 1
          },
          {
            "pas": 16,
            "hvalue": 1
          },
          {
            "pas": 17,
            "hvalue": 1
          },
          {
            "pas": 18,
            "hvalue": 1
          },
          {
            "pas": 19,
            "hvalue": 1
          },
          {
            "pas": 20,
            "hvalue": 1
          },
          {
            "pas": 21,
            "hvalue": 1
          },
          {
            "pas": 22,
            "hvalue": 1
          },
          {
            "pas": 23,
            "hvalue": 1
          }
        ],
        "date": "2024-01-02",
        "datetime": "2024-01-02T00:00:00+01:00"
      },
      {
        "GenerationFichier": "2023-12-30T23:00:00+01:00",
        "jour": "2024-01-03T00:00:00+01:00",
        "dvalue": 1,
        "message": "Pas d’alerte.",
        "values": [
          {
            "pas": 0,
            "hvalue": 1
          },
          {
            "pas": 1,
            "hvalue": 1
          },
          {
            "pas": 2,
            "hvalue": 1
          },
          {
            "pas": 3,
            "hvalue": 1
          },
          {
            "pas": 4,
            "hvalue": 1
          },
          {
            "pas": 5,
            "hvalue": 1
          },
          {
            "pas": 6,
            "hvalue": 1
          },
          {
            "pas": 7,
            "hvalue": 1
          },
          {
            "pas": 8,
            "hvalue": 1
          },
          {
            "pas": 9,
            "hvalue": 1
          },
          {
            "pas": 10,
            "hvalue": 1
          },
          {
            "pas": 11,
            "hvalue": 1
          },
          {
            "pas": 12,
            "hvalue": 1
          },
          {
            "pas": 13,
            "hvalue": 1
          },
          {
            "pas": 14,
            "hvalue": 1
          },
          {
            "pas": 15,
            "hvalue": 1
          },
          {
            "pas": 16,
            "hvalue": 1
          },
          {
            "pas": 17,
            "hvalue": 1
          },
          {
            "pas": 18,
            "hvalue": 1
          },
          {
            "pas": 19,
            "hvalue": 1
          },
          {
            "pas": 20,
            "hvalue": 1
          },
          {
            "pas": 21,
            "hvalue": 1
          },
          {
            "pas": 22,
            "hvalue": 1
          },
          {
            "pas": 23,
            "hvalue": 1
          }
        ],
        "date": "2024-01-03",
        "datetime": "2024-01-03T00:00:00+01:00"
      }
    ]
  }
}

@kamaradclimber
Copy link
Owner

Merci, ce qui est étrange est que le format du body n'est pas le même:

  • le tien est parsé alors qu'il est normalement sous forme brute
  • le tien contient la valeur "signal" dans la réponse de l'api alors que normalement on a la forme brute.

Je me demande comment ca a pu arriver.

Suggestion: renommer ce fichier (par exemple rte_ecowatt.bak). Le refraichissement suivant devrait fonctionner.

kamaradclimber added a commit to kamaradclimber/geovelo-homeassistant that referenced this issue Jan 27, 2024
Due to the way DataCoordinator are made, the data is fetched twice at
startup. This is a behavior that I don't know yet how to fix (probably
with a debouncer).
This, in combination with usage of `Store` class, leads to load data
from cache **twice**.
`Store` class has some clever mechanism to join two concurrent load
tasks in one.
This results in the **same** object being returned by two concurrent
loads, which are uncompressed twice.
A deep copy mitigates this (even though we still load twice)

This is probably the same issue than affects my other integrations (see
kamaradclimber/rte-ecowatt#79 for instance)

Reference: https://github.com/home-assistant/core/blob/858fb1fa376af47e570b0a9f718502de2b0d2636/homeassistant/helpers/storage.py#L125-L126
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants