GuyKh / iec-custom-component

HomeAssistant Custom Component for IEC
MIT License
122 stars 4 forks source link

Initialization failure after upgrading from 0.0.30 to 0.0.32 #156

Closed mikeage closed 1 week ago

mikeage commented 3 weeks ago

System Health details

System Information

version core-2024.7.3
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 GitHub API Calls Remaining | 4818 Installed Version | 1.34.0 Stage | running Available Repositories | 1400 Downloaded Repositories | 25
AccuWeather can_reach_server | ok -- | -- remaining_requests | 38
Dashboards dashboards | 2 -- | -- resources | 14 views | 14 mode | storage
Recorder oldest_recorder_run | August 6, 2024 at 6:42 PM -- | -- current_recorder_run | August 21, 2024 at 5:19 AM estimated_db_size | 636.64 MiB database_engine | mysql database_version | 10.11.9

Checklist

Describe the issue

2024-08-21 05:22:09.499 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 312, 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 659, in _estimate_bill
    power_size = await self._get_power_size(connection_size)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/iec/coordinator.py", line 195, in _get_power_size
    power_size = await self.api.get_power_size(connection_size)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/iec_api/iec_client.py", line 527, in get_power_size
    return await static_data.get_power_size(self._session, connection)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/iec_api/static_data.py", line 126, in get_power_size
    power_size = connection_to_power_size_map[connection]
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: '40'

Note that I current pay for electricity from Pazgas, if that matters.

Reproduction steps

  1. Upgrade

Debug logs

See https://termbin.com/c975

Diagnostics dump

No response

mikeage commented 3 weeks ago

FWIW, 0.0.31 was also broken for me, with a different error (I don't care about this, but just for helping to figure out when it happened):

2024-08-21 05:33:55.441 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 312, 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 640, in _estimate_bill
    if not is_private_producer or not last_meter_read:
                                      ^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'last_meter_read' where it is not associated with a value

I've gone back to 0.0.30 for now

Gugulator commented 3 weeks ago

same problem described in issue 154

GuyKh commented 1 week ago

https://github.com/GuyKh/py-iec-api/pull/130

GuyKh commented 1 week ago

@mikeage try with 0.0.33 (currently in Pre-Release)

mikeage commented 1 week ago

Looks good (there's a new exception that I didn't remember from before, but it's not relevant). I'll open a new issue for that one. Edit: #161