Struggling to get Withings integrations fully operational

Oh my goodness!! After hours and hours searching EVERYWHERE and trial and error I found your post and IT WORKED! I don’t understand why this is not merged in the official instructions to install this integration. Thanks a lot @wilcymay !

I can confirm this method works and is repeatable. I set it up successfully twice, with two different withings accounts and two different sleep sensors. I am using Nabu Casa, and in my case, the callbacks still did not work until I went to settings->system->network and disabled “use home assistant cloud” under “Home Assistant URL”. I then manually pasted my Nabu Casa URL into the address box below and restarted home assistant and restarted Home Assistant. Once that was done, there were no withings or webhook related errors in the logs, and the in_bed sensors began functioning properly. Thanks @wilcymay!!

What kind of delay are you getting with this configuration on notifications? Specifically the in_bed.

1 Like

Hello,

The steps I followed are exactly the same as @wilcymay
So the summarize what i’ve done

  1. Add code to configuration.yaml
withings:
  use_webhook: true
  1. Add to Withings dev portal https://my.home-assistant.io/redirect/oauth. Set it up to point to your nabu casa instance (https://my_nabu_casa_id.ui.nabu.casa/)
  2. Go to integrations and add Withings integration and choose your user in Withings
  3. Get the UUID - can we found in setting - home assistant cloud - Webhooks
  4. Add to Withings dev portal https://my_nabu_casa_id.ui.nabu.casa/api/webhook/UUID but leave https://my.home-assistant.io/redirect/oauth in there.
  5. Went to settings->system->network and disabled “use home assistant cloud” under “Home Assistant URL”. I then manually pasted my Nabu Casa URL into the address box below
  6. Restarted home assistant

Resulting in no more errors. The reading of the bed will start once you have laid in the bed.

Sadly this still isn’t working for me. I am not using Nabu Casa. I just deleted it all and re-setup the integration. I set the profile name to my email address (should it be something else?). The test button turned the field green with the /api/webhook/ url.

HA is able to reach out to the API and can get the sleep data, but the in_bed sensor is still unavailable (even after laying on the bed); evidently it’s not getting the webhook data.

I get this error in the logs on reboot:

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 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 195, in _async_update_data
    return await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 321, in async_subscribe_webhook
    return await self._do_retry(self._async_subscribe_webhook)
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 317, in _do_retry
    raise exception
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 306, in _do_retry
    return await func()
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 363, in _async_subscribe_webhook
    await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/withings_api/__init__.py", line 348, in notify_subscribe
    self.request(path=self.PATH_NOTIFY, params=params)
  File "/usr/local/lib/python3.10/site-packages/withings_api/__init__.py", line 115, in request
    return response_body_or_raise(
  File "/usr/local/lib/python3.10/site-packages/withings_api/common.py", line 830, in response_body_or_raise
    raise InvalidParamsException(status=status)
withings_api.common.InvalidParamsException: Error code 293

Any idea?

I’m having the same issue. Also not using Nabu Casa for external access. It won’t even reach my domain/api/webook/UUID, but I am able to create nabu casa webhook and reach HA that way (since I still have Nabu Casa). I get that same error.

EDIT: I solved my issue. I use a Cloudflare tunnel for remote access and was blocking foreign countries accessing my HA instance. Withings webhook server was pinging from France, so I had to update my filter

I also use a cloudflare tunnel, what exactly did you do to unblock the other countries? I whitelisted those IP’s you get from the dig here: Keep user’s data up to date | Withings

My router/reverse proxy also blocks foreign countries. Allowing France is what fixed it for me.

I still block all countries, but allow “/api”. My rule is as follows:

  1. Country not equal US
    AND
  2. URI Path does not contain /api
    THEN Block/Managed Challenge
1 Like

For those still struggeling, some additional info from todays point of view:
The commands dig +short TXT ipblock-front.withings.net and dig +short TXT ipblock-notify.withings.net turned out to return empty. On reddit however I found:

dig +short TXT ipblock-front.withings.net
"89.30.121.143 89.30.121.144 89.30.121.145 89.30.121.146 89.30.121.140 89.30.121.150 89.30.121.160 89.30.121.170"
 dig +short TXT ipblock-notify.withings.net
"89.30.121.171 89.30.121.172 89.30.121.173 89.30.121.174 89.30.121.150" 

This may be combined as 89.30.121.0/24, but as it turns out, I did not need any explicit IP whitelisting.

I am using duckdns. Originally, I was using the “NGINX Home Assistant SSL proxy” addon as well, but I did not manage to whitelist 89.30.121.0/24 using this add-on. Also withings only reported the 293 error or “unknown” values on the sensor. There are no options for ip or subnet whitelisting in above add-on

Digging a bit deeper, I found out that there is a much more powerful NGINX-addon available, named: Nginx Proxy Manager: GitHub - hassio-addons/addon-nginx-proxy-manager: Nginx Proxy Manager - Home Assistant Community Add-ons
So I removed the “NGINX Home Assistant SSL proxy” addon and installed " Nginx Proxy Manager" instead. I followed the installation steps provided here: addon-nginx-proxy-manager/DOCS.md at dab35df9a3b6f2df832d89d0548243b67a95c748 · hassio-addons/addon-nginx-proxy-manager · GitHub which involved installing MariaDB and additionally editing my port forward rule to include port 80:80 in addition to the 443:443 as well.

I then created a proxy hosts rule in the Proxy Manager Web Interface for Duckdns (examples are available online on how to do this). I selected “Websocket Support”, Publicly Accessible and “Force SSL” in the various tabs.

Next, I extended the trusted_proxies part in configuration.yaml to:

trusted_proxies:
    - 127.0.0.1
    - 172.30.33.0/24
    - ::1

I did not touch anything in the cors_allowed_origins field, which is set to the following for me, following an online tutorial which recommended this configuration (I was wondering if this also had a role in it, but apparently not):

cors_allowed_origins:
    - https://google.com
    - https://www.home-assistant.io

After a reboot the Withings integration worked straight away (I had already done steps 1-4 from @wilcymay before)!

So, it turned out that I did not need to actively add any whitelisting or custom proxy configuration in the proxy manager. Just the change of the add-on and the addition of above lines in configuration.yaml was sufficient. I cannot say which of the two actions made the difference now, but I suspect that it is the add-on change, where the configuration change is just a requirement for the addon to run properly.

@wilcymay has the solution.

Clarifying Notes:

Use the same domain in the my.home-assistant.io redirect as your callback URL in the Withings dev app.

If My Home Assistant is enabled, the setup flow always sends https://my.home-assistant.io/redirect/oauth, so you need to use it and have it set up to match your configuration in Withings Dev.

The Withings servers are reaching out to your Home Assistant server, and until they get a 200 back from their webhook request. This means if you aren’t using Nabu Casa you have to verify the withing servers are passing through your router/firewall/reverse proxy and reaching your Home Assistant server. You’ll see 6 webhook requests come through from Withings every 10 minutes or so unless you trigger a sensor.

@Jens_Wymeersch mentioned: The reading of the bed will start once you have laid in the bed.
You won’t get an In Bed detected until you trigger that sensor.
Don’t be fooled by the red Unavailable icon after completing the setup. It’s probably working.
The API returns Unavailable when ‘in bed’ is not detected for more a full check-in period. The sequence is “in bed: Detected”, “in bed: not detected”, “in bed: Unavailable. So about 10 minutes after you get out of bed, the sensor turns Unavailable but will switch back to Detected as soon as you lay day again.

I found this
works a dream

1 Like

what code in step 1?
And what are you doing in step 2?

UPDATE: nvm, I just followed the original post of @wilcymay and it worked. Not sure if your list makes it easier as the steps you describe seem to miss a lot.

@john2014 You are totally right. Hence, I’ve updated the steps accordingly. Please let me know if something is missing.

1 Like

thanks, will sure help the next person that will set this up!

Should I remove the config? What will be the new setup?

The Withings YAML configuration is being removed
This stops working in version 2024.4.0. Please address before upgrading.
Configuring Withings using YAML is being removed.

Your existing YAML configuration has been imported into the UI automatically.

Remove the withings configuration from your configuration.yaml file and restart Home Assistant to fix this issue.

You should be safe to remove the yaml config portion.

Hello,

I have a issuewith the withings integration on my home assistant and more specifically with the sleep sensor.

I get no feedback from the sleep sensor (the scale works).

I’ve looked on several forums and it seems to be a webhook problem. Unfortunately when I try to activate it, as @wilcymay says on

My ha doesn’t want to know (I did put the line of code before installing it) but I still have “false” in my core.config file and I get a ha error telling me the line I put in configuration.yaml is deprecated.

Capture d'écran 2023-10-21 133422

Do you have any idea how to activate webhook?

Since 2023.10, the integration will detect if you can use webhooks and will automatically create them.

All this for a scale… I feel like it’s not worth it. It’s so stupid how they make it so hard