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

2025.1.b5 failed to load sensor #18

Open
joselito11 opened this issue Jan 2, 2025 · 4 comments
Open

2025.1.b5 failed to load sensor #18

joselito11 opened this issue Jan 2, 2025 · 4 comments

Comments

@joselito11
Copy link

I have motion sensor dch-s150
Logger: homeassistant.util.loop
Source: util/loop.py:77
First occurred: 16:28:49 (1 occurrences)
Last logged: 16:28:49

Detected blocking call to import_module with args ('custom_components.dlink_hnap.binary_sensor',) in /usr/src/homeassistant/homeassistant/loader.py, line 1304: return importlib.import_module(f"{self.pkg_path}.{platform_name}") inside the event loop; This is causing stability issues. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#import_module Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 227, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 213, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.13/asyncio/base_events.py", line 707, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 678, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2033, in _run_once handle._run() File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/config.py", line 1055, in _async_load_and_validate_platform_integration platform = await p_integration.integration.async_get_platform(domain) File "/usr/src/homeassistant/homeassistant/loader.py", line 1108, in async_get_platform platforms = await self.async_get_platforms((platform_name,)) File "/usr/src/homeassistant/homeassistant/loader.py", line 1173, in async_get_platforms platforms.update(self._load_platforms(platform_names)) File "/usr/src/homeassistant/homeassistant/loader.py", line 1098, in _load_platforms platform_name: self._load_platform(platform_name) File "/usr/src/homeassistant/homeassistant/loader.py", line 1272, in _load_platform cache[full_name] = self._import_platform(platform_name) File "/usr/src/homeassistant/homeassistant/loader.py", line 1304, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}")

@MichaelB2018
Copy link

same problem

@MichaelB2018
Copy link

MichaelB2018 commented Jan 8, 2025

Has some luck with these changes to binary_sensor.py:

Remove the old imports:

from homeassistant.components.binary_sensor import (
    DEVICE_CLASS_MOTION,
    DEVICE_CLASS_MOISTURE,
)

Repalce with the new-style enums from homeassistant.components.binary_sensor:

from homeassistant.components.binary_sensor import (
    BinarySensorDeviceClass,
    BinarySensorEntity,
    PLATFORM_SCHEMA,
)

Replace references to DEVICE_CLASS_MOTION with BinarySensorDeviceClass.MOTION and references to DEVICE_CLASS_MOISTURE with BinarySensorDeviceClass.MOISTURE:

    def __init__(self, name, timeout, sensor):
        """Initialize the D-Link motion sensor."""
        super().__init__(name, sensor, BinarySensorDeviceClass.MOTION)
        self._timeout = timeout
    def __init__(self, name, sensor):
        """Initialize the D-Link water sensor."""
        super().__init__(name, sensor, BinarySensorDeviceClass.MOISTURE)

But need to test more. So only use this for your own testing.

@joselito11
Copy link
Author

Thank you very much, it is working now!

@Oto868
Copy link

Oto868 commented Jan 9, 2025

Has some luck with these changes to binary_sensor.py:

Remove the old imports:

from homeassistant.components.binary_sensor import (
    DEVICE_CLASS_MOTION,
    DEVICE_CLASS_MOISTURE,
)

Repalce with the new-style enums from homeassistant.components.binary_sensor:

from homeassistant.components.binary_sensor import (
    BinarySensorDeviceClass,
    BinarySensorEntity,
    PLATFORM_SCHEMA,
)

Replace references to DEVICE_CLASS_MOTION with BinarySensorDeviceClass.MOTION and references to DEVICE_CLASS_MOISTURE with BinarySensorDeviceClass.MOISTURE:

    def __init__(self, name, timeout, sensor):
        """Initialize the D-Link motion sensor."""
        super().__init__(name, sensor, BinarySensorDeviceClass.MOTION)
        self._timeout = timeout
    def __init__(self, name, sensor):
        """Initialize the D-Link water sensor."""
        super().__init__(name, sensor, BinarySensorDeviceClass.MOISTURE)

But need to test more. So only use this for your own testing.

Thank you for your tutorial, but in my case it causes another error, not working:
Snímka obrazovky 2025-01-09 110607

I have water leak sensors DHC-S161

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

No branches or pull requests

3 participants