ESPHome 2025.5.0
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 {
14namespace am43 {
15
17
19 public:
20 void setup() override;
21 void update() override;
22 void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
23 esp_ble_gattc_cb_param_t *param) override;
24 void dump_config() override;
25 float get_setup_priority() const override { return setup_priority::DATA; }
26 void set_battery(sensor::Sensor *battery) { battery_ = battery; }
27 void set_illuminance(sensor::Sensor *illuminance) { illuminance_ = illuminance; }
28
29 protected:
30 uint16_t char_handle_;
31 std::unique_ptr<Am43Encoder> encoder_;
32 std::unique_ptr<Am43Decoder> decoder_;
37 // The AM43 often gets into a state where it spams loads of battery update
38 // notifications. Here we will limit to no more than every 10s.
40};
41
42} // namespace am43
43} // namespace esphome
44
45#endif
This class simplifies creating components that periodically check a state.
Definition component.h:301
void update() override
std::unique_ptr< Am43Decoder > decoder_
Definition am43_sensor.h:32
void set_battery(sensor::Sensor *battery)
Definition am43_sensor.h:26
void set_illuminance(sensor::Sensor *illuminance)
Definition am43_sensor.h:27
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:35
void setup() override
sensor::Sensor * battery_
Definition am43_sensor.h:34
void dump_config() override
std::unique_ptr< Am43Encoder > encoder_
Definition am43_sensor.h:31
float get_setup_priority() const override
Definition am43_sensor.h:25
uint8_t last_battery_update_
Definition am43_sensor.h:39
Base-class for all sensors.
Definition sensor.h:57
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7