home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.35k stars 30.28k forks source link

Tado - set hot water temprature gives an error #25235

Closed Diondk closed 4 years ago

Diondk commented 5 years ago

Home Assistant release with the issue: 0.96.0

Last working Home Assistant release (if known): Never worked, but never got an error either.

Operating environment (Hass.io/Docker/Windows/etc.): Hass.io

Component/platform: https://www.home-assistant.io/components/tado/

Description of problem: I am getting a http 422 error when trying to set my water temprature.

Log files shows the following error.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 121, in handle_call_service
    connection.context(msg))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 194, in handle_service
    required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 316, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 339, in _handle_service_platform_call
    await func(entity, data)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 497, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 358, in async_set_temperature
    ft.partial(self.set_temperature, **kwargs))
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/tado/climate.py", line 240, in set_temperature
    self._control_heating()
  File "/usr/src/homeassistant/homeassistant/components/tado/climate.py", line 381, in _control_heating
    self.zone_id, self._current_operation, self._target_temp)
  File "/usr/src/homeassistant/homeassistant/components/tado/__init__.py", line 120, in set_zone_overlay
    self.tado.setZoneOverlay(zone_id, mode, temperature, duration)
  File "/usr/local/lib/python3.7/site-packages/PyTado/interface.py", line 287, in setZoneOverlay
    data = self._apiCall(cmd, "PUT", post_data)
  File "/usr/local/lib/python3.7/site-packages/PyTado/interface.py", line 81, in _apiCall
    response = self.opener.open(req)
  File "/usr/local/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 422: 

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

Traceback (if applicable):

Additional information:

AaronSpittles commented 5 years ago

The component appears to be mostly broken when commands are involved. It appears to be reading states OK, but any attempt to change modes etc results in errors:

HTTP Error 422: 
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 121, in handle_call_service
    connection.context(msg))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 194, in handle_service
    required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 316, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 337, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 382, in async_set_hvac_mode
    await self.hass.async_add_executor_job(self.set_hvac_mode, hvac_mode)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/tado/climate.py", line 255, in set_hvac_mode
    self._control_heating()
  File "/usr/src/homeassistant/homeassistant/components/tado/climate.py", line 381, in _control_heating
    self.zone_id, self._current_operation, self._target_temp)
  File "/usr/src/homeassistant/homeassistant/components/tado/__init__.py", line 120, in set_zone_overlay
    self.tado.setZoneOverlay(zone_id, mode, temperature, duration)
  File "/usr/local/lib/python3.7/site-packages/PyTado/interface.py", line 287, in setZoneOverlay
    data = self._apiCall(cmd, "PUT", post_data)
  File "/usr/local/lib/python3.7/site-packages/PyTado/interface.py", line 81, in _apiCall
    response = self.opener.open(req)
  File "/usr/local/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 422: 

And

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1159, in _safe_execute
    await self._execute_service(handler, service_call)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 194, in handle_service
    required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 316, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 337, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 428, in async_turn_on
    await self.async_set_hvac_mode(mode)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 382, in async_set_hvac_mode
    await self.hass.async_add_executor_job(self.set_hvac_mode, hvac_mode)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/tado/climate.py", line 255, in set_hvac_mode
    self._control_heating()
  File "/usr/src/homeassistant/homeassistant/components/tado/climate.py", line 381, in _control_heating
    self.zone_id, self._current_operation, self._target_temp)
  File "/usr/src/homeassistant/homeassistant/components/tado/__init__.py", line 120, in set_zone_overlay
    self.tado.setZoneOverlay(zone_id, mode, temperature, duration)
  File "/usr/local/lib/python3.7/site-packages/PyTado/interface.py", line 287, in setZoneOverlay
    data = self._apiCall(cmd, "PUT", post_data)
  File "/usr/local/lib/python3.7/site-packages/PyTado/interface.py", line 81, in _apiCall
    response = self.opener.open(req)
  File "/usr/local/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 422: 
Diondk commented 5 years ago

Yes reading works fine, i just updated to 0.96.1 still an issue.

dwa2010 commented 5 years ago

It's the same HTTP error code as #22290, and I note that the off command which was fixed in #22291 works successfully.

Diondk commented 5 years ago

It's the same HTTP error code as #22290, and I note that the off command which was fixed in #22291 works successfully.

still cant change temprature and when we are both away it shows N/A instead of off

Diondk commented 5 years ago

@frenck i did create my own issue, and was refered to the old threat. But the issue still exists in latest HA release.

HTTP Error 422: 

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 121, in handle_call_service
    connection.context(msg))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 194, in handle_service
    required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 316, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 339, in _handle_service_platform_call
    await func(entity, data)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 497, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 358, in async_set_temperature
    ft.partial(self.set_temperature, **kwargs))
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/tado/climate.py", line 240, in set_temperature
    self._control_heating()
  File "/usr/src/homeassistant/homeassistant/components/tado/climate.py", line 381, in _control_heating
    self.zone_id, self._current_operation, self._target_temp)
  File "/usr/src/homeassistant/homeassistant/components/tado/__init__.py", line 120, in set_zone_overlay
    self.tado.setZoneOverlay(zone_id, mode, temperature, duration)
  File "/usr/local/lib/python3.7/site-packages/PyTado/interface.py", line 287, in setZoneOverlay
    data = self._apiCall(cmd, "PUT", post_data)
  File "/usr/local/lib/python3.7/site-packages/PyTado/interface.py", line 81, in _apiCall
    response = self.opener.open(req)
  File "/usr/local/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 422: 
timdonovanuk commented 5 years ago

How are you even trying to control hot water in HA? I'm not seeing any controllable entities relating to hot water via Tado in my instance (0.98), just a read only sensor.hot_water_power.

x-real-ip commented 5 years ago

This problem is still there. Is someone or Home Assistant working on a solution?

timdonovanuk commented 5 years ago

@coen17st could you look at my question please. I can't even start looking at why this is broken - I don't have any hot water controllable entities.

bartn commented 5 years ago

@timdonovanuk , @coen17st isn't that the issue? PyTado supports control of the 'hot water' system, and of course one can control it in the Tado app. Home Assistant features a 'water heater' component, but they systems are not linked.

timdonovanuk commented 5 years ago

I've ended up just doing it with a template rest switch, as below:

switch:
  - platform: rest
    method: put
    name: hot_water_power
    resource: https://my.tado.com/api/v2/homes/666/zones/0/overlay?username=foo&password=bar
    body_on: '{"setting": {"type": "HOT_WATER","power": "ON"},"termination": {"type": "MANUAL"}}'
    body_off: '{"setting": {"type": "HOT_WATER","power": "OFF"},"termination": {"type": "MANUAL"}}'
    is_on_template: '{{states.sensor.hot_water_power.state=="ON"}}'
    headers:
      Content-Type: application/json
Diondk commented 5 years ago

How are you even trying to control hot water in HA? I'm not seeing any controllable entities relating to hot water via Tado in my instance (0.98), just a read only sensor.hot_water_power.

Hi,

when i add my tado, i have a climate.heating and a climate.water.

I linked both to the custom: simple-thermostate

i believe you need to ask Tado support to allow you to control the temprature and water seperated before you get the climate.water in your HA. Atleast that is what i did after i got my tado a few years back.

Kr, Dion

DSchumacher2104 commented 4 years ago

The reason for this issue is, that the Tado Component uses a fixed "type":"HEATING" for setting a Tado-device except a/c-devices (see line 535 in home-assistant/homeassistant/components/tado/climate.py):

            self._store.set_zone_overlay(
                self.zone_id,
                self._current_operation,
                self._target_temp,
                None,
                "HEATING",
            )

To set a Tado-hot-water-device, type has to be "type":"HOT_WATER", otherwise you'll get the http error 422 from tado server. If you read the zones, hot water devices are nearly identically to thermostats, except they have a different type-attribute:

{"id":0,"name":"Warmwasser","type":"HOT_WATER","dateCreated":"2017-12-27T08:53:52.580Z","deviceTypes":["RU01"],"devices":[{"deviceType":"RU01","serialNo":"RUxxxxxxxxxx","shortSerialNo":"RUxxxxxxxxxx","currentFwVersion":"54.11","connectionState":{"value":true,"timestamp":"2019-11-21T08:34:14.391Z"},"characteristics":{"capabilities":["INSIDE_TEMPERATURE_MEASUREMENT","IDENTIFY"]},"batteryState":"NORMAL","duties":["ZONE_UI","ZONE_DRIVER","ZONE_LEADER"]}],"reportAvailable":false,"supportsDazzle":false,"dazzleEnabled":false,"dazzleMode":{"supported":false},"openWindowDetection":{"supported":false}

So if a programmer could change this part of the component and uses the "type:"-value not fixed but as reported from tado-device (thermostats reports "HEATING" as fixed in component), everything would work with hot water control (perhaps self.type instead of "HEATING"). But i can't code this because sadly i'm not a programmer.

Niomar-R commented 4 years ago

Did you managed to change this for your install? I am running a docker version and would like to fix it if possible since we dont know if anyone will change the code

DSchumacher2104 commented 4 years ago

No, cause i think, "type" is not assinged. First someone has to modify the code and assign "type" to JSON value of each tado device!

michaelarnauts commented 4 years ago

Check out #27266 for a fix.

Niomar-R commented 4 years ago

Check out #27266 for a fix.

Hi Michael, from your link it is not clear to me what the fix is and how to apply it. Could you clarify?

michaelarnauts commented 4 years ago

Check out #27266 for a fix.

Hi Michael, from your link it is not clear to me what the fix is and how to apply it. Could you clarify?

Work is being done there to fix this issue. It's not ready yet.

noohi commented 4 years ago

Hi Michael.

Just found this topic due to an error 422 when trying to re-enable tado's hot water (climate.hot_water) entity.

Using the climate turn_on produced an error 422. Desperately trying things out, used the set_temperature: 55C first, then again turn_on and it worked, no more error 422 when turning on the hot water.

Btw it worked the day before even without the set_temperature workaround, it's as if a cookie times out and without it the problem is not apparent.

Since now I see you are moving the water heater to be without the temperature setting, I may lose the only way to get this working when it's stuck. I'm on Home Assistant 0.103.5, maybe I should just ignore this for now and try the water_heater.hot_water when released on stable?

Thanks regardless!

michaelarnauts commented 4 years ago

This should be fixed with the new code, but please, go ahead and put the files from my branch in custom_components and try it out. It works fine on my system, but it always can use some more testing.

michaelarnauts commented 4 years ago

BTW, the water heater is WITH temperature control. This change makes it accessable for systems without temperature control since there, no climate platform was created.

noohi commented 4 years ago

Thanks Michael. Since it's not clear to me why it worked one day and then day after didn't on the current code, I'll wait for your rewrite release and report any issues with clear repro steps.