pawelhulek / pgnig-sensor

This sensor is gathering gas usage data from PGNIG ebok page.
MIT License
31 stars 8 forks source link

pgnig_gas_sensor: Error on device update! #51

Closed n4ts closed 9 months ago

n4ts commented 1 year ago

Od wersji HA 2023.7.0 raportowany jest błąd i dane nie są zczytywane poprawnie.

Poniżej logi: 2023-07-14 10:21:01.436 ERROR (MainThread) [homeassistant.components.sensor] pgnig_gas_sensor: Error on device update! Traceback (most recent call last): File "/home/pi/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 570, in _async_add_entity await entity.async_device_update(warning=False) File "/home/pi/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity.py", line 940, in async_device_update await self.async_update() File "/home/pi/.homeassistant/custom_components/pgnig_gas_sensor/sensor.py", line 171, in async_update self._state = await self.hass.async_add_executor_job(self.invoices_summary) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.homeassistant/custom_components/pgnig_gas_sensor/sensor.py", line 182, in invoices_summary next_payment_item = min(filter(upcoming_payment_for_meter, self.api.invoices().invoices_list), ^^^^^^^^^^^^^^^^^^^ File "/home/pi/.homeassistant/custom_components/pgnig_gas_sensor/PgnigApi.py", line 41, in invoices return invoices_from_dict(requests.get(invoices_url, headers={ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.homeassistant/custom_components/pgnig_gas_sensor/Invoices.py", line 185, in invoices_from_dict return Invoices.from_dict(s) ^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.homeassistant/custom_components/pgnig_gas_sensor/Invoices.py", line 162, in from_dict invoices_list = from_list(InvoicesList.from_dict, obj.get("InvoicesList")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.homeassistant/custom_components/pgnig_gas_sensor/Invoices.py", line 38, in from_list return [f(y) for y in x] ^^^^^^^^^^^^^^^^^ File "/home/pi/.homeassistant/custom_components/pgnig_gas_sensor/Invoices.py", line 38, in return [f(y) for y in x] ^^^^ File "/home/pi/.homeassistant/custom_components/pgnig_gas_sensor/Invoices.py", line 110, in from_dict automatic_payment_date = from_datetime(obj.get("AutomaticPaymentDate")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.homeassistant/custom_components/pgnig_gas_sensor/Invoices.py", line 14, in from_datetime return dateutil.parser.parse(x) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/homeassistant/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 1368, in parse return DEFAULTPARSER.parse(timestr, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/homeassistant/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 640, in parse res, skipped_tokens = self._parse(timestr, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/homeassistant/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 719, in _parse l = _timelex.split(timestr) # Splits the timestr into tokens ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/homeassistant/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 201, in split return list(cls(s)) ^^^^^^ File "/home/pi/homeassistant/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 69, in init raise TypeError('Parser must be a string or character stream, not ' TypeError: Parser must be a string or character stream, not NoneType

pawelhulek commented 9 months ago

@n4ts Wybacz poślizg. Przeoczyłem kompletnie ze wskoczyło kilka issuesów.

Problem dalej występuje? Lokalnie nie udalo mi sie powtórzyć. Natomiast widze ze leci blad na polu AutomaticPaymentDate, które nie powinno byc uzywane.

Dla pewności. Nie korzystasz z forka? Nie podmieniales sobie kodu pod spodem?

Jeśli to nie to pewnie wystarczy ze usune odczyt tego pola z API, bo pewnie zachowuje sie u Ciebie odrobine inaczej.

pawelhulek commented 9 months ago

@n4ts Zerkniesz na wersje. Prawodobpodbnie masz opcjonalne pole którego nie spodziewalem sie ze bedzie opcjonalne. image

pawelhulek commented 9 months ago

Bardzo prosze o sprawdzenie: V2.3.5_beta_2

pawelhulek commented 9 months ago

Poprawione w https://github.com/pawelhulek/pgnig-sensor/releases/v2.3.5