10static constexpr uint16_t TYPE_REPORT_LOW_POWER = 0x0A12;
11static constexpr uint16_t TYPE_REPORT_WORK_MODE = 0x0A14;
13static constexpr uint32_t CMD_LOW_POWER_ON = 0x16;
14static constexpr uint32_t CMD_LOW_POWER_OFF = 0x17;
15static constexpr uint32_t CMD_GET_LOW_POWER = 0x18;
18 this->LD600XComponent::setup();
26 bool want_low_power = this->low_power_switch_ !=
nullptr;
30 this->low_power_switch_->restore(
false);
33 bool want_low_power =
false;
36 want_low_power = want_low_power || this->work_mode_text_sensor_ !=
nullptr;
44 ESP_LOGCONFIG(TAG,
" Auto wake: %s", this->
auto_wake_ ? LOG_STR_LITERAL(
"true") : LOG_STR_LITERAL(
"false"));
50 LOG_SWITCH(
" ",
"Low Power", this->low_power_switch_);
58 return this->work_mode_text_sensor_ !=
nullptr;
66 case TYPE_REPORT_LOW_POWER:
69 case TYPE_REPORT_WORK_MODE:
80 bool enabled = data[0] != 0;
84 PUBLISH_STATE(this->low_power_switch_, enabled);
94 const bool low_power = (data[0] == 0);
96 if (this->work_mode_text_sensor_ !=
nullptr) {
113#ifdef USE_TEXT_SENSOR
126#ifdef USE_TEXT_SENSOR
127 if (this->work_mode_text_sensor_ ==
nullptr) {
131 this->work_mode_text_sensor_->publish_state(low_power ?
"low_power" :
"normal");
141 if (len > 0 && data !=
nullptr) {
178 if (entity != this->low_power_switch_)
179 return this->LD600XComponent::set_switch_state(entity,
state);
194 this->LD600XComponent::press_button(kind);
bool cancel_timeout(const char *name)
Cancel a timeout function.
void set_timeout(const char *name, uint32_t timeout, SchedulerCallback &&f)
Set a timeout function with a const char* name.
bool next(T value)
Feeds the next item in the series to the deduplicator and returns false if this is a duplicate.
virtual void digital_write(bool value)=0
bool defer_frame_write(uint16_t type, const uint8_t *data, uint8_t len, bool track) override
uint32_t wakeup_pulse_ms_
void setup_model() override
std::array< uint8_t, ld600x::CMD_MAX_DATA_LEN > wake_scratch_
void dump_model_config() override
static constexpr uint32_t WAKE_BUTTON_TIMEOUT_ID
bool handle_model_report(uint16_t type, const uint8_t *data, uint16_t len) override
void handle_low_power_report_(const uint8_t *data, uint16_t len)
void publish_work_mode_(bool low_power)
Deduplicator< bool > work_mode_low_power_
void handle_work_mode_report_(const uint8_t *data, uint16_t len)
SUB_SWITCH(low_power) bool set_switch_state(switch_ void press_button(uint8_t kind) override
bool model_wants_target_stream() const override
void update_work_mode_fallback_()
virtual bool set_switch_state(switch_::Switch *entity, bool state)
void write_frame_(uint16_t type, const uint8_t *data, uint8_t len, bool track)
bool target_display_enabled_
void clear_area_presence_()
bool target_presence_any_
bool send_control_command_(uint32_t command)
Base class for all switches.
ESPHOME_LOG_TAG(TAG, "ld6002b")
void setup_output_pin(GPIOPin *pin, bool level)
Set up pin and drive it to level. Does nothing when pin is null, so an optional pin needs no check.