SebuZet / samsungrac

Home Assistant Climate Device for controlling (not only) Samsung AC
64 stars 31 forks source link

Import Error on upgrade to Python3.8 #13

Open tinstep opened 4 years ago

tinstep commented 4 years ago

Hi After upgrade to 0.102.0 Home Assistant and python upgrade to 3.8 (from 3.6), I got the following error in the logs and the climate_ip component is unavailable. It cant import 'ATTR_HVAC_ACTIONS'

2019-11-21 15:54:40 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for climate_ip which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.                                                                                                                            
2019-11-21 15:54:40 ERROR (MainThread) [homeassistant.config] Platform error: climate                                                                                                                   
Traceback (most recent call last):                                                                                                                                                                      
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/config.py", line 762, in async_process_component_config                                                                            
    platform = p_integration.get_platform(domain)                                                                                                                                                       
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/loader.py", line 231, in get_platform                                                                                              
    cache[full_name] = importlib.import_module(                                                                                                                                                         
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module                                                                                                                           
    return _bootstrap._gcd_import(name[level:], package, level)                                                                                                                                         
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import                                                                                                                                       
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load                                                                                                                                     
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked                                                                                                                            
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked                                                                                                                                     
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module                                                                                                                               
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed                                                                                                                          
  File "/home/homeassistant/.homeassistant/custom_components/climate_ip/climate.py", line 21, in <module>                                                                                               
    from homeassistant.components.climate import (ClimateDevice, DOMAIN,                                                                                                                                
ImportError: cannot import name 'ATTR_HVAC_ACTIONS' from 'homeassistant.components.climate' (/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/climate/__init__.py)               
2019-11-21 15:54:40 ERROR (MainThread) [homeassistant.config] Platform error: climate                                                                                                                   
Traceback (most recent call last):                                                                                                                                                                      
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/config.py", line 762, in async_process_component_config                                                                            
    platform = p_integration.get_platform(domain)                                                                                                                                                       
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/loader.py", line 231, in get_platform                                                                                              
    cache[full_name] = importlib.import_module(                                                                                                                                                         
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/climate_ip/climate.py", line 21, in <module>
    from homeassistant.components.climate import (ClimateDevice, DOMAIN,
ImportError: cannot import name 'ATTR_HVAC_ACTIONS' from 'homeassistant.components.climate' (/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/climate/__init__.py)
2019-11-21 15:54:45 ERROR (SyncWorker_1) [homeassistant.components.nut.sensor] NUT Sensor has no data, unable to set up
2019-11-21 15:54:46 WARNING (MainThread) [homeassistant.components.sensor] Platform nut not ready yet. Retrying in 30 seconds.
orsacchiotto commented 4 years ago

Hi After upgrade to 0.102.0 , Same problem here

GGalloppa commented 4 years ago

Same here

arch x86_64
dev false
docker true
hassio true
os_name Linux
python_version 3.7.4
timezone Europe/Rome
version 0.102.0
virtualenv false
emme73 commented 4 years ago

I'm using Climate_ip platform from HACS to connect to a Samsung CDZ https://github.com/SebuZet/samsungrac/

I've checked and think to have found the issue: homeassistant.components.climate const after update is ATTR_HVAC_ACTION while climate_ip is calling ATTR_HVAC_ACTIONS

a wired thing is that the same const file include both ATTR_HVAC_MODE and ATTR_HVAC_MODES

don't know if this is wanted or just miss the ATTR_HVAC_ACTIONS in the new HA climate file

atxbyea commented 4 years ago

Broken here after 0.102.0 also, tried removing "ATTR_HVAC_ACTIONS" and "MODES" but that only made it worse ;-)

emme73 commented 4 years ago

I think we do need to replace all calls to ATTR_HVAC_ACTIONS to ATTR_HVAC_ACTION in the samsungrac component

unfortunately my HA hangs and I'm not at home to reboot it :(

emme73 commented 4 years ago

folks, I confirm! you need to edit climate.py file under /config/custom_components/climate_ip and replace the 2 references on ATTR_HVAC_ACTIONS to ATTR_HVAC_ACTION, save and reboot, it will work

tinstep commented 4 years ago

@emme73 That worked like a charm. well done and thanks!

atxbyea commented 4 years ago

Verified, working nice here too, I will create a pull request for it.