core icon indicating copy to clipboard operation
core copied to clipboard

Withings - Stops working after reboot

Open danbayliss opened this issue 1 year ago • 27 comments

The problem

Whenever I reboot Home Assistant my Withings integration stops working and I have to delete it and re-add it

What version of Home Assistant Core has the issue?

core-2024.4.4

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/

Diagnostics information

home-assistant_withings_2024-05-14T09-58-36.023Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

danbayliss avatar May 14 '24 10:05 danbayliss

Hey there @joostlek, mind taking a look at this issue as it has been labeled with an integration (withings) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of withings can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign withings Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


withings documentation withings source (message by IssueLinks)

home-assistant[bot] avatar May 14 '24 10:05 home-assistant[bot]

How many accounts do you have?

joostlek avatar May 14 '24 10:05 joostlek

I have one account

danbayliss avatar May 14 '24 10:05 danbayliss

It's saying something about invalid callback. Can you try setting up the whole integration again with new withings application credentials?

joostlek avatar May 14 '24 10:05 joostlek

I had only set it up again a few days prior to the issue however I have just set it up again now

2024-05-14 11:41:02.061 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings measurements data in 0.106 seconds (success: True)
2024-05-14 11:41:02.241 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings activity data in 0.180 seconds (success: True)
2024-05-14 11:41:02.241 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings bed presence data in 0.000 seconds (success: True)
2024-05-14 11:41:02.356 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings goals data in 0.115 seconds (success: True)
2024-05-14 11:41:02.587 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings sleep data in 0.231 seconds (success: True)
2024-05-14 11:41:02.713 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings workout data in 0.126 seconds (success: True)
2024-05-14 11:41:03.714 DEBUG (MainThread) [homeassistant.components.withings] Registered Withings webhook at hass: https://removed.duckdns.org/api/webhook/26620dd535d26cef7f9de017210b0dd9421f3058e9ad4017cf4ae1c07e8d0705
2024-05-14 11:41:03.889 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://removed.duckdns.org/api/webhook/26620dd535d26cef7f9de017210b0dd9421f3058e9ad4017cf4ae1c07e8d0705 for 1 in 5.0 seconds

I then rebooted

2024-05-14 11:43:42.475 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings activity data in 0.203 seconds (success: True)
2024-05-14 11:43:42.475 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings bed presence data in 0.000 seconds (success: True)
2024-05-14 11:43:42.667 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings workout data in 0.191 seconds (success: True)
2024-05-14 11:43:42.809 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings goals data in 0.142 seconds (success: True)
2024-05-14 11:43:42.976 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings sleep data in 0.167 seconds (success: True)
2024-05-14 11:43:43.978 DEBUG (MainThread) [homeassistant.components.withings] Registered Withings webhook at hass: https://removed.duckdns.org/api/webhook/26620dd535d26cef7f9de017210b0dd9421f3058e9ad4017cf4ae1c07e8d0705
2024-05-14 11:43:44.133 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://removed.duckdns.org/api/webhook/26620dd535d26cef7f9de017210b0dd9421f3058e9ad4017cf4ae1c07e8d0705 for 1 in 5.0 seconds
2024-05-14 11:43:59.477 ERROR (Recorder) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 107, in _request
    response = await self.session.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 608, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
    await self._waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 106, in _request
    async with asyncio.timeout(self.request_timeout):
  File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 330, in register_webhook
    await async_subscribe_webhooks(self.withings_data.client, webhook_url)
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 260, in async_subscribe_webhooks
    await client.subscribe_notification(webhook_url, notification)
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 351, in subscribe_notification
    await self._request(
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 115, in _request
    raise WithingsConnectionError(msg) from exception
aiowithings.exceptions.WithingsConnectionError: Timeout occurred while connecting to Withings

I then tried another reboot to see if I was being rate limited and/or if it would recover

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 330, in register_webhook
    await async_subscribe_webhooks(self.withings_data.client, webhook_url)
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 260, in async_subscribe_webhooks
    await client.subscribe_notification(webhook_url, notification)
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 351, in subscribe_notification
    await self._request(
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 135, in _request
    raise WithingsInvalidParamsError(error)
aiowithings.exceptions.WithingsInvalidParamsError: The callback URL is either absent or incorrect

danbayliss avatar May 14 '24 11:05 danbayliss

Double check: You used new application credentials for this?

Something is odd, Withings responds that The callback URL is either absent or incorrect. But we can definitely see the webhook url in the log messages, so it has to be that the url is incorrect. My other idea would be that there is something in your URL that withings just does not like, as I am assuming you replaced your duckdns prefix with removed

joostlek avatar May 14 '24 11:05 joostlek

Apologies I misunderstood and reauthenticated. I'll setup a new application credential later this afternoon and give it a try. I agree with your thoughts regarding the URL but the fact it works when setting up and then doesn't later is strange.

I did change the URL to hide my duckdns name from the public

danbayliss avatar May 14 '24 11:05 danbayliss

Understandable, can you maybe give some info about that URL? Does it contain any special characters? I am also wondering, does it always show the same URL in the logs? (this should. stay the same between restarts, but will change if you delete the integration and add it back again)

joostlek avatar May 14 '24 11:05 joostlek

The URL is just alpha characters. Happy to share this with you in a direct message if you need it.

I've just setup a new application credential however when I add the Withings integration to Home Assistant and it redirects me to Withings website it asks me if I want to allow my old app credentials and I can't find how to switch it to use my new app credentials. I've tried to delete my old one but it takes 7 days to delete. Any idea how to force the new one?

Once I've got the new app credentials working I'll do some further testing and compare the URLs

danbayliss avatar May 14 '24 11:05 danbayliss

You can remove them via https://my.home-assistant.io/redirect/application_credentials/

joostlek avatar May 14 '24 11:05 joostlek

Thanks. I've removed them and added the new app credentials and seeing the same. Below log shows me setting it up

2024-05-14 12:33:44.932 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://removed.duckdns.org/api/webhook/8704e448412be5041cc81ff791228436c699e92ce57f32690a961be4b51c38da for 16 in 5.0 seconds
2024-05-14 12:33:50.207 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://removed.duckdns.org/api/webhook/8704e448412be5041cc81ff791228436c699e92ce57f32690a961be4b51c38da for 50 in 5.0 seconds
2024-05-14 12:33:55.474 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://removed.duckdns.org/api/webhook/8704e448412be5041cc81ff791228436c699e92ce57f32690a961be4b51c38da for 51 in 5.0 seconds
2024-05-14 12:34:00.877 DEBUG (MainThread) [homeassistant.components.withings] Registered Withings webhook at Withings: https://removed.duckdns.org/api/webhook/8704e448412be5041cc81ff791228436c699e92ce57f32690a961be4b51c38da
2024-05-14 12:43:27.956 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings measurements data in 0.247 seconds (success: True)
2024-05-14 12:43:28.071 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings activity data in 0.206 seconds (success: True)
2024-05-14 12:43:28.243 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings sleep data in 0.142 seconds (success: True)
2024-05-14 12:43:28.260 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings workout data in 0.136 seconds (success: True)
2024-05-14 13:33:28.295 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings goals data in 0.197 seconds (success: True)

I then do the reboot and get the below. The URLs remain the same

2024-05-14 14:05:39.719 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings workout data in 0.156 seconds (success: True)
2024-05-14 14:05:39.834 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings measurements data in 0.115 seconds (success: True)
2024-05-14 14:05:40.039 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings sleep data in 0.205 seconds (success: True)
2024-05-14 14:05:40.153 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings goals data in 0.114 seconds (success: True)
2024-05-14 14:05:40.153 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings bed presence data in 0.000 seconds (success: True)
2024-05-14 14:05:41.155 DEBUG (MainThread) [homeassistant.components.withings] Registered Withings webhook at hass: https://removed.duckdns.org/api/webhook/8704e448412be5041cc81ff791228436c699e92ce57f32690a961be4b51c38da
2024-05-14 14:05:41.343 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://removed.duckdns.org/api/webhook/8704e448412be5041cc81ff791228436c699e92ce57f32690a961be4b51c38da for 1 in 5.0 seconds
2024-05-14 14:05:56.666 ERROR (SyncWorker_12) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 107, in _request
    response = await self.session.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 608, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
    await self._waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 106, in _request
    async with asyncio.timeout(self.request_timeout):
  File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 330, in register_webhook
    await async_subscribe_webhooks(self.withings_data.client, webhook_url)
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 260, in async_subscribe_webhooks
    await client.subscribe_notification(webhook_url, notification)
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 351, in subscribe_notification
    await self._request(
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 115, in _request
    raise WithingsConnectionError(msg) from exception
aiowithings.exceptions.WithingsConnectionError: Timeout occurred while connecting to Withings```

danbayliss avatar May 14 '24 13:05 danbayliss

Does it raise a reauth? It only says that it had a timeout, nothing more

joostlek avatar May 14 '24 13:05 joostlek

No it doesn't. I don't see any error message in Home Assistant but my bed status is 'unknown' and doesn't change when I go and lie on it and no errors in the log at point of lying down and getting out of bed. This is what my entities looks like after it stops working

3NML191

danbayliss avatar May 14 '24 13:05 danbayliss

Oh right, I understood that it would raise a reauth. which is incorect.

Hmm,one thing that I kinda notice is that it doesn't unsubscribe the webhooks for what matter. I would expect that it would first get a list of all notifications and remove the current ones and register new ones

joostlek avatar May 14 '24 13:05 joostlek

Just a note. If I reload the integration, rather than delete and re-add, it appears to register the webhook but the bed sensor entity does not update when I then go and lie in the bed

**EDIT - It does then show a timeout error 10 minutes later

2024-05-14 14:43:51.105 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://removed.duckdns.org/api/webhook/8704e448412be5041cc81ff791228436c699e92ce57f32690a961be4b51c38da for 1 in 5.0 seconds```

danbayliss avatar May 14 '24 13:05 danbayliss

Can you post the full log of that reload -> timeout?

joostlek avatar May 14 '24 13:05 joostlek

Sure

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 107, in _request
    response = await self.session.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 608, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
    await self._waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 106, in _request
    async with asyncio.timeout(self.request_timeout):
  File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 330, in register_webhook
    await async_subscribe_webhooks(self.withings_data.client, webhook_url)
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 260, in async_subscribe_webhooks
    await client.subscribe_notification(webhook_url, notification)
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 351, in subscribe_notification
    await self._request(
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 115, in _request
    raise WithingsConnectionError(msg) from exception
aiowithings.exceptions.WithingsConnectionError: Timeout occurred while connecting to Withings
2024-05-14 14:53:49.583 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings sleep data in 0.174 seconds (success: True)
2024-05-14 14:53:49.600 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings activity data in 0.148 seconds (success: True)
2024-05-14 14:53:49.720 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings workout data in 0.099 seconds (success: True)
2024-05-14 14:53:49.790 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings measurements data in 0.074 seconds (success: True)

danbayliss avatar May 14 '24 14:05 danbayliss

Do you have the full logs?

joostlek avatar May 14 '24 14:05 joostlek

Here is the full log home-assistant.log

danbayliss avatar May 14 '24 15:05 danbayliss

Following along, I'm experiencing this also for the 'in bed' sensor.

update my spouses bed sensor appeared after some time (several hours) and shows as it should. Strange because i presumed that it should show up on the next state change. However, my bed sensor remains in 'unknown' status. I've noticed that my bed sensor does go to a 'clear' state at some point while I'm sleeping and then goes back to an unknown status.

Here's a history of my sensor behavior. It does get recognized eventually, but it takes a while to display also note that i have to reboot HA quite often because of various changes so the bed sensor takes a while to recover when it does.

2024-05-15 23_57_18-History – Home Assistant - Vivaldi

update again as per usual, when i start to complain about the 'in bed' status remaining 'unknown' then it sorts itself out. Not sure why this particular sensor seems to have sporadic behaviors unlike the rest of the sensors, but for both of my persons in withings the 'in bed' sensor looks as it should.

Shredder5262 avatar May 15 '24 14:05 Shredder5262

Is there anyone who can help with this? Everytime I reboot HA I have to delete and re-add my Withings integration

danbayliss avatar Jun 23 '24 19:06 danbayliss

I have made some progress on this and resolved the timeout error. I rebooted the other day and it worked fine so I looked into what was different and AdGuard was turned off. I had previously checked the logs and couldn't see that it was blocking anything. I've now changed the DNS Server for HA OS and I don't get a timeout error anymore. I am still experiencing issues but only sometimes when I reboot and when I have to set it up again it sometimes happens

This is the log of me setting it up from scratch, it fails and then next time it works fine. It's strange that it doesn't like the callback URL first time but does the second time

2024-08-17 14:19:12.169 INFO (MainThread) [homeassistant.components.withings.config_flow] Successfully authenticated
2024-08-17 14:19:12.296 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 activity data in 0.126 seconds (success: True)
2024-08-17 14:19:12.296 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 bed presence data in 0.000 seconds (success: True)
2024-08-17 14:19:12.407 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 measurements data in 0.111 seconds (success: True)
2024-08-17 14:19:12.481 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 workout data in 0.073 seconds (success: True)
2024-08-17 14:19:12.564 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 goals data in 0.084 seconds (success: True)
2024-08-17 14:19:12.721 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 sleep data in 0.156 seconds (success: True)
2024-08-17 14:19:13.722 DEBUG (MainThread) [homeassistant.components.withings] Registered Withings webhook at hass: https://xxx.duckdns.org/api/webhook/e776c9567991e4627573860f8ebe546b011cdd32df9f724f656edd39de174d8e
2024-08-17 14:19:13.868 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/e776c9567991e4627573860f8ebe546b011cdd32df9f724f656edd39de174d8e for 1 in 5.0 seconds
2024-08-17 14:19:21.478 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 263, in register_webhook
    await async_subscribe_webhooks(self.withings_data.client, webhook_url)
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 193, in async_subscribe_webhooks
    await client.subscribe_notification(webhook_url, notification)
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 352, in subscribe_notification
    await self._request(
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 136, in _request
    raise WithingsInvalidParamsError(error)
aiowithings.exceptions.WithingsInvalidParamsError: The callback URL is either absent or incorrect
2024-08-17 14:21:27.836 INFO (MainThread) [homeassistant.components.withings.config_flow] Successfully authenticated
2024-08-17 14:21:27.930 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 goals data in 0.093 seconds (success: True)
2024-08-17 14:21:28.174 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 workout data in 0.244 seconds (success: True)
2024-08-17 14:21:28.174 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 bed presence data in 0.000 seconds (success: True)
2024-08-17 14:21:28.259 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 measurements data in 0.084 seconds (success: True)
2024-08-17 14:21:28.397 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 sleep data in 0.138 seconds (success: True)
2024-08-17 14:21:28.499 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 activity data in 0.102 seconds (success: True)
2024-08-17 14:21:29.501 DEBUG (MainThread) [homeassistant.components.withings] Registered Withings webhook at hass: https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37
2024-08-17 14:21:29.661 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 1 in 5.0 seconds
2024-08-17 14:21:34.941 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 4 in 5.0 seconds
2024-08-17 14:21:40.112 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 44 in 5.0 seconds
2024-08-17 14:21:45.362 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 16 in 5.0 seconds
2024-08-17 14:21:50.607 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 50 in 5.0 seconds
2024-08-17 14:21:55.793 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 51 in 5.0 seconds
2024-08-17 14:22:01.017 DEBUG (MainThread) [homeassistant.components.withings] Registered Withings webhook at Withings: https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37

I then reload the integration and get the following

2024-08-17 14:26:27.105 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 sleep data in 0.272 seconds (success: True)
2024-08-17 14:26:27.207 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 workout data in 0.102 seconds (success: True)
2024-08-17 14:26:27.323 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 activity data in 0.116 seconds (success: True)
2024-08-17 14:26:27.413 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 measurements data in 0.090 seconds (success: True)
2024-08-17 14:26:27.500 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 goals data in 0.087 seconds (success: True)
2024-08-17 14:26:27.500 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 bed presence data in 0.000 seconds (success: True)
2024-08-17 14:26:28.501 DEBUG (MainThread) [homeassistant.components.withings] Registered Withings webhook at hass: https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37
2024-08-17 14:26:28.656 DEBUG (MainThread) [homeassistant.components.withings] Unsubscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 1 in 1.0 seconds
2024-08-17 14:26:29.724 DEBUG (MainThread) [homeassistant.components.withings] Unsubscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 4 in 1.0 seconds
2024-08-17 14:26:30.800 DEBUG (MainThread) [homeassistant.components.withings] Unsubscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 16 in 1.0 seconds
2024-08-17 14:26:31.863 DEBUG (MainThread) [homeassistant.components.withings] Unsubscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 44 in 1.0 seconds
2024-08-17 14:26:32.941 DEBUG (MainThread) [homeassistant.components.withings] Unsubscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 50 in 1.0 seconds
2024-08-17 14:26:34.007 DEBUG (MainThread) [homeassistant.components.withings] Unsubscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 51 in 1.0 seconds
2024-08-17 14:26:35.082 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 1 in 5.0 seconds
2024-08-17 14:26:42.459 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 263, in register_webhook
    await async_subscribe_webhooks(self.withings_data.client, webhook_url)
  File "/usr/src/homeassistant/homeassistant/components/withings/__init__.py", line 193, in async_subscribe_webhooks
    await client.subscribe_notification(webhook_url, notification)
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 352, in subscribe_notification
    await self._request(
  File "/usr/local/lib/python3.12/site-packages/aiowithings/withings.py", line 136, in _request
    raise WithingsInvalidParamsError(error)
aiowithings.exceptions.WithingsInvalidParamsError: The callback URL is either absent or incorrect

Then another reload and it works

2024-08-17 14:28:18.868 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 measurements data in 0.234 seconds (success: True)
2024-08-17 14:28:18.964 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 workout data in 0.096 seconds (success: True)
2024-08-17 14:28:19.124 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 sleep data in 0.160 seconds (success: True)
2024-08-17 14:28:19.124 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 bed presence data in 0.000 seconds (success: True)
2024-08-17 14:28:19.208 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 activity data in 0.084 seconds (success: True)
2024-08-17 14:28:19.291 DEBUG (MainThread) [homeassistant.components.withings] Finished fetching Withings 36599212 goals data in 0.083 seconds (success: True)
2024-08-17 14:28:20.292 DEBUG (MainThread) [homeassistant.components.withings] Registered Withings webhook at hass: https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37
2024-08-17 14:28:20.454 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 1 in 5.0 seconds
2024-08-17 14:28:26.739 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 4 in 5.0 seconds
2024-08-17 14:28:31.983 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 44 in 5.0 seconds
2024-08-17 14:28:37.214 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 16 in 5.0 seconds
2024-08-17 14:28:42.468 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 50 in 5.0 seconds
2024-08-17 14:28:47.741 DEBUG (MainThread) [homeassistant.components.withings] Subscribing https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37 for 51 in 5.0 seconds
2024-08-17 14:28:52.943 DEBUG (MainThread) [homeassistant.components.withings] Registered Withings webhook at Withings: https://xxx.duckdns.org/api/webhook/5a3ea67b46e7fd93c642d34a5cd5c1868f4e13efd0c4ead30acf28ac1b2feb37

danbayliss avatar Aug 17 '24 13:08 danbayliss

Withings does try to reach your device to test, that's why we wait 5 seconds to fully process. We are sure the callback URL is correct and is sent, but apparently Withings doesn't like that URL. I have no clue why that happens though

joostlek avatar Aug 17 '24 14:08 joostlek

Appreciate it's a Withings problem but is there anything that could be done to retry after x mins if that error appears or perhaps raise a repair log so I'm at least aware? Currently it fails silently so I only notice it the next day when I notice my alarm doesn't turn off when I get out of bed

danbayliss avatar Aug 17 '24 14:08 danbayliss

I'll have to double check. Usually we want our issues to be actionable, and I need to double check if "hey we could not subscribe to the webhook" is actionable enough

joostlek avatar Aug 17 '24 14:08 joostlek

Not super helpful, but I wanted to add another data point. My bed sensor stopped working about a week ago, after a HA restart. I see this in the logs Logger: homeassistant.components.withings Source: components/withings/init.py:243 integration: Withings (documentation, issues) First occurred: 10:08:56 AM (2 occurrences) Last logged: 10:08:56 AM

Webhook not registered - https and port 443 is required to register the webhook

I have not updated my version of HA and am running 2024.8.2. I've had this integration running for several years, and it's been mostly stable. Definitely no issues for 6 months or more.

ptdalen avatar Sep 19 '24 15:09 ptdalen

Something probably changed in your setup, it can't register a webhook

joostlek avatar Sep 20 '24 13:09 joostlek

Something probably changed in your setup, it can't register a webhook

You were correct. I had made a change with my system -> network settings a while before I rebooted. All good now.

ptdalen avatar Sep 23 '24 14:09 ptdalen

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

The issue still happens now and again. The issue is that fails silently instead if raising a repair or showing an error with the device setting up like other devices do

danbayliss avatar Dec 22 '24 19:12 danbayliss