1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 21:32:21 +01:00

Light & Switch Inverted Restore mode (#1810)

This commit is contained in:
Franck Nijhof
2021-05-23 22:20:11 +02:00
committed by GitHub
parent aebad04c0b
commit 0ce57e5a39
6 changed files with 32 additions and 2 deletions

View File

@@ -18,6 +18,12 @@ void GPIOSwitch::setup() {
case GPIO_SWITCH_RESTORE_DEFAULT_ON:
initial_state = this->get_initial_state().value_or(true);
break;
case GPIO_SWITCH_RESTORE_INVERTED_DEFAULT_OFF:
initial_state = !this->get_initial_state().value_or(true);
break;
case GPIO_SWITCH_RESTORE_INVERTED_DEFAULT_ON:
initial_state = !this->get_initial_state().value_or(false);
break;
case GPIO_SWITCH_ALWAYS_OFF:
initial_state = false;
break;
@@ -49,6 +55,12 @@ void GPIOSwitch::dump_config() {
case GPIO_SWITCH_RESTORE_DEFAULT_ON:
restore_mode = "Restore (Defaults to ON)";
break;
case GPIO_SWITCH_RESTORE_INVERTED_DEFAULT_ON:
restore_mode = "Restore inverted (Defaults to ON)";
break;
case GPIO_SWITCH_RESTORE_INVERTED_DEFAULT_OFF:
restore_mode = "Restore inverted (Defaults to OFF)";
break;
case GPIO_SWITCH_ALWAYS_OFF:
restore_mode = "Always OFF";
break;