Refactor battery sensor configuration to use MAX17048 with updated parameters
This commit is contained in:
@@ -133,41 +133,41 @@ font:
|
||||
|
||||
# --- Battery fuel gauge (Adafruit MAX17048 via compatible driver) ---
|
||||
sensor:
|
||||
# - 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: '%'
|
||||
- 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: '%'
|
||||
|
||||
Reference in New Issue
Block a user