Struggling to get Withings integrations fully operational

HA Setup:
Home Assistant OS version 7.5
core-2022.3.7
supervisor-2022.03.5
using nabu casa

Withings Devices:
Sleep Mat

I cannot get the binary_sensor.withings_in_bed_XXXXX to become available.
I have followed the instructions for the integrations – Withings - Home Assistant.
I am getting data from Withings for other entities added by the Withings Integration.
Based on the information I have found regarding this particular binary sensor entity, I have gotten into and out of bed many times to attempt to trigger the in_bed sensor to become available. In the Withings Health Mate app, I have integrated IFTTT and have an IFTTT Applet adding rows to a Google Sheet in which I can see when I get into and out of bed so I am sure that Withings is recording that data.

I am seeing this in my logs:

Logger: homeassistant.components.withings
Source: components/withings/common.py:702 
Integration: Withings (documentation, issues) 
First occurred: 9:22:57 PM (1 occurrences) 
Last logged: 9:22:57 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 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 147, in _async_update_data
    return await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 660, in async_subscribe_webhook
    return await self._do_retry(self._async_subscribe_webhook)
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 656, in _do_retry
    raise exception
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 649, in _do_retry
    return await func()
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 702, in _async_subscribe_webhook
    await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.9/site-packages/withings_api/__init__.py", line 348, in notify_subscribe
    self.request(path=self.PATH_NOTIFY, params=params)
  File "/usr/local/lib/python3.9/site-packages/withings_api/__init__.py", line 115, in request
    return response_body_or_raise(
  File "/usr/local/lib/python3.9/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 help is appreciated.

Hi,

same here !!
all seems working except for binary sensor bed occupancy …

any news ?

thank’s.
Gdi.

Had the same - Many attempts needed to get it working. The in bed sensor is the only thing that will not work until the webhook is properly registered and working. This is what fixed it for me:

  1. Make sure you have the option to use the webhook set to true in the Withings configuration
  2. Make sure the remote URL for Home Assistant is specified in configuration.yaml. Specifying it in the Home Assistant UI didn’t work for me.
  3. The above URL must match the start of the URL you provide in the Withings app as the return URL
  4. Register the Withings integration in Home Assistant from the browser, also using the same URL as provided at 2.
  5. Enable the Withings webhook in the Home Assistant cloud settings (it seems to be disabled by default).
  6. Restart Home Assistant (not sure if needed, but I did)
  7. Go lie in bed, the sensor will be unavailable until you do (and again at every reboot).
4 Likes

You are awesome! It is working now!! Thank you!
Now I just have to set up an automation for when my wife gets out of bed so I know when to hide my midnight ice cream snack :smile:

2 Likes

Glad it worked because I forgot step 0, which I think was absolutely crucial to my success:

  1. Ask every one in the house to be absolutely quiet for the next 15-30 minutes because you’ve tried this sooooo many times, and failed each time, that you cannot bear it going wrong again because you got distracted at a crucial step. :crazy_face:

BTW: thank you for suggesting IFTTT - that is what I used in the mean time before I got the nerve to try it again.

2 Likes

@Edwin_D, this sounds like it could save some of the remaining hair on my head.
I have a question about your step 2, though. Where or how do you put the HA remote URL in configuration.yaml for the Withings integration to recognise it?

Put this in your configuration.yaml

homeassistant:
  external_url: "https://www.example.com"
  internal_url: "http://homeassistant.local:8123"
1 Like

Thank you! This works. Marvellous, and fortunately still some hair left!

1 Like

I only got it to work when I used

https://[MY_SECRET_URL].ui.nabu.casa/auth/external/callback
1 Like

Hi There!

Can someone please help?
Im getting the error:
“{“errors”:[{“message”:“redirect_uri_mismatch: The redirect URI provided is missing or does not match partner callback url”}]}”

My WT URL is like: “https://lp3b3g2hipdy3jjdx5ba6acjgyz1a26z.ui.nabu.casa/auth/external/callback
And when i test it i get :" Partner error: Host Unreachable"

In the HA config file i have the correct client and secret id, like this:
withings:
client_id: 0aba660e21204e15585af591eb2dcu509870ea1aec040afdcd9241c1fbf47bb1
client_secret: 36b66918218b833f8abe1f45c7514ead6cca774a299d4c3f8b4561e2b3d65819
use_webhook: true

What am i missing here?
Thank you in advance!

same issue here, any solutions already testing for weeks .

I just connected:

  1. Withings to IFTTT
  2. IFTTT to HA via Webhooks Automation on HA
  3. Created a boolean Helper inside HA that could be integrated with node red.
    Easy solution :wink:

thank you, i wil try that.

Cannot achieve step 3 :frowning:

First create a Helper (Boolean) in “Device & Services” and name it something like: “Human in bed”.
Then create an automation like this:

alias: Human in bed ON
description: “”
trigger:

  • platform: webhook
    webhook_id: human_bed_on
    condition: []
    action:
  • service: input_boolean.turn_on
    data: {}
    target:
    entity_id: input_boolean.Human in bed
    mode: single

You must created one automation and webhook for ON and others for OFF. Because of IFTTT control.
Then u can place the boolean in your lovelace just to control visually and add it to Red Node/HA Automations to automate whatever u want.

My setup also stopped working after working before. Withings integration send the wrong URL to withings oauth. Seems it does not take the remote_URL config parameter into account anymore.

I think I’m seeing this too. I’ve just tried to set up a brand new Withings integration on my system. Run the wizard, it doesn’t ask me for my dev client_id, but populates it with something which Withings then reject as invalid client_id. Pasting my actual client_id from the Withings account into the URL does get me further into authorising it on Withings, but then the configuration wizard in HA just flashes back a box with Error (and no contents). Withings doesn’t get installed.

Can I see the configuration parameters for Withings in the configuration.yaml so that I can put in my settings directly without the wizard?

I just recently got this working (including in_bed sensor) after struggling for a bit. My set-up is completely without Nabu Casa / Home Assistant Cloud.

Steps to re-produce a working set-up:

  1. BEFORE adding the withings integration (or after removing) add the below to the configuration.yml file and restart. The integration seems to only read this config when it’s first added, not when it’s changed afterwards.

    withings:
      use_webhook: true
    

    See: Withings webhook for in_bed state not working · Issue #37290 · home-assistant/core · GitHub

  2. During integration set-up https://my.home-assistant.io/redirect/oauth is needed in Withings as a Callback URL to set-up the integration & authentication. The Withings website will say Partner error: Host Unreachable when you “Test” this callback. Make sure you’ve configured my.home-assistant.io to point to your external URL (duckDNS in my case).

    The set-up should be trivial after this, the re-direct will take you to my.home-assistant.io you click “Link Account” and it’ll close the tab and the integration has finished.

  3. After setting up the integration the webhook won’t be working. The trick is the following, in the file /config/.storage/core.config_entries there is now a Withings entry ("domain": "withings"). Note the following (by doing e.g. cat /config/.storage/core.config_entries from terminal):
    (a) It says "use_webhook": true (otherwise back to step 1)
    (b) It will say "webhook_id": "{UUID}" where you want to copy the {UUID} part.

  4. Go back to the Withings developer portal, add a new Callback URL using “Register Another url” and add https://{EXTERNAL_URL}/api/webhook/{UUID}. Where {EXTERNAL_URL} is the external Home Assistant URL (only accepts ports 80 or 443, for me it was XXXX.duckdns.org), and {UUID} is the UUID from step 3b. When pressing “Test” the border of the field should turn green.

  5. PROFIT!


Additional pointers should you get stuck. Enable debug logging on the Withings integration, and look for webhook related entries in the log (HELP: Received message for unregistered webhook).

17 Likes

This post should be included in the Withings integration’s official documentation. It solved my issues and now all the sensors receive data, including in_bed. Thanks @wilcymay !

Tried what @wilcymay specified above and still no go. I get a “405: method not allowed” when I put the URL in my browser from step 4, everything else works as expected though I don’t get a green success when adding the api/webhook into the Withings developer portal. I’m got the following setup in case something helps someone figure out why it’s not working for me:
Cloudflare->Nginx Proxy Manager->Home Assistant

I can reach my Home Assistant using the public domain I have for my home assistant, but adding in the /api/webhook/ gets me a 405.

Also, when I enabled the logger for my webhooks, there’s nothing in the HA logs to indicate any problems with webhooks, there’s actually nothing in the logs about webhooks even when entering in the URL from step 4.

Any ideas on what I should check?

1 Like