ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
cw2017.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::cw2017 {
8
9static constexpr uint8_t PROFILE_SIZE = 80;
10
11class CW2017 : public PollingComponent, public i2c::I2CDevice {
12 public:
13 explicit CW2017(const uint8_t *profile) : profile_(profile) {}
14
15 SUB_SENSOR(battery_level)
16 SUB_SENSOR(battery_voltage)
17
18 void setup() override;
19 void update() override;
20 void dump_config() override;
21
22 protected:
23 void init_();
24 void init_failed_(const LogString *reason);
25 bool read_profile_matches_(bool &matches);
26 bool upload_profile_();
27 void restart_();
28 void restart_step_(uint8_t step);
29 void wait_ready_(uint8_t attempt);
30
31 const uint8_t *profile_;
32 bool ready_{false};
33 bool restart_pending_{false};
34 uint8_t init_attempts_{0};
35};
36
37} // namespace esphome::cw2017
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:532
void init_failed_(const LogString *reason)
Definition cw2017.cpp:69
void restart_step_(uint8_t step)
Definition cw2017.cpp:132
SUB_SENSOR(battery_level) SUB_SENSOR(battery_voltage) void setup() override
const uint8_t * profile_
Definition cw2017.h:31
void wait_ready_(uint8_t attempt)
Definition cw2017.cpp:145
void update() override
Definition cw2017.cpp:162
CW2017(const uint8_t *profile)
Definition cw2017.h:13
void dump_config() override
Definition cw2017.cpp:183
bool read_profile_matches_(bool &matches)
Definition cw2017.cpp:49
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144