1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 23:21:54 +00:00

fix template regression

This commit is contained in:
J. Nick Koston
2025-10-29 14:24:02 -05:00
parent b6516c687d
commit 299c937e67
8 changed files with 24 additions and 0 deletions

View File

@@ -37,6 +37,9 @@ void TemplateDate::setup() {
}
void TemplateDate::update() {
if (!this->f_.has_value())
return;
auto val = this->f_();
if (val.has_value()) {
this->year_ = val->year;

View File

@@ -40,6 +40,9 @@ void TemplateDateTime::setup() {
}
void TemplateDateTime::update() {
if (!this->f_.has_value())
return;
auto val = this->f_();
if (val.has_value()) {
this->year_ = val->year;

View File

@@ -37,6 +37,9 @@ void TemplateTime::setup() {
}
void TemplateTime::update() {
if (!this->f_.has_value())
return;
auto val = this->f_();
if (val.has_value()) {
this->hour_ = val->hour;

View File

@@ -27,6 +27,9 @@ void TemplateNumber::setup() {
}
void TemplateNumber::update() {
if (!this->f_.has_value())
return;
auto val = this->f_();
if (val.has_value()) {
this->publish_state(*val);

View File

@@ -28,6 +28,9 @@ void TemplateSelect::setup() {
}
void TemplateSelect::update() {
if (!this->f_.has_value())
return;
auto val = this->f_();
if (val.has_value()) {
if (!this->has_option(*val)) {

View File

@@ -8,6 +8,9 @@ namespace template_ {
static const char *const TAG = "template.sensor";
void TemplateSensor::update() {
if (!this->f_.has_value())
return;
auto val = this->f_();
if (val.has_value()) {
this->publish_state(*val);

View File

@@ -24,6 +24,9 @@ void TemplateText::setup() {
}
void TemplateText::update() {
if (!this->f_.has_value())
return;
auto val = this->f_();
if (val.has_value()) {
this->publish_state(*val);

View File

@@ -7,6 +7,9 @@ namespace template_ {
static const char *const TAG = "template.text_sensor";
void TemplateTextSensor::update() {
if (!this->f_.has_value())
return;
auto val = this->f_();
if (val.has_value()) {
this->publish_state(*val);