Withings Integration after update to 2021.3

Solved!
Firstly, thanks to everyone working hard with HA. I’m so impressed with all this!

Just a little question if any have experienced the same problem with the Withings integration as me, after upgrade to 2021.3.

Now my Withings sensors do not update, and I get “unawailable” as a result!

Can it be something after update, or has anything other gone wrong??
I update the permission for HA to fetch data from Withings everytime I am asked!

My log file looks like this:

2021-03-05 12:18:43 INFO (MainThread) [homeassistant.components.withings] Updating all withings data
2021-03-05 12:18:45 INFO (MainThread) [homeassistant.components.withings] Updating all withings data
2021-03-05 12:18:46 INFO (MainThread) [homeassistant.components.withings] Updating all withings data
2021-03-05 12:18:47 ERROR (MainThread) [homeassistant.components.withings] Unexpected error fetching poll_data_update_coordinator data: Error code 503
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 151, in async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 139, in _async_update_data
    return await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 765, in async_get_all_data
    raise exception
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 734, in async_get_all_data
    return await self._do_retry(self._async_get_all_data)
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 654, in _do_retry
    raise exception
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 647, in _do_retry
    return await func()
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 771, in _async_get_all_data
    **await self.async_get_sleep_summary(),
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 837, in async_get_sleep_summary
    response = await self._hass.async_add_executor_job(get_sleep_summary)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 814, in get_sleep_summary
    return self._api.sleep_get_summary(
  File "/usr/local/lib/python3.8/site-packages/withings_api/__init__.py", line 221, in sleep_get_summary
    self.request(path=self.PATH_V2_SLEEP, params=params)
  File "/usr/local/lib/python3.8/site-packages/withings_api/__init__.py", line 81, in request
    return response_body_or_raise(
  File "/usr/local/lib/python3.8/site-packages/withings_api/common.py", line 896, in response_body_or_raise
    raise InvalidParamsException(status=status)
withings_api.common.InvalidParamsException: Error code 503

I’ve been getting notifications that the integration needs attention almost every morning for a long time now. Once I re-authorize the integration it seems to work—at least for a day. That’s been happening since before 2021.3.0 for me. It never bothered me enough to check the logs before, so I can’t say what the issue was but I can verify what you’re seeing now at least:

2021-03-04 18:15:24 ERROR (MainThread) [homeassistant.components.withings] Unexpected error fetching poll_data_update_coordinator data: Error code 503
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 151, in async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 139, in _async_update_data
    return await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 765, in async_get_all_data
    raise exception
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 734, in async_get_all_data
    return await self._do_retry(self._async_get_all_data)
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 654, in _do_retry
    raise exception
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 647, in _do_retry
    return await func()
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 771, in _async_get_all_data
    **await self.async_get_sleep_summary(),
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 837, in async_get_sleep_summary
    response = await self._hass.async_add_executor_job(get_sleep_summary)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 814, in get_sleep_summary
    return self._api.sleep_get_summary(
  File "/usr/local/lib/python3.8/site-packages/withings_api/__init__.py", line 221, in sleep_get_summary
    self.request(path=self.PATH_V2_SLEEP, params=params)
  File "/usr/local/lib/python3.8/site-packages/withings_api/__init__.py", line 81, in request
    return response_body_or_raise(
  File "/usr/local/lib/python3.8/site-packages/withings_api/common.py", line 896, in response_body_or_raise
    raise InvalidParamsException(status=status)
withings_api.common.InvalidParamsException: Error code 503

After re-authorizing the integration, I briefly get this message, which is either an error or a success. Withings does seem to work afterwards.
aborted

1 Like

Same problem for me. Used to work after reauthentication, but now has completely failed.

1 Like

I’m also having this issue, it seems really random the interval between needing to reauthenticate the integration and I also get unavailable against a number of the sensors now. Would love to get this back working again.

I’m having the same issue,

Did anyone get anywhere with this?

Same problem for me as well, since the 2021.3 update. Withings sensors are unavailable and I get the 503 error in the logs. I have also had to re-authorise the integration several times during the last couple of weeks, before the 2021.3 update, but now that doesn’t help.

I wonder if this could be related to the breaking change with base_url. I have the internal network URL set as internal_url and the Nabu Casa URL set as external_url and the latter is also what is set up in the Withings application setting.

WAR

There’s a workaround on github (link above), for those who don’t need sleep data. The directions for docker in the comment after the one with the WAR did work for me and I’m now getting data (except sleep, which I didn’t use before anyhow).

3 Likes

I just did this, and it works!
Thank you for the link!
:+1:

Even though I really appreciate that there is a workaround, I am trying to figure out if there is a way to apply it also when running the OS version of Home Assistant and not being a developer.

Could a possible way be to do the changes in the source code of the Withings integration in a different environment, compile it and then install it manually as a custom component (removing the integration in the Lovelace interface first)?

Or do I have to wait until this has been corrected in an upcoming update of Home Assistant?

It should be exactly the same as the docker instructions, minus the first step where you log into docker. If the files aren’t in /usr/src/homeassistant/homeassistant/components/withings you could try “find / -type d -iname withings” and it should find the directory. From there, just edit the two files in the WAR and it should start working immediately.

A bit off topic: who is currently a main maintainer of this component?

I’ve recently found on Withings devpages they are going to provide real time telemetry data stream. If it will work as expected it might be the thing.
Just to make you know

1 Like

Thanks, but unfortunately this doesn’t seem to work. The /usr/src/ directory is completely empty and I can’t find the withings directory anywhere else either, at least not when I try to do it via the Terminal & SSH add-on. I wonder if this could be due to that the source code for some reason is not included in my installation (it’s HassOS on a raspberry Pi, installed from an image a couple of years ago) or if I simply can’t get access to these directories via the Terminal & SSH add-on.

You can get it from github as well.

I was finally able to apply the patch by following the instructions from SeraphimSerapis in the linked Github thread. Seems to work again now, including the sleep sensor. Now I just have to figure out if I can do some manual SQL inserts of the missing data from previous days, as I use the sensors to do some calculations based on historical data from the last 14 days.

Where is the link sorry?

I was able to install the withings intergration, it sucessfully authenticated but its stays empty, I do not see any sensors or entities showing up.
Do I do something wrong?

1 Like

‘withings_api.common.InvalidParamsException’: Error code 503
for me too.
install the withings intergration, sucessfull, but no empty …

It looks like no one is maintaining the code at the moment. I wish I knew how to fix it but it’s beyond me.

EDIT:
Hi. I’m new.
I cannot addd Withings Integration. It says:
“Aborted
The component is not configured. Please follow the documentation.”

I createdd Withing DEV account, I upadtes HASS configuration (via File Editore) for Withings and THEN added Integration. It not works.

Thx for help.

I ran into the same exact thing. After some googling I went back and checked the step by step documentation a bit more carefully. I realized I had not entered the user ID and consumer key into the Configuration.yaml the way indicated in “Step 2” here: Withings - Home Assistant

At first I thought that was perhaps part of a later step once I had first installed the general integration into Home Assistant, but this needs to be in place before that can happen. I just put it in exactly the way it is listed in the steps with my own ID and Secret, at the bottom of my configuration.yaml file and then the integrations worked like a charm.