core: Withings Sleep Mat Sensor never available

The problem

After configuring my Withings Sleep mat within the Withings HealthMate app, creating a development account with Withings, adding a Personal App to Withings, getting my Client ID and Client Secret, and following the Withings integration setup instructions here –https://www.home-assistant.io/integrations/withings/ – some data for the Withings integration import, but the binary sensor associated with my Sleep mat never becomes available. I have gotten into and out of bed to attempt to force the binary sensor to become available since I had seen that others had also had that sensor become available after getting into and out of bed.

I know that Withings is registering the “in bed” and “out of bed” times because I set up IFTTT to write new lines to a Google Sheet on updates, and those Sheets record all of my into and out of bed times.

To troubleshoot: I have deleted and added the integration many times. I have deleted the integration, removed the Sleep mat from my Withings, hard reset the Sleep mat, added the Sleep mat back to Withings, added the integration back to HA. All without any change in the binary sensors status.

What version of Home Assistant Core has the issue?

core-2022.3.7

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

No response

Diagnostics information

No response

Example YAML snippet

withings:
  client_id: !secret withings_id
  client_secret: !secret withings_secret
  use_webhook: true

Anything in the logs that might be useful for us?

Logger: homeassistant.components.withings
Source: components/withings/common.py:702 
Integration: Withings (documentation, issues) 
First occurred: 4:44:13 PM (1 occurrences) 
Last logged: 4:44:13 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

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 10
  • Comments: 72 (1 by maintainers)

Most upvoted comments

I’m using the same callback and tried turning off webhooks but the in bed status is still perpetually unavailable

OK there is one setting that I just realized that I forgot to revert in my troubleshooting. I don’t know if this will do the trick, but it may be worth a try.

Settings --> System --> Network --> In here for the Home Assistant URL I disabled Use Home Assistant Cloud and I just pasted in my cloud url in this format: https://xxxxxxxxxxxx.ui.nabu.casa

As mentioned here Integration does not work with nabu’s external cloud address and that’s why withings fails to register callback correctly.

Workaround is to manually enter your cloud address to network external address field. I hope this will be fixed soon.

I’m using the same callback and tried turning off webhooks but the in bed status is still perpetually unavailable

OK there is one setting that I just realized that I forgot to revert in my troubleshooting. I don’t know if this will do the trick, but it may be worth a try.

Settings --> System --> Network --> In here for the Home Assistant URL I disabled Use Home Assistant Cloud and I just pasted in my cloud url in this format: https://xxxxxxxxxxxx.ui.nabu.casa

hallo,

same here…never seen working !!

I just figured out my problem. When registering my withings app (on the Withing’s developer portal), I had been using the suggested “My Home Assistant” method (using the https://my.home-assistant.io/redirect/oath URL). However…I realized that I had registered my INTERNAL URL when I setup my.home-assistant, rather than my Nabu Casa URL. Do the following:

  1. Visit https://my.home-assistant.io
  2. Verify that the “HOME ASSISTANT INSTANCE” listed is your Nabu Casa URL. (ie. https://youruniquehash.ui.nabu.casa). If you don’t know this information, goto your Home Assistant Console --> Settings --> Home Assistant Cloud --> Remote Control and click the copy to clipboard icon.
  3. Goto the Withings developer dashboard and edit your app (per the integration instructions, using the https://my.home-assistant.io/redirect/oauth URL as the REGISTERED URLS). If you run a “Test”, it will fail, just disregard that error.
  4. Save your Withings Developer Application configuration (“DONE” at the bottom of the page)
  5. In your Home Assistant Console, delete the withings integration.
  6. Re-add the Withings integration. You will be redirected to Withings for you to logon, then your redirect URL should work.
  7. Finally, be sure you enable the Withings webhook. In your Home Assistant Console --> Settings --> Home Assistant Cloud --> Webhooks (bottom of page). Locate the “Withings notify (withings)” hook, and turn it on.
  8. Go lay on your bed for a moment, and the binary_sensor.withings_in_bed_username entity state should change to occupied.

Mine is working fine, yes it shows unavailable sometimes but once you get into bed it activates. It has always done this, I have been using it now for over 3yrs.

Screenshot 2022-07-17 084401

I spoke to a support guy from Withings about this Callback URL Test. Apparently the callback URL you provide must be able to respond to POST and HEAD requests in under 2000ms (2 seconds).

I notice my /auth/external/callback URL gives a “method not supported” error when attempting to make a HTTP request with both POST and HEAD method types.