GuyKh / iec-custom-component

HomeAssistant Custom Component for IEC
MIT License
131 stars 5 forks source link

Exception thrown while calculating estimate #161

Closed mikeage closed 2 months ago

mikeage commented 2 months ago

System Health details

System Information

version core-2024.8.2
installation_type Home Assistant Container
dev false
hassio false
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.1.0-22-amd64
arch x86_64
timezone Asia/Jerusalem
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok HACS Data | ok GitHub API Calls Remaining | 4975 Installed Version | 2.0.0 Stage | running Available Repositories | 1401 Downloaded Repositories | 25
AccuWeather can_reach_server | ok -- | -- remaining_requests | 29
Dashboards dashboards | 2 -- | -- resources | 14 views | 14 mode | storage
Recorder oldest_recorder_run | September 1, 2024 at 6:19 AM -- | -- current_recorder_run | September 2, 2024 at 10:33 AM estimated_db_size | 800.25 MiB database_engine | mysql database_version | 10.11.9

Checklist

Describe the issue

Exception thrown while calculating estimate. (if it matters, I'm a customer of Pazgas, not IEC directly anymore)

Reproduction steps

  1. Install 0.33.0
  2. Restart

Debug logs

2024-09-02 10:34:17.689 WARNING (MainThread) [iec_api.commons] Failed call: (Code 401): Unauthorized
2024-09-02 10:34:17.702 ERROR (MainThread) [custom_components.iec.coordinator] Unexpected error fetching Iec data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/iec/coordinator.py", line 423, in _async_update_data
    total_kva_price, estimated_kwh_consumption = await self._estimate_bill(contract_id, device.device_number,
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/iec/coordinator.py", line 648, in _estimate_bill
    last_meter_read = last_meter_reading.reading
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'reading'


### Diagnostics dump

_No response_
mikeage commented 2 months ago

Actually, I'm not sure about this one. Several restarts later, it didn't reproduce.

GuyKh commented 2 months ago

Yeah, it means it wasn't able to read data from the meter; Shouldn't be happening