mirror of
https://github.com/esphome/esphome.git
synced 2026-02-18 15:35:59 -07:00
Merge branch 'stale_wifi_signal_on_connect' into integration
This commit is contained in:
@@ -171,7 +171,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
*
|
||||
* This will change the image of the component `pic` to the image with ID `4`.
|
||||
*/
|
||||
void set_component_picture(const char *component, uint8_t picture_id);
|
||||
void set_component_picture(const char *component, uint8_t picture_id) { set_component_picc(component, picture_id); };
|
||||
|
||||
/**
|
||||
* Set the background color of a component.
|
||||
@@ -374,7 +374,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
*
|
||||
* This will change the picture id of the component `textview`.
|
||||
*/
|
||||
void set_component_pic(const char *component, uint8_t pic_id);
|
||||
void set_component_pic(const char *component, uint16_t pic_id);
|
||||
|
||||
/**
|
||||
* Set the background picture id of component.
|
||||
@@ -388,7 +388,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
*
|
||||
* This will change the background picture id of the component `textview`.
|
||||
*/
|
||||
void set_component_picc(const char *component, uint8_t pic_id);
|
||||
void set_component_picc(const char *component, uint16_t pic_id);
|
||||
|
||||
/**
|
||||
* Set the font color of a component.
|
||||
@@ -910,7 +910,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
* Draws a QR code with a Wi-Fi network credentials starting at the given coordinates (25,25).
|
||||
*/
|
||||
void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size = 200, uint16_t background_color = 65535,
|
||||
uint16_t foreground_color = 0, uint8_t logo_pic = -1, uint8_t border_width = 8);
|
||||
uint16_t foreground_color = 0, int32_t logo_pic = -1, uint8_t border_width = 8);
|
||||
|
||||
/**
|
||||
* Draws a QR code in the screen
|
||||
@@ -935,7 +935,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
*/
|
||||
void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size,
|
||||
Color background_color = Color(255, 255, 255), Color foreground_color = Color(0, 0, 0),
|
||||
uint8_t logo_pic = -1, uint8_t border_width = 8);
|
||||
int32_t logo_pic = -1, uint8_t border_width = 8);
|
||||
|
||||
/** Set the brightness of the backlight.
|
||||
*
|
||||
|
||||
@@ -143,12 +143,12 @@ void Nextion::set_component_pressed_font_color(const char *component, Color colo
|
||||
}
|
||||
|
||||
// Set picture
|
||||
void Nextion::set_component_pic(const char *component, uint8_t pic_id) {
|
||||
this->add_no_result_to_queue_with_printf_("set_component_pic", "%s.pic=%" PRIu8, component, pic_id);
|
||||
void Nextion::set_component_pic(const char *component, uint16_t pic_id) {
|
||||
this->add_no_result_to_queue_with_printf_("set_component_pic", "%s.pic=%" PRIu16, component, pic_id);
|
||||
}
|
||||
|
||||
void Nextion::set_component_picc(const char *component, uint8_t pic_id) {
|
||||
this->add_no_result_to_queue_with_printf_("set_component_picc", "%s.picc=%" PRIu8, component, pic_id);
|
||||
void Nextion::set_component_picc(const char *component, uint16_t pic_id) {
|
||||
this->add_no_result_to_queue_with_printf_("set_component_picc", "%s.picc=%" PRIu16, component, pic_id);
|
||||
}
|
||||
|
||||
// Set video
|
||||
@@ -217,10 +217,6 @@ void Nextion::disable_component_touch(const char *component) {
|
||||
this->add_no_result_to_queue_with_printf_("disable_component_touch", "tsw %s,0", component);
|
||||
}
|
||||
|
||||
void Nextion::set_component_picture(const char *component, uint8_t picture_id) {
|
||||
this->add_no_result_to_queue_with_printf_("set_component_picture", "%s.pic=%" PRIu8, component, picture_id);
|
||||
}
|
||||
|
||||
void Nextion::set_component_text(const char *component, const char *text) {
|
||||
this->add_no_result_to_queue_with_printf_("set_component_text", "%s.txt=\"%s\"", component, text);
|
||||
}
|
||||
@@ -330,14 +326,14 @@ void Nextion::filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radiu
|
||||
}
|
||||
|
||||
void Nextion::qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size, uint16_t background_color,
|
||||
uint16_t foreground_color, uint8_t logo_pic, uint8_t border_width) {
|
||||
uint16_t foreground_color, int32_t logo_pic, uint8_t border_width) {
|
||||
this->add_no_result_to_queue_with_printf_(
|
||||
"qrcode", "qrcode %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu8 ",%" PRIu8 ",\"%s\"", x1,
|
||||
y1, size, background_color, foreground_color, logo_pic, border_width, content);
|
||||
}
|
||||
|
||||
void Nextion::qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size, Color background_color,
|
||||
Color foreground_color, uint8_t logo_pic, uint8_t border_width) {
|
||||
Color foreground_color, int32_t logo_pic, uint8_t border_width) {
|
||||
this->add_no_result_to_queue_with_printf_(
|
||||
"qrcode", "qrcode %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu8 ",%" PRIu8 ",\"%s\"", x1,
|
||||
y1, size, display::ColorUtil::color_to_565(background_color), display::ColorUtil::color_to_565(foreground_color),
|
||||
|
||||
@@ -334,6 +334,12 @@ class LWIPRawImpl : public Socket {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ssize_t recvfrom(void *buf, size_t len, sockaddr *addr, socklen_t *addr_len) override {
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t internal_write(const void *buf, size_t len) {
|
||||
if (pcb_ == nullptr) {
|
||||
errno = ECONNRESET;
|
||||
|
||||
@@ -113,6 +113,9 @@ class LwIPSocketImpl : public Socket {
|
||||
}
|
||||
int listen(int backlog) override { return lwip_listen(fd_, backlog); }
|
||||
ssize_t read(void *buf, size_t len) override { return lwip_read(fd_, buf, len); }
|
||||
ssize_t recvfrom(void *buf, size_t len, sockaddr *addr, socklen_t *addr_len) override {
|
||||
return lwip_recvfrom(fd_, buf, len, 0, addr, addr_len);
|
||||
}
|
||||
ssize_t readv(const struct iovec *iov, int iovcnt) override { return lwip_readv(fd_, iov, iovcnt); }
|
||||
ssize_t write(const void *buf, size_t len) override { return lwip_write(fd_, buf, len); }
|
||||
ssize_t send(void *buf, size_t len, int flags) { return lwip_send(fd_, buf, len, flags); }
|
||||
|
||||
@@ -39,9 +39,7 @@ class Socket {
|
||||
virtual int setsockopt(int level, int optname, const void *optval, socklen_t optlen) = 0;
|
||||
virtual int listen(int backlog) = 0;
|
||||
virtual ssize_t read(void *buf, size_t len) = 0;
|
||||
#ifdef USE_SOCKET_IMPL_BSD_SOCKETS
|
||||
virtual ssize_t recvfrom(void *buf, size_t len, sockaddr *addr, socklen_t *addr_len) = 0;
|
||||
#endif
|
||||
virtual ssize_t readv(const struct iovec *iov, int iovcnt) = 0;
|
||||
virtual ssize_t write(const void *buf, size_t len) = 0;
|
||||
virtual ssize_t writev(const struct iovec *iov, int iovcnt) = 0;
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
using namespace esphome::alarm_control_panel;
|
||||
|
||||
@@ -286,5 +285,4 @@ void TemplateAlarmControlPanel::control(const AlarmControlPanelCall &call) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
#endif
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
enum BinarySensorFlags : uint16_t {
|
||||
@@ -169,5 +168,4 @@ class TemplateAlarmControlPanel final : public alarm_control_panel::AlarmControl
|
||||
void arm_(optional<std::string> code, alarm_control_panel::AlarmControlPanelState state, uint32_t delay);
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "template_binary_sensor.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.binary_sensor";
|
||||
|
||||
@@ -23,5 +22,4 @@ void TemplateBinarySensor::loop() {
|
||||
|
||||
void TemplateBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Template Binary Sensor", this); }
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "esphome/core/template_lambda.h"
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateBinarySensor final : public Component, public binary_sensor::BinarySensor {
|
||||
public:
|
||||
@@ -21,5 +20,4 @@ class TemplateBinarySensor final : public Component, public binary_sensor::Binar
|
||||
TemplateLambda<bool> f_;
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
#include "esphome/components/button/button.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateButton final : public button::Button {
|
||||
public:
|
||||
@@ -11,5 +10,4 @@ class TemplateButton final : public button::Button {
|
||||
void press_action() override{};
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "template_cover.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
using namespace esphome::cover;
|
||||
|
||||
@@ -133,5 +132,4 @@ void TemplateCover::stop_prev_trigger_() {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include "esphome/core/template_lambda.h"
|
||||
#include "esphome/components/cover/cover.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
enum TemplateCoverRestoreMode {
|
||||
COVER_NO_RESTORE,
|
||||
@@ -63,5 +62,4 @@ class TemplateCover final : public cover::Cover, public Component {
|
||||
bool has_tilt_{false};
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.date";
|
||||
|
||||
@@ -104,7 +103,6 @@ void TemplateDate::dump_config() {
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
#endif // USE_DATETIME_DATE
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#include "esphome/core/time.h"
|
||||
#include "esphome/core/template_lambda.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateDate final : public datetime::DateEntity, public PollingComponent {
|
||||
public:
|
||||
@@ -41,7 +40,6 @@ class TemplateDate final : public datetime::DateEntity, public PollingComponent
|
||||
ESPPreferenceObject pref_;
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
#endif // USE_DATETIME_DATE
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.datetime";
|
||||
|
||||
@@ -143,7 +142,6 @@ void TemplateDateTime::dump_config() {
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
#endif // USE_DATETIME_DATETIME
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#include "esphome/core/time.h"
|
||||
#include "esphome/core/template_lambda.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateDateTime final : public datetime::DateTimeEntity, public PollingComponent {
|
||||
public:
|
||||
@@ -41,7 +40,6 @@ class TemplateDateTime final : public datetime::DateTimeEntity, public PollingCo
|
||||
ESPPreferenceObject pref_;
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
#endif // USE_DATETIME_DATETIME
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.time";
|
||||
|
||||
@@ -104,7 +103,6 @@ void TemplateTime::dump_config() {
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
#endif // USE_DATETIME_TIME
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#include "esphome/core/time.h"
|
||||
#include "esphome/core/template_lambda.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateTime final : public datetime::TimeEntity, public PollingComponent {
|
||||
public:
|
||||
@@ -41,7 +40,6 @@ class TemplateTime final : public datetime::TimeEntity, public PollingComponent
|
||||
ESPPreferenceObject pref_;
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
#endif // USE_DATETIME_TIME
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/event/event.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateEvent final : public Component, public event::Event {};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "template_fan.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.fan";
|
||||
|
||||
@@ -34,5 +33,4 @@ void TemplateFan::control(const fan::FanCall &call) {
|
||||
this->publish_state();
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/fan/fan.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateFan final : public Component, public fan::Fan {
|
||||
public:
|
||||
@@ -27,5 +26,4 @@ class TemplateFan final : public Component, public fan::Fan {
|
||||
std::vector<const char *> preset_modes_{};
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
#include "esphome/core/automation.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
template<typename... Ts> class TemplateLockPublishAction : public Action<Ts...>, public Parented<TemplateLock> {
|
||||
public:
|
||||
@@ -14,5 +13,4 @@ template<typename... Ts> class TemplateLockPublishAction : public Action<Ts...>,
|
||||
void play(const Ts &...x) override { this->parent_->publish_state(this->state_.value(x...)); }
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "template_lock.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
using namespace esphome::lock;
|
||||
|
||||
@@ -56,5 +55,4 @@ void TemplateLock::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, " Optimistic: %s", YESNO(this->optimistic_));
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include "esphome/core/template_lambda.h"
|
||||
#include "esphome/components/lock/lock.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateLock final : public lock::Lock, public Component {
|
||||
public:
|
||||
@@ -36,5 +35,4 @@ class TemplateLock final : public lock::Lock, public Component {
|
||||
Trigger<> *prev_trigger_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "template_number.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.number";
|
||||
|
||||
@@ -51,5 +50,4 @@ void TemplateNumber::dump_config() {
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include "esphome/core/preferences.h"
|
||||
#include "esphome/core/template_lambda.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateNumber final : public number::Number, public PollingComponent {
|
||||
public:
|
||||
@@ -34,5 +33,4 @@ class TemplateNumber final : public number::Number, public PollingComponent {
|
||||
ESPPreferenceObject pref_;
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "esphome/components/output/binary_output.h"
|
||||
#include "esphome/components/output/float_output.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateBinaryOutput final : public output::BinaryOutput {
|
||||
public:
|
||||
@@ -27,5 +26,4 @@ class TemplateFloatOutput final : public output::FloatOutput {
|
||||
Trigger<float> *trigger_ = new Trigger<float>();
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "template_select.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.select";
|
||||
|
||||
@@ -63,5 +62,4 @@ void TemplateSelect::dump_config() {
|
||||
YESNO(this->optimistic_), this->option_at(this->initial_option_index_), YESNO(this->restore_value_));
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include "esphome/core/preferences.h"
|
||||
#include "esphome/core/template_lambda.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateSelect final : public select::Select, public PollingComponent {
|
||||
public:
|
||||
@@ -34,5 +33,4 @@ class TemplateSelect final : public select::Select, public PollingComponent {
|
||||
ESPPreferenceObject pref_;
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include <cmath>
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.sensor";
|
||||
|
||||
@@ -24,5 +23,4 @@ void TemplateSensor::dump_config() {
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "esphome/core/template_lambda.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateSensor final : public sensor::Sensor, public PollingComponent {
|
||||
public:
|
||||
@@ -21,5 +20,4 @@ class TemplateSensor final : public sensor::Sensor, public PollingComponent {
|
||||
TemplateLambda<float> f_;
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "template_switch.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.switch";
|
||||
|
||||
@@ -57,5 +56,4 @@ void TemplateSwitch::dump_config() {
|
||||
}
|
||||
void TemplateSwitch::set_assumed_state(bool assumed_state) { this->assumed_state_ = assumed_state; }
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include "esphome/core/template_lambda.h"
|
||||
#include "esphome/components/switch/switch.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateSwitch final : public switch_::Switch, public Component {
|
||||
public:
|
||||
@@ -37,5 +36,4 @@ class TemplateSwitch final : public switch_::Switch, public Component {
|
||||
Trigger<> *prev_trigger_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "template_text.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.text";
|
||||
|
||||
@@ -51,5 +50,4 @@ void TemplateText::dump_config() {
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include "esphome/core/preferences.h"
|
||||
#include "esphome/core/template_lambda.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
// We keep this separate so we don't have to template and duplicate
|
||||
// the text input for each different size flash allocation.
|
||||
@@ -84,5 +83,4 @@ class TemplateText final : public text::Text, public PollingComponent {
|
||||
TemplateTextSaverBase *pref_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "template_text_sensor.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
static const char *const TAG = "template.text_sensor";
|
||||
|
||||
@@ -20,5 +19,4 @@ float TemplateTextSensor::get_setup_priority() const { return setup_priority::HA
|
||||
|
||||
void TemplateTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Template Sensor", this); }
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include "esphome/core/template_lambda.h"
|
||||
#include "esphome/components/text_sensor/text_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
class TemplateTextSensor final : public text_sensor::TextSensor, public PollingComponent {
|
||||
public:
|
||||
@@ -22,5 +21,4 @@ class TemplateTextSensor final : public text_sensor::TextSensor, public PollingC
|
||||
TemplateLambda<std::string> f_{};
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
#include "esphome/core/automation.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
template<typename... Ts> class TemplateValvePublishAction : public Action<Ts...>, public Parented<TemplateValve> {
|
||||
TEMPLATABLE_VALUE(float, position)
|
||||
@@ -20,5 +19,4 @@ template<typename... Ts> class TemplateValvePublishAction : public Action<Ts...>
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "template_valve.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
using namespace esphome::valve;
|
||||
|
||||
@@ -127,5 +126,4 @@ void TemplateValve::stop_prev_trigger_() {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include "esphome/core/template_lambda.h"
|
||||
#include "esphome/components/valve/valve.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
namespace esphome::template_ {
|
||||
|
||||
enum TemplateValveRestoreMode {
|
||||
VALVE_NO_RESTORE,
|
||||
@@ -57,5 +56,4 @@ class TemplateValve final : public valve::Valve, public Component {
|
||||
bool has_position_{false};
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
} // namespace esphome::template_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import sensor
|
||||
from esphome.components import sensor, wifi
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||
@@ -25,5 +25,6 @@ CONFIG_SCHEMA = sensor.sensor_schema(
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
wifi.request_wifi_listeners()
|
||||
var = await sensor.new_sensor(config)
|
||||
await cg.register_component(var, config)
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
#ifdef USE_WIFI
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace wifi_signal {
|
||||
namespace esphome::wifi_signal {
|
||||
|
||||
static const char *const TAG = "wifi_signal.sensor";
|
||||
|
||||
void WiFiSignalSensor::dump_config() { LOG_SENSOR("", "WiFi Signal", this); }
|
||||
|
||||
} // namespace wifi_signal
|
||||
} // namespace esphome
|
||||
} // namespace esphome::wifi_signal
|
||||
#endif
|
||||
|
||||
@@ -5,17 +5,19 @@
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/wifi/wifi_component.h"
|
||||
#ifdef USE_WIFI
|
||||
namespace esphome {
|
||||
namespace wifi_signal {
|
||||
namespace esphome::wifi_signal {
|
||||
|
||||
class WiFiSignalSensor : public sensor::Sensor, public PollingComponent {
|
||||
class WiFiSignalSensor : public sensor::Sensor, public PollingComponent, public wifi::WiFiConnectStateListener {
|
||||
public:
|
||||
void setup() override { wifi::global_wifi_component->add_connect_state_listener(this); }
|
||||
void update() override { this->publish_state(wifi::global_wifi_component->wifi_rssi()); }
|
||||
void dump_config() override;
|
||||
|
||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||
|
||||
// WiFiConnectStateListener interface - update RSSI immediately on connect
|
||||
void on_wifi_connect_state(const std::string &ssid, const wifi::bssid_t &bssid) override { this->update(); }
|
||||
};
|
||||
|
||||
} // namespace wifi_signal
|
||||
} // namespace esphome
|
||||
} // namespace esphome::wifi_signal
|
||||
#endif
|
||||
|
||||
@@ -773,6 +773,10 @@ bool HOT Scheduler::SchedulerItem::cmp(const std::unique_ptr<SchedulerItem> &a,
|
||||
: (a->next_execution_high_ > b->next_execution_high_);
|
||||
}
|
||||
|
||||
// Recycle a SchedulerItem back to the pool for reuse.
|
||||
// IMPORTANT: Caller must hold the scheduler lock before calling this function.
|
||||
// This protects scheduler_item_pool_ from concurrent access by other threads
|
||||
// that may be acquiring items from the pool in set_timer_common_().
|
||||
void Scheduler::recycle_item_main_loop_(std::unique_ptr<SchedulerItem> item) {
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
@@ -274,6 +274,7 @@ class Scheduler {
|
||||
// Helper to recycle a SchedulerItem back to the pool.
|
||||
// IMPORTANT: Only call from main loop context! Recycling clears the callback,
|
||||
// so calling from another thread while the callback is executing causes use-after-free.
|
||||
// IMPORTANT: Caller must hold the scheduler lock before calling this function.
|
||||
void recycle_item_main_loop_(std::unique_ptr<SchedulerItem> item);
|
||||
|
||||
// Helper to perform full cleanup when too many items are cancelled
|
||||
@@ -330,7 +331,10 @@ class Scheduler {
|
||||
now = this->execute_item_(item.get(), now);
|
||||
}
|
||||
// Recycle the defer item after execution
|
||||
this->recycle_item_main_loop_(std::move(item));
|
||||
{
|
||||
LockGuard lock(this->lock_);
|
||||
this->recycle_item_main_loop_(std::move(item));
|
||||
}
|
||||
}
|
||||
|
||||
// If we've consumed all items up to the snapshot point, clean up the dead space
|
||||
|
||||
25
tests/components/text/common.yaml
Normal file
25
tests/components/text/common.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
text:
|
||||
- platform: template
|
||||
name: "Test Text"
|
||||
id: test_text
|
||||
optimistic: true
|
||||
min_length: 0
|
||||
max_length: 100
|
||||
mode: text
|
||||
|
||||
- platform: template
|
||||
name: "Test Text with Pattern"
|
||||
id: test_text_pattern
|
||||
optimistic: true
|
||||
min_length: 1
|
||||
max_length: 50
|
||||
pattern: "[A-Za-z0-9 ]+"
|
||||
mode: text
|
||||
|
||||
- platform: template
|
||||
name: "Test Password"
|
||||
id: test_password
|
||||
optimistic: true
|
||||
min_length: 8
|
||||
max_length: 32
|
||||
mode: password
|
||||
2
tests/components/text/test.esp32-idf.yaml
Normal file
2
tests/components/text/test.esp32-idf.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
||||
2
tests/components/text/test.esp8266-ard.yaml
Normal file
2
tests/components/text/test.esp8266-ard.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
||||
Reference in New Issue
Block a user