oischinger/ha_vicare

HA log full of DEVICE_COMMUNICATION_ERROR

Closed this issue · 13 comments

Hello,
My HA log is filled up with many vicare integration DEVICE_COMMUNICATION_ERROR messages. Sample below.
Is that something you'll change to be less frequent (e.g. not for every sensor but only once per API call or something similar)?
I think we all know that this API is not a perfectly stable and available so would be good to have less error messages in the log.

2021-10-08 23:53:02 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.vicare_heating fails
Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 438, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 625, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/homeassistant/custom_components/vicare/climate.py", line 208, in update
    _room_temperature = self._circuit.getRoomTemperature()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareUtils.py", line 45, in feature_flag_wrapper
    return wrapper(*args, **kwargs)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareUtils.py", line 38, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareDevice.py", line 410, in getRoomTemperature
    return self.service.getProperty(f"heating.circuits.{self.circuit}.sensors.temperature.room")["properties"]["value"]["value"]
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareCachedService.py", line 24, in getProperty
    data = self.__get_or_update_cache()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareCachedService.py", line 36, in __get_or_update_cache
    data = self.fetch_all_features()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareService.py", line 56, in fetch_all_features
    return self.oauth_manager.get(url)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 41, in get
    self.__handle_server_error(response)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 60, in __handle_server_error
    raise PyViCareInternalServerError(response)
PyViCare.PyViCareUtils.PyViCareInternalServerError: (PyViCareInternalServerError(...), 'Request failed with status code 502 and message "DEVICE_COMMUNICATION_ERROR". ViCare ErrorId: req-44a4f22bc8c84a0ea277889be438f711')

Thanks in advance!

Yes, we need to handle
PyViCareInternalServerError.
Unfortunately this is a very generic error and can have many causes. I need to check how to best deal with it.

Just a small update: today the vicare API is undergoing maintenance and my log file has swollen to 30MB. Any news on the reduction of number of error messages?
image

It's on my todo list up next. Haven't forgotten it.
Can you send me an example of the logs you got in that case?

Sure, here it is. Let me know if you need more, I have over 30MB of log file filled with the vicare mostly :)

2021-10-19 10:25:11 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.vicare_burner_hours fails
Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 438, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 625, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/homeassistant/custom_components/vicare/sensor.py", line 411, in update
    self._state = self.entity_description.value_getter(self._api)
  File "/home/homeassistant/homeassistant/custom_components/vicare/sensor.py", line 211, in <lambda>
    value_getter=lambda api: api.getHours(),
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareUtils.py", line 45, in feature_flag_wrapper
    return wrapper(*args, **kwargs)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareUtils.py", line 38, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareGazBoiler.py", line 141, in getHours
    return self.service.getProperty(f"heating.burners.{self.burner}.statistics")["properties"]["hours"]["value"]
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareCachedService.py", line 24, in getProperty
    data = self.__get_or_update_cache()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareCachedService.py", line 36, in __get_or_update_cache
    data = self.fetch_all_features()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareService.py", line 56, in fetch_all_features
    return self.oauth_manager.get(url)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 41, in get
    self.__handle_server_error(response)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 60, in __handle_server_error
    raise PyViCareInternalServerError(response)
PyViCare.PyViCareUtils.PyViCareInternalServerError: (PyViCareInternalServerError(...), 'Request failed with status code 502 and message "DEVICE_COMMUNICATION_ERROR". ViCare ErrorId: req-bd574f32849c4837b92277e448785f5b')
2021-10-19 10:25:11 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.vicare_burner_modulation fails
Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 438, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 625, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/homeassistant/custom_components/vicare/sensor.py", line 411, in update
    self._state = self.entity_description.value_getter(self._api)
  File "/home/homeassistant/homeassistant/custom_components/vicare/sensor.py", line 218, in <lambda>
    value_getter=lambda api: api.getModulation(),
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareUtils.py", line 45, in feature_flag_wrapper
    return wrapper(*args, **kwargs)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareUtils.py", line 38, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareGazBoiler.py", line 149, in getModulation
    return self.service.getProperty(f"heating.burners.{self.burner}.modulation")["properties"]["value"]["value"]
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareCachedService.py", line 24, in getProperty
    data = self.__get_or_update_cache()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareCachedService.py", line 36, in __get_or_update_cache
    data = self.fetch_all_features()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareService.py", line 56, in fetch_all_features
    return self.oauth_manager.get(url)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 41, in get
    self.__handle_server_error(response)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 60, in __handle_server_error
    raise PyViCareInternalServerError(response)
PyViCare.PyViCareUtils.PyViCareInternalServerError: (PyViCareInternalServerError(...), 'Request failed with status code 502 and message "DEVICE_COMMUNICATION_ERROR". ViCare ErrorId: req-9ce78db4a9964b76804d0f0c86021188')
2021-10-19 10:25:38 ERROR (MainThread) [homeassistant.helpers.entity] Update for binary_sensor.vicare_dhw_circulation_pump_active fails
Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 438, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 625, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/homeassistant/custom_components/vicare/binary_sensor.py", line 225, in update
    self._state = self.entity_description.value_getter(self._api)
  File "/home/homeassistant/homeassistant/custom_components/vicare/binary_sensor.py", line 45, in <lambda>
    value_getter=lambda api: api.getDomesticHotWaterCirculationPumpActive(),
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareUtils.py", line 45, in feature_flag_wrapper
    return wrapper(*args, **kwargs)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareUtils.py", line 38, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareDevice.py", line 119, in getDomesticHotWaterCirculationPumpActive
    status = self.service.getProperty("heating.dhw.pumps.circulation")[
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareCachedService.py", line 24, in getProperty
    data = self.__get_or_update_cache()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareCachedService.py", line 36, in __get_or_update_cache
    data = self.fetch_all_features()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareService.py", line 56, in fetch_all_features
    return self.oauth_manager.get(url)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 41, in get
    self.__handle_server_error(response)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 60, in __handle_server_error
    raise PyViCareInternalServerError(response)
PyViCare.PyViCareUtils.PyViCareInternalServerError: (PyViCareInternalServerError(...), 'Request failed with status code 502 and message "DEVICE_COMMUNICATION_ERROR". ViCare ErrorId: req-a1006aeed5f74f1f8cd13a11f9a64354')

I have the same error since homeassistant 2021.11

similar error here.

core-2021.11.1
supervisor-2021.10.8

File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 41, in get
self.__handle_server_error(response)

File "/usr/local/lib/python3.9/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 60, in __handle_server_error
raise PyViCareInternalServerError(response)

PyViCare.PyViCareUtils.PyViCareInternalServerError: (PyViCareInternalServerError(...), 'Request failed with status code 502 and message "DEVICE_COMMUNICATION_ERROR". ViCare ErrorId: req-09d41c826833445ab65198962bd46e6e')

I just started to get these yesterday as well: https://gist.github.com/hnykda/615499c348d0d50ad447d23c9d998528

Home Assistant 2021.11.2

Out of nowhere. Can connect to the device via the official app just fine. There is some maintenance work scheduled between 21-23 Nov 11, so let's see.

Still the same, no data are being updated now :-(

Unfortunately from yesterday I have the same problem. All my sensors are unavailable and in the log there is an entry:
PyViCare.PyViCareUtils.PyViCareInternalServerError: (PyViCareInternalServerError(...), 'Request failed with status code 500 and message "Internal server error". ViCare ErrorId: req-d9297a1c8dd341019f16862ed884521a')

Thanks for advice. In my case, I have one circuit, delete and re-add the integration helped.

I just had the same problem. I tried to delete and add the integration in HA. For this I wanted to retrieve my API Key from https://developer.viessmann.com/de/clients but the list was empty. When creating a new API Key I got an error message and my old key re-appeared. Using the old key I could re-integrate ViCare with HA.

tl;dr:

Make sure Viessmann still lists your API key, create a new one if required and try to delete and re-add the Viessmann integration in HA.
Your existing Cards/Visualizations/Statistics should survive this action, at least this is my observation.

I believe it is fixed long time ago now.