updates
This commit is contained in:
@@ -49,14 +49,6 @@ globals:
|
||||
type: uint32_t
|
||||
restore_value: no
|
||||
initial_value: '0'
|
||||
- id: last_battery_level_pct
|
||||
type: float
|
||||
restore_value: no
|
||||
initial_value: '-1.0'
|
||||
- id: battery_charging_inferred
|
||||
type: bool
|
||||
restore_value: no
|
||||
initial_value: 'false'
|
||||
|
||||
interval:
|
||||
- interval: 1s
|
||||
@@ -158,53 +150,3 @@ sensor:
|
||||
device_class: battery
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
const float pct = x;
|
||||
const bool valid = pct >= 0.0f && pct <= 100.0f;
|
||||
|
||||
// Infer charging from SOC trend when no dedicated charge-detect pin exists.
|
||||
if (valid) {
|
||||
if (id(last_battery_level_pct) >= 0.0f) {
|
||||
if (pct > id(last_battery_level_pct) + 0.2f) {
|
||||
id(battery_charging_inferred) = true;
|
||||
} else if (pct < id(last_battery_level_pct) - 0.2f) {
|
||||
id(battery_charging_inferred) = false;
|
||||
}
|
||||
}
|
||||
id(last_battery_level_pct) = pct;
|
||||
}
|
||||
|
||||
const char *icon = "\U000F0091"; // mdi:battery-unknown
|
||||
if (!valid) {
|
||||
icon = "\U000F0091"; // mdi:battery-unknown
|
||||
} else if (pct >= 99.0f) {
|
||||
icon = "\U000F0079"; // mdi:battery (full)
|
||||
} else if (id(battery_charging_inferred)) {
|
||||
if (pct < 40.0f) {
|
||||
icon = "\U000F12A4"; // mdi:battery-charging-low
|
||||
} else if (pct < 80.0f) {
|
||||
icon = "\U000F12A5"; // mdi:battery-charging-medium
|
||||
} else {
|
||||
icon = "\U000F12A6"; // mdi:battery-charging-high
|
||||
}
|
||||
} else {
|
||||
if (pct < 15.0f) {
|
||||
icon = "\U000F10CD"; // mdi:battery-alert-variant-outline
|
||||
} else if (pct < 40.0f) {
|
||||
icon = "\U000F12A1"; // mdi:battery-low
|
||||
} else if (pct < 80.0f) {
|
||||
icon = "\U000F12A2"; // mdi:battery-medium
|
||||
} else {
|
||||
icon = "\U000F12A3"; // mdi:battery-high
|
||||
}
|
||||
}
|
||||
|
||||
lv_label_set_text(id(nav_battery_icon_home), icon);
|
||||
lv_label_set_text(id(nav_battery_icon_living_room), icon);
|
||||
lv_label_set_text(id(nav_battery_icon_kitchen), icon);
|
||||
lv_label_set_text(id(nav_battery_icon_upstairs), icon);
|
||||
lv_label_set_text(id(nav_battery_icon_office), icon);
|
||||
lv_label_set_text(id(nav_battery_icon_garage), icon);
|
||||
lv_label_set_text(id(nav_battery_icon_outside), icon);
|
||||
|
||||
Reference in New Issue
Block a user