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.69k stars 30.82k forks source link

Add new Withings sensors #103291

Closed backslashV closed 10 months ago

backslashV commented 1 year ago

The problem

Hi, Withings recently added the following new sensors (and some others) after their launch of the Body Scan scale:

Can you please add support for these?

What version of Home Assistant Core has the issue?

core-2023.10.3

What was the last working version of Home Assistant Core?

core-2023.10.3

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

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 1 year 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 1 year ago

Yes, but what the hell do they mean 😂

backslashV commented 1 year ago

Yes, but what the hell do they mean 😂

;D here are some screenshots explaining them because I'm too lazy to type. Screenshot_20231103-091723.png

Screenshot_20231103-091753.png

The segmental body composition also shows you the fat and muscle mass for different parts of your body.

joostlek commented 11 months ago

Okay, I made the code change but I need some input from you as I don't know what the unit should be. Could you please run

cd /config
curl -o- -L https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d withings -p 105561

This will install the changes as a custom component. After a restart it should create the new sensors (they are disabled by default). Could you please compare this with your app and give me the unit of measurement of every sensor. (We do this comparison to avoid issues with 0.1 - 1 etc)

backslashV commented 11 months ago

Please give me a few days. I'm sick currently.

joostlek commented 11 months ago

The 2024.1 beta cuts at 27-12, would love to have it in before that haha

backslashV commented 11 months ago

Yes, will definitely do it before then.

backslashV commented 11 months ago

Hi, I've installed the component. However, I am not seeing any of the sensors I mentioned in my original request. I do see the following disabled sensors:

joostlek commented 11 months ago

When is the last time you did a measurement?

backslashV commented 11 months ago

I just did a measurement and can see the following sensors:

joostlek commented 11 months ago

Did you restart HA after running the command?

backslashV commented 11 months ago

Yes!

joostlek commented 11 months ago

Can you send the diagnostics file?

backslashV commented 11 months ago

Can you send the diagnostics file? Sure. Here.

joostlek commented 11 months ago

Heh, I am expecting that it created sensors for all 6 of them. They might be disabled by default. Can you check again? I can't believe this doesn't work

backslashV commented 11 months ago

Heh, I am expecting that it created sensors for all 6 of them. They might be disabled by default. Can you check again? I can't believe this doesn't work

I'm only seeing the previously posted disabled sensors. These are the enabled ones:

Screenshot_20231220-190702.png

Screenshot_20231220-190713.png

Do you suggest removing and re-adding the integration?

joostlek commented 11 months ago

Sure, give it a shot

backslashV commented 10 months ago

Hi, removed and reinstalled the integration along with running the commands you mentioned. After a reboot and a new measurement, I am only seeing 25 entities with 9 of them hidden by default.

Extracellular water sensor.withings_extracellular_water | Withings

Hydration sensor.withings_hydration | Withings

Intracellular water sensor.withings_intracellular_water | Withings

sensor.withings_none sensor.withings_none | Withings

sensor.withings_none_2 sensor.withings_none_2 | Withings

sensor.withings_none_3 sensor.withings_none_3 | Withings

sensor.withings_none_4 sensor.withings_none_4 | Withings

sensor.withings_none_5 sensor.withings_none_5 | Withings

sensor.withings_none_6 sensor.withings_none_6 | Withings

Withings Bone mass sensor.withings_bone_mass | Withings —

Withings Calories burnt last workout sensor.withings_calories_burnt_last_workout | Withings —

Withings Distance travelled last workout sensor.withings_distance_travelled_last_workout | Withings —

Withings Elevation change last workout sensor.withings_elevation_change_last_workout | Withings —

Withings Fat free mass sensor.withings_fat_free_mass | Withings —

Withings Fat mass sensor.withings_fat_mass | Withings —

Withings Fat ratio sensor.withings_fat_ratio | Withings —

Withings Heart pulse sensor.withings_heart_pulse | Withings —

Withings Last workout duration sensor.withings_last_workout_duration | Withings —

Withings Last workout intensity sensor.withings_last_workout_intensity | Withings —

Withings Last workout type sensor.withings_last_workout_type | Withings —

Withings Muscle mass sensor.withings_muscle_mass | Withings —

Withings Pause during last workout sensor.withings_pause_during_last_workout | Withings —

Withings Weight sensor.withings_weight | Withings —

Withings Weight goal sensor.withings_weight_goal | Withings —

Withings Workouts calendar.withings_workouts | Withings

joostlek commented 10 months ago

Oh those 6 none might be it? Can you check the values with the app?

backslashV commented 10 months ago

Ok. I could only correlate two of those "none" sensors to an actual value in the app. I can see one of them is the visceral fat which is an index and unitless. Another one is showing as a whole number in the app but with decimals in HA. I think they are both referring to electrodermal activity which is a score and unitless.

backslashV commented 10 months ago

I am observing that the numbers between HA and the app are rather different. For example, in HA, my bone mass shows as 2.95 kg. In the app, it shows as 4.1% of my total weight which when calculated manually, comes out to 2.91 kg. I think those other none sensors are referring to some of the segmental body compositions but because of this difference in accuracy, I can't tell which is which.

joostlek commented 10 months ago

Oh lol, I made a mistake, let me update the PR

joostlek commented 10 months ago

I updated the PR, please run the script again and restart. It should now show the actual name for the sensors.

backslashV commented 10 months ago

After updating, my previous observation is confirmed regarding those two sensors. I am seeing 3 sensors for electrodermal activity (left foot, right foot, avg of both). There is also these sensors which don't correspond to a number in the app:

FYI, in the app, the fat mass section shows the avg fat percentage for 1) arms 2) torso 3) legs

Clicking on 1) and 3) gives the exact percentage for the right and left limbs. The same goes for muscle mass.

joostlek commented 10 months ago

Can you give me the unit of measurement for the electrodermal acitivty?

We still have Visceral fat iirc.

For the segments, from what I understand, in the app you can view certain segments fat percentage in detail. But from the Withings API I only receive 1 value. Is that value now the same as normal mass? (muscle mass for segments == muscle mass)? Or does it maybe just show you the mass of the fat in the limbs? (Because in that case I would prefer to rename it to something different than "Muscle mass for segments" (because I would not have connected "segment" to "arms/torso/legs" in the first place))

backslashV commented 10 months ago

Can you give me the unit of measurement for the electrodermal acitivty?

This one is unitless. It's a number out of 100.

We still have Visceral fat iirc.

Yes, this one is "Visceral fat index" which ranges from 1 to 20. It's unitless.

The numbers for "Muscle mass for segments" and "Muscle mass" are not the same. For me, the former is 3.51, and the latter is 55.72 kg. For "Fat mass for segments", I am seeing 0.56. For "Fat mass" I am seeing 12.29 kg. In the app, fir fat mass, I am seeing 12.7% for avg arms, 18.9% for torso, and 16.2% for avg legs.

joostlek commented 10 months ago

his one is unitless. It's a number out of 100.

Is it a percentage?

Right, do you maybe have a moment to check if 3.51 could maybe be just the value of 1 limb or so?

To be honest, I would like to know what the number of ".. for segments" actually mean, because I don't feel like adding sensors for data that we don't even understand or can put into perspective.

backslashV commented 10 months ago

Is it a percentage?

It's not shown as a percentage in the app, but you could say it is a percentage since its max value is 100.

Right, do you maybe have a moment to check if 3.51 could maybe be just the value of 1 limb or so?

Ok, I see what's going on. The "Muscle mass for segments" sensor's unit seems to be in kg. My app is set to lb. Changed the app to kg, and I can see 3.51 is referring to my right arm's muscle mass.

joostlek commented 10 months ago

Ooooh, I think I might have an idea of what's happening. Withings returns us a list of measurements. I think they are posting all segments under the same measurement type. So this does mean that we have more context for these numbers, but I also don't have any guarantee that the numbers will always be in the same order. I think that's something we could dive in deeper but that would require some more changes and some data from your side to checkout if it is even possible to differentiate on the numbers we get back.

I will add all sensors except for the segments one since for now I don't except to be able to give a good constant number back.

Can you maybe open an issue over at https://github.com/joostlek/python-withings? That's maybe a better place to discuss this.

backslashV commented 10 months ago

Sure, created an issue there.