mirror of
https://github.com/esphome/esphome.git
synced 2024-12-27 17:28:01 +01:00
Remove template switch restore_state (#5106)
This commit is contained in:
parent
74e062fdb3
commit
d57a5d1793
@ -43,7 +43,9 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.Optional(CONF_TURN_ON_ACTION): automation.validate_automation(
|
||||
single=True
|
||||
),
|
||||
cv.Optional(CONF_RESTORE_STATE, default=False): cv.boolean,
|
||||
cv.Optional(CONF_RESTORE_STATE): cv.invalid(
|
||||
"The restore_state option has been removed in 2023.7.0. Use the restore_mode option instead"
|
||||
),
|
||||
}
|
||||
)
|
||||
.extend(cv.COMPONENT_SCHEMA),
|
||||
@ -70,7 +72,6 @@ async def to_code(config):
|
||||
)
|
||||
cg.add(var.set_optimistic(config[CONF_OPTIMISTIC]))
|
||||
cg.add(var.set_assumed_state(config[CONF_ASSUMED_STATE]))
|
||||
cg.add(var.set_restore_state(config[CONF_RESTORE_STATE]))
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
|
@ -40,9 +40,6 @@ float TemplateSwitch::get_setup_priority() const { return setup_priority::HARDWA
|
||||
Trigger<> *TemplateSwitch::get_turn_on_trigger() const { return this->turn_on_trigger_; }
|
||||
Trigger<> *TemplateSwitch::get_turn_off_trigger() const { return this->turn_off_trigger_; }
|
||||
void TemplateSwitch::setup() {
|
||||
if (!this->restore_state_)
|
||||
return;
|
||||
|
||||
optional<bool> initial_state = this->get_initial_state_with_restore_mode();
|
||||
|
||||
if (initial_state.has_value()) {
|
||||
@ -57,10 +54,8 @@ void TemplateSwitch::setup() {
|
||||
}
|
||||
void TemplateSwitch::dump_config() {
|
||||
LOG_SWITCH("", "Template Switch", this);
|
||||
ESP_LOGCONFIG(TAG, " Restore State: %s", YESNO(this->restore_state_));
|
||||
ESP_LOGCONFIG(TAG, " Optimistic: %s", YESNO(this->optimistic_));
|
||||
}
|
||||
void TemplateSwitch::set_restore_state(bool restore_state) { this->restore_state_ = restore_state; }
|
||||
void TemplateSwitch::set_assumed_state(bool assumed_state) { this->assumed_state_ = assumed_state; }
|
||||
|
||||
} // namespace template_
|
||||
|
@ -15,7 +15,6 @@ class TemplateSwitch : public switch_::Switch, public Component {
|
||||
void dump_config() override;
|
||||
|
||||
void set_state_lambda(std::function<optional<bool>()> &&f);
|
||||
void set_restore_state(bool restore_state);
|
||||
Trigger<> *get_turn_on_trigger() const;
|
||||
Trigger<> *get_turn_off_trigger() const;
|
||||
void set_optimistic(bool optimistic);
|
||||
@ -35,7 +34,6 @@ class TemplateSwitch : public switch_::Switch, public Component {
|
||||
Trigger<> *turn_on_trigger_;
|
||||
Trigger<> *turn_off_trigger_;
|
||||
Trigger<> *prev_trigger_{nullptr};
|
||||
bool restore_state_{false};
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
|
@ -2475,7 +2475,6 @@ switch:
|
||||
level: !lambda "return 0.5;"
|
||||
turn_off_action:
|
||||
- switch.turn_on: living_room_lights_off
|
||||
restore_state: false
|
||||
on_turn_on:
|
||||
- switch.template.publish:
|
||||
id: livingroom_lights
|
||||
@ -2511,7 +2510,6 @@ switch:
|
||||
}
|
||||
optimistic: true
|
||||
assumed_state: false
|
||||
restore_state: true
|
||||
on_turn_off:
|
||||
- switch.template.publish:
|
||||
id: my_switch
|
||||
|
Loading…
Reference in New Issue
Block a user