1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-07 11:20:28 +01:00

[ld2450] Fix bluetooth state not reported correctly (#8458)

This commit is contained in:
Keith Burzinski 2025-03-25 15:21:10 -05:00
parent ea4b573f9a
commit f95b2ba898
No known key found for this signature in database
GPG Key ID: 802564C5F0EEFFBE

View File

@ -15,6 +15,7 @@ namespace esphome {
namespace ld2450 {
static const char *const TAG = "ld2450";
static const char *const NO_MAC("08:05:04:03:02:01");
static const char *const UNKNOWN_MAC("unknown");
// LD2450 UART Serial Commands
@ -614,12 +615,12 @@ bool LD2450Component::handle_ack_data_(uint8_t *buffer, uint8_t len) {
ESP_LOGV(TAG, "MAC address: %s", this->mac_.c_str());
#ifdef USE_TEXT_SENSOR
if (this->mac_text_sensor_ != nullptr) {
this->mac_text_sensor_->publish_state(this->mac_);
this->mac_text_sensor_->publish_state(this->mac_ == NO_MAC ? UNKNOWN_MAC : this->mac_);
}
#endif
#ifdef USE_SWITCH
if (this->bluetooth_switch_ != nullptr) {
this->bluetooth_switch_->publish_state(this->mac_ != UNKNOWN_MAC);
this->bluetooth_switch_->publish_state(this->mac_ != NO_MAC);
}
#endif
break;