esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

MiScale catty/jin units factor, and detecting catty on Mi Scale V2 #4038

Open x11x opened 1 year ago

x11x commented 1 year ago

The problem

Possibly incorrect conversion factor for Mi Scale V1

I was reading the code for Xiaomi MiScale and came across this https://github.com/esphome/esphome/blob/351ea045175c7f9fbd1afc3ff51cf1b61098a416/esphome/components/xiaomi_miscale/xiaomi_miscale.cpp#L98 For Chinese catty/jin units, it is multiplied by 0.6f. I thought it should be 0.5f. Is this possibly a typo in the code? I don't actually have a Mi Scale V1, I have Mi Body Composition Scale V2. And I don't actually use catty units. I have just been doing some research and noticed this while reading through your code. This issue probably needs to be confirmed by users who are actually using Mi Scale V1 with catty as unit, but I have seen elsewhere catty is 0.5 kg

EDIT: I have noticed on the Catty wikipedia page that in Korea and some other parts of Asia, a catty is 0.6 kg. So maybe the Korean models need the 0.6f conversion factor? Mine needed 0.5.

Not detected at all for Mi Scale V2

I have discovered that on Mi Body Composition Scale V2 (and probably Mi Scale V2 and others too), you can detect catty units by checking data[1] & (1 << 6) (6th bit of control byte counting from LSB as 0). Currently the xiaomi_miscale.cpp code is not detecting catty units at all for V2 scales, so this could be added. But as I said, I have only tested on my scale, and don't actually use catty units.

I have found other sources doing the same thing (6th bit of control byte 1):

Which version of ESPHome has the issue?

2022.12.3 (and all prior)

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP8266

Board

No response

Component causing the issue

xiaomi_miscale

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.