Add MAX17043 battery sensor support and related components

This commit is contained in:
Joshua King
2026-02-19 19:59:24 -05:00
parent 7316d9c38b
commit 0ae5f13859
8 changed files with 248 additions and 28 deletions

View File

@@ -131,32 +131,43 @@ 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) ---
# --- Battery fuel gauge (Adafruit MAX17048 via compatible driver) ---
sensor:
- platform: max17048
id: max17048_battery
i2c_id: i2c_main
update_interval: 120s
battery_voltage:
name: "Remote Battery Voltage"
id: remote_battery_voltage
entity_category: diagnostic
device_class: voltage
state_class: measurement
accuracy_decimals: 3
on_value:
then:
- lambda: |-
ESP_LOGI("battery", "Voltage: %.3f V", x);
battery_level:
name: "Remote Battery Level"
id: remote_battery_level
entity_category: diagnostic
device_class: battery
state_class: measurement
accuracy_decimals: 0
on_value:
then:
- lambda: |-
const float pct = x;
ESP_LOGI("battery", "Level: %.0f%%", pct);
# - platform: max17043
# id: max17048_battery
# i2c_id: i2c_main
# update_interval: 120s
# battery_voltage:
# name: "Remote Battery Voltage"
# id: remote_battery_voltage
# entity_category: diagnostic
# device_class: voltage
# state_class: measurement
# accuracy_decimals: 3
# on_value:
# then:
# - lambda: |-
# ESP_LOGI("battery", "Voltage: %.3f V", x);
# battery_level:
# name: "Remote Battery Level"
# id: remote_battery_level
# entity_category: diagnostic
# device_class: battery
# state_class: measurement
# accuracy_decimals: 0
# on_value:
# then:
# - lambda: |-
# const float pct = x;
# ESP_LOGI("battery", "Level: %.0f%%", pct);
- platform: custom
lambda: |-
auto max17048_sensor = new MAX17048Sensor();
App.register_component(max17048_sensor);
return {max17048_sensor->voltage_sensor, max17048_sensor->percentage_sensor};
sensors:
- name: "Voltage"
unit_of_measurement: V
accuracy_decimals: 2
- name: "Percentage"
unit_of_measurement: '%'