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

Configuration warnings cannot import name 'DEVICE_CLASS_TEMPERATURE #373

Open
3 tasks done
loki-sft opened this issue Jan 27, 2025 · 1 comment
Open
3 tasks done
Labels
bug Something isn't working needs more info Further information is requested

Comments

@loki-sft
Copy link

Describe the bug

When I check my config I get this warning:

Configuration warnings
Platform error 'sensor' from integration 'pirateweather' - cannot import name 'DEVICE_CLASS_TEMPERATURE' from 'homeassistant.components.sensor' (/usr/src/homeassistant/homeassistant/components/sensor/__init__.py)

my config:

sensor:
  - platform: pirateweather
    api_key: "xxx"
    latitude: 12.345
    longitude: 12.234
    scan_interval: '00:15:00'
    monitored_conditions:
      - temperature
      - humidity
      - cloud_cover

Expected behavior

I expect no warning

Actual behavior

I get the warning

Operating System Information

Core 2025.1.4
Supervisor 2024.12.3
Operating System 14.2
Frontend 20250109.2

Log Output

Logger: homeassistant.config
Source: config.py:1055
First occurred: 20:21:31 (1 occurrences)
Last logged: 20:21:31

Platform error: sensor - cannot import name 'DEVICE_CLASS_TEMPERATURE' from 'homeassistant.components.sensor' (/usr/src/homeassistant/homeassistant/components/sensor/__init__.py)
Traceback (most recent call last):
  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 1185, in async_get_platforms
    import_future.result()
    ~~~~~~~~~~~~~~~~~~~~^^
  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}")
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/darksky/sensor.py", line 9, in <module>
    from homeassistant.components.sensor import (
    ...<3 lines>...
    )
ImportError: cannot import name 'DEVICE_CLASS_TEMPERATURE' from 'homeassistant.components.sensor' (/usr/src/homeassistant/homeassistant/components/sensor/__init__.py)

Troubleshooting steps

  • This issue is related to the self-hosting code and not an API issue.
  • I have read through the README before opening this issue.
  • I have written an informative title.
@loki-sft loki-sft added bug Something isn't working Needs Review labels Jan 27, 2025
@cloneofghosts cloneofghosts transferred this issue from Pirate-Weather/pirate-weather-code Jan 27, 2025
@cloneofghosts cloneofghosts added needs more info Further information is requested and removed Needs Review labels Feb 3, 2025
@cloneofghosts cloneofghosts moved this from Todo to In Progress in Pirate Weather Home Assistant Feb 3, 2025
@cloneofghosts
Copy link
Collaborator

Thanks for opening this issue and sorry about the slow reply. What version of the integration are you running? I don't see any of these errors in my HA install though I set it up using the config flow.

I'm not super familiar with the YAML configuration so will defer to @alexander0042 to see how this error can be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs more info Further information is requested
Projects
Status: In Progress
Development

No branches or pull requests

2 participants