Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed deprecation warnings #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dotnetdummy
Copy link

@dotnetdummy dotnetdummy commented Nov 24, 2024

This fixes all the imports and usage of deprecated fields etc that is mentioned in #47

Also removed the usage of async_add_job that was deprecated in HA 2024.4 as described here

Note: The warning [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7f9a54f6ba50>,) seems to be related to an open issue at HA Core

@robinostlund
Copy link

I think that the ssl issue only solves it for the pyoverkiz custom compontent https://github.com/iMicknl/python-overkiz-api/pull/1448/files

@dotnetdummy
Copy link
Author

Yeah exactly @robinostlund but it also references this as the main problem, and that is still open. I looked through the link you sent and made a PR in ngenicpy here that fixes the warning.

Overall this repo seems to have little to none activity nowadays so if you want these changes directly, feel free to use my fork here. I've added some more sensors as well (battery and signal-strengh) and am looking into the ability to control schedules etc as well.

@robinostlund
Copy link

@dotnetdummy can you enable "issues" on your repo? :), got this:

custom_components.ngenic.ngenicpy.exceptions.ClientException: (ClientException(...), 'A request exception occurred: Too many requests have been made, retry again after 12/04/2024 10:00:00 UTC')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/logging/handlers.py", line 1493, in emit
    self.enqueue(self.prepare(record))
                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/logging/handlers.py", line 1475, in prepare
    msg = self.format(record)
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/logging/__init__.py", line 999, in format
    return fmt.format(record)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/logging/__init__.py", line 703, in format
    record.message = record.getMessage()
                     ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/logging/__init__.py", line 392, in getMessage
    msg = msg % self.args
          ~~~~^~~~~~~~~~~
TypeError: format requires a mapping
Call stack:
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 728, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
    await self.async_update()
  File "/config/custom_components/ngenic/sensor.py", line 358, in async_update
    _LOGGER.exception("Failed to update sensor '%(unique_id)s'", self.unique_id)
  File "/usr/local/lib/python3.12/logging/__init__.py", line 1574, in exception
    self.error(msg, *args, exc_info=exc_info, **kwargs)
  File "/usr/local/lib/python3.12/logging/__init__.py", line 1568, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/local/lib/python3.12/logging/__init__.py", line 1684, in _log
    self.handle(record)
  File "/usr/local/lib/python3.12/logging/__init__.py", line 1700, in handle
    self.callHandlers(record)
  File "/usr/local/lib/python3.12/logging/__init__.py", line 1762, in callHandlers
    hdlr.handle(record)
  File "/usr/src/homeassistant/homeassistant/util/logging.py", line 41, in handle
    self.emit(record)
Message: "Failed to update sensor '%(unique_id)s'"
Arguments: ('7e498680-1195-ea11-96d2-000d3ab212db-HUMIDITY-sensor',)
--- Logging error ---
Traceback (most recent call last):
  File "/config/custom_components/ngenic/ngenicpy/models/base.py", line 213, in _async_request
    r.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/httpx/_models.py", line 763, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '429 Too Many Requests' for url 'https://app.ngenic.se/api/v3/tunes/9667f840-f8bf-e811-af11-000d3ab14962/nodestatus'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429

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

Traceback (most recent call last):
  File "/config/custom_components/ngenic/sensor.py", line 353, in async_update
    new_state = await self._async_fetch_measurement()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ngenic/sensor.py", line 423, in _async_fetch_measurement
    status = await self._node.async_status()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ngenic/ngenicpy/models/node.py", line 232, in async_status
    rsp_json = self._parse(await self._async_get(url))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ngenic/ngenicpy/models/base.py", line 286, in _async_get
    return await self._async_request("get", False, f"{API_URL}/{url}", **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ngenic/ngenicpy/models/base.py", line 228, in _async_request
    raise ClientException(
custom_components.ngenic.ngenicpy.exceptions.ClientException: (ClientException(...), 'A request exception occurred: Too many requests have been made, retry again after 12/04/2024 10:00:00 UTC')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/logging/handlers.py", line 1493, in emit
    self.enqueue(self.prepare(record))
                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/logging/handlers.py", line 1475, in prepare
    msg = self.format(record)
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/logging/__init__.py", line 999, in format
    return fmt.format(record)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/logging/__init__.py", line 703, in format
    record.message = record.getMessage()
                     ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/logging/__init__.py", line 392, in getMessage
    msg = msg % self.args
          ~~~~^~~~~~~~~~~
TypeError: format requires a mapping
Call stack:
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 728, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
    await self.async_update()
  File "/config/custom_components/ngenic/sensor.py", line 358, in async_update
    _LOGGER.exception("Failed to update sensor '%(unique_id)s'", self.unique_id)
  File "/usr/local/lib/python3.12/logging/__init__.py", line 1574, in exception
    self.error(msg, *args, exc_info=exc_info, **kwargs)
  File "/usr/local/lib/python3.12/logging/__init__.py", line 1568, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/local/lib/python3.12/logging/__init__.py", line 1684, in _log
    self.handle(record)
  File "/usr/local/lib/python3.12/logging/__init__.py", line 1700, in handle
    self.callHandlers(record)
  File "/usr/local/lib/python3.12/logging/__init__.py", line 1762, in callHandlers
    hdlr.handle(record)
  File "/usr/src/homeassistant/homeassistant/util/logging.py", line 41, in handle
    self.emit(record)
Message: "Failed to update sensor '%(unique_id)s'"
Arguments: ('7e498680-1195-ea11-96d2-000d3ab212db-BATTERY-sensor',)```

@dotnetdummy
Copy link
Author

Nice! I've enabled it now @robinostlund. Interesting error you got

@sfalkman
Copy link
Owner

sfalkman commented Dec 8, 2024

Yeah exactly @robinostlund but it also references this as the main problem, and that is still open. I looked through the link you sent and made a PR in ngenicpy here that fixes the warning.

Overall this repo seems to have little to none activity nowadays so if you want these changes directly, feel free to use my fork here. I've added some more sensors as well (battery and signal-strengh) and am looking into the ability to control schedules etc as well.

Hey, sorry for the lack of response, I'm in talks with Ngenic to transfer the project to them as I haven't found any time to work on this as of late. Thanks for the pull requests and the work you all put in to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants