laszlojakab/homeassistant-dijnet

registry file not found

amaximus opened this issue · 5 comments

Dijnet integration v0.5.6.

Suddenly registry file is not found (it used to work before):

2022-11-18 09:55:14.404 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.dijnet_b3_szemet fails
Traceback (most recent call last):
  File "/home/pi/ha_venv3_9/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 527, in async_update_ha_state
    await self.async_device_update()
  File "/home/pi/ha_venv3_9/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 722, in async_device_update
    raise exc
  File "/home/pi/homeassistant_conf/custom_components/dijnet/sensor.py", line 121, in async_update
    invoices = [invoice for invoice in await self._controller.get_unpaid_invoices() if invoice.display_name == self._invoice_issuer.display_name and invoice.provider == self._provider]
  File "/home/pi/homeassistant_conf/custom_components/dijnet/controller.py", line 362, in get_unpaid_invoices
    await self.update_invoices()
  File "/home/pi/homeassistant_conf/custom_components/dijnet/controller.py", line 588, in update_invoices
    with open(get_registry_filename(self._username), "w") as file:
PermissionError: [Errno 13] Permission denied: '.dijnet_registry_amaximus.yaml'
(ha_venv3_9) pi@raspberrypi:~/homeassistant_conf $find . -name \*dijnet_registry_amaximus\*
(ha_venv3_9) pi@raspberrypi:~/homeassistant_conf $ls -a custom_components/dijnet/
.  ..  config_flow.py  const.py  controller.py  dijnet_session.py  __init__.py  manifest.json  __pycache__  sensor.py  strings.json  translations
(ha_venv3_9) pi@raspberrypi:~/homeassistant_conf $

As I see the structure of Dijnet pages changed a little bit. The integration has to be modified according to it.

@laszlojakab unfortunately this one also says:

2022-11-19 00:30:50.223 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.dijnet_b3_szemet fails
Traceback (most recent call last):
  File "/home/pi/ha_venv3_9/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 527, in async_update_ha_state
    await self.async_device_update()
  File "/home/pi/ha_venv3_9/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 730, in async_device_update
    await task
  File "/home/pi/homeassistant_conf/custom_components/dijnet/sensor.py", line 121, in async_update
    invoices = [invoice for invoice in await self._controller.get_unpaid_invoices() if invoice.display_name == self._invoice_issuer.display_name and invoice.provider == self._provider]
  File "/home/pi/homeassistant_conf/custom_components/dijnet/controller.py", line 362, in get_unpaid_invoices
    await self.update_invoices()
  File "/home/pi/homeassistant_conf/custom_components/dijnet/controller.py", line 567, in update_invoices
    with open(get_paid_invoices_filename(self._username), "a") as file:
PermissionError: [Errno 13] Permission denied: '.dijnet_paid_invoices_amaximus.yaml'

The solution is to use absolute path for controller.py lines 27 and 28, e.g.

PAID_INVOICES_FILENAME = "/tmp/.dijnet_paid_invoices_{0}.yaml"
REGISTRY_FILENAME = "/tmp/.dijnet_registry_{0}.yaml"

This is to make sure the python interpreter uses a location for these files where the user has write permission.

Okay so this issue not related to the changed webpage structure change.