ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
bq25186_text_sensor.cpp
Go to the documentation of this file.
2#ifdef USE_TEXT_SENSOR
3
5
6namespace esphome::bq25186 {
7
8// STAT0[6:5] charge status, then STAT1[4:3] TS status
9PROGMEM_STRING_TABLE(StatusStrings, "Not Charging", "Constant Current", "Constant Voltage", "Charge Done/Disabled",
10 "Normal", "Hot/Cold (Charging Suspended)", "Cool (Current Reduced)", "Warm (Voltage Reduced)");
11
13 const uint8_t value = (status[this->reg_] >> this->shift_) & 0x03;
14 if (value == this->last_)
15 return;
16 this->last_ = value;
17 this->publish_state(StatusStrings::get_progmem_str(this->first_ + value, StatusStrings::LAST_INDEX));
18}
19
20} // namespace esphome::bq25186
21
22#endif // USE_TEXT_SENSOR
uint8_t status
Definition bl0942.h:8
void on_status(const BQ25186StatusRegisters &status)
void publish_state(const std::string &state)
Definition text_sensor.h:42
PROGMEM_STRING_TABLE(StatusStrings, "Not Charging", "Constant Current", "Constant Voltage", "Charge Done/Disabled", "Normal", "Hot/Cold (Charging Suspended)", "Cool (Current Reduced)", "Warm (Voltage Reduced)")
std::array< uint8_t, BQ25186_STATUS_REGISTER_COUNT > BQ25186StatusRegisters
Definition bq25186.h:39
uint32_t value
Definition hal.cpp:41