Core: Withings webhook for in_bed state not working

Created on 1 Jul 2020  Â·  30Comments  Â·  Source: home-assistant/core

The problem

After setting up the new use_webhook: true YAML value and trying to get the in_bed state of my Withings Sleep, it's not working, and I'm getting an error in the logs that look related.

Environment

  • Home Assistant Core release with the issue: 0.112.0
  • Last working Home Assistant Core release (if known): N/A
  • Operating environment (OS/Container/Supervised/Core): OS
  • Integration causing this issue: Withings
  • Link to integration documentation on our website:

Problem-relevant configuration.yaml

withings:
  client_id: redacted
  client_secret: redacted
  use_webhook: true

Traceback/Error logs

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 136, in async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 124, in _async_update_data
    return await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 652, in async_subscribe_webhook
    return await self._do_retry(self._async_subscribe_webhook)
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 648, in _do_retry
    raise exception
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 641, in _do_retry
    return await func()
  File "/usr/src/homeassistant/homeassistant/components/withings/common.py", line 699, in _async_subscribe_webhook
    self._api.notify_subscribe, self._webhook_config.url, appli
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/withings_api/__init__.py", line 285, in notify_subscribe
    self.request(path=self.PATH_NOTIFY, params=params)
  File "/usr/local/lib/python3.7/site-packages/withings_api/__init__.py", line 82, in request
    self._request(method=method, path=path, params=params)
  File "/usr/local/lib/python3.7/site-packages/withings_api/common.py", line 896, in response_body_or_raise
    raise InvalidParamsException(status=status)
withings_api.common.InvalidParamsException: Error code 293

Additional information

withings

Most helpful comment

Ah, that's got it working!

I've set my external URL to Nabu Casa, left my internal URL as my remote.subdomain.com:8123.

Resetup my Withings integration and it now all seems to be working!

All 30 comments

i have the exact same logs, in addition the wohle integration not working as it should. Take a look here https://github.com/home-assistant/core/issues/37321

Same here. Is it supposed to work with Sleep Mat?

Same here. Is it supposed to work with Sleep Mat?

Yes, there is a new binary sensor for "In_bed", but it doesn't appear to be working currently. The sensor appears, but it never updates and an error (as above) is in the logs.

Same here. Is it supposed to work with Sleep Mat?

Yes, there is a new binary sensor for "In_bed", but it doesn't appear to be working currently. The sensor appears, but it never updates and an error (as above) is in the logs.

It's discussed here a bit more https://github.com/home-assistant/core/issues/37368 i had the same error logs. The issue for me was that i used my own subdomain sub.domain.com:8123 in Home Assistant in External URL the integration uses this url (when set) prior to nabu casa url. But Whitings Api don't work with other ports than 443.

Any ideas on how I can get it to work. I have the same issues. I'm using remote.cooldomain.com:8123 as my external URL, but I understand that won't work with Withings. So I used my Nabu Casa URL, which seems to work OK when I setup the integration, but this webhook still isn't working.

you have to either remove your own url from external url (in this case the integration would fall back to your nabu casa url) or set-up some kind of proxy like nginx with certs and all that nice complicated stuff so you can use remote.cooldomain.com without port.

I used this problem to completely get rid of my own subdomain and changed everything to nabu casa. It has a security plus cause i don't have to open port 8123 anymore.

But you could also change your external url to nabu casa url (in case some other or custom integration needs this set, don't know if necessary) and change all places where your own url is set to nabu casa (like i did).
You can still leave port 8123 open and use your own url to have access to HA when config things. (cause it's easier to remember than nabu casa url)

Ah, that's got it working!

I've set my external URL to Nabu Casa, left my internal URL as my remote.subdomain.com:8123.

Resetup my Withings integration and it now all seems to be working!

Hi,

I don't have nabu casa and do not plan to use it, especially, for this type of sensors. I use my own domain and port 443, however, the webhook doesn't work (no change in statis). Also, there is nothing in logs.

Hi,

I don't have nabu casa and do not plan to use it, especially, for this type of sensors. I use my own domain and port 443, however, the webhook doesn't work (no change in statis). Also, there is nothing in logs.

I tried the same before I resorted to Nabu Casa and that didn't work for me either. I suspect there is actually a bug somewhere and it wants to default to your Nabu Casa URL (even if you don't have one!)

Is there anything that needs to be provided to fix the issue, perhaps, @vangorra could have a look?

@danielsmith89 @Molodax
Thee are only 2 parameters for that API call, one of which is an immutable constant. I suspect Withings does not like your webhook_url. Could you post the webhook_url for the withings config entry from .storage/core.config_entries?

Could you post the webhook_url for the withings config entry from .storage/core.config_entries?

Hi @vangorra, here is my redacted webhook_url

"webhook_url": "https://xxx.xxx/api/webhook/XXX1ae6c6264f54ebfXXX63b5e3c0c396f70b21ac8a1340d4e0f0b7e9859eXXX"

it doesn't seem strange to be not "liked" by Withings.
What I noticed in core.config_entries that
"use_webhook": false,
even though it is use_webhook: true in my configuration.yaml

Setting use_webhook, client_id or client_secret does not affect existing configs. You'll have to re add the integration to make that work. This is expected behavior for config imports by hass. I'm working on a change that removes the configuration file config to avoid this confusion.
Regarding your webhook. Is the domain fully qualified and using a publicly recognized certificate authority? Withings is very picky about that.

You'll have to re add the integration to make that work. This is expected behavior for config imports by hass.

Well, the binary_sensor works when I've re-added the integration. I'd say it is not intuitive as well as cannot understand why sleeping duration sensors were hidden again. Is it expected that many other sleeping related sensors such as sleeping score, sleeping heart rate etc. are not available/unknown too?

Entities are linked to integration configurations. If you remove the integration, the entities are removed as well. When you added the integration, it detailed to disabling certain entities.
You're correct this can be improved. I'm working in it.

Anyway, thank you @vangorra for the component!
I, and many others, would love to see it further improving and developing in a way that the info can be retrieved similar to as in the app.

Ah, that's got it working!

I've set my external URL to Nabu Casa, left my internal URL as my remote.subdomain.com:8123.

Resetup my Withings integration and it now all seems to be working!

sorry, what did you do?
im running NabuCasa too but not sure on how to apply these steps sorry

Under general settings configure your external and internal URL's as
mentioned.

On Sat, Aug 8, 2020 at 9:11 AM JamieP notifications@github.com wrote:

Ah, that's got it working!

I've set my external URL to Nabu Casa, left my internal URL as my
remote.subdomain.com:8123.

Resetup my Withings integration and it now all seems to be working!

sorry, what did you do?
im running NabuCasa too but not sure on how to apply these steps sorry

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/core/issues/37290#issuecomment-670842849,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABGQEIFFFMEP3VLIMUBVDILR7UCCHANCNFSM4ONYFGSA
.

hey,
ive done that but still doesnt work?

image

If you're using nabu casa, your shouldn't have to do anything. The withings integration will use it automatically, then external url.
However, I did identify a bug where the url never changes after you setup a profile. So if you setup a profile, then enabled nabu casa, the external url will always be used. The same goes on reverse as well. I'll get this fixed.

Thanks
So is there something I need to do to fix this on my end to make this work?

Thanks,
Jamie

Sent from my iPhone

On 22 Aug 2020, at 4:22 pm, Robert Van Gorkom notifications@github.com wrote:



If you're using nabu casa, your shouldn't have to do anything. The withings integration will use it automatically, then external url.
However, I did identify a bug where the url never changes after you setup a profile. So if you setup a profile, then enabled baby casa, the external url will always be used. The same goes on reverse as well. I'll get this fixed.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/37290#issuecomment-678653452, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALSRFJCDJDSI2K3B5LVIJF3SB7PB3ANCNFSM4ONYFGSA.

@JamieP83 i had to delete and re-add my withings component to fix it.

My in_bed sensor is not working at all any more and I am getting the same error within the logs. Uninstalling and reinstalling the integration didn't help. I'm running HA with Nabu Casa cloud.

What version of HA are you on? Are you using HA Cloud? Did you turn on the web hook in the cloud control panel?

I just updated from 0.115.2 to 0.116.0, had the problem on both versions. Yes, I am using HA cloud and I just took a look at my webhooks, I dont have a withings webhook I can activate (only some Deleted webhooks from the mobile_app).

EDIT: I am sorry, the integration was deleted, therefore I did not have a webhook. I added the integration again and now I can see there is a webhook but when I activate it, and reload the HA Cloud page, the webhook is deactivated again.

Do you have use_wrbhooks on in your config file?

Webhooks not being able to be activated/managed is a bug of the newest HA (0.116). I reverted back to my previous HA and could activate the webhook again - now the in_bed sensor is working again. Only the problem persists that after a HA restart the sensor will be unavailable until it reports a state. Thanks!

It's all working OK for me in 0.116. The only thing which persists, which seems to have been a problem since I started using the integration in 0.112, is that as you mentioned it says "Unavailable" until it reports a state.

Sorry for kinda hijacking this issue. If requested, I can make a new issue. But for me some sensors (like sleep duration) work fine, but others remain unknown forever:

image

Yet when I query the Withings API manually, these values do come through. Any thoughts?

Update: I've created a PR to fix this:
https://github.com/home-assistant/core/pull/41504

You should create a separate issue for that @DiederikvandenB

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coolriku picture coolriku  Â·  3Comments

kirichkov picture kirichkov  Â·  3Comments

MartinHjelmare picture MartinHjelmare  Â·  3Comments

ofuangka picture ofuangka  Â·  3Comments

Konstigt picture Konstigt  Â·  3Comments