ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
am43_sensor.h
Go to the documentation of this file.
1#pragma once
2
8
9#ifdef USE_ESP32
10
11#include <esp_gattc_api.h>
12
13namespace esphome::am43 {
14
16
18 public:
19 void setup() override;
20 void update() override;
21 void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
22 esp_ble_gattc_cb_param_t *param) override;
23 void dump_config() override;
24 void set_battery(sensor::Sensor *battery) { battery_ = battery; }
25 void set_illuminance(sensor::Sensor *illuminance) { illuminance_ = illuminance; }
26
27 protected:
28 uint16_t char_handle_;
29 std::unique_ptr<Am43Encoder> encoder_;
30 std::unique_ptr<Am43Decoder> decoder_;
35 // The AM43 often gets into a state where it spams loads of battery update
36 // notifications. Here we will limit to no more than every 10s.
38};
39
40} // namespace esphome::am43
41
42#endif
This class simplifies creating components that periodically check a state.
Definition component.h:585
void update() override
uint32_t last_battery_update_
Definition am43_sensor.h:37
std::unique_ptr< Am43Decoder > decoder_
Definition am43_sensor.h:30
void set_battery(sensor::Sensor *battery)
Definition am43_sensor.h:24
void set_illuminance(sensor::Sensor *illuminance)
Definition am43_sensor.h:25
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
sensor::Sensor * illuminance_
Definition am43_sensor.h:33
void setup() override
sensor::Sensor * battery_
Definition am43_sensor.h:32
void dump_config() override
std::unique_ptr< Am43Encoder > encoder_
Definition am43_sensor.h:29
Base-class for all sensors.
Definition sensor.h:47
static void uint32_t