GuyKh / iec-custom-component

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

Unknown error when attempting to add the integration #159

Closed Tsury closed 2 months ago

Tsury commented 2 months ago

System Health details

System Information

version core-2024.8.3
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.31-haos-raspi
arch aarch64
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 | 5000 Installed Version | 2.0.0 Stage | running Available Repositories | 1389 Downloaded Repositories | 21
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | July 18, 2025 at 03:00 relayer_connected | true relayer_region | eu-central-1 remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | false remote_server | eu-central-1-14.ui.nabu.casa certificate_status | ready instance_id | 24a164e59210484b8efa612b5af4e048 can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 13.1 -- | -- update_channel | stable supervisor_version | supervisor-2024.08.0 agent_version | 1.6.0 docker_version | 26.1.4 disk_total | 219.4 GB disk_used | 22.8 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | Studio Code Server (5.15.0), Home Assistant Google Drive Backup (0.112.1), ArgonOne Active Cooling (30a), RPC Shutdown (2.5), Terminal & SSH (9.14.0)
Dashboards dashboards | 2 -- | -- resources | 14 views | 2 mode | storage
MiWifi version | 3.0.0 -- | -- 192.168.31.1 (xiaomi.router.ra70) | ok
Recorder oldest_recorder_run | August 24, 2024 at 00:35 -- | -- current_recorder_run | September 1, 2024 at 15:39 estimated_db_size | 568.53 MiB database_engine | sqlite database_version | 3.45.3
Spotify api_endpoint_reachable | ok -- | --

Checklist

Describe the issue

Upon inputting my ID and attempting to add the integration, an "unknown error" occurs:

Reproduction steps

  1. Install from HACS
  2. Restart HA
  3. Attempt to add integration

Debug logs

Logger: aiohttp.server
Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:433
First occurred: 15:42:02 (1 occurrences)
Last logged: 15:42:02

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/iec_api/login.py", line 144, in first_login
    session_token = await send_otp_code(session, factor_id, state_token)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/iec_api/login.py", line 94, in send_otp_code
    response = await commons.send_post_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/iec_api/commons.py", line 182, in send_post_request
    parse_error_response(resp, json_resp)
  File "/usr/local/lib/python3.12/site-packages/iec_api/commons.py", line 101, in parse_error_response
    raise IECLoginError(resp.status, resp.reason + ": " + login_error_response.error_summary)
iec_api.models.exceptions.IECLoginError: (Code 403): Forbidden: Invalid Passcode/Answer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 462, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 537, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 366, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 413, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 516, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/iec/config_flow.py", line 94, in async_step_user
    return await self.async_step_mfa()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/iec/config_flow.py", line 142, in async_step_mfa
    await client.login_with_id()
  File "/usr/local/lib/python3.12/site-packages/iec_api/iec_client.py", line 717, in login_with_id
    state_token, factor_id, session_token = self._login_response = await login.first_login(
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/iec_api/login.py", line 149, in first_login
    raise IECLoginError(-1, "Failed at first login") from error
iec_api.models.exceptions.IECLoginError: (Code -1): Failed at first login

Diagnostics dump

No response

GuyKh commented 2 months ago

This is the error you're getting:

(Code 403): Forbidden: Invalid Passcode/Answer

Can you make sure that you're able to connect through iec.co.il?

Tsury commented 2 months ago

Huh. Apparently there were authorization issues - I called them and fixed it. thanks. Btw, I see that Last bill amount to pay and Last bill electric cost are 0 - will that change over time?

GuyKh commented 2 months ago

Are you using a private provider? If so - IEC has no data of your bill. What I've added in 0.3.x versions is a (rough) estimate of the future bill

Tsury commented 2 months ago

Yeah using Pazgas, got it, makes sense. Thanks again, great integration <3