Open rpaines opened 4 months ago
Hey there @allenporter, mind taking a look at this issue as it has been labeled with an integration (fitbit
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
fitbit documentation fitbit source (message by IssueLinks)
I came across this code recently when rewriting the code but left the behavior untouched, finding it very strange. I was mostly worried that changing it would break something else accidentally, or there were some norms about UK weights I was unaware of.
Can we just request from the API in metric and then let the home assistant UI display however the user wants it?
Any concerns about cases where this may be working corr correctly today for some users that may change/break?
So, traditionally people in the UK measure bodyweight in stone (whilst weighing basically anything else in Kg), but this is changing over time and it's just not a unit that converts very well. You also need to convert it to calculate things like BMI. I would suggest that the best thing would be to just get it in metric from the API and let the home assistant UI get it to whatever unit people want to see. It's going to lead to better (or no) conversion for people who want Kg or lbs, whilst still allowing users to have it in stone if preferred. Looking at the Fitbit API documentation, the only measure which is different between the UK and metric options is weight, everything else is just metric in both cases. https://dev.fitbit.com/build/reference/web-api/developer-guide/application-design/#Units I guess this could be a breaking change for users who use stone, although I don't know how the home assistant UI would handle it, would it just transparently introduce the conversion when the integration changes the unit it provides? Worst case scenario, the fix would be for those users to change the unit in the UI.
It seems to make sense to just change everything as you've suggested and the UI should handle things. (e.g. it should know the "native unit of measurement" and produce the correct UI values). One thing i'm unsure about is how statistics and history will be handled if at all, so I may need to test that out and see what happens.
@emontnemery I spent a little time looking at what will happen, but wasn't sure so thought you might know: Is it reasonable to just fix the native unit of measurement going forward or do any internal cleanups/repairs need to happen for something like this where the prior native unit of measurement is different?
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 problem
As a user in the UK, the Fitbit integration forces the use of stones as the weight unit, rather than the more useful and standard metric system here. The integration then rounds this value to 1 decimal place, even though the API returns a value accurate to 3 decimal places here. In turn, this means that setting the units to Kg in the Home Assistant UI provides the wrong value because it is converting from this value with reduced precision. Due to the difference in scale between stone and Kg, this leads to a significant discrepancy between the value provided in the Fitbit UI / on the scale (in Kg) and the value provided in Home Assistant. Ideally, I believe that the integration should always request a metric result from the Fitbit API, keeping all provided precision available for conversion to the user's preferred units within the Home Assistant entity.
What version of Home Assistant Core has the issue?
core-2024.4.3
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
Fitbit
Link to integration documentation on our website
https://www.home-assistant.io/integrations/fitbit/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
No response