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

Compare commits

...

42 Commits

Author SHA1 Message Date
J. Nick Koston
177026d8c4 simplify 2025-11-19 23:25:45 -06:00
J. Nick Koston
4533b8f92c tweaks 2025-11-19 23:20:24 -06:00
J. Nick Koston
b9595c0795 cover 2025-11-19 22:49:52 -06:00
J. Nick Koston
efe2a1a506 cleanup 2025-11-19 22:32:41 -06:00
J. Nick Koston
185c1dec43 cleanup 2025-11-19 22:24:00 -06:00
J. Nick Koston
c39d17f864 cleanup 2025-11-19 22:20:12 -06:00
J. Nick Koston
b400a98fb3 [api] Store Home Assistant state subscriptions in flash instead of heap 2025-11-19 22:17:16 -06:00
B48D81EFCC
83307684a3 [stts22h] Add support for STTS22H temperature sensor (#11778)
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2025-11-20 03:58:39 +00:00
David Woodhouse
da25951f6e [socket] Fix IPv6 address parsing for BSD sockets (#11996) 2025-11-19 21:01:32 -06:00
Jonathan Swoboda
4398fd84d2 [graph] Fix legend border (#12000) 2025-11-20 13:09:22 +13:00
Jonathan Swoboda
bbd6d019e5 Merge branch 'release' into dev 2025-11-19 17:37:58 -05:00
Jonathan Swoboda
625172e07d Merge pull request #12004 from esphome/bump-2025.11.0
2025.11.0
2025-11-19 17:37:42 -05:00
Jonathan Swoboda
1e9c7d3c6d Bump version to 2025.11.0 2025-11-19 16:02:52 -05:00
Jonathan Swoboda
4cdab4e2d8 Merge branch 'beta' into dev 2025-11-19 15:06:55 -05:00
Jonathan Swoboda
c2bc7b3cdc Merge pull request #12003 from esphome/bump-2025.11.0b5
2025.11.0b5
2025-11-19 15:06:44 -05:00
dependabot[bot]
2c3417062a Bump pyupgrade from 3.21.1 to 3.21.2 (#12002)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-19 13:47:40 -06:00
Jonathan Swoboda
c75abfb894 Bump version to 2025.11.0b5 2025-11-19 14:17:03 -05:00
Jesse Hills
1157b4aee8 [epaper_spi] Add basic 7.3in-Spectra-E6 model (#12001) 2025-11-19 14:17:03 -05:00
J. Nick Koston
71dc2d374d [web_server_idf] Fix pbuf_free crash by moving shutdown before close (#11995) 2025-11-19 14:17:03 -05:00
Jonathan Swoboda
0a224f919b [wifi] Fix positive RSSI values on 8266 (#11994) 2025-11-19 14:17:03 -05:00
Jonathan Swoboda
7ef4b4f3d9 [text_sensor] Fix infinite loop in substitute filter (#11989)
Co-authored-by: J. Nick Koston <nick@koston.org>
2025-11-19 14:17:03 -05:00
J. Nick Koston
13b875c763 [tests] Fix SNTP time ID conflicts in component tests for grouped testing (#11990) 2025-11-19 14:17:03 -05:00
Jesse Hills
b02b07ffaf [epaper_spi] Add basic 7.3in-Spectra-E6 model (#12001) 2025-11-19 14:11:45 -05:00
J. Nick Koston
8804bc2815 [web_server_idf] Fix pbuf_free crash by moving shutdown before close (#11995) 2025-11-20 07:58:33 +13:00
Jonathan Swoboda
61cef0a75c [api] Fix format warnings in dump (#11999) 2025-11-19 12:58:47 -05:00
Jonathan Swoboda
73bc5252a1 [wifi] Fix positive RSSI values on 8266 (#11994) 2025-11-19 10:12:57 -05:00
Jonathan Swoboda
f2b10ad132 [text_sensor] Fix infinite loop in substitute filter (#11989)
Co-authored-by: J. Nick Koston <nick@koston.org>
2025-11-19 10:12:34 -05:00
J. Nick Koston
100ea46f03 [tests] Fix SNTP time ID conflicts in component tests for grouped testing (#11990) 2025-11-18 23:19:54 -06:00
J. Nick Koston
b3ef05e5e1 [ld24xx] Modernize namespace declarations to C++17 syntax (#11988) 2025-11-19 04:00:39 +00:00
J. Nick Koston
45c994e4de [light] Modernize namespace declarations to C++17 syntax (#11986) 2025-11-18 21:56:23 -06:00
Jesse Hills
a72545639d Merge branch 'beta' into dev 2025-11-19 13:43:25 +13:00
Jesse Hills
dfd614c00c Merge pull request #11980 from esphome/bump-2025.11.0b4
2025.11.0b4
2025-11-19 13:22:09 +13:00
J. Nick Koston
29374837c6 [wifi, captive_portal, web_server, wifi_info] Use stack allocation for MAC address formatting (#11963) 2025-11-18 17:06:34 -06:00
Jesse Hills
2681a14d05 Bump version to 2025.11.0b4 2025-11-19 09:17:33 +13:00
J. Nick Koston
f436f6ee2e [wifi] Fix captive portal unusable when WiFi credentials are wrong (#11965) 2025-11-19 09:17:33 +13:00
Jonathan Swoboda
f18bc62690 [sfa30] Fix negative temperature values (#11973) 2025-11-19 09:17:33 +13:00
J. Nick Koston
6db73df649 [scheduler] Add defensive nullptr checks and explicit locking requirements (#11974) 2025-11-19 09:17:33 +13:00
Jonathan Swoboda
93215f1737 [esp32] Fix Arduino build on some ESP32 S2 boards (#11972) 2025-11-19 09:17:33 +13:00
Clyde Stubbs
70aa94b8a4 [lvgl] Apply scale to spinbox value (#11946) 2025-11-19 09:17:33 +13:00
strange_v
e8998a79c7 [mipi_rgb] Fix GUITION-4848S040 colors (#11709) 2025-11-19 09:17:33 +13:00
Jonathan Swoboda
3b25fdbc5f [core] Add support for setting environment variables (#11953) 2025-11-19 09:17:33 +13:00
J. Nick Koston
6c8577678c [captive_portal] Warn when enabled without WiFi AP configured (#11856) 2025-11-19 09:17:33 +13:00
160 changed files with 654 additions and 562 deletions

View File

@@ -460,6 +460,7 @@ esphome/components/st7735/* @SenexCrenshaw
esphome/components/st7789v/* @kbx81
esphome/components/st7920/* @marsjan155
esphome/components/statsd/* @Links2004
esphome/components/stts22h/* @B48D81EFCC
esphome/components/substitutions/* @esphome/core
esphome/components/sun/* @OttoWinter
esphome/components/sun_gtil2/* @Mat931

View File

@@ -1535,8 +1535,13 @@ bool APIConnection::send_device_info_response(const DeviceInfoRequest &msg) {
#ifdef USE_API_HOMEASSISTANT_STATES
void APIConnection::on_home_assistant_state_response(const HomeAssistantStateResponse &msg) {
for (auto &it : this->parent_->get_state_subs()) {
if (it.entity_id == msg.entity_id && it.attribute.value() == msg.attribute) {
it.callback(msg.state);
// Compare entity_id and attribute with message fields
bool entity_match = (strcmp(it.entity_id_, msg.entity_id.c_str()) == 0);
bool attribute_match = (it.attribute_ != nullptr && strcmp(it.attribute_, msg.attribute.c_str()) == 0) ||
(it.attribute_ == nullptr && msg.attribute.empty());
if (entity_match && attribute_match) {
it.callback_(msg.state);
}
}
}
@@ -1873,12 +1878,12 @@ void APIConnection::process_state_subscriptions_() {
const auto &it = subs[this->state_subs_at_];
SubscribeHomeAssistantStateResponse resp;
resp.set_entity_id(StringRef(it.entity_id));
resp.set_entity_id(StringRef(it.entity_id_));
// Avoid string copy by directly using the optional's value if it exists
resp.set_attribute(it.attribute.has_value() ? StringRef(it.attribute.value()) : StringRef(""));
// Avoid string copy by using the const char* pointer if it exists
resp.set_attribute(it.attribute_ != nullptr ? StringRef(it.attribute_) : StringRef(""));
resp.once = it.once;
resp.once = it.once_;
if (this->send_message(resp, SubscribeHomeAssistantStateResponse::MESSAGE_TYPE)) {
this->state_subs_at_++;
}

View File

@@ -66,7 +66,7 @@ static void dump_field(std::string &out, const char *field_name, float value, in
static void dump_field(std::string &out, const char *field_name, uint64_t value, int indent = 2) {
char buffer[64];
append_field_prefix(out, field_name, indent);
snprintf(buffer, 64, "%llu", value);
snprintf(buffer, 64, "%" PRIu64, value);
append_with_newline(out, buffer);
}

View File

@@ -431,25 +431,56 @@ void APIServer::handle_action_response(uint32_t call_id, bool success, const std
#endif // USE_API_HOMEASSISTANT_SERVICES
#ifdef USE_API_HOMEASSISTANT_STATES
// Helper to add subscription (reduces duplication)
void APIServer::add_state_subscription_(const char *entity_id, const char *attribute,
std::function<void(std::string)> f, bool once) {
this->state_subs_.push_back(HomeAssistantStateSubscription{
.entity_id_ = entity_id, .attribute_ = attribute, .callback_ = std::move(f), .once_ = once,
// entity_id_copy_ and attribute_copy_ remain nullptr (no heap allocation)
});
}
// Helper to add subscription with heap-allocated strings (reduces duplication)
void APIServer::add_state_subscription_(std::string entity_id, optional<std::string> attribute,
std::function<void(std::string)> f, bool once) {
HomeAssistantStateSubscription sub;
// Allocate heap storage for the strings
sub.entity_id_copy_ = std::make_unique<std::string>(std::move(entity_id));
sub.entity_id_ = sub.entity_id_copy_->c_str();
if (attribute.has_value()) {
sub.attribute_copy_ = std::make_unique<std::string>(std::move(attribute.value()));
sub.attribute_ = sub.attribute_copy_->c_str();
} else {
sub.attribute_ = nullptr;
}
sub.callback_ = std::move(f);
sub.once_ = once;
this->state_subs_.push_back(std::move(sub));
}
// New const char* overload (for internal components - zero allocation)
void APIServer::subscribe_home_assistant_state(const char *entity_id, const char *attribute,
std::function<void(std::string)> f) {
this->add_state_subscription_(entity_id, attribute, std::move(f), false);
}
void APIServer::get_home_assistant_state(const char *entity_id, const char *attribute,
std::function<void(std::string)> f) {
this->add_state_subscription_(entity_id, attribute, std::move(f), true);
}
// Existing std::string overload (for custom_api_device.h - heap allocation)
void APIServer::subscribe_home_assistant_state(std::string entity_id, optional<std::string> attribute,
std::function<void(std::string)> f) {
this->state_subs_.push_back(HomeAssistantStateSubscription{
.entity_id = std::move(entity_id),
.attribute = std::move(attribute),
.callback = std::move(f),
.once = false,
});
this->add_state_subscription_(std::move(entity_id), std::move(attribute), std::move(f), false);
}
void APIServer::get_home_assistant_state(std::string entity_id, optional<std::string> attribute,
std::function<void(std::string)> f) {
this->state_subs_.push_back(HomeAssistantStateSubscription{
.entity_id = std::move(entity_id),
.attribute = std::move(attribute),
.callback = std::move(f),
.once = true,
});
};
this->add_state_subscription_(std::move(entity_id), std::move(attribute), std::move(f), true);
}
const std::vector<APIServer::HomeAssistantStateSubscription> &APIServer::get_state_subs() const {
return this->state_subs_;

View File

@@ -154,16 +154,27 @@ class APIServer : public Component, public Controller {
#ifdef USE_API_HOMEASSISTANT_STATES
struct HomeAssistantStateSubscription {
std::string entity_id;
optional<std::string> attribute;
std::function<void(std::string)> callback;
bool once;
const char *entity_id_; // Pointer to flash (internal) or heap (external)
const char *attribute_; // Pointer to flash or nullptr (nullptr means no attribute)
std::function<void(std::string)> callback_;
bool once_;
// Storage for external components using std::string API (custom_api_device.h)
// These are only allocated when using the std::string overload
std::unique_ptr<std::string> entity_id_copy_;
std::unique_ptr<std::string> attribute_copy_;
};
// New const char* overload (for internal components - zero allocation)
void subscribe_home_assistant_state(const char *entity_id, const char *attribute, std::function<void(std::string)> f);
void get_home_assistant_state(const char *entity_id, const char *attribute, std::function<void(std::string)> f);
// Existing std::string overload (for custom_api_device.h - heap allocation)
void subscribe_home_assistant_state(std::string entity_id, optional<std::string> attribute,
std::function<void(std::string)> f);
void get_home_assistant_state(std::string entity_id, optional<std::string> attribute,
std::function<void(std::string)> f);
const std::vector<HomeAssistantStateSubscription> &get_state_subs() const;
#endif
#ifdef USE_API_SERVICES
@@ -185,6 +196,13 @@ class APIServer : public Component, public Controller {
bool update_noise_psk_(const SavedNoisePsk &new_psk, const LogString *save_log_msg, const LogString *fail_log_msg,
const psk_t &active_psk, bool make_active);
#endif // USE_API_NOISE
#ifdef USE_API_HOMEASSISTANT_STATES
// Helper methods to reduce code duplication
void add_state_subscription_(const char *entity_id, const char *attribute, std::function<void(std::string)> f,
bool once);
void add_state_subscription_(std::string entity_id, optional<std::string> attribute,
std::function<void(std::string)> f, bool once);
#endif // USE_API_HOMEASSISTANT_STATES
// Pointers and pointer-like types first (4 bytes each)
std::unique_ptr<socket::Socket> socket_ = nullptr;
#ifdef USE_API_CLIENT_CONNECTED_TRIGGER

View File

@@ -13,14 +13,16 @@ static const char *const TAG = "captive_portal";
void CaptivePortal::handle_config(AsyncWebServerRequest *request) {
AsyncResponseStream *stream = request->beginResponseStream(ESPHOME_F("application/json"));
stream->addHeader(ESPHOME_F("cache-control"), ESPHOME_F("public, max-age=0, must-revalidate"));
char mac_s[18];
const char *mac_str = get_mac_address_pretty_into_buffer(mac_s);
#ifdef USE_ESP8266
stream->print(ESPHOME_F("{\"mac\":\""));
stream->print(get_mac_address_pretty().c_str());
stream->print(mac_str);
stream->print(ESPHOME_F("\",\"name\":\""));
stream->print(App.get_name().c_str());
stream->print(ESPHOME_F("\",\"aps\":[{}"));
#else
stream->printf(R"({"mac":"%s","name":"%s","aps":[{})", get_mac_address_pretty().c_str(), App.get_name().c_str());
stream->printf(R"({"mac":"%s","name":"%s","aps":[{})", mac_str, App.get_name().c_str());
#endif
for (auto &scan : wifi::global_wifi_component->get_scan_result()) {

View File

@@ -102,7 +102,7 @@ def customise_schema(config):
"""
config = cv.Schema(
{
cv.Required(CONF_MODEL): cv.one_of(*MODELS, upper=True),
cv.Required(CONF_MODEL): cv.one_of(*MODELS, upper=True, space="-"),
},
extra=cv.ALLOW_EXTRA,
)(config)

View File

@@ -32,11 +32,15 @@ class SpectraE6(EpaperModel):
spectra_e6 = SpectraE6("spectra-e6")
spectra_e6.extend(
"Seeed-reTerminal-E1002",
spectra_e6_7p3 = spectra_e6.extend(
"7.3in-Spectra-E6",
width=800,
height=480,
data_rate="20MHz",
)
spectra_e6_7p3.extend(
"Seeed-reTerminal-E1002",
cs_pin=10,
dc_pin=11,
reset_pin=12,

View File

@@ -337,7 +337,7 @@ void Graph::draw_legend(display::Display *buff, uint16_t x_offset, uint16_t y_of
return;
/// Plot border
if (this->border_) {
if (legend_->border_) {
int w = legend_->width_;
int h = legend_->height_;
buff->horizontal_line(x_offset, y_offset, w, color);

View File

@@ -19,11 +19,10 @@ void HomeassistantBinarySensor::setup() {
case PARSE_ON:
case PARSE_OFF:
bool new_state = val == PARSE_ON;
if (this->attribute_.has_value()) {
ESP_LOGD(TAG, "'%s::%s': Got attribute state %s", this->entity_id_.c_str(),
this->attribute_.value().c_str(), ONOFF(new_state));
if (this->attribute_ != nullptr) {
ESP_LOGD(TAG, "'%s::%s': Got attribute state %s", this->entity_id_, this->attribute_, ONOFF(new_state));
} else {
ESP_LOGD(TAG, "'%s': Got state %s", this->entity_id_.c_str(), ONOFF(new_state));
ESP_LOGD(TAG, "'%s': Got state %s", this->entity_id_, ONOFF(new_state));
}
if (this->initial_) {
this->publish_initial_state(new_state);
@@ -37,9 +36,9 @@ void HomeassistantBinarySensor::setup() {
}
void HomeassistantBinarySensor::dump_config() {
LOG_BINARY_SENSOR("", "Homeassistant Binary Sensor", this);
ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_.c_str());
if (this->attribute_.has_value()) {
ESP_LOGCONFIG(TAG, " Attribute: '%s'", this->attribute_.value().c_str());
ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_);
if (this->attribute_ != nullptr) {
ESP_LOGCONFIG(TAG, " Attribute: '%s'", this->attribute_);
}
}
float HomeassistantBinarySensor::get_setup_priority() const { return setup_priority::AFTER_WIFI; }

View File

@@ -8,15 +8,15 @@ namespace homeassistant {
class HomeassistantBinarySensor : public binary_sensor::BinarySensor, public Component {
public:
void set_entity_id(const std::string &entity_id) { entity_id_ = entity_id; }
void set_attribute(const std::string &attribute) { attribute_ = attribute; }
void set_entity_id(const char *entity_id) { this->entity_id_ = entity_id; }
void set_attribute(const char *attribute) { this->attribute_ = attribute; }
void setup() override;
void dump_config() override;
float get_setup_priority() const override;
protected:
std::string entity_id_;
optional<std::string> attribute_;
const char *entity_id_{nullptr};
const char *attribute_{nullptr};
bool initial_{true};
};

View File

@@ -12,21 +12,21 @@ static const char *const TAG = "homeassistant.number";
void HomeassistantNumber::state_changed_(const std::string &state) {
auto number_value = parse_number<float>(state);
if (!number_value.has_value()) {
ESP_LOGW(TAG, "'%s': Can't convert '%s' to number!", this->entity_id_.c_str(), state.c_str());
ESP_LOGW(TAG, "'%s': Can't convert '%s' to number!", this->entity_id_, state.c_str());
this->publish_state(NAN);
return;
}
if (this->state == number_value.value()) {
return;
}
ESP_LOGD(TAG, "'%s': Got state %s", this->entity_id_.c_str(), state.c_str());
ESP_LOGD(TAG, "'%s': Got state %s", this->entity_id_, state.c_str());
this->publish_state(number_value.value());
}
void HomeassistantNumber::min_retrieved_(const std::string &min) {
auto min_value = parse_number<float>(min);
if (!min_value.has_value()) {
ESP_LOGE(TAG, "'%s': Can't convert 'min' value '%s' to number!", this->entity_id_.c_str(), min.c_str());
ESP_LOGE(TAG, "'%s': Can't convert 'min' value '%s' to number!", this->entity_id_, min.c_str());
return;
}
ESP_LOGD(TAG, "'%s': Min retrieved: %s", get_name().c_str(), min.c_str());
@@ -36,7 +36,7 @@ void HomeassistantNumber::min_retrieved_(const std::string &min) {
void HomeassistantNumber::max_retrieved_(const std::string &max) {
auto max_value = parse_number<float>(max);
if (!max_value.has_value()) {
ESP_LOGE(TAG, "'%s': Can't convert 'max' value '%s' to number!", this->entity_id_.c_str(), max.c_str());
ESP_LOGE(TAG, "'%s': Can't convert 'max' value '%s' to number!", this->entity_id_, max.c_str());
return;
}
ESP_LOGD(TAG, "'%s': Max retrieved: %s", get_name().c_str(), max.c_str());
@@ -46,7 +46,7 @@ void HomeassistantNumber::max_retrieved_(const std::string &max) {
void HomeassistantNumber::step_retrieved_(const std::string &step) {
auto step_value = parse_number<float>(step);
if (!step_value.has_value()) {
ESP_LOGE(TAG, "'%s': Can't convert 'step' value '%s' to number!", this->entity_id_.c_str(), step.c_str());
ESP_LOGE(TAG, "'%s': Can't convert 'step' value '%s' to number!", this->entity_id_, step.c_str());
return;
}
ESP_LOGD(TAG, "'%s': Step Retrieved %s", get_name().c_str(), step.c_str());
@@ -55,22 +55,19 @@ void HomeassistantNumber::step_retrieved_(const std::string &step) {
void HomeassistantNumber::setup() {
api::global_api_server->subscribe_home_assistant_state(
this->entity_id_, nullopt, std::bind(&HomeassistantNumber::state_changed_, this, std::placeholders::_1));
this->entity_id_, nullptr, std::bind(&HomeassistantNumber::state_changed_, this, std::placeholders::_1));
api::global_api_server->get_home_assistant_state(
this->entity_id_, optional<std::string>("min"),
std::bind(&HomeassistantNumber::min_retrieved_, this, std::placeholders::_1));
this->entity_id_, "min", std::bind(&HomeassistantNumber::min_retrieved_, this, std::placeholders::_1));
api::global_api_server->get_home_assistant_state(
this->entity_id_, optional<std::string>("max"),
std::bind(&HomeassistantNumber::max_retrieved_, this, std::placeholders::_1));
this->entity_id_, "max", std::bind(&HomeassistantNumber::max_retrieved_, this, std::placeholders::_1));
api::global_api_server->get_home_assistant_state(
this->entity_id_, optional<std::string>("step"),
std::bind(&HomeassistantNumber::step_retrieved_, this, std::placeholders::_1));
this->entity_id_, "step", std::bind(&HomeassistantNumber::step_retrieved_, this, std::placeholders::_1));
}
void HomeassistantNumber::dump_config() {
LOG_NUMBER("", "Homeassistant Number", this);
ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_.c_str());
ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_);
}
float HomeassistantNumber::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; }

View File

@@ -11,7 +11,7 @@ namespace homeassistant {
class HomeassistantNumber : public number::Number, public Component {
public:
void set_entity_id(const std::string &entity_id) { this->entity_id_ = entity_id; }
void set_entity_id(const char *entity_id) { this->entity_id_ = entity_id; }
void setup() override;
void dump_config() override;
@@ -25,7 +25,7 @@ class HomeassistantNumber : public number::Number, public Component {
void control(float value) override;
std::string entity_id_;
const char *entity_id_{nullptr};
};
} // namespace homeassistant
} // namespace esphome

View File

@@ -12,25 +12,24 @@ void HomeassistantSensor::setup() {
this->entity_id_, this->attribute_, [this](const std::string &state) {
auto val = parse_number<float>(state);
if (!val.has_value()) {
ESP_LOGW(TAG, "'%s': Can't convert '%s' to number!", this->entity_id_.c_str(), state.c_str());
ESP_LOGW(TAG, "'%s': Can't convert '%s' to number!", this->entity_id_, state.c_str());
this->publish_state(NAN);
return;
}
if (this->attribute_.has_value()) {
ESP_LOGD(TAG, "'%s::%s': Got attribute state %.2f", this->entity_id_.c_str(),
this->attribute_.value().c_str(), *val);
if (this->attribute_ != nullptr) {
ESP_LOGD(TAG, "'%s::%s': Got attribute state %.2f", this->entity_id_, this->attribute_, *val);
} else {
ESP_LOGD(TAG, "'%s': Got state %.2f", this->entity_id_.c_str(), *val);
ESP_LOGD(TAG, "'%s': Got state %.2f", this->entity_id_, *val);
}
this->publish_state(*val);
});
}
void HomeassistantSensor::dump_config() {
LOG_SENSOR("", "Homeassistant Sensor", this);
ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_.c_str());
if (this->attribute_.has_value()) {
ESP_LOGCONFIG(TAG, " Attribute: '%s'", this->attribute_.value().c_str());
ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_);
if (this->attribute_ != nullptr) {
ESP_LOGCONFIG(TAG, " Attribute: '%s'", this->attribute_);
}
}
float HomeassistantSensor::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; }

View File

@@ -8,15 +8,15 @@ namespace homeassistant {
class HomeassistantSensor : public sensor::Sensor, public Component {
public:
void set_entity_id(const std::string &entity_id) { entity_id_ = entity_id; }
void set_attribute(const std::string &attribute) { attribute_ = attribute; }
void set_entity_id(const char *entity_id) { this->entity_id_ = entity_id; }
void set_attribute(const char *attribute) { this->attribute_ = attribute; }
void setup() override;
void dump_config() override;
float get_setup_priority() const override;
protected:
std::string entity_id_;
optional<std::string> attribute_;
const char *entity_id_{nullptr};
const char *attribute_{nullptr};
};
} // namespace homeassistant

View File

@@ -10,7 +10,7 @@ static const char *const TAG = "homeassistant.switch";
using namespace esphome::switch_;
void HomeassistantSwitch::setup() {
api::global_api_server->subscribe_home_assistant_state(this->entity_id_, nullopt, [this](const std::string &state) {
api::global_api_server->subscribe_home_assistant_state(this->entity_id_, nullptr, [this](const std::string &state) {
auto val = parse_on_off(state.c_str());
switch (val) {
case PARSE_NONE:
@@ -20,7 +20,7 @@ void HomeassistantSwitch::setup() {
case PARSE_ON:
case PARSE_OFF:
bool new_state = val == PARSE_ON;
ESP_LOGD(TAG, "'%s': Got state %s", this->entity_id_.c_str(), ONOFF(new_state));
ESP_LOGD(TAG, "'%s': Got state %s", this->entity_id_, ONOFF(new_state));
this->publish_state(new_state);
break;
}
@@ -29,7 +29,7 @@ void HomeassistantSwitch::setup() {
void HomeassistantSwitch::dump_config() {
LOG_SWITCH("", "Homeassistant Switch", this);
ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_.c_str());
ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_);
}
float HomeassistantSwitch::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; }

View File

@@ -8,14 +8,14 @@ namespace homeassistant {
class HomeassistantSwitch : public switch_::Switch, public Component {
public:
void set_entity_id(const std::string &entity_id) { this->entity_id_ = entity_id; }
void set_entity_id(const char *entity_id) { this->entity_id_ = entity_id; }
void setup() override;
void dump_config() override;
float get_setup_priority() const override;
protected:
void write_state(bool state) override;
std::string entity_id_;
const char *entity_id_{nullptr};
};
} // namespace homeassistant

View File

@@ -10,20 +10,19 @@ static const char *const TAG = "homeassistant.text_sensor";
void HomeassistantTextSensor::setup() {
api::global_api_server->subscribe_home_assistant_state(
this->entity_id_, this->attribute_, [this](const std::string &state) {
if (this->attribute_.has_value()) {
ESP_LOGD(TAG, "'%s::%s': Got attribute state '%s'", this->entity_id_.c_str(),
this->attribute_.value().c_str(), state.c_str());
if (this->attribute_ != nullptr) {
ESP_LOGD(TAG, "'%s::%s': Got attribute state '%s'", this->entity_id_, this->attribute_, state.c_str());
} else {
ESP_LOGD(TAG, "'%s': Got state '%s'", this->entity_id_.c_str(), state.c_str());
ESP_LOGD(TAG, "'%s': Got state '%s'", this->entity_id_, state.c_str());
}
this->publish_state(state);
});
}
void HomeassistantTextSensor::dump_config() {
LOG_TEXT_SENSOR("", "Homeassistant Text Sensor", this);
ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_.c_str());
if (this->attribute_.has_value()) {
ESP_LOGCONFIG(TAG, " Attribute: '%s'", this->attribute_.value().c_str());
ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_);
if (this->attribute_ != nullptr) {
ESP_LOGCONFIG(TAG, " Attribute: '%s'", this->attribute_);
}
}
float HomeassistantTextSensor::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; }

View File

@@ -8,15 +8,15 @@ namespace homeassistant {
class HomeassistantTextSensor : public text_sensor::TextSensor, public Component {
public:
void set_entity_id(const std::string &entity_id) { entity_id_ = entity_id; }
void set_attribute(const std::string &attribute) { attribute_ = attribute; }
void set_entity_id(const char *entity_id) { this->entity_id_ = entity_id; }
void set_attribute(const char *attribute) { this->attribute_ = attribute; }
void setup() override;
void dump_config() override;
float get_setup_priority() const override;
protected:
std::string entity_id_;
optional<std::string> attribute_;
const char *entity_id_{nullptr};
const char *attribute_{nullptr};
};
} // namespace homeassistant

View File

@@ -4,8 +4,7 @@
#include "esphome/core/component.h"
#include "ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
template<typename... Ts> class BluetoothPasswordSetAction : public Action<Ts...> {
public:
@@ -18,5 +17,4 @@ template<typename... Ts> class BluetoothPasswordSetAction : public Action<Ts...>
LD2410Component *ld2410_comp_;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,9 +1,7 @@
#include "factory_reset_button.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
void FactoryResetButton::press_action() { this->parent_->factory_reset(); }
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/button/button.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class FactoryResetButton : public button::Button, public Parented<LD2410Component> {
public:
@@ -14,5 +13,4 @@ class FactoryResetButton : public button::Button, public Parented<LD2410Componen
void press_action() override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,9 +1,7 @@
#include "query_button.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
void QueryButton::press_action() { this->parent_->read_all_info(); }
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/button/button.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class QueryButton : public button::Button, public Parented<LD2410Component> {
public:
@@ -14,5 +13,4 @@ class QueryButton : public button::Button, public Parented<LD2410Component> {
void press_action() override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,9 +1,7 @@
#include "restart_button.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
void RestartButton::press_action() { this->parent_->restart_and_read_all_info(); }
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/button/button.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class RestartButton : public button::Button, public Parented<LD2410Component> {
public:
@@ -14,5 +13,4 @@ class RestartButton : public button::Button, public Parented<LD2410Component> {
void press_action() override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -9,8 +9,7 @@
#include "esphome/core/application.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
static const char *const TAG = "ld2410";
@@ -782,5 +781,4 @@ void LD2410Component::set_gate_still_sensor(uint8_t gate, sensor::Sensor *s) {
}
#endif
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -29,8 +29,7 @@
#include <array>
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
using namespace ld24xx;
@@ -133,5 +132,4 @@ class LD2410Component : public Component, public uart::UARTDevice {
#endif
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,7 +1,6 @@
#include "gate_threshold_number.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
GateThresholdNumber::GateThresholdNumber(uint8_t gate) : gate_(gate) {}
@@ -10,5 +9,4 @@ void GateThresholdNumber::control(float value) {
this->parent_->set_gate_threshold(this->gate_);
}
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/number/number.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class GateThresholdNumber : public number::Number, public Parented<LD2410Component> {
public:
@@ -15,5 +14,4 @@ class GateThresholdNumber : public number::Number, public Parented<LD2410Compone
void control(float value) override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,12 +1,10 @@
#include "light_threshold_number.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
void LightThresholdNumber::control(float value) {
this->publish_state(value);
this->parent_->set_light_out_control();
}
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/number/number.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class LightThresholdNumber : public number::Number, public Parented<LD2410Component> {
public:
@@ -14,5 +13,4 @@ class LightThresholdNumber : public number::Number, public Parented<LD2410Compon
void control(float value) override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,12 +1,10 @@
#include "max_distance_timeout_number.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
void MaxDistanceTimeoutNumber::control(float value) {
this->publish_state(value);
this->parent_->set_max_distances_timeout();
}
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/number/number.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class MaxDistanceTimeoutNumber : public number::Number, public Parented<LD2410Component> {
public:
@@ -14,5 +13,4 @@ class MaxDistanceTimeoutNumber : public number::Number, public Parented<LD2410Co
void control(float value) override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,12 +1,10 @@
#include "baud_rate_select.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
void BaudRateSelect::control(size_t index) {
this->publish_state(index);
this->parent_->set_baud_rate(this->option_at(index));
}
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/select/select.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class BaudRateSelect : public select::Select, public Parented<LD2410Component> {
public:
@@ -14,5 +13,4 @@ class BaudRateSelect : public select::Select, public Parented<LD2410Component> {
void control(size_t index) override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,12 +1,10 @@
#include "distance_resolution_select.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
void DistanceResolutionSelect::control(size_t index) {
this->publish_state(index);
this->parent_->set_distance_resolution(this->option_at(index));
}
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/select/select.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class DistanceResolutionSelect : public select::Select, public Parented<LD2410Component> {
public:
@@ -14,5 +13,4 @@ class DistanceResolutionSelect : public select::Select, public Parented<LD2410Co
void control(size_t index) override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,12 +1,10 @@
#include "light_out_control_select.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
void LightOutControlSelect::control(size_t index) {
this->publish_state(index);
this->parent_->set_light_out_control();
}
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/select/select.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class LightOutControlSelect : public select::Select, public Parented<LD2410Component> {
public:
@@ -14,5 +13,4 @@ class LightOutControlSelect : public select::Select, public Parented<LD2410Compo
void control(size_t index) override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,12 +1,10 @@
#include "bluetooth_switch.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
void BluetoothSwitch::write_state(bool state) {
this->publish_state(state);
this->parent_->set_bluetooth(state);
}
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/switch/switch.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class BluetoothSwitch : public switch_::Switch, public Parented<LD2410Component> {
public:
@@ -14,5 +13,4 @@ class BluetoothSwitch : public switch_::Switch, public Parented<LD2410Component>
void write_state(bool state) override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,12 +1,10 @@
#include "engineering_mode_switch.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
void EngineeringModeSwitch::write_state(bool state) {
this->publish_state(state);
this->parent_->set_engineering_mode(state);
}
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -3,8 +3,7 @@
#include "esphome/components/switch/switch.h"
#include "../ld2410.h"
namespace esphome {
namespace ld2410 {
namespace esphome::ld2410 {
class EngineeringModeSwitch : public switch_::Switch, public Parented<LD2410Component> {
public:
@@ -14,5 +13,4 @@ class EngineeringModeSwitch : public switch_::Switch, public Parented<LD2410Comp
void write_state(bool state) override;
};
} // namespace ld2410
} // namespace esphome
} // namespace esphome::ld2410

View File

@@ -1,9 +1,7 @@
#include "factory_reset_button.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void FactoryResetButton::press_action() { this->parent_->factory_reset(); }
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/button/button.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class FactoryResetButton : public button::Button, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class FactoryResetButton : public button::Button, public Parented<LD2412Componen
void press_action() override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -1,9 +1,7 @@
#include "query_button.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void QueryButton::press_action() { this->parent_->read_all_info(); }
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/button/button.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class QueryButton : public button::Button, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class QueryButton : public button::Button, public Parented<LD2412Component> {
void press_action() override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -1,9 +1,7 @@
#include "restart_button.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void RestartButton::press_action() { this->parent_->restart_and_read_all_info(); }
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/button/button.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class RestartButton : public button::Button, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class RestartButton : public button::Button, public Parented<LD2412Component> {
void press_action() override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -2,10 +2,8 @@
#include "restart_button.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void StartDynamicBackgroundCorrectionButton::press_action() { this->parent_->start_dynamic_background_correction(); }
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/button/button.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class StartDynamicBackgroundCorrectionButton : public button::Button, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class StartDynamicBackgroundCorrectionButton : public button::Button, public Par
void press_action() override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -10,8 +10,7 @@
#include "esphome/core/application.h"
#include "esphome/core/helpers.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
static const char *const TAG = "ld2412";
@@ -855,5 +854,4 @@ void LD2412Component::set_gate_still_sensor(uint8_t gate, sensor::Sensor *s) {
}
#endif
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -29,8 +29,7 @@
#include <array>
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
using namespace ld24xx;
@@ -137,5 +136,4 @@ class LD2412Component : public Component, public uart::UARTDevice {
#endif
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -1,7 +1,6 @@
#include "gate_threshold_number.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
GateThresholdNumber::GateThresholdNumber(uint8_t gate) : gate_(gate) {}
@@ -10,5 +9,4 @@ void GateThresholdNumber::control(float value) {
this->parent_->set_gate_threshold();
}
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/number/number.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class GateThresholdNumber : public number::Number, public Parented<LD2412Component> {
public:
@@ -15,5 +14,4 @@ class GateThresholdNumber : public number::Number, public Parented<LD2412Compone
void control(float value) override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -1,12 +1,10 @@
#include "light_threshold_number.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void LightThresholdNumber::control(float value) {
this->publish_state(value);
this->parent_->set_light_out_control();
}
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/number/number.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class LightThresholdNumber : public number::Number, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class LightThresholdNumber : public number::Number, public Parented<LD2412Compon
void control(float value) override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -1,12 +1,10 @@
#include "max_distance_timeout_number.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void MaxDistanceTimeoutNumber::control(float value) {
this->publish_state(value);
this->parent_->set_basic_config();
}
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/number/number.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class MaxDistanceTimeoutNumber : public number::Number, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class MaxDistanceTimeoutNumber : public number::Number, public Parented<LD2412Co
void control(float value) override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -1,12 +1,10 @@
#include "baud_rate_select.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void BaudRateSelect::control(size_t index) {
this->publish_state(index);
this->parent_->set_baud_rate(this->option_at(index));
}
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/select/select.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class BaudRateSelect : public select::Select, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class BaudRateSelect : public select::Select, public Parented<LD2412Component> {
void control(size_t index) override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -1,12 +1,10 @@
#include "distance_resolution_select.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void DistanceResolutionSelect::control(size_t index) {
this->publish_state(index);
this->parent_->set_distance_resolution(this->option_at(index));
}
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/select/select.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class DistanceResolutionSelect : public select::Select, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class DistanceResolutionSelect : public select::Select, public Parented<LD2412Co
void control(size_t index) override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -1,12 +1,10 @@
#include "light_out_control_select.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void LightOutControlSelect::control(size_t index) {
this->publish_state(index);
this->parent_->set_light_out_control();
}
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/select/select.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class LightOutControlSelect : public select::Select, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class LightOutControlSelect : public select::Select, public Parented<LD2412Compo
void control(size_t index) override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -1,12 +1,10 @@
#include "bluetooth_switch.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void BluetoothSwitch::write_state(bool state) {
this->publish_state(state);
this->parent_->set_bluetooth(state);
}
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/switch/switch.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class BluetoothSwitch : public switch_::Switch, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class BluetoothSwitch : public switch_::Switch, public Parented<LD2412Component>
void write_state(bool state) override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -1,12 +1,10 @@
#include "engineering_mode_switch.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
void EngineeringModeSwitch::write_state(bool state) {
this->publish_state(state);
this->parent_->set_engineering_mode(state);
}
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -3,8 +3,7 @@
#include "esphome/components/switch/switch.h"
#include "../ld2412.h"
namespace esphome {
namespace ld2412 {
namespace esphome::ld2412 {
class EngineeringModeSwitch : public switch_::Switch, public Parented<LD2412Component> {
public:
@@ -14,5 +13,4 @@ class EngineeringModeSwitch : public switch_::Switch, public Parented<LD2412Comp
void write_state(bool state) override;
};
} // namespace ld2412
} // namespace esphome
} // namespace esphome::ld2412

View File

@@ -2,8 +2,7 @@
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
static const char *const TAG = "ld2420.binary_sensor";
@@ -12,5 +11,4 @@ void LD2420BinarySensor::dump_config() {
LOG_BINARY_SENSOR(" ", "Presence", this->presence_bsensor_);
}
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -3,8 +3,7 @@
#include "../ld2420.h"
#include "esphome/components/binary_sensor/binary_sensor.h"
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
class LD2420BinarySensor : public LD2420Listener, public Component, binary_sensor::BinarySensor {
public:
@@ -21,5 +20,4 @@ class LD2420BinarySensor : public LD2420Listener, public Component, binary_senso
binary_sensor::BinarySensor *presence_bsensor_{nullptr};
};
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -4,13 +4,11 @@
static const char *const TAG = "ld2420.button";
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
void LD2420ApplyConfigButton::press_action() { this->parent_->apply_config_action(); }
void LD2420RevertConfigButton::press_action() { this->parent_->revert_config_action(); }
void LD2420RestartModuleButton::press_action() { this->parent_->restart_module_action(); }
void LD2420FactoryResetButton::press_action() { this->parent_->factory_reset_action(); }
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -3,8 +3,7 @@
#include "esphome/components/button/button.h"
#include "../ld2420.h"
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
class LD2420ApplyConfigButton : public button::Button, public Parented<LD2420Component> {
public:
@@ -38,5 +37,4 @@ class LD2420FactoryResetButton : public button::Button, public Parented<LD2420Co
void press_action() override;
};
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -58,8 +58,7 @@ Gate 0 high thresh = 10 00 uint16_t 0x0010, Threshold value = 60 EA 00 00 uint32
Gate 0 low thresh = 20 00 uint16_t 0x0020, Threshold value = 60 EA 00 00 uint32_t 0x0000EA60
*/
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
static const char *const TAG = "ld2420";
@@ -880,5 +879,4 @@ void LD2420Component::refresh_gate_config_numbers() {
#endif
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -17,8 +17,7 @@
#include "esphome/components/button/button.h"
#endif
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
static const uint8_t CALIBRATE_SAMPLES = 64;
static const uint8_t MAX_LINE_LENGTH = 46; // Max characters for serial buffer
@@ -193,5 +192,4 @@ class LD2420Component : public Component, public uart::UARTDevice {
std::vector<LD2420Listener *> listeners_{};
};
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -4,8 +4,7 @@
static const char *const TAG = "ld2420.number";
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
void LD2420TimeoutNumber::control(float timeout) {
this->publish_state(timeout);
@@ -69,5 +68,4 @@ void LD2420StillThresholdNumbers::control(float still_threshold) {
}
}
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -3,8 +3,7 @@
#include "esphome/components/number/number.h"
#include "../ld2420.h"
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
class LD2420TimeoutNumber : public number::Number, public Parented<LD2420Component> {
public:
@@ -74,5 +73,4 @@ class LD2420MoveThresholdNumbers : public number::Number, public Parented<LD2420
void control(float move_threshold) override;
};
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -2,8 +2,7 @@
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
static const char *const TAG = "ld2420.select";
@@ -12,5 +11,4 @@ void LD2420Select::control(size_t index) {
this->parent_->set_operating_mode(this->option_at(index));
}
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -3,8 +3,7 @@
#include "../ld2420.h"
#include "esphome/components/select/select.h"
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
class LD2420Select : public Component, public select::Select, public Parented<LD2420Component> {
public:
@@ -14,5 +13,4 @@ class LD2420Select : public Component, public select::Select, public Parented<LD
void control(size_t index) override;
};
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -2,8 +2,7 @@
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
static const char *const TAG = "ld2420.sensor";
@@ -12,5 +11,4 @@ void LD2420Sensor::dump_config() {
LOG_SENSOR(" ", "Distance", this->distance_sensor_);
}
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -3,8 +3,7 @@
#include "../ld2420.h"
#include "esphome/components/sensor/sensor.h"
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
class LD2420Sensor : public LD2420Listener, public Component, sensor::Sensor {
public:
@@ -30,5 +29,4 @@ class LD2420Sensor : public LD2420Listener, public Component, sensor::Sensor {
std::vector<sensor::Sensor *> energy_sensors_ = std::vector<sensor::Sensor *>(TOTAL_GATES);
};
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -2,8 +2,7 @@
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
static const char *const TAG = "ld2420.text_sensor";
@@ -12,5 +11,4 @@ void LD2420TextSensor::dump_config() {
LOG_TEXT_SENSOR(" ", "Firmware", this->fw_version_text_sensor_);
}
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -3,8 +3,7 @@
#include "../ld2420.h"
#include "esphome/components/text_sensor/text_sensor.h"
namespace esphome {
namespace ld2420 {
namespace esphome::ld2420 {
class LD2420TextSensor : public LD2420Listener, public Component, text_sensor::TextSensor {
public:
@@ -20,5 +19,4 @@ class LD2420TextSensor : public LD2420Listener, public Component, text_sensor::T
text_sensor::TextSensor *fw_version_text_sensor_{nullptr};
};
} // namespace ld2420
} // namespace esphome
} // namespace esphome::ld2420

View File

@@ -1,9 +1,7 @@
#include "factory_reset_button.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
void FactoryResetButton::press_action() { this->parent_->factory_reset(); }
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -3,8 +3,7 @@
#include "esphome/components/button/button.h"
#include "../ld2450.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
class FactoryResetButton : public button::Button, public Parented<LD2450Component> {
public:
@@ -14,5 +13,4 @@ class FactoryResetButton : public button::Button, public Parented<LD2450Componen
void press_action() override;
};
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -1,9 +1,7 @@
#include "restart_button.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
void RestartButton::press_action() { this->parent_->restart_and_read_all_info(); }
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -3,8 +3,7 @@
#include "esphome/components/button/button.h"
#include "../ld2450.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
class RestartButton : public button::Button, public Parented<LD2450Component> {
public:
@@ -14,5 +13,4 @@ class RestartButton : public button::Button, public Parented<LD2450Component> {
void press_action() override;
};
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -13,8 +13,7 @@
#include <cmath>
#include <numbers>
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
static const char *const TAG = "ld2450";
@@ -939,5 +938,4 @@ float LD2450Component::restore_from_flash_() {
}
#endif
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -31,8 +31,7 @@
#include <array>
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
using namespace ld24xx;
@@ -193,5 +192,4 @@ class LD2450Component : public Component, public uart::UARTDevice {
#endif
};
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -1,12 +1,10 @@
#include "presence_timeout_number.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
void PresenceTimeoutNumber::control(float value) {
this->publish_state(value);
this->parent_->set_presence_timeout();
}
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -3,8 +3,7 @@
#include "esphome/components/number/number.h"
#include "../ld2450.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
class PresenceTimeoutNumber : public number::Number, public Parented<LD2450Component> {
public:
@@ -14,5 +13,4 @@ class PresenceTimeoutNumber : public number::Number, public Parented<LD2450Compo
void control(float value) override;
};
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -1,7 +1,6 @@
#include "zone_coordinate_number.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
ZoneCoordinateNumber::ZoneCoordinateNumber(uint8_t zone) : zone_(zone) {}
@@ -10,5 +9,4 @@ void ZoneCoordinateNumber::control(float value) {
this->parent_->set_zone_coordinate(this->zone_);
}
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -3,8 +3,7 @@
#include "esphome/components/number/number.h"
#include "../ld2450.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
class ZoneCoordinateNumber : public number::Number, public Parented<LD2450Component> {
public:
@@ -15,5 +14,4 @@ class ZoneCoordinateNumber : public number::Number, public Parented<LD2450Compon
void control(float value) override;
};
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -1,12 +1,10 @@
#include "baud_rate_select.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
void BaudRateSelect::control(size_t index) {
this->publish_state(index);
this->parent_->set_baud_rate(this->option_at(index));
}
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -3,8 +3,7 @@
#include "esphome/components/select/select.h"
#include "../ld2450.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
class BaudRateSelect : public select::Select, public Parented<LD2450Component> {
public:
@@ -14,5 +13,4 @@ class BaudRateSelect : public select::Select, public Parented<LD2450Component> {
void control(size_t index) override;
};
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -1,12 +1,10 @@
#include "zone_type_select.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
void ZoneTypeSelect::control(size_t index) {
this->publish_state(index);
this->parent_->set_zone_type(this->option_at(index));
}
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -3,8 +3,7 @@
#include "esphome/components/select/select.h"
#include "../ld2450.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
class ZoneTypeSelect : public select::Select, public Parented<LD2450Component> {
public:
@@ -14,5 +13,4 @@ class ZoneTypeSelect : public select::Select, public Parented<LD2450Component> {
void control(size_t index) override;
};
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -1,12 +1,10 @@
#include "bluetooth_switch.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
void BluetoothSwitch::write_state(bool state) {
this->publish_state(state);
this->parent_->set_bluetooth(state);
}
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

View File

@@ -3,8 +3,7 @@
#include "esphome/components/switch/switch.h"
#include "../ld2450.h"
namespace esphome {
namespace ld2450 {
namespace esphome::ld2450 {
class BluetoothSwitch : public switch_::Switch, public Parented<LD2450Component> {
public:
@@ -14,5 +13,4 @@ class BluetoothSwitch : public switch_::Switch, public Parented<LD2450Component>
void write_state(bool state) override;
};
} // namespace ld2450
} // namespace esphome
} // namespace esphome::ld2450

Some files were not shown because too many files have changed in this diff Show More