Skip to content

Commit 93544e9

Browse files
Merge pull request #16 from ronnnnnnnnnnnnn/multi-user
Multi user support
2 parents 1466c64 + 17bddc0 commit 93544e9

File tree

16 files changed

+5400
-325
lines changed

16 files changed

+5400
-325
lines changed

.github/workflows/hassfest.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Validate with Hassfest
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: ["*"]
76

87
pull_request:
98
branches: ["*"]

.github/workflows/lint.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ name: "Lint"
22

33
on:
44
push:
5-
branches:
6-
- "main"
5+
branches: ["*"]
76
pull_request:
8-
branches:
9-
- "main"
7+
branches: ["*"]
108

119
jobs:
1210
ruff:

.github/workflows/validate.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Validate with Hacs
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: ["*"]
76

87
pull_request:
98
branches: ["*"]

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ This custom integration allows you to connect your Etekcity Bluetooth Low Energy
77
## Features
88

99
- Automatic discovery of Etekcity BLE fitness scales
10+
- Intelligent multi-user support:
11+
- Automatically detects which person is using the scale based on their weight history.
12+
- Uses an adaptive tolerance system that adjusts to each user's weight fluctuations over time.
13+
- Supports linking users to Home Assistant Person entities to exclude users who are `not_home`.
1014
- Real-time weight and impedance measurements
1115
- Optional body composition metrics calculation including:
1216
- Body Mass Index (BMI)
@@ -47,6 +51,8 @@ This custom integration allows you to connect your Etekcity Bluetooth Low Energy
4751

4852
## Configuration
4953

54+
### Initial Setup
55+
5056
1. In Home Assistant, go to "Configuration" > "Integrations".
5157
2. Click the "+" button to add a new integration.
5258
3. Search for "Etekcity Fitness Scale BLE" and select it.
@@ -58,6 +64,102 @@ This custom integration allows you to connect your Etekcity Bluetooth Low Energy
5864
- Enter your date of birth
5965
- Enter your height
6066

67+
### User Profile Configuration Options
68+
69+
When adding or editing user profiles (**Settings > Devices & Services > Etekcity Fitness Scale BLE > Configure**), you can configure the following options:
70+
71+
- **User Name:** Display name for the user profile.
72+
73+
- **Person Entity (optional):** Link this user profile to a Home Assistant person entity. When linked, the integration uses the person's location state to improve automatic assignment:
74+
- If the person is marked as `not_home`, they are excluded from automatic assignment for new measurements
75+
- This helps avoid incorrectly assigning measurements when household members are away
76+
77+
- **Mobile Devices (optional):** Select one or more mobile devices (via Home Assistant companion app) to receive actionable notifications for ambiguous measurements:
78+
- When enabled, you'll receive a mobile notification with tap-to-assign buttons directly on your phone
79+
- Each candidate user gets a personalized notification with "This is me" and "Not me" buttons
80+
81+
- **Enable body composition metrics:** Calculate additional health metrics (BMI, body fat %, etc.) based on impedance measurements. Requires sex, date of birth, and height.
82+
83+
## Multi-User Support
84+
85+
This integration is designed for households with multiple users. You can create a unique profile for each person using the scale.
86+
87+
### Person Detection
88+
89+
When a new measurement is received, the integration attempts to automatically assign it to the correct person based on two factors:
90+
91+
1. **Weight History:** The measurement is compared against each user's weight history.
92+
2. **Location:** If a user profile is linked to a Home Assistant `person` entity, the integration checks if that person is `home`. Users who are `not_home` are excluded from automatic assignment.
93+
94+
If a single user is a clear match, the measurement is assigned automatically.
95+
96+
### Ambiguous Measurements
97+
98+
If the measurement is ambiguous (e.g., two users have similar weights, or a new user has no history), the integration will notify you:
99+
100+
- **Mobile Notifications (if configured):** Each candidate user receives a personalized notification on their mobile device with actionable buttons:
101+
- "This is me" - Assigns the measurement to you
102+
- "Not me" - Dismisses your notification (measurement remains available for others)
103+
104+
- **Persistent Notifications:** A notification appears in the Home Assistant notifications panel with instructions to manually assign the measurement using the `assign_measurement` service.
105+
106+
### Managing Users
107+
108+
You can manage user profiles by navigating to your device in **Settings > Devices & Services > Etekcity Fitness Scale BLE**. Click **CONFIGURE** to:
109+
- **Add a new user:** Create a new profile with optional person entity link and mobile notification settings.
110+
- **Edit a user:** Update a user's name, linked person entity, mobile devices, or body metric settings.
111+
- **Remove a user:** Delete a user's profile and all associated sensor entities.
112+
113+
## Legacy Default User (Old Version Migration)
114+
115+
If you used the original single-user version of the integration, migrating to this version keeps your existing sensors by creating a "Default User" whose `user_id` is an empty string (`""`):
116+
- Sensors for the legacy user keep their original entity IDs (no name prefix) so dashboards and automations continue working.
117+
- When calling services, set `user_id: ""` anytime you want to target the legacy profile.
118+
119+
## Services
120+
121+
The integration provides services to manage measurements, especially for handling ambiguous weigh-ins. You can use these in scripts or automations, or call them directly from **Developer Tools > Actions**.
122+
123+
### `etekcity_fitness_scale_ble.assign_measurement`
124+
Assign a pending (ambiguous) measurement to a specific user. The `timestamp` and candidate `user_id`s are provided in the persistent notification.
125+
126+
**Example:**
127+
```yaml
128+
service: etekcity_fitness_scale_ble.assign_measurement
129+
data:
130+
device_id: <your_scale_device_id>
131+
timestamp: "2025-11-06T15:30:00.123456"
132+
user_id: "jane" # or "" for legacy user
133+
```
134+
135+
### `etekcity_fitness_scale_ble.reassign_measurement`
136+
Reassign the most recent measurement from one user to another. This is useful if a measurement was automatically but incorrectly assigned.
137+
138+
**Example:**
139+
```yaml
140+
service: etekcity_fitness_scale_ble.reassign_measurement
141+
data:
142+
device_id: <your_scale_device_id>
143+
from_user_id: "john2"
144+
to_user_id: "jane" # or "" for legacy user
145+
```
146+
147+
### `etekcity_fitness_scale_ble.remove_measurement`
148+
Remove the last measurement for a specific user. This will revert the user's sensors to their previous values.
149+
150+
**Example:**
151+
```yaml
152+
service: etekcity_fitness_scale_ble.remove_measurement
153+
data:
154+
device_id: <your_scale_device_id>
155+
user_id: "john2" # or "" for legacy user
156+
```
157+
158+
## Diagnostic Sensors
159+
160+
The integration creates two diagnostic sensors to provide visibility into its state:
161+
- **User Directory:** Shows the number of configured user profiles and lists their details (including `user_id`) in the attributes.
162+
- **Pending Measurements:** Shows the number of ambiguous measurements awaiting manual assignment and lists their timestamps in the attributes.
61163

62164
## Supported Devices
63165

0 commit comments

Comments
 (0)