ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
am43
sensor
am43_sensor.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/components/ble_client/ble_client.h
"
5
#include "
esphome/components/esp32_ble_tracker/esp32_ble_tracker.h
"
6
#include "
esphome/components/sensor/sensor.h
"
7
#include "
esphome/components/am43/am43_base.h
"
8
9
#ifdef USE_ESP32
10
11
#include <esp_gattc_api.h>
12
13
namespace
esphome::am43
{
14
15
namespace
espbt
=
esphome::esp32_ble_tracker
;
16
17
class
Am43
final :
public
esphome::ble_client::BLEClientNode
,
public
PollingComponent
{
18
SUB_SENSOR(battery)
19
SUB_SENSOR(illuminance)
20
21
public
:
22
void
update
()
override
;
23
void
gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
24
esp_ble_gattc_cb_param_t *param)
override
;
25
void
dump_config()
override
;
26
27
protected
:
29
void
write_packet_
(
const
Am43Packet
&packet);
30
// The AM43 often gets into a state where it spams loads of battery update
31
// notifications. Here we will limit to no more than every 10s.
32
uint32_t
last_battery_update_
{0};
33
uint16_t
char_handle_
{0};
34
uint8_t
current_sensor_
{0};
35
};
36
37
}
// namespace esphome::am43
38
39
#endif
am43_base.h
ble_client.h
esphome::PollingComponent
This class simplifies creating components that periodically check a state.
Definition
component.h:532
esphome::PollingComponent::update
virtual void update()=0
esphome::am43::Am43
Definition
am43_sensor.h:17
esphome::am43::Am43::current_sensor_
uint8_t current_sensor_
Definition
am43_sensor.h:34
esphome::am43::Am43::last_battery_update_
uint32_t last_battery_update_
Definition
am43_sensor.h:32
esphome::am43::Am43::char_handle_
uint16_t char_handle_
Definition
am43_sensor.h:33
esphome::am43::Am43::write_packet_
void write_packet_(const Am43Packet &packet)
Writes a request to the control characteristic; logs on failure.
Definition
am43_sensor.cpp:83
esphome::ble_client::BLEClientNode
Definition
ble_client.h:26
component.h
esp32_ble_tracker.h
esphome::am43
Definition
am43_base.cpp:6
esphome::esp32_ble_tracker
Definition
automation.h:9
uint32_t
static void uint32_t
Definition
crash_handler.cpp:153
sensor.h
esphome::am43::Am43Packet
Definition
am43_base.h:13
Generated by
1.12.0