ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
esphome::ld6002b::LD6002BComponent Class Referencefinal

#include <ld6002b.h>

Inheritance diagram for esphome::ld6002b::LD6002BComponent:
esphome::ld600x::LD600XComponent esphome::Component esphome::uart::UARTDevice

Public Member Functions

 LD6002BComponent ()
 
void setup () override
 
void set_wakeup_pin (GPIOPin *pin)
 
void set_wakeup_pulse_ms (uint32_t ms)
 
void set_auto_wake (bool enable)
 
SUB_SWITCH(low_power) bool set_switch_state(switch_ void press_button (uint8_t kind) override
 
- Public Member Functions inherited from esphome::ld600x::LD600XComponent
 LD600XComponent (const LogString *log_tag)
 
void setup () override
 
void loop () override
 
void dump_config () override
 
 SUB_SENSOR_WITH_DEDUP (target_count, uint32_t) SUB_SENSOR_WITH_DEDUP(point_count
 
uint32_t void set_target_x_sensor (uint8_t target, sensor::Sensor *sensor)
 
void set_target_y_sensor (uint8_t target, sensor::Sensor *sensor)
 
void set_target_z_sensor (uint8_t target, sensor::Sensor *sensor)
 
void set_target_dop_idx_sensor (uint8_t target, sensor::Sensor *sensor)
 
void set_target_cluster_id_sensor (uint8_t target, sensor::Sensor *sensor)
 
void set_area_sensor (uint8_t kind, uint8_t area, uint8_t axis, sensor::Sensor *sensor)
 
 SUB_BINARY_SENSOR (presence) void set_target_presence_binary_sensor(uint8_t target
 
void set_area_presence_binary_sensor (uint8_t area, binary_sensor::BinarySensor *sensor)
 
virtual SUB_TEXT_SENSOR(work_mode) SUB_TEXT_SENSOR(ota_version) SUB_NUMBER(hold_delay) SUB_NUMBER(z_min) SUB_NUMBER(z_max) SUB_NUMBER(low_power_sleep) SUB_NUMBER(area_x_min) SUB_NUMBER(area_x_max) SUB_NUMBER(area_y_min) SUB_NUMBER(area_y_max) SUB_NUMBER(area_z_min) SUB_NUMBER(area_z_max) SUB_SELECT(sensitivity) SUB_SELECT(trigger_speed) SUB_SELECT(installation) SUB_SELECT(area_id) SUB_SWITCH(point_cloud) SUB_SWITCH(target_display) virtual bool set_number_value(number bool set_select_value (select::Select *entity, size_t index)
 
virtual bool set_switch_state (switch_::Switch *entity, bool state)
 
- Public Member Functions inherited from esphome::Component
virtual float get_setup_priority () const
 priority of setup().
 
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
virtual bool teardown ()
 Called during teardown to allow component to gracefully finish operations.
 
virtual void on_powerdown ()
 Called last before a reboot or deep sleep to power down hardware.
 
uint8_t get_component_state () const
 
void reset_to_construction_state ()
 Reset this component back to the construction state to allow setup to run again.
 
bool is_in_loop_state () const
 Check if this component has completed setup and is in the loop state.
 
bool is_idle () const
 Check if this component is idle.
 
void mark_failed ()
 Mark this component as failed.
 
void mark_failed (const LogString *message)
 
bool ESPHOME_ALWAYS_INLINE setup_check (bool ok)
 Marks the component failed with message (default "Communication failed") unless ok; returns ok.
 
bool ESPHOME_ALWAYS_INLINE setup_check (bool ok, const LogString *message)
 
void disable_loop ()
 Disable this component's loop.
 
void enable_loop ()
 Enable this component's loop.
 
void enable_loop_soon_any_context ()
 Thread and ISR-safe version of enable_loop() that can be called from any context.
 
bool is_failed () const
 
bool is_ready () const
 
virtual bool can_proceed ()
 
bool status_has_warning () const
 
bool status_has_error () const
 
void status_set_warning ()
 
void status_set_warning (const char *message)
 
void status_set_warning (const LogString *message)
 
bool status_comm_result (bool ok)
 Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
 
bool status_comm_result (bool ok, const LogString *message)
 
void status_set_error ()
 
void status_set_error (const LogString *message)
 
void status_clear_warning ()
 
void status_clear_error ()
 
 ESPDEPRECATED ("Use status_momentary_warning() without a name. Removed in 2027.5.0", "2026.11.0") void status_momentary_warning(const char *name
 
void status_momentary_warning (uint32_t length=5000)
 Set warning status flag and clear it after length ms.
 
void status_momentary_warning (const LogString *message, uint32_t length=5000)
 
 ESPDEPRECATED ("Use status_momentary_error() without a name. Removed in 2027.5.0", "2026.11.0") void status_momentary_error(const char *name
 
void status_momentary_error (uint32_t length=5000)
 Set error status flag and clear it after length ms.
 
void status_momentary_error (const LogString *message, uint32_t length=5000)
 
bool has_overridden_loop () const
 
const LogString * get_component_log_str () const ESPHOME_ALWAYS_INLINE
 Get the integration where this component was declared as a LogString for logging.
 
bool should_warn_of_blocking (uint32_t blocking_time, uint32_t &threshold_ms_out)
 
- Public Member Functions inherited from esphome::uart::UARTDevice
 UARTDevice ()=default
 
 UARTDevice (UARTComponent *parent)
 
void set_uart_parent (UARTComponent *parent)
 
void write_byte (uint8_t data)
 
void set_rx_full_threshold (size_t rx_full_threshold)
 
void set_rx_full_threshold_ms (size_t time)
 
size_t get_rx_full_threshold ()
 
void set_rx_timeout (size_t rx_timeout)
 
size_t get_rx_timeout ()
 
void write_array (const uint8_t *data, size_t len)
 
void write_array_progmem (const uint8_t *data, size_t len)
 
void write_array (const std::vector< uint8_t > &data)
 
template<size_t N>
void write_array (const std::array< uint8_t, N > &data)
 
void write_str (const char *str)
 
bool read_byte (uint8_t *data)
 
bool peek_byte (uint8_t *data)
 
bool read_array (uint8_t *data, size_t len)
 
template<size_t N>
optional< std::array< uint8_t, N > > read_array ()
 
size_t available ()
 
template<size_t N = 64, typename F >
bool read_available_chunks (F &&on_chunk)
 Pass the bytes available now to on_chunk(data, len) in N byte chunks; returning false stops.
 
template<size_t N = 64, typename F >
bool read_available_chunks (F &&on_chunk, size_t count)
 Same, reading exactly count bytes; count must not exceed available().
 
template<size_t N = 64, typename F >
bool read_available (F &&on_byte)
 Same as read_available_chunks(), calling on_byte(uint8_t) once per byte.
 
template<size_t N = 64, typename F >
bool read_available (F &&on_byte, size_t count)
 
void discard_available ()
 Read and drop every byte waiting in the receive buffer.
 
UARTFlushResult flush ()
 
int read ()
 
size_t write (uint8_t data)
 
int peek ()
 
 ESPDEPRECATED ("Use uart.final_validate_device_schema() in Python instead. Removed in 2027.3.0", "2026.9.0") void check_uart_settings(uint32_t baud_rate
 Check that the configuration of the UART bus matches the provided values and otherwise print a warning.
 

Protected Member Functions

bool handle_model_report (uint16_t type, const uint8_t *data, uint16_t len) override
 
bool model_wants_target_stream () const override
 
void on_presence_update () override
 
bool defer_frame_write (uint16_t type, const uint8_t *data, uint8_t len, bool track) override
 
void setup_model () override
 
void dump_model_config () override
 
void handle_low_power_report_ (const uint8_t *data, uint16_t len)
 
void handle_work_mode_report_ (const uint8_t *data, uint16_t len)
 
void update_work_mode_fallback_ ()
 
void publish_work_mode_ (bool low_power)
 
void wake_ ()
 
- Protected Member Functions inherited from esphome::ld600x::LD600XComponent
void handle_frame_ (uint16_t type, const uint8_t *data, uint16_t len)
 
void handle_target_report_ (const uint8_t *data, uint16_t len)
 
void handle_point_cloud_ (const uint8_t *data, uint16_t len)
 
void handle_area_presence_ (const uint8_t *data, uint16_t len)
 
void handle_area_report_ (uint8_t kind, const uint8_t *data, uint16_t len)
 
void handle_delay_report_ (const uint8_t *data, uint16_t len)
 
void handle_sensitivity_report_ (const uint8_t *data, uint16_t len)
 
void handle_trigger_speed_report_ (const uint8_t *data, uint16_t len)
 
void handle_z_range_report_ (const uint8_t *data, uint16_t len)
 
void handle_installation_report_ (const uint8_t *data, uint16_t len)
 
void handle_low_power_sleep_report_ (const uint8_t *data, uint16_t len)
 
void handle_version_report_ (const uint8_t *data, uint16_t len)
 
void clear_target_state_ ()
 
void clear_area_presence_ ()
 
void restore_deferred_edits_ ()
 
void publish_area_numbers_ ()
 
void clear_target_slot_ (uint8_t index)
 
void publish_number_clamped_ (number::Number *number, float value)
 
void update_area_numbers_ (const AreaConfig &area)
 
void update_area_numbers_for_id_ (uint8_t area_id)
 
bool queue_area_config_ (uint8_t area_id, const AreaConfig &desired)
 
void try_apply_pending_area_ (uint8_t reported_kind)
 
void init_area_id_pref_ ()
 
void save_area_id_pref_ (uint8_t value)
 
void init_version_pref_ ()
 
void save_version_pref_ (const char *value)
 
bool queue_command_ (uint16_t type, const uint8_t *data, uint8_t len)
 
void process_command_queue_ ()
 
void send_command_ (uint16_t type, const uint8_t *data, uint8_t len)
 
void send_command_internal_ (uint16_t type, const uint8_t *data, uint8_t len, bool track)
 
void write_frame_ (uint16_t type, const uint8_t *data, uint8_t len, bool track)
 
bool send_control_command_ (uint32_t command)
 
bool send_z_range_ (float z_min, float z_max)
 
bool queue_u32_setting_ (uint16_t type, float value)
 
void apply_area_config_ ()
 
- Protected Member Functions inherited from esphome::Component
friend void::setup ()
 
friend void::original_setup ()
 
void set_component_source_ (uint8_t index)
 Set where this component was loaded from for some debug messages.
 
virtual void call_setup ()
 
void call_dump_config_ ()
 
void enable_loop_slow_path_ ()
 
void set_component_state_ (uint8_t state)
 Helper to set component state (clears state bits and sets new state)
 
bool set_status_flag_ (uint8_t flag)
 Helper to set a status LED flag on both this component and the app.
 
bool set_error_flag_ (const LogString *message)
 Set the error flag and log it; true when it was not set before.
 
void set_interval (const char *name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a const char* name.
 
void set_interval (uint32_t id, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a numeric ID (zero heap allocation).
 
void set_interval (InternalSchedulerID id, uint32_t interval, std::function< void()> &&f)
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const char *name)
 Cancel an interval function.
 
bool cancel_interval (uint32_t id)
 
bool cancel_interval (InternalSchedulerID id)
 
void set_timeout (const char *name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a const char* name.
 
void set_timeout (uint32_t id, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a numeric ID (zero heap allocation).
 
void set_timeout (InternalSchedulerID id, uint32_t timeout, std::function< void()> &&f)
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const char *name)
 Cancel a timeout function.
 
bool cancel_timeout (uint32_t id)
 
bool cancel_timeout (InternalSchedulerID id)
 
void defer (const char *name, std::function< void()> &&f)
 Defer a callback to the next loop() call with a const char* name.
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call.
 
void defer (uint32_t id, std::function< void()> &&f)
 Defer a callback with a numeric ID (zero heap allocation)
 
bool cancel_defer (const char *name)
 Cancel a defer callback using the specified name, name must not be empty.
 
bool cancel_defer (uint32_t id)
 
void status_clear_warning_slow_path_ ()
 
void status_clear_error_slow_path_ ()
 

Protected Attributes

GPIOPin * wakeup_pin_ {nullptr}
 
uint32_t wakeup_pulse_ms_ {50}
 
std::array< uint8_t, ld600x::CMD_MAX_DATA_LEN > wake_scratch_ {}
 
bool auto_wake_ {true}
 
bool wake_pulse_pending_ {false}
 
bool work_mode_reported_ {false}
 
bool low_power_enabled_ {false}
 
bool low_power_reported_ {false}
 
Deduplicator< bool > work_mode_low_power_
 
- Protected Attributes inherited from esphome::ld600x::LD600XComponent
const char * log_tag_
 
std::array< TargetSensors, LD600X_MAX_TARGETS > targets_ {}
 
std::array< AreaSensors, AREA_COUNT *LD600X_AREA_KINDS > areas_ {}
 
std::array< binary_sensor::BinarySensor *, LD600X_MAX_TARGETS > target_presence_ {}
 
std::array< binary_sensor::BinarySensor *, AREA_COUNT > area_presence_ {}
 
ESPPreferenceObject version_pref_ {}
 
bool version_pref_initialized_ {false}
 
ESPPreferenceObject area_id_pref_ {}
 
bool area_id_pref_initialized_ {false}
 
FrameParser parser_
 
uint16_t next_frame_id_ {0}
 
StaticRingBuffer< PendingCommand, CMD_QUEUE_SIZE > cmd_queue_
 
bool command_active_ {false}
 
bool command_sent_ {false}
 
PendingCommand active_command_ {}
 
uint8_t retries_left_ {0}
 
uint32_t last_send_ms_ {0}
 
uint32_t last_traffic_ms_ {0}
 
uint8_t attempts_sent_ {0}
 
uint8_t acks_expected_ {0}
 
uint16_t stale_ack_type_ {0}
 
uint8_t stale_ack_count_ {0}
 
uint32_t stale_ack_ms_ {0}
 
uint8_t send_generation_ {0}
 
float z_min_ {NAN}
 
float z_max_ {NAN}
 
float area_x_min_ {NAN}
 
float area_x_max_ {NAN}
 
float area_y_min_ {NAN}
 
float area_y_max_ {NAN}
 
float area_z_min_ {NAN}
 
float area_z_max_ {NAN}
 
AreaConfig area_edits_ {}
 
std::array< AreaConfig, AREA_COUNT *LD600X_AREA_KINDS > area_values_ {}
 
uint8_t area_id_ {0xFF}
 
bool area_id_set_ {false}
 
std::array< int32_t, LD600X_MAX_TARGETS > slot_cluster_ {}
 
std::array< bool, LD600X_MAX_TARGETS > slot_occupied_ {}
 
bool target_presence_any_ {false}
 
bool target_display_enabled_ {false}
 
bool point_cloud_enabled_ {false}
 
bool area_presence_any_ {false}
 
bool area_write_in_flight_ {false}
 
bool deferred_apply_pending_ {false}
 
uint8_t pending_area_id_ {0xFF}
 
AreaConfig pending_area_updates_ {}
 
std::array< bool, LD600X_MAX_TARGETS > last_target_presence_ {}
 
- Protected Attributes inherited from esphome::Component
uint8_t component_source_index_ {0}
 Index into component source PROGMEM lookup table (0 = not set)
 
uint8_t warn_if_blocking_over_ {WARN_IF_BLOCKING_OVER_CS}
 Warn threshold in centiseconds (max 2550ms)
 
uint8_t component_state_ {0x00}
 State of this component - each bit has a purpose: Bits 0-2: Component state (0x00=CONSTRUCTION, 0x01=SETUP, 0x02=LOOP, 0x03=FAILED, 0x04=LOOP_DONE) Bit 3: STATUS_LED_WARNING Bit 4: STATUS_LED_ERROR Bit 5: Has overridden loop() (set at registration time) Bits 6-7: Unused - reserved for future expansion.
 
volatile bool pending_enable_loop_ {false}
 ISR-safe flag for enable_loop_soon_any_context.
 
ComponentRuntimeStats runtime_stats_
 
- Protected Attributes inherited from esphome::uart::UARTDevice
UARTComponent * parent_ {nullptr}
 

Static Protected Attributes

static constexpr uint32_t WAKE_BUTTON_TIMEOUT_ID = MODEL_TIMEOUT_ID
 
- Static Protected Attributes inherited from esphome::ld600x::LD600XComponent
static constexpr uint8_t CMD_QUEUE_SIZE = 24
 
static constexpr uint32_t CMD_ACK_TIMEOUT_MS = 300
 
static constexpr uint32_t CMD_FIRST_ACK_TIMEOUT_MS = 600
 
static constexpr uint32_t MODULE_AWAKE_MS = 10000
 
static constexpr uint8_t CMD_MAX_RETRIES = 3
 
static constexpr uint32_t MODEL_TIMEOUT_ID = 0
 
static constexpr uint32_t AREA_REFRESH_TIMEOUT_ID = 1
 
static constexpr uint32_t STALE_ACK_MAX_AGE_MS = 1000
 

Additional Inherited Members

- Data Fields inherited from esphome::ld600x::LD600XComponent
binary_sensor::BinarySensor * sensor
 
this target_presence_ [target] = sensor
 
- Data Fields inherited from esphome::Component
uint32_t length = 5000)
 
- Data Fields inherited from esphome::uart::UARTDevice
uint8_t stop_bits = 1
 
uint8_t UARTParityOptions parity = UART_CONFIG_PARITY_NONE
 
uint8_t UARTParityOptions uint8_t data_bits = 8)
 
- Static Protected Member Functions inherited from esphome::uart::UARTDevice
template<typename F , typename... A>
static bool continue_after (F &f, A... args)
 Call f(args...) and return its result; a void callback always continues.
 

Detailed Description

Definition at line 12 of file ld6002b.h.

Constructor & Destructor Documentation

◆ LD6002BComponent()

esphome::ld6002b::LD6002BComponent::LD6002BComponent ( )
inline

Definition at line 14 of file ld6002b.h.

Member Function Documentation

◆ defer_frame_write()

bool esphome::ld6002b::LD6002BComponent::defer_frame_write ( uint16_t type,
const uint8_t * data,
uint8_t len,
bool track )
overrideprotectedvirtual

Reimplemented from esphome::ld600x::LD600XComponent.

Definition at line 139 of file ld6002b.cpp.

◆ dump_model_config()

void esphome::ld6002b::LD6002BComponent::dump_model_config ( )
overrideprotectedvirtual

Reimplemented from esphome::ld600x::LD600XComponent.

Definition at line 46 of file ld6002b.cpp.

◆ handle_low_power_report_()

void esphome::ld6002b::LD6002BComponent::handle_low_power_report_ ( const uint8_t * data,
uint16_t len )
protected

Definition at line 80 of file ld6002b.cpp.

◆ handle_model_report()

bool esphome::ld6002b::LD6002BComponent::handle_model_report ( uint16_t type,
const uint8_t * data,
uint16_t len )
overrideprotectedvirtual

Reimplemented from esphome::ld600x::LD600XComponent.

Definition at line 67 of file ld6002b.cpp.

◆ handle_work_mode_report_()

void esphome::ld6002b::LD6002BComponent::handle_work_mode_report_ ( const uint8_t * data,
uint16_t len )
protected

Definition at line 92 of file ld6002b.cpp.

◆ model_wants_target_stream()

bool esphome::ld6002b::LD6002BComponent::model_wants_target_stream ( ) const
overrideprotectedvirtual

Reimplemented from esphome::ld600x::LD600XComponent.

Definition at line 57 of file ld6002b.cpp.

◆ on_presence_update()

void esphome::ld6002b::LD6002BComponent::on_presence_update ( )
inlineoverrideprotectedvirtual

Reimplemented from esphome::ld600x::LD600XComponent.

Definition at line 33 of file ld6002b.h.

◆ press_button()

void esphome::ld6002b::LD6002BComponent::press_button ( uint8_t kind)
overridevirtual

Reimplemented from esphome::ld600x::LD600XComponent.

Definition at line 190 of file ld6002b.cpp.

◆ publish_work_mode_()

void esphome::ld6002b::LD6002BComponent::publish_work_mode_ ( bool low_power)
protected

Definition at line 128 of file ld6002b.cpp.

◆ set_auto_wake()

void esphome::ld6002b::LD6002BComponent::set_auto_wake ( bool enable)
inline

Definition at line 20 of file ld6002b.h.

◆ set_wakeup_pin()

void esphome::ld6002b::LD6002BComponent::set_wakeup_pin ( GPIOPin * pin)
inline

Definition at line 18 of file ld6002b.h.

◆ set_wakeup_pulse_ms()

void esphome::ld6002b::LD6002BComponent::set_wakeup_pulse_ms ( uint32_t ms)
inline

Definition at line 19 of file ld6002b.h.

◆ setup()

void esphome::ld6002b::LD6002BComponent::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 17 of file ld6002b.cpp.

◆ setup_model()

void esphome::ld6002b::LD6002BComponent::setup_model ( )
overrideprotectedvirtual

Reimplemented from esphome::ld600x::LD600XComponent.

Definition at line 27 of file ld6002b.cpp.

◆ update_work_mode_fallback_()

void esphome::ld6002b::LD6002BComponent::update_work_mode_fallback_ ( )
protected

Definition at line 115 of file ld6002b.cpp.

◆ wake_()

void esphome::ld6002b::LD6002BComponent::wake_ ( )
protected

Definition at line 165 of file ld6002b.cpp.

Field Documentation

◆ auto_wake_

bool esphome::ld6002b::LD6002BComponent::auto_wake_ {true}
protected

Definition at line 52 of file ld6002b.h.

◆ low_power_enabled_

bool esphome::ld6002b::LD6002BComponent::low_power_enabled_ {false}
protected

Definition at line 55 of file ld6002b.h.

◆ low_power_reported_

bool esphome::ld6002b::LD6002BComponent::low_power_reported_ {false}
protected

Definition at line 56 of file ld6002b.h.

◆ WAKE_BUTTON_TIMEOUT_ID

uint32_t esphome::ld6002b::LD6002BComponent::WAKE_BUTTON_TIMEOUT_ID = MODEL_TIMEOUT_ID
staticconstexprprotected

Definition at line 46 of file ld6002b.h.

◆ wake_pulse_pending_

bool esphome::ld6002b::LD6002BComponent::wake_pulse_pending_ {false}
protected

Definition at line 53 of file ld6002b.h.

◆ wake_scratch_

std::array<uint8_t, ld600x::CMD_MAX_DATA_LEN> esphome::ld6002b::LD6002BComponent::wake_scratch_ {}
protected

Definition at line 51 of file ld6002b.h.

◆ wakeup_pin_

GPIOPin* esphome::ld6002b::LD6002BComponent::wakeup_pin_ {nullptr}
protected

Definition at line 48 of file ld6002b.h.

◆ wakeup_pulse_ms_

uint32_t esphome::ld6002b::LD6002BComponent::wakeup_pulse_ms_ {50}
protected

Definition at line 49 of file ld6002b.h.

◆ work_mode_low_power_

Deduplicator<bool> esphome::ld6002b::LD6002BComponent::work_mode_low_power_
protected

Definition at line 57 of file ld6002b.h.

◆ work_mode_reported_

bool esphome::ld6002b::LD6002BComponent::work_mode_reported_ {false}
protected

Definition at line 54 of file ld6002b.h.


The documentation for this class was generated from the following files: