Hi everyone!
For people looking for an affordable wearable device that can control your Home Assistant and update Health / Fitness data to Home Assistant, this might be interesting for you.
ZeppOS Wearable App
Home Assistant Cards
yaml configuration
type: custom:config-template-card
entities:
- sensor.amazfit_band_7_bram_sleep_minutes
variables:
sleep_duration: states['sensor.amazfit_band_7_bram_sleep_minutes'].state+'min'
sleep_start: >-
states['sensor.amazfit_band_7_bram_sleep_minutes'].attributes.sleep_stage_data[0].start
+'min'
card:
type: custom:apexcharts-card
apex_config:
grid:
show: true
legend:
formatter: |
EVAL:function(seriesName, opts) {
return seriesName
}
tooltip:
x:
format: hh:mm
stroke:
show: true
curve: straight
graph_span: ${sleep_duration}
span:
start: day
offset: ${'+' + sleep_start}
yaxis:
- min: 0
max: 4
apex_config:
tickAmount: 4
labels:
formatter: |
EVAL:function(value) {
if (value == 4) {
return "Awake";
}
else if (value == 3) {
return "REM";
}
else if (value == 2) {
return "Light";
}
else if (value == 1) {
return "Deep";
}
}
series:
- entity: sensor.amazfit_band_7_bram_sleep_minutes
name: Awake
color: red
stroke_width: 40
data_generator: |
let data = []
entity.attributes.sleep_stage_data.map((val) => {
if (val.model == 7) {
let start = moment().startOf('day').minutes(val.start).valueOf();
let stop = moment().startOf('day').minutes(val.stop).valueOf();
data.push([start, 4]);
data.push([stop, 4]);
data.push([stop, null]);
}
});
return data;
- entity: sensor.amazfit_band_7_bram_sleep_minutes
name: REM Sleep
color: '#2a7fbd'
stroke_width: 40
data_generator: |
let data = []
entity.attributes.sleep_stage_data.map((val) => {
if (val.model == 8) {
let start = moment().startOf('day').minutes(val.start).valueOf();
let stop = moment().startOf('day').minutes(val.stop).valueOf();
data.push([start, 3]);
data.push([stop, 3]);
data.push([stop, null]);
}
});
return data;
- entity: sensor.amazfit_band_7_bram_sleep_minutes
name: Light Sleep
color: '#2a3dbd'
stroke_width: 40
data_generator: |
let data = []
entity.attributes.sleep_stage_data.map((val) => {
if (val.model == 4) {
let start = moment().startOf('day').minutes(val.start).valueOf();
let stop = moment().startOf('day').minutes(val.stop).valueOf();
data.push([start, 2]);
data.push([stop, 2]);
data.push([stop, null]);
}
});
return data;
- entity: sensor.amazfit_band_7_bram_sleep_minutes
name: Deep Sleep
color: '#7a489c'
stroke_width: 40
data_generator: |
let data = []
entity.attributes.sleep_stage_data.map((val) => {
if (val.model == 5) {
let start = moment().startOf('day').minutes(val.start).valueOf();
let stop = moment().startOf('day').minutes(val.stop).valueOf();
data.push([start, 1]);
data.push([stop, 1]);
data.push([stop, null]);
}
});
return data;
- entity: sensor.amazfit_band_7_bram_sleep_minutes
name: Heart Rate
color: rgb(245, 39, 39)
opacity: 0.7
stroke_width: 1
data_generator: |
let min_in = entity.attributes.sleep_hr_data[0];
let max_in = entity.attributes.sleep_hr_data[0];
const min_out = 0.65
const max_out = 4
entity.attributes.sleep_hr_data.forEach((val) => {
if (val < min_in) {
min_in = val;
}
if (val > max_in) {
max_in = val;
}
});
let data = []
let t_start = entity.attributes.sleep_stage_data[0].start-1
entity.attributes.sleep_hr_data.map((val) => {
t_start += 1
let t = moment().startOf('day').minutes(t_start).valueOf();
let newVal = (val - min_in) * (max_out - min_out) / (max_in - min_in) + min_out;
data.push([t, newVal]);
});
return data;
card_mod:
style: |
ha-card {
overflow: unset !important;
}
.apexcharts-tooltip.apexcharts-active {
display: none;
}
yaml configuration
type: custom:config-template-card
entities:
- sensor.amazfit_band_7_bram_heart_rate
variables:
span: >-
states['sensor.amazfit_band_7_bram_heart_rate'].attributes.today_values.length+'min'
card:
type: custom:apexcharts-card
graph_span: ${span}
span:
start: day
series:
- entity: sensor.amazfit_band_7_bram_heart_rate
stroke_width: 1.5
color: '#e35d54'
data_generator: |
var start = new Date();
start.setHours(0,-1,0,0);
const min = 60000;
let t0 = start.getTime()
return entity.attributes.today_values.map((val) => {
t0 += min
return [t0, val];
});
ZeppOS app that uses the Home Assistant REST API to control entities and updates the wearable sensors to Home Assistant including:
- Daily Heart Rate values
- Recent Sleep data
- Battery %
- PAI values
- Daily Steps
- Daily Calories burnt
- Daily Standing hours
- Wear status
A few months ago, I “upgraded” my wearable device from an old, slow and expensive Fossil smart watch to a €35,- smart band (Xiaomi Mi Band 7). The main features that I require from my wearable is that it can control my Home Assistant entities, and keep track of my health / fitness (and of course display the time).
I became aware of the Smart Band concept, but most of them do not support the Home Assistant Companion App (which is on WearOS watches only), or app development at all. The brand that I found that allows app development on their smart bands/watches is Zepp Health through their wearable operating system called ZeppOS. The company owns the Amazfit brand which has a line of wearable products that use ZeppOS, but also some other wearables have ZeppOS, such as the Xiaomi Mi Band 7.
I found the ha-zepp repository which already has (limited) Home Assistant entity control using the REST API. I added some extra entity types that I required myself, and asked the owner of the repository if I could post about it here, which was fine. I am currently working on the feature that updates the wearable sensors to Home Assistant and trying to make this a stable background updater. The picture on the top of the HA lovelace is an example UI for the wearable sensors. I might follow up on this post if there is any interest.
NOTES:
-
The Mi Band 7 is not officially supported for ZeppOS app development, but its possible to pair it as the Amazfit Band 7 device using this modified Android APK of the Zepp App.
-
The ha-zepp app is created specifically for the Mi Band 7, but could also be built for any other Zepp OS 1.0 device.