diff --git a/components/ratgdo/light/ratgdo_light_output.cpp b/components/ratgdo/light/ratgdo_light_output.cpp index 4994d08..efcdab6 100644 --- a/components/ratgdo/light/ratgdo_light_output.cpp +++ b/components/ratgdo/light/ratgdo_light_output.cpp @@ -17,6 +17,7 @@ namespace ratgdo { { ESP_LOGD(TAG, "on_light_state: %d", state); if (this->light_state_) { + this->has_initial_state_ = true; set_state(state); } } @@ -44,6 +45,8 @@ namespace ratgdo { void RATGDOLightOutput::write_state(light::LightState* state) { + if (!this->has_initial_state_) + return; bool binary; state->current_values_as_binary(&binary); if (binary) { diff --git a/components/ratgdo/light/ratgdo_light_output.h b/components/ratgdo/light/ratgdo_light_output.h index 4dee47c..9404ac9 100644 --- a/components/ratgdo/light/ratgdo_light_output.h +++ b/components/ratgdo/light/ratgdo_light_output.h @@ -22,6 +22,7 @@ namespace ratgdo { protected: light::LightState* light_state_; + bool has_initial_state_ = false; }; } // namespace ratgdo