GuyKh / iec-custom-component

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

version 0.0.31 fail to initialize #154

Closed Gugulator closed 1 week ago

Gugulator commented 3 weeks ago

System Health details

System Information

version core-2024.8.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.44-haos
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 | 4627 Installed Version | 1.34.0 Stage | running Available Repositories | 1391 Downloaded Repositories | 32
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 13.0 -- | -- update_channel | stable supervisor_version | supervisor-2024.08.0 agent_version | 1.6.0 docker_version | 26.1.4 disk_total | 30.8 GB disk_used | 7.7 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | kvm board | ova supervisor_api | ok version_api | ok installed_addons | File editor (5.8.0), Mosquitto broker (6.4.1), Home Assistant Google Drive Backup (0.112.1), Zigbee2MQTT (1.39.1-1), Samba share (12.3.2), Network UPS Tools (0.13.1), Vaultwarden (Bitwarden) (0.22.0), Advanced SSH & Web Terminal (18.0.0), RPC Shutdown (2.5), SQLite Web (4.2.0)
Dashboards dashboards | 5 -- | -- resources | 17 views | 23 mode | storage
Recorder oldest_recorder_run | August 9, 2024 at 21:14 -- | -- current_recorder_run | August 19, 2024 at 21:28 estimated_db_size | 86.76 MiB database_engine | sqlite database_version | 3.45.3

Checklist

Describe the issue

Needs attention IEC Account (my id) No devices or entities Failed setup, will retry: cannot access local variable 'last_meter_read' where it is not associated with a value

Reproduction steps

fresh install of integration.

system details: Core 2024.8.2 Supervisor 2024.08.0 Operating System 13.0 Frontend 20240809.0

Debug logs

Logger: custom_components.iec.coordinator
Source: helpers/update_coordinator.py:354
integration: Israel Electric Corporation (IEC)

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 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

Diagnostics dump

No response

GuyKh commented 3 weeks ago

Use 0.0.31-fix

Gugulator commented 3 weeks ago

Use 0.0.31-fix

how to install the fix?

GuyKh commented 3 weeks ago

just install 0.0.32

Gugulator commented 3 weeks ago

ok, manually copied files of 0.31.fix still getting error in logs:

Logger: custom_components.iec.coordinator Source: helpers/update_coordinator.py:354 integration: Israel Electric Corporation (IEC) (documentation, issues) First occurred: 22:05:07 (2 occurrences) Last logged: 22:05:26

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 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: '25'
Gugulator commented 3 weeks ago

upgraded to 0.0.32 still same error:

Logger: custom_components.iec.coordinator Source: helpers/update_coordinator.py:354 integration: Israel Electric Corporation (IEC) (documentation, issues) First occurred: 22:07:45 (1 occurrences) Last logged: 22:07:45

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 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: '25'
Gugulator commented 3 weeks ago

currently 2 new errors appeared in logs, probably due to some service down on IEC side.

Logger: custom_components.iec.coordinator

Source: custom_components/iec/coordinator.py:120 integration: Israel Electric Corporation (IEC) (documentation, issues) First occurred: 22:15:00 (1 occurrences) Last logged: 22:15:00

Bad logger message: Failed fetching device details by meter id my_clock_id_number ((IECError('(Code 500): Something went wrong please try again!'),))

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'

tzagim commented 3 weeks ago

+1 0.0.31 and 0.0.32 on all releases contain an error :(

GuyKh commented 3 weeks ago

Install 0.0.30 for now. I'm on a holiday

GuyKh commented 1 week ago

Found the issue for:

power_size = connection_to_power_size_map[connection]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: '25'

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

GuyKh commented 1 week ago

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

GuyKh commented 1 week ago

Closing for now