Remove MAX17043 component and update to MAX17048 in configuration
This commit is contained in:
@@ -50,14 +50,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
|
||||
@@ -139,9 +131,9 @@ font:
|
||||
# Note: On ESP32-S3-Touch-LCD-7, GPIO14 is used by the RGB display bus,
|
||||
# so it cannot be reused as ADC for battery telemetry in this display mode.
|
||||
|
||||
# --- Battery fuel gauge (Adafruit MAX17048 via MAX17043-compatible driver) ---
|
||||
# --- Battery fuel gauge (Adafruit MAX17048) ---
|
||||
sensor:
|
||||
- platform: max17043
|
||||
- platform: max17048
|
||||
id: max17048_battery
|
||||
i2c_id: i2c_main
|
||||
update_interval: 120s
|
||||
@@ -168,49 +160,3 @@ sensor:
|
||||
- lambda: |-
|
||||
const float pct = x;
|
||||
ESP_LOGI("battery", "Level: %.0f%%", pct);
|
||||
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