From eb859e83f82b48fc2ed311f889dcb90164373e40 Mon Sep 17 00:00:00 2001 From: Sergey Dudanov Date: Thu, 13 Jul 2023 00:44:30 +0400 Subject: [PATCH] Fix use of optional (#5091) --- .../template/binary_sensor/template_binary_sensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/template/binary_sensor/template_binary_sensor.cpp b/esphome/components/template/binary_sensor/template_binary_sensor.cpp index fce11f63d6..5ce8894a8a 100644 --- a/esphome/components/template/binary_sensor/template_binary_sensor.cpp +++ b/esphome/components/template/binary_sensor/template_binary_sensor.cpp @@ -11,7 +11,7 @@ void TemplateBinarySensor::setup() { return; if (this->f_ != nullptr) { - this->publish_initial_state(*this->f_()); + this->publish_initial_state(this->f_().value_or(false)); } else { this->publish_initial_state(false); }