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

pgnig_gas_sensor: Error on device update! #51

Closed
n4ts opened this issue Jul 14, 2023 · 4 comments
Closed

pgnig_gas_sensor: Error on device update! #51

n4ts opened this issue Jul 14, 2023 · 4 comments

Comments

@n4ts
Copy link

n4ts commented Jul 14, 2023

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
Copy link
Owner

@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
Copy link
Owner

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

@pawelhulek
Copy link
Owner

Bardzo prosze o sprawdzenie: V2.3.5_beta_2

@pawelhulek
Copy link
Owner

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