(Forked from etekcity_esf551_ble
This package provides a basic unofficial interface for interacting with Vitafit Body Fat Scale (no affiliate link) using Bluetooth Low Energy (BLE). It allows you to easily connect to the scale, receive weight and impedance measurements, manage the display unit settings, and calculate various body metrics.
It has only been tested on the Body Fat scale VT701 model. I have no idea whether it might also work with some other bluetooth bathroom scale models from Vitafit. If you try it with a different model, please let me know whether it works or not.
Disclaimer: This is an unofficial, community-developed library. It is not affiliated with, officially maintained by, or in any way officially connected with Vitafit, or any of their subsidiaries or affiliates. The official Vitafit website can be found at https://www.vitafit.com. The names "Vitafit" as well as related names, marks, emblems and images are registered trademarks of their respective owners.
Install the package using pip:
pip install vitafit_vt701_ble
Here's a basic example of how to use the library:
import asyncio
from vitafit_vt701_ble import (
IMPEDANCE_KEY,
WEIGHT_KEY,
VitafitBodyFatScale,
ScaleData,
WeightUnit,
BodyMetrics,
Sex,
)
async def main():
def notification_callback(data: ScaleData):
print(f"Weight: {data.measurements[WEIGHT_KEY]} kg")
print(f"Display Unit: {data.display_unit.name}")
if IMPEDANCE_KEY in data.measurements:
print(f"Impedance: {data.measurements[IMPEDANCE_KEY]} Ω")
# Calculate body metrics
# Note: Replace with your actual height, age and sex
body_metrics = BodyMetrics(
weight_kg=data.measurements[WEIGHT_KEY],
height_m=1.75, # Example height
age=30, # Example age
sex=Sex.Male, # Example sex
impedance=data.measurements[IMPEDANCE_KEY]
)
print(f"Body Mass Index: {body_metrics.body_mass_index:.2f}")
print(f"Body Fat Percentage: {body_metrics.body_fat_percentage:.1f}%")
print(f"Fat-Free Weight: {body_metrics.fat_free_weight:.2f} kg")
print(f"Subcutaneous Fat Percentage: {body_metrics.subcutaneous_fat_percentage:.1f}%")
print(f"Visceral Fat Value: {body_metrics.visceral_fat_value}")
print(f"Body Water Percentage: {body_metrics.body_water_percentage:.1f}%")
print(f"Basal Metabolic Rate: {body_metrics.basal_metabolic_rate} calories")
print(f"Skeletal Muscle Percentage: {body_metrics.skeletal_muscle_percentage:.1f}%")
print(f"Muscle Mass: {body_metrics.muscle_mass:.2f} kg")
print(f"Bone Mass: {body_metrics.bone_mass:.2f} kg")
print(f"Protein Percentage: {body_metrics.protein_percentage:.1f}%")
print(f"Metabolic Age: {body_metrics.metabolic_age} years")
# Replace XX:XX:XX:XX:XX:XX with your scale's Bluetooth address
scale = VitafitBodyFatScale("XX:XX:XX:XX:XX:XX", notification_callback)
scale.display_unit = WeightUnit.KG # Set display unit to kilograms
await scale.async_start()
await asyncio.sleep(30) # Wait for measurements
await scale.async_stop()
asyncio.run(main())
TODO For a real-life usage example of this library, check out the Etekcity Fitness Scale BLE Integration for Home Assistant. TODO
The main class for interacting with the scale.
__init__(self, address: str, notification_callback: Callable[[ScaleData], None], display_unit: WeightUnit = None)
async_start()
: Start scanning for and connecting to the scale.async_stop()
: Stop the connection to the scale.
display_unit
: Get or set the display unit (WeightUnit.KG, WeightUnit.LB or WeightUnit.ST). Returns None if the display unit is currently unknown (not set by the user and not yet received from the scale together with a stable weight measurement).hw_version
: Get the hardware version of the scale (read-only).sw_version
: Get the software version of the scale (read-only).
An enum representing the possible display units:
WeightUnit.KG
: KilogramsWeightUnit.LB
: PoundsWeightUnit.ST
: Stones
A dataclass containing scale measurement data:
name
: Scale nameaddress
: Scale Bluetooth addresshw_version
: Hardware versionsw_version
: Software versiondisplay_unit
: Current display unit (concerns only the weight as displayed on the scale, the measurement itself is always provided by the API in kilograms)measurements
: Dictionary of measurements (currently supports: weight in kilograms and impedance in ohms)
A class for calculating various body composition metrics based on height, age, sex, and the weight and impedance as measured by the scale, similar to the metrics calculated and shown in the VeSync app. Note that currently "Athlete Mode" is not supported.
__init__(self, weight_kg: float, height_m: float, age: int, sex: Sex, impedance: int)
body_mass_index
: Body Mass Index (BMI)body_fat_percentage
: Estimated body fat percentagefat_free_weight
: Weight of non-fat body mass in kgsubcutaneous_fat_percentage
: Estimated subcutaneous fat percentagevisceral_fat_value
: Estimated visceral fat level (unitless)body_water_percentage
: Estimated body water percentagebasal_metabolic_rate
: Estimated basal metabolic rate in caloriesskeletal_muscle_percentage
: Estimated skeletal muscle percentagemuscle_mass
: Estimated muscle mass in kgbone_mass
: Estimated bone mass in kgprotein_percentage
: Estimated protein percentageweight_score
: Calculated weight score (0-100)fat_score
: Calculated fat score (0-100)bmi_score
: Calculated BMI score (0-100)health_score
: Overall health score based on other metrics (0-100)metabolic_age
: Estimated metabolic age in years
An enum representing biological sex for body composition calculations:
Sex.Male
Sex.Female
- Tested on Mac (Apple Silicon) and Raspberry Pi 4
- Compatibility with Windows is unknown
On Raspberry Pi 4 (and possibly other Linux machines using BlueZ), if you encounter a org.bluez.Error.InProgress
error, try the following in bluetoothctl
:
power off
power on
scan on
(See home-assistant/core#76186 (comment))
If you find this unofficial project helpful, consider buying me a coffee! Your support helps maintain and improve this library.
This project is licensed under the MIT License - see the LICENSE file for details.
This is an independent project developed by the community. It is not endorsed by, directly affiliated with, maintained, authorized, or sponsored by Vitafit, or any of their affiliates or subsidiaries. All product and company names are the registered trademarks of their original owners. The use of any trade name or trademark is for identification and reference purposes only and does not imply any association with the trademark holder of their product brand.