mirror of
https://github.com/esphome/esphome.git
synced 2024-11-30 10:44:13 +01:00
Revert "Add assumed_state support to the light component"
This reverts commit 58603634eb
.
This commit is contained in:
parent
58603634eb
commit
d50d2f9d04
3 changed files with 6 additions and 17 deletions
|
@ -18,7 +18,6 @@ from esphome.const import (
|
||||||
CONF_TRIGGER_ID,
|
CONF_TRIGGER_ID,
|
||||||
CONF_COLD_WHITE_COLOR_TEMPERATURE,
|
CONF_COLD_WHITE_COLOR_TEMPERATURE,
|
||||||
CONF_WARM_WHITE_COLOR_TEMPERATURE,
|
CONF_WARM_WHITE_COLOR_TEMPERATURE,
|
||||||
CONF_ASSUMED_STATE,
|
|
||||||
)
|
)
|
||||||
from esphome.core import coroutine_with_priority
|
from esphome.core import coroutine_with_priority
|
||||||
from esphome.cpp_helpers import setup_entity
|
from esphome.cpp_helpers import setup_entity
|
||||||
|
@ -55,6 +54,7 @@ RESTORE_MODES = {
|
||||||
"RESTORE_INVERTED_DEFAULT_ON": LightRestoreMode.LIGHT_RESTORE_INVERTED_DEFAULT_ON,
|
"RESTORE_INVERTED_DEFAULT_ON": LightRestoreMode.LIGHT_RESTORE_INVERTED_DEFAULT_ON,
|
||||||
"RESTORE_AND_OFF": LightRestoreMode.LIGHT_RESTORE_AND_OFF,
|
"RESTORE_AND_OFF": LightRestoreMode.LIGHT_RESTORE_AND_OFF,
|
||||||
"RESTORE_AND_ON": LightRestoreMode.LIGHT_RESTORE_AND_ON,
|
"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(
|
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.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)
|
mqtt_ = cg.new_Pvariable(config[CONF_MQTT_ID], light_var)
|
||||||
await mqtt.register_mqtt_component(mqtt_, config)
|
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):
|
async def register_light(output_var, config):
|
||||||
light_var = cg.new_Pvariable(config[CONF_ID], output_var)
|
light_var = cg.new_Pvariable(config[CONF_ID], output_var)
|
||||||
|
|
|
@ -79,12 +79,10 @@ void LightState::setup() {
|
||||||
case LIGHT_ALWAYS_ON:
|
case LIGHT_ALWAYS_ON:
|
||||||
recovered.state = true;
|
recovered.state = true;
|
||||||
break;
|
break;
|
||||||
}
|
case LIGHT_RESTORE_DISABLED:
|
||||||
|
call.set_publish(false);
|
||||||
if (this->assumed_state_) {
|
this->next_write_ = false;
|
||||||
call.set_publish(false);
|
return;
|
||||||
// In assumed state mode we need to prevent the first run of the loop causing a write out
|
|
||||||
this->next_write_ = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
call.set_color_mode_if_supported(recovered.color_mode);
|
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_);
|
this->gamma_correct_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightState::set_assumed_state(bool assumed_state) { this->assumed_state_ = assumed_state; }
|
|
||||||
|
|
||||||
void LightState::start_effect_(uint32_t effect_index) {
|
void LightState::start_effect_(uint32_t effect_index) {
|
||||||
this->stop_effect_();
|
this->stop_effect_();
|
||||||
if (effect_index == 0)
|
if (effect_index == 0)
|
||||||
|
|
|
@ -26,6 +26,7 @@ enum LightRestoreMode {
|
||||||
LIGHT_RESTORE_INVERTED_DEFAULT_ON,
|
LIGHT_RESTORE_INVERTED_DEFAULT_ON,
|
||||||
LIGHT_RESTORE_AND_OFF,
|
LIGHT_RESTORE_AND_OFF,
|
||||||
LIGHT_RESTORE_AND_ON,
|
LIGHT_RESTORE_AND_ON,
|
||||||
|
LIGHT_RESTORE_DISABLED,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This class represents the communication layer between the front-end MQTT layer and the
|
/** 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 current_values_as_ct(float *color_temperature, float *white_brightness);
|
||||||
|
|
||||||
void set_assumed_state(bool assumed_state);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend LightOutput;
|
friend LightOutput;
|
||||||
friend LightCall;
|
friend LightCall;
|
||||||
|
@ -205,8 +204,6 @@ class LightState : public EntityBase, public Component {
|
||||||
LightRestoreMode restore_mode_;
|
LightRestoreMode restore_mode_;
|
||||||
/// List of effects for this light.
|
/// List of effects for this light.
|
||||||
std::vector<LightEffect *> effects_;
|
std::vector<LightEffect *> effects_;
|
||||||
/// Whether the light's true state is not know.
|
|
||||||
bool assumed_state_{false};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace light
|
} // namespace light
|
||||||
|
|
Loading…
Reference in a new issue