jamiewalters / python-verisure-climate

7 stars 3 forks source link

Climate component does not work with Home Assistant 0.88 or 0.89 and up #4

Closed taugusti closed 5 years ago

taugusti commented 5 years ago

After updating home assistant (RPI / HASS.IO) to version 0.89.1, the verisure component stopped working.

In the log: Unable to find platform verisureclimate.

I tried to rename the folder and .py file as described here:

When I do that I get this in the log:

Error loading custom_components.verisureclimate.climate. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/loader.py", line 166, in _load_file
    module = importlib.import_module(path)

...

  File "/config/custom_components/verisureclimate/climate.py", line 7, in <module>
    from homeassistant.components.climate import (
ImportError: cannot import name 'SUPPORT_TARGET_TEMPERATURE' from 'homeassistant.components.climate' (/usr/local/lib/python3.7/site-packages/homeassistant/components/climate/__init__.py)

The core seems to be some sort of change in the home assiatant climate component...?

taugusti commented 5 years ago

Ok - a fairly simple fix as it turns out...

  1. rename the /custom_components/climate folder to /custom_components/verisureclimate
  2. rename verisureclimate.py to climate.py
  3. edit climate.py and split the import from in two parts (line 7-11): from:
    from homeassistant.components.climate import (
    ClimateDevice,
    SUPPORT_TARGET_TEMPERATURE, SUPPORT_FAN_MODE,
    SUPPORT_OPERATION_MODE, SUPPORT_SWING_MODE,
    SUPPORT_ON_OFF, PLATFORM_SCHEMA)

    to

    from homeassistant.components.climate import (
    ClimateDevice,
    PLATFORM_SCHEMA)
    from homeassistant.components.climate.const import (
    SUPPORT_TARGET_TEMPERATURE, 
    SUPPORT_FAN_MODE, SUPPORT_OPERATION_MODE, 
    SUPPORT_SWING_MODE, SUPPORT_ON_OFF)    
  4. reboot hass

The reason for this change is that constants have been moved to const.py in the climate component. See here: https://github.com/home-assistant/home-assistant/pull/20945

I will try to get a pull-request to work - but I have to admit that my git skills are not that good...

taugusti commented 5 years ago

Ok - I think I managed to make a pullrequest... :-)

jamiewalters commented 5 years ago

I have merged this to master

taugusti commented 5 years ago

Awesome - I will close the issue!

follox commented 5 years ago

Great stuff you guys 👍 What should I do to get this to work now?

taugusti commented 5 years ago

Hi @follox Just delete the old /config/custom_components/climate folder and copy the downloaded project to /config/custom_components/verisureclimate.

The guide on the front page is also updated.

follox commented 5 years ago

Alright, I got it to work. Thanks for that! But hass.io is complaining with the following: Your configuration contains extra key that the platform does not support (but were silently acceptet before 0.88). Please find and remove the followin. This will become a breaking change.

[uername], [password] Line 109

I am using the Verisure component as well so the configuration looks like this: verisure: username: xxxx password: !secret verisure_pw locks: 1 smartplugs: 1 alarm: 1 hygrometers: 1 thermometers: 1 door_window: 1

Then line 109: climate:

taugusti commented 5 years ago

Hi I am not able to access my configuration at the moment - I will send you how mine looks next weekend /th

jamiewalters commented 5 years ago

I am working on a pull request to add this to Home Assistant as a part of the Verisure component. If anyone wants to test it it let me know

taugusti commented 5 years ago

Hi I would like to help - I have to admit that I have no clue on how to test a complete Hass component :-) But lets find out :-) /th

follox commented 5 years ago

Thanks to both of you. It will be great to have it integrated within the Verisure component. Please give me a heads up when it is ready. I can also help out testing, but not sure what I should do?

jamiewalters commented 5 years ago

It is ready, but you need access to the home assistant installation files to do this, not sure where this is located on eg hassio. It is here: https://github.com/jamiewalters/home-assistant/tree/dev/homeassistant/components/verisure

Copy init and climate to your verisure folder in your home assistant installation. No more config is needed.

I just need to complete some more steps in order to finish the pull request.

jamiewalters commented 5 years ago

Pull request completed:

https://github.com/home-assistant/home-assistant/pull/22555

Waiting for review.