home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.24k stars 30.59k forks source link

Withings sleep analyzer, Breathings disturbances always double #103568

Closed manderss99 closed 11 months ago

manderss99 commented 11 months ago

The problem

The breathing disturbances are always double the amount that is shown in the withings app. I have seen this before but have specifically followed it the last three days, Example; this morning the app show 15 but the integration show 30. please look into this, I'm happy to help with testing.

What version of Home Assistant Core has the issue?

core-2023.11.1

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

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 11 months ago

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.

(message by CodeOwnersMention)


withings documentation withings source (message by IssueLinks)

joostlek commented 11 months ago

Do you still see this? Is it consistently doubled?

manderss99 commented 11 months ago

this night the api show 9 and mobile app 4, maybe rounding issue. otherwise for quite a few days I've checked this the api has reported exactly double the amount of diisturbances compared to the app. Never the same value. My CPAP machine always reports quite a bit lower values than the app, but to get the api report the same value as the app would be good.

manderss99 commented 11 months ago

want to mention that comparing api with monbile app I also see some discrepanicies with average bpm and wakeup duration, however they are consistent with the withings web application so not likely a problem with the home assistant integration.

manderss99 commented 11 months ago

What I find missing though is the datetime of the sleep session reported, now we get the values but not the time which creates problems with presentation, but maybe that should be a separate ticket.

joostlek commented 11 months ago

It's currently fetching the last sleep data and presenting it, so I'm a bit confused why this happens. Curious what your API returns

manderss99 commented 11 months ago

so, this is the raw data from withings api then? for now I just display the number in lovelace, this night I got 29 from integration while the app say 14, likely bc of rounding. not sure how useful this is anyway since my cpap reports AHI 3.5. I could give you temporary access to my withings account for debugging, if that would help.

joostlek commented 11 months ago

Yes. I just checked the API docs and its talking about "breathing_disturbances_intensity" instead of "the amount of breathing disurbances". I think the conclusion I am getting is that Withings just isn't enclosing the data we expected.

joostlek commented 11 months ago

Just checked the sensor definition, and we are talking about intensity in the entity description so I think its just a difference in intrepetation

manderss99 commented 11 months ago

you mean the api does give some other measurement than what is in the app`? in the app it is presented as breathing disturbances, with 0.-15 good, 15-30 moderate and over 30 severe measured as disturbances per hour, this night the integration give 6 and the app show 3, I've checked this many days and it always seem to be int(integration value / 2) But I guess as long as the integration delivers what withings api provides, its difficult to blame the integration. Not of much use though if its unclear what the value represents.

joostlek commented 11 months ago

I mean, the amount of breathing disturbances doesn't really tell how intense it is and vice versa. The app shows the amount, the API provides the intensity.

Technically I could do something with the fact that the value is half the API value, but we do not know if this behaviour is with all Withings devices. So I don't really want to add it, since it could be strange for someone else in the future.

If you really want the amount of disturbances, feel free to use a template sensor.

Unless there's more to say, I think we found the root of this issue. So I'll be closing this issue.