core: Withings integration not working
The problem
For the last week I’ve been trying to setup the Withings integration using the Sleep Analyzer. I’ve managed to configure the integration to the point where it’s on the Integrations list and 34 entities are identified, but:
- The in_bed sensor is reported as Unavailable and none of the other entities provide any data;
- By checking the logs I can see that the service is constantly throwing an error when trying to subscribe to notifications;
I’ve tried updating the app on withings and reinstalling the integration on HA, but nothing seems to help. I know there are some other issues opened and that there’s a currently ongoing PR with some fixes, but from what I gathered none of them was caused by this error.
What is version of Home Assistant Core has the issue?
core-2021.2.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
withings
Link to integration documentation on our website
https://www.home-assistant.io/integrations/withings/
Example YAML snippet
# Put your YAML below this line
withings:
client_id: !secret withings_client_id
client_secret: !secret withings_client_secret
use_webhook: true
Anything in the logs that might be useful for us?
# Put your logs below this line
Logger: homeassistant.components.withings
Source: components/withings/common.py:704
Integration: Withings (documentation, issues)
First occurred: 11:13:23 PM (2 occurrences)
Last logged: 11:13:53 PM
Unexpected error fetching subscription_update_coordinator data: Error code 293
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 149, in async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 137, in _async_update_data
return await self.update_method()
File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 658, in async_subscribe_webhook
return await self._do_retry(self._async_subscribe_webhook)
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 704, in _async_subscribe_webhook
await self._hass.async_add_executor_job(
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.8/site-packages/withings_api/__init__.py", line 285, in notify_subscribe
self.request(path=self.PATH_NOTIFY, 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 293
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 88 (4 by maintainers)
I think I got it working. Here’s what I needed to do:
The combination of these steps seemed to work for me. If others find the same then I can submit a documentation improvement edit.
One thing I’m not sure about is why I had to explicitly configurre the home assistant URL when using home assistant cloud / nabu casa. This setting is only visible when you switch to advanced mode, so I am imaging this is supposed to work auto-magically in some way without needing to explicitly configure it. Perhaps one of the home assistant or withings component maintainers know the answer to this?
Note that the in_bed sensor still shows as unavailable until you first get in or out of bed. After that it shows the right state.
To help me debug the external URL issue, I added the following lines to my configuration.yaml:
You can then see more of the logs from the withings component (Configuration->Logs->Load Full Home Assistant Log). This is where I previously saw it using the local IP address for the web hook. Not sure if this will give you any more clues to why in your case it is not working.
I solved the 293 error. I am freaking excited. It’s working.
Alright, what a mess/journey. I had to learn enough python to dump tons of crap to the log.
For my notes: /usr/local/lib/python3.9/site-packages/withings_api/init.py I setup a logger at the top of the file: import logging _LOGGER = logging.getLogger(“test”)
Then down on line 312 I added _LOGGER.warn(“+++ notify_sub”) _LOGGER.warn(params) _LOGGER.warn(callbackurl)
This made me realize that despite my callbackURL being correct in my withings account, it was still trying to hit port 8123 and withings only accepts 80 and 443.
I was banging my head against the wall looking for it for a while. Then I remembered the post by @amaisano https://github.com/home-assistant/core/issues/46425#issuecomment-856172133
Aha! In /config/.storage/core.config_entries sure enough my callbackURL was incorrect. I have no idea where you edit this through the UI or how one would even know about this config but his documentation above helped tremendously.
For the first time error 293 was GONE, but wait, there’s more… It still wasn’t working. I was getting a reverse proxy warning. Because I am self-hosting and not using the cloud, I am reverse proxying a very specific set of URLs to homeassistant. Fortunately, I found this issue. https://github.com/home-assistant/core/issues/51986
I ended up adding my reverse proxy to the trusted list and I restarted once again to no errors. I promptly ran to the bed and sat for a moment and my sensor was reporting.
I hope this helps someone else.
@lxpollitt they helped significantly - def. a need for doc improvement there (on both accounts). I’ve done this and my
in_bed
sensor is working fine, but NONE of the other sensors work (and there are like, 30 of them). Should they?@milkplus27 there is a trick to this if the other device is on a separate account. You just use the same config and the same API app you created. You add a second Withings integration in the UI, and when asked to authorize, log out of Withings (“Not you?”) in the browser and log in with that other user’s account and approve.
If you have two devices on the same account, I can’t speak to that, but I’m pretty sure it works in a similar way – maybe THAT’s where profile name becomes important…
Thanks! I’ll give this a go and see what I can glean from it. That you managed to get it working has given me a modicum of hope!
My situation is exactly the same as yours. Other withings entities populate (albeit not in real-time) and the bed presence sensor is forever unavailable. With regards to selecting the right profile, I suspect that this only happens when you have more than one person registered on your Withings account. When I configure the integration, after I log into Withings, it asks me which user I am - I then choose one and then retype that name as the Profile back in HA. Doesn’t seem to help though…
I too am confused by what the profile name is supposed to be. I don’t recall at any point in any of the pages I used to set up the app in the withings developer site it using the word “profile”. The configurable fields I see for the app in the withings site are:
APPLICATION'S NAME
,DESCRIPTION
,CONTACT EMAIL
,COMPANY
,CALLBACK URL
, andENVIRONMENT
. There is alsoCLIENT ID
, andCONSUMER SECRET
, which withings assigns to the app. I setENVIRONMENT
to Prod, since someone else on this issue thread said that’s what they used and it worked for them. I set both the application name and description to “Withings Home Assistant Data”. This withings autorization dialog does not display an obvious profile name. It does display the app name (“Withings Home Assitant Data” in my case). So I guessed this is what the home assistant integration needed for the profile name. I have also tried using the email address as the profile name (that I use for my main withings account and withings developer app) as the profile. The results have been the same in each case, which I’ll describe next. It might also be worth noting that my withings account is only configured with a single user (myself) in case that makes a difference to the question of why there’s no obvious profile name displayed during the authorization step.Most of my withings data shows up correctly within home assistant. For example, I can see my latest weight measurments from my withings scales. This data gets populated when first adding the integration and then periodically, but doesn’t look to be updated in near real time, so I’m guessing the webhook is not working.
The one sensor that I wanted to use from the withings integrration which is reporting unavailable is the binary_sensor.withings_in_bed sensor. I read somewhere that this is only populated after the sensor is triggered, but mine is still showing unavailable the next day despite having gone to bed the previous night. Withings is reporting the sleep data correctly within the withings app itself, so I know the withings device is worrking.
My configuration.yaml includes this snippet (with the correct id and secret values):
I’m running core-2021.6.2 with supervisor-2021.05.4 on Home Assistant OS 5.13.
I’m using Nabu Casa cloud and set my withings app callback url to
https://myprefix.ui.nabu.casa/auth/external/callback
(with the correct prefix for my account).Home Assistant logs reports the following error which I’m guessing indicates the webhook isn’t working correctly, but am not sure without diving into the code.
Any help is much appreciated. Or please let me know if there is anything anyone would like me to try or do to help debug this. (I woud normally try to understand the code and debug it myself, perhaps raise a PR to fix, but unfortunately I’m struggling with a health issue at the moment and don’t think I have the energy to dive into home assistant development right now as I’ve never done any of it before.)
I’m also unable to get Withings sleep mats to report bed occupancy. I have mats from the Withings Aura. Not sure if that makes a difference?
Same problem here…
Yes,it seems that there is not anymore captain in this boat !
So it is normal . This version does not include the fix You need Dev version from 2021.4 But you wil get sensors but they will keep empty as it does not work