wmalgadey / tado_component

Custom home-assistant component for tado (using PyTado)
GNU General Public License v3.0
12 stars 1 forks source link

Compatibility with cooling-only Tado devices #23

Open ravens opened 6 years ago

ravens commented 6 years ago

Hi, I have the following error when instanciating this component :

homeassistant_1  | 2018-06-30 18:52:40 ERROR (MainThread) [homeassistant.components.climate] Error while setting up platform tado_v1
homeassistant_1  | Traceback (most recent call last):
homeassistant_1  |   File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
homeassistant_1  |     SLOW_SETUP_MAX_WAIT, loop=hass.loop)
homeassistant_1  |   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
homeassistant_1  |     return fut.result()
homeassistant_1  |   File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
homeassistant_1  |     result = self.fn(*self.args, **self.kwargs)
homeassistant_1  |   File "/config/custom_components/climate/tado_v1.py", line 60, in setup_platform
homeassistant_1  |     tado, hass, zone, zone['name'], zone['id']))
homeassistant_1  |   File "/config/custom_components/climate/tado_v1.py", line 77, in create_climate_device
homeassistant_1  |     min_temp = float(capabilities['HEAT']['temperatures']['celsius']['min'])
homeassistant_1  | KeyError: 'HEAT'

Looking at the "capabilities" endpoint of the REST API of my.tado.com, I have the following output : {"type":"AIR_CONDITIONING","COOL":{"temperatures":{"celsius":{"min":18,"max":30,"step":1.0},"fahrenheit":{"min":64,"max":86,"step":1.0}}}}

I have no heating section, which makes sense as my tado-controlled equipment is fairly basic. Looking at the tado_v1.py I see that the HEAT key is called during the create_climate_device

    if ac_mode:
        min_temp = float(capabilities['HEAT']['temperatures']['celsius']['min'])
        max_temp = float(capabilities['HEAT']['temperatures']['celsius']['max'])        
    else:
        min_temp = float(capabilities['temperatures']['celsius']['min'])
        max_temp = float(capabilities['temperatures']['celsius']['max'])

Could it be possible to add support for cooling only climate device ? Is there any known limitation with Homeassistant ?

Thanks for any hint,

wmalgadey commented 5 years ago

I did a change in https://github.com/wmalgadey/home-assistant/tree/tado_ac, I try to update my custom component too. But it takes some time, I may not finish this today or this week, sorry!

Yippy commented 5 years ago

Probably best to resolve this here, less clutter.

I've tried fixing the encountered errors

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/setup.py", line 56, in async_setup_component
    return await task  # type: ignore
  File "/usr/src/app/homeassistant/setup.py", line 103, in _async_setup_component
    component = loader.get_component(hass, domain)
  File "/usr/src/app/homeassistant/loader.py", line 92, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/tado.py", line 132
    power = "ON" if temperature is not None "OFF"
                                                ^
SyntaxError: invalid syntax

/config/custom_components/tado.py

        power = "ON"
        if not (temperature is None):
            power = "OFF"

/config/custom_components/climate/tado.py line 12 missing it requires the convert_temperature function

from homeassistant.util.temperature import convert as convert_temperature

Still got issue with HEAT key doesn't existing line 83

    if ac_mode:
        if CONST_MODE_COOL in capabilities:
            temperatures = capabilities[CONST_MODE_COOL]['temperatures']
        else:
            temperatures = capabilities[CONST_MODE_HEAT]['temperatures']

Looks like these changes now work, just testing functions

wmalgadey commented 5 years ago

sorry, I didn't test the changes. Thank you for your work here. I made some commits, to reflect this changes