Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

cannot import name 'ATTR_WHITE_VALUE' #68

Open
feradelectronics opened this issue Sep 5, 2022 · 8 comments
Open

cannot import name 'ATTR_WHITE_VALUE' #68

feradelectronics opened this issue Sep 5, 2022 · 8 comments

Comments

@feradelectronics
Copy link

Get error recently with HA

log error:

Logger: homeassistant.config
Source: custom_components/dmx/light.py:40
Integration: dmx (documentation)
First occurred: 8:37:24 AM (1 occurrences)
Last logged: 8:37:24 AM

Platform error: light
Traceback (most recent call last):
File "/config/custom_components/dmx/light.py", line 25, in
from homeassistant.components.light import (
ImportError: cannot import name 'ATTR_WHITE_VALUE' from 'homeassistant.components.light' (/usr/src/homeassistant/homeassistant/components/light/init.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config.py", line 878, in async_process_component_config
platform = p_integration.get_platform(domain)
File "/usr/src/homeassistant/homeassistant/loader.py", line 681, in get_platform
cache[full_name] = self._import_platform(platform_name)
File "/usr/src/homeassistant/homeassistant/loader.py", line 698, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/config/custom_components/dmx/light.py", line 40, in
from homeassistant.components.light import (
ImportError: cannot import name 'ATTR_WHITE_VALUE' from 'homeassistant.components.light' (/usr/src/homeassistant/homeassistant/components/light/init.py)

@kic68
Copy link
Contributor

kic68 commented Sep 7, 2022

Unfortunately/naturally I am getting the same error. Just upgraded to HA 2022.9.0.
Could be related to home-assistant/core#47720

@303Bryan
Copy link

303Bryan commented Sep 7, 2022

Same issue here... It does look related to: LightEntity no longer supports white_value in 2022.9

Platform error light.dmx - cannot import name 'ATTR_WHITE_VALUE' from 'homeassistant.components.light' (/usr/src/homeassistant/homeassistant/components/light/init.py)
Platform error light.dmx - cannot import name 'ATTR_WHITE_VALUE' from 'homeassistant.components.light' (/usr/src/homeassistant/homeassistant/components/light/init.py)

@tobias-friedrich
Copy link

Same here after upgrade to HA 2022.9.0
It goes away when downgrading to HA 2022.8.7.

@Breina
Copy link
Contributor

Breina commented Sep 9, 2022

Just for providing a solution here, you can switch over to my fork which has a complete compatible configuration and supports HA 2022.9:
https://github.com/Breina/ha-artnet-led

@acronce
Copy link

acronce commented Sep 10, 2022

I'm seeing the same problem after updating to 2022.9.1. I'll give @Breina's fork a try.

@acronce
Copy link

acronce commented Sep 10, 2022

I couldn't even restart HA due to the ATTR_WHITE_VALUE error. I guess it considers a failed integration as a configuration issue.

To work around this I edited the dmx/light.py script to remove references to ATTR_WHITE_VALUE and SUPPORT_WHITE_VALUE, as well as the few lines of code that used those values. That allowed me to pass the configuration test and reboot.

As a side effect, this fixed the hass-dmx integration for me. But I'm still planning on moving given that this project doesn't seem very well supported currently.

@kic68
Copy link
Contributor

kic68 commented Sep 10, 2022

https://github.com/Breina/ha-artnet-led is really working fine... you have to slightly change your configuration, but just follow the good documentation and you're immediately up and running.
In fact you can have both HACS repos active at the same time (while still being below 2022.9.0) and adapt your existing configuration to the new format, then have the validity checked until all is fine before restarting homeassistant.

My diff (controlling aquarium lights this way) looks like this:

-- platform: dmx
+- platform: artnet_led
   host: aquarium.local
-  default_type: dimmer
   port: 6454
-  dmx_channels: 512 
-  default_level: 255
-  universe: 0
-  devices:
-    - channel: 1
-      name: Aquarium Polar
-    - channel: 2
-      name: Aquarium Day
-    - channel: 3
-      name: Aquarium Sunset
+  universes:
+    0:
+      output_correction: quadratic
+      devices:
+        - channel: 1
+          type: dimmer
+          name: Aquarium Polar
+        - channel: 2
+          type: dimmer
+          name: Aquarium Day
+        - channel: 3
+          type: dimmer
+          name: Aquarium Sunset

@jacobmellin
Copy link

I fixed this (temporarily) by commenting out ATTR_WHITE_VALUE and SUPPORT_WHITE_VALUE from the import statement in dmx/light.py and setting them explicitly below, like so:

try:
    from homeassistant.components.light import (
        ATTR_BRIGHTNESS,
        ATTR_HS_COLOR,
        ATTR_TRANSITION,
#        ATTR_WHITE_VALUE,
        ATTR_COLOR_TEMP,
        LightEntity,
        PLATFORM_SCHEMA,
        SUPPORT_BRIGHTNESS,
        SUPPORT_COLOR,
        SUPPORT_WHITE_VALUE,
        SUPPORT_TRANSITION,
        SUPPORT_COLOR_TEMP,
    )
except ImportError:
    from homeassistant.components.light import (
        ATTR_BRIGHTNESS,
        ATTR_HS_COLOR,
        ATTR_TRANSITION,
#        ATTR_WHITE_VALUE,
        ATTR_COLOR_TEMP,
#        Light as LightEntity,
        LightEntity,
        PLATFORM_SCHEMA,
        SUPPORT_BRIGHTNESS,
        SUPPORT_COLOR,
#        SUPPORT_WHITE_VALUE,
        SUPPORT_TRANSITION,
        SUPPORT_COLOR_TEMP,
    )
from homeassistant.util.color import color_rgb_to_rgbw
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv
import homeassistant.util.color as color_util
import voluptuous as vol

ATTR_WHITE_VALUE = 255
SUPPORT_WHITE_VALUE = True

I also had to change Light as LightEntity to LightEntity.

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

No branches or pull requests

7 participants