mirror of
https://github.com/esphome/esphome.git
synced 2025-11-01 15:41:52 +00:00
fix template regression
This commit is contained in:
@@ -37,6 +37,9 @@ void TemplateDate::setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TemplateDate::update() {
|
void TemplateDate::update() {
|
||||||
|
if (!this->f_.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
auto val = this->f_();
|
auto val = this->f_();
|
||||||
if (val.has_value()) {
|
if (val.has_value()) {
|
||||||
this->year_ = val->year;
|
this->year_ = val->year;
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ void TemplateDateTime::setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TemplateDateTime::update() {
|
void TemplateDateTime::update() {
|
||||||
|
if (!this->f_.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
auto val = this->f_();
|
auto val = this->f_();
|
||||||
if (val.has_value()) {
|
if (val.has_value()) {
|
||||||
this->year_ = val->year;
|
this->year_ = val->year;
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ void TemplateTime::setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TemplateTime::update() {
|
void TemplateTime::update() {
|
||||||
|
if (!this->f_.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
auto val = this->f_();
|
auto val = this->f_();
|
||||||
if (val.has_value()) {
|
if (val.has_value()) {
|
||||||
this->hour_ = val->hour;
|
this->hour_ = val->hour;
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ void TemplateNumber::setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TemplateNumber::update() {
|
void TemplateNumber::update() {
|
||||||
|
if (!this->f_.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
auto val = this->f_();
|
auto val = this->f_();
|
||||||
if (val.has_value()) {
|
if (val.has_value()) {
|
||||||
this->publish_state(*val);
|
this->publish_state(*val);
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ void TemplateSelect::setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TemplateSelect::update() {
|
void TemplateSelect::update() {
|
||||||
|
if (!this->f_.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
auto val = this->f_();
|
auto val = this->f_();
|
||||||
if (val.has_value()) {
|
if (val.has_value()) {
|
||||||
if (!this->has_option(*val)) {
|
if (!this->has_option(*val)) {
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ namespace template_ {
|
|||||||
static const char *const TAG = "template.sensor";
|
static const char *const TAG = "template.sensor";
|
||||||
|
|
||||||
void TemplateSensor::update() {
|
void TemplateSensor::update() {
|
||||||
|
if (!this->f_.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
auto val = this->f_();
|
auto val = this->f_();
|
||||||
if (val.has_value()) {
|
if (val.has_value()) {
|
||||||
this->publish_state(*val);
|
this->publish_state(*val);
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ void TemplateText::setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TemplateText::update() {
|
void TemplateText::update() {
|
||||||
|
if (!this->f_.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
auto val = this->f_();
|
auto val = this->f_();
|
||||||
if (val.has_value()) {
|
if (val.has_value()) {
|
||||||
this->publish_state(*val);
|
this->publish_state(*val);
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ namespace template_ {
|
|||||||
static const char *const TAG = "template.text_sensor";
|
static const char *const TAG = "template.text_sensor";
|
||||||
|
|
||||||
void TemplateTextSensor::update() {
|
void TemplateTextSensor::update() {
|
||||||
|
if (!this->f_.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
auto val = this->f_();
|
auto val = this->f_();
|
||||||
if (val.has_value()) {
|
if (val.has_value()) {
|
||||||
this->publish_state(*val);
|
this->publish_state(*val);
|
||||||
|
|||||||
Reference in New Issue
Block a user