oischinger / ha_vicare

Inofficial Home Assistant custom component for Viessmann ViCare API
60 stars 31 forks source link

VALIDATION_ERROR #69

Open RafalHo opened 2 years ago

RafalHo commented 2 years ago

Hello,

from the very beginning I have a problem with this integration, the HA displays the temperature of domestic water and heating, but I can not change anything, nor, for example, turn off the heating. I can only set the temperature of domestic water. I tried the version with energy support, but there was no new entity for gas or electricity consumption, and I have all this data in the Vicare application.

Below I am pasting the log that was generated when I tried to turn off the heating.

Logger: homeassistant.components.websocket_api.http.connection
Source: components/vicare/climate.py:277
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 12:23:01 (1 occurrences)
Last logged: 12:23:01

[140010213410080] (PyViCareCommandError(...), 'Command failed with status code 422. Reason given was: VALIDATION_ERROR')
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 667, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 863, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 704, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 470, in async_set_hvac_mode
    await self.hass.async_add_executor_job(self.set_hvac_mode, hvac_mode)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/vicare/climate.py", line 277, in set_hvac_mode
    self._circuit.setMode(vicare_mode)
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareDevice.py", line 330, in setMode
    r = self.service.setProperty(
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareCachedService.py", line 29, in setProperty
    response = super().setProperty(property_name, action, data)
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareService.py", line 52, in setProperty
    return self.oauth_manager.post(url, post_data)
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 91, in post
    self.__handle_command_error(response)
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 67, in __handle_command_error
    raise PyViCareCommandError(response)
PyViCare.PyViCareUtils.PyViCareCommandError: (PyViCareCommandError(...), 'Command failed with status code 422. Reason given was: VALIDATION_ERROR')
oischinger commented 2 years ago

Looks like an auth failure. Are you sure you retrieved the correct client id and use correct username and password?

RafalHo commented 2 years ago

I checked again, but the data is correct. If they were wrong, would I see the current heating and domestic water temperature in HA? I can even change the domestic hot water temperature, but I cannot turn off the heating or change to a schedule.

oischinger commented 2 years ago

Maybe it's a read only token or so. Did you follow the instructions here to create the token: https://github.com/somm15/PyViCare#api-usage-in-postman

RafalHo commented 2 years ago

I did according to this: https://www.home-assistant.io/integrations/vicare/#configuration

oischinger commented 2 years ago

Yes, that's the same. Maybe it's also the stored token. The integration persists a token in /config (vicare.token I believe) can you tryto delete it?

RafalHo commented 2 years ago

Found the token and removed it (found here: config.storage\vicare_token.save) I even generated a new Client ID on developer.viessmann.com/en/clients. Unfortunately, still an error, the log is attached below. Should I use some other integration instead of the original one (https://www.home-assistant.io/integrations/vicare/)? Is it possible to read gas and electricity consumption at all through integration?

Logger: homeassistant.components.websocket_api.http.connection
Source: components/vicare/climate.py:277
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 22:30:59 (2 occurrences)
Last logged: 22:31:12

[140698296623648] (PyViCareCommandError(...), 'Command failed with status code 422. Reason given was: VALIDATION_ERROR')
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 667, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 863, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 704, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 470, in async_set_hvac_mode
    await self.hass.async_add_executor_job(self.set_hvac_mode, hvac_mode)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/vicare/climate.py", line 277, in set_hvac_mode
    self._circuit.setMode(vicare_mode)
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareDevice.py", line 330, in setMode
    r = self.service.setProperty(
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareCachedService.py", line 29, in setProperty
    response = super().setProperty(property_name, action, data)
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareService.py", line 52, in setProperty
    return self.oauth_manager.post(url, post_data)
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 91, in post
    self.__handle_command_error(response)
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 67, in __handle_command_error
    raise PyViCareCommandError(response)
PyViCare.PyViCareUtils.PyViCareCommandError: (PyViCareCommandError(...), 'Command failed with status code 422. Reason given was: VALIDATION_ERROR')
Pampasgras commented 2 years ago

I have the very same issue when choosing the Auto option in Pyvicare Heating (I can set the temperature, and read other statistics)

Logger: homeassistant.components.websocket_api.http.connection
Source: components/vicare/climate.py:276
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 14:54:41 (1 occurrences)
Last logged: 14:54:41

[547861626112] (PyViCareCommandError(...), 'Command failed with status code 422. Reason given was: VALIDATION_ERROR')
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
..............................
..............................
..............................
  File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 67, in __handle_command_error
    raise PyViCareCommandError(response)
PyViCare.PyViCareUtils.PyViCareCommandError: (PyViCareCommandError(...), 'Command failed with status code 422. Reason given was: VALIDATION_ERROR')

--> I use climate.set_vicare_mode instead So I cannot use the lovelace thermostat

oischinger commented 2 years ago

Can you please check which vicare_modes your device supports? you should see it as an attribute of the climate entity

Pampasgras commented 2 years ago

Can you please check which vicare_modes your device supports? you should see it as an attribute of the climate entity

hvac_modes:

vicare_modes:

Vicare modes are all supported with climate.set_vicare_mode. (tested them all)

climate.set_hvac_mode "heat" --> vicare_mode forcedNormal climate.set_hvac_mode "off" --> vicare_mode forcedReduced climate.set_hvac_mode "auto" -->error 422 (I expect vicare_mode heating)

oischinger commented 2 years ago

I have created a branch with a potential fix @KurtSponik : https://github.com/oischinger/ha_vicare/pull/85

To the others: Can you please provide the same information as @KurtSponik did? Do all your heating devices have in common that they don't provide domestic hot water?

ol3k commented 2 years ago

I get the same Validation Error (but with dhw mode)

hvac_modes:

oischinger commented 2 years ago

@ol3k I'm interested in the data shown in the developer tools like below: image

ol3k commented 2 years ago

I think this is the data I copied above (just c&p with mobile phone out of HA, find screenshot attached)

image

darianf01 commented 2 years ago

Same issue as encountered by @ol3k when trying to change the hvac mode

PyViCare.PyViCareUtils.PyViCareCommandError: (PyViCareCommandError(...), 'Command failed with status code 422. Reason given was: VALIDATION_ERROR') Vitodens 100-w + Vitoconnect OT2 + Vitotrol OT1

image

TOMSLAUS commented 2 years ago

Same issue to me, error gets thrown when trying to do anything.