mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 16:38:16 +01:00
modbus_switch: honor switch:restore_mode (#4122)
This commit is contained in:
parent
027284c29c
commit
d706f40ce1
1 changed files with 11 additions and 1 deletions
|
@ -6,7 +6,17 @@ namespace modbus_controller {
|
||||||
|
|
||||||
static const char *const TAG = "modbus_controller.switch";
|
static const char *const TAG = "modbus_controller.switch";
|
||||||
|
|
||||||
void ModbusSwitch::setup() {}
|
void ModbusSwitch::setup() {
|
||||||
|
optional<bool> initial_state = Switch::get_initial_state_with_restore_mode();
|
||||||
|
if (initial_state.has_value()) {
|
||||||
|
// if it has a value, restore_mode is not "DISABLED", therefore act on the switch:
|
||||||
|
if (initial_state.value()) {
|
||||||
|
this->turn_on();
|
||||||
|
} else {
|
||||||
|
this->turn_off();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
void ModbusSwitch::dump_config() { LOG_SWITCH(TAG, "Modbus Controller Switch", this); }
|
void ModbusSwitch::dump_config() { LOG_SWITCH(TAG, "Modbus Controller Switch", this); }
|
||||||
|
|
||||||
void ModbusSwitch::parse_and_publish(const std::vector<uint8_t> &data) {
|
void ModbusSwitch::parse_and_publish(const std::vector<uint8_t> &data) {
|
||||||
|
|
Loading…
Reference in a new issue