From d50d2f9d0491794e54e1d8e3840c8bf8425c7502 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 14 Jul 2024 16:06:00 +0100 Subject: [PATCH] Revert "Add assumed_state support to the light component" This reverts commit 58603634eb5b9836f27ee617bb74be7332a8efc3. --- esphome/components/light/__init__.py | 6 +----- esphome/components/light/light_state.cpp | 12 ++++-------- esphome/components/light/light_state.h | 5 +---- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/esphome/components/light/__init__.py b/esphome/components/light/__init__.py index 67def70a44..0d2c8bb231 100644 --- a/esphome/components/light/__init__.py +++ b/esphome/components/light/__init__.py @@ -18,7 +18,6 @@ from esphome.const import ( CONF_TRIGGER_ID, CONF_COLD_WHITE_COLOR_TEMPERATURE, CONF_WARM_WHITE_COLOR_TEMPERATURE, - CONF_ASSUMED_STATE, ) from esphome.core import coroutine_with_priority from esphome.cpp_helpers import setup_entity @@ -55,6 +54,7 @@ RESTORE_MODES = { "RESTORE_INVERTED_DEFAULT_ON": LightRestoreMode.LIGHT_RESTORE_INVERTED_DEFAULT_ON, "RESTORE_AND_OFF": LightRestoreMode.LIGHT_RESTORE_AND_OFF, "RESTORE_AND_ON": LightRestoreMode.LIGHT_RESTORE_AND_ON, + "DISABLED": LightRestoreMode.LIGHT_RESTORE_DISABLED, } LIGHT_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(cv.MQTT_COMMAND_COMPONENT_SCHEMA).extend( @@ -79,7 +79,6 @@ LIGHT_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(cv.MQTT_COMMAND_COMPONENT_SCHEMA).ex cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(LightStateTrigger), } ), - cv.Optional(CONF_ASSUMED_STATE): cv.boolean, } ) @@ -177,9 +176,6 @@ async def setup_light_core_(light_var, output_var, config): mqtt_ = cg.new_Pvariable(config[CONF_MQTT_ID], light_var) await mqtt.register_mqtt_component(mqtt_, config) - if CONF_ASSUMED_STATE in config: - cg.add(light_var.set_assumed_state(config[CONF_ASSUMED_STATE])) - async def register_light(output_var, config): light_var = cg.new_Pvariable(config[CONF_ID], output_var) diff --git a/esphome/components/light/light_state.cpp b/esphome/components/light/light_state.cpp index a53ff32faa..d3aab43c83 100644 --- a/esphome/components/light/light_state.cpp +++ b/esphome/components/light/light_state.cpp @@ -79,12 +79,10 @@ void LightState::setup() { case LIGHT_ALWAYS_ON: recovered.state = true; break; - } - - if (this->assumed_state_) { - call.set_publish(false); - // In assumed state mode we need to prevent the first run of the loop causing a write out - this->next_write_ = false; + case LIGHT_RESTORE_DISABLED: + call.set_publish(false); + this->next_write_ = false; + return; } call.set_color_mode_if_supported(recovered.color_mode); @@ -220,8 +218,6 @@ void LightState::current_values_as_ct(float *color_temperature, float *white_bri this->gamma_correct_); } -void LightState::set_assumed_state(bool assumed_state) { this->assumed_state_ = assumed_state; } - void LightState::start_effect_(uint32_t effect_index) { this->stop_effect_(); if (effect_index == 0) diff --git a/esphome/components/light/light_state.h b/esphome/components/light/light_state.h index 131101d2c9..0a86dc5ff7 100644 --- a/esphome/components/light/light_state.h +++ b/esphome/components/light/light_state.h @@ -26,6 +26,7 @@ enum LightRestoreMode { LIGHT_RESTORE_INVERTED_DEFAULT_ON, LIGHT_RESTORE_AND_OFF, LIGHT_RESTORE_AND_ON, + LIGHT_RESTORE_DISABLED, }; /** This class represents the communication layer between the front-end MQTT layer and the @@ -144,8 +145,6 @@ class LightState : public EntityBase, public Component { void current_values_as_ct(float *color_temperature, float *white_brightness); - void set_assumed_state(bool assumed_state); - protected: friend LightOutput; friend LightCall; @@ -205,8 +204,6 @@ class LightState : public EntityBase, public Component { LightRestoreMode restore_mode_; /// List of effects for this light. std::vector effects_; - /// Whether the light's true state is not know. - bool assumed_state_{false}; }; } // namespace light