Revert "Add assumed_state support to the light component"

This reverts commit 58603634eb.
This commit is contained in:
Michael Telatynski 2024-07-14 16:06:00 +01:00
parent 58603634eb
commit d50d2f9d04
No known key found for this signature in database
GPG key ID: A2B008A5F49F5D0D
3 changed files with 6 additions and 17 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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<LightEffect *> effects_;
/// Whether the light's true state is not know.
bool assumed_state_{false};
};
} // namespace light