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:
		| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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)) { | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user