Skip to content

Commit d8bc919

Browse files
Fix optional toggle only switch
1 parent 09a0287 commit d8bc919

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

components/secplus_gdo/secplus_gdo.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,14 @@ static void gdo_event_handler(const gdo_status_t *status, gdo_cb_event_t event,
133133
}
134134

135135
void GDOComponent::setup() {
136+
#ifdef GDO_TOGGLE_ONLY
136137
// Set the toggle only state and control here because we cannot guarantee the
137138
// cover instance was created before the switch
138139
this->door_->set_toggle_only(this->toggle_only_switch_->state);
139140
this->toggle_only_switch_->set_control_function(
140141
std::bind(&esphome::secplus_gdo::GDODoor::set_toggle_only, this->door_,
141142
std::placeholders::_1));
142-
143+
#endif
143144
gdo_config_t gdo_conf = {
144145
.uart_num = UART_NUM_1,
145146
.obst_from_status = GDO_OBST_FROM_STATE,

components/secplus_gdo/switch/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929

3030
async def to_code(config):
3131
var = cg.new_Pvariable(config[CONF_ID])
32-
await switch.register_switch(var, config)
32+
if "learn" in str(config[CONF_TYPE]):
33+
await switch.register_switch(var, config)
34+
elif "toggle_only" in str(config[CONF_TYPE]):
35+
cg.add_define("GOD_TOGGLE_ONLY")
36+
await switch.register_switch(var, config)
3337
await cg.register_component(var, config)
3438
parent = await cg.get_variable(config[CONF_SECPLUS_GDO_ID])
3539
fcall = str(parent) + "->" + str(TYPES[config[CONF_TYPE]])

0 commit comments

Comments
 (0)