diff --git a/esphome/components/demo/__init__.py b/esphome/components/demo/__init__.py index 33bdc3dee2..0a56073284 100644 --- a/esphome/components/demo/__init__.py +++ b/esphome/components/demo/__init__.py @@ -154,10 +154,6 @@ NUMBER_TYPES = { 2: DemoNumberType.TYPE_2, 3: DemoNumberType.TYPE_3, } -SELECT_TYPES = { - 1: DemoSelectType.TYPE_1, - 2: DemoSelectType.TYPE_2, -} TEXT_TYPES = { 1: DemoTextType.TYPE_1, 2: DemoTextType.TYPE_2, @@ -439,18 +435,15 @@ CONFIG_SCHEMA = cv.Schema( { CONF_NAME: "Demo Select 1", CONF_OPTIONS: ["Option 1", "Option 2", "Option 3"], - CONF_TYPE: 1, }, { CONF_NAME: "Demo Select 2", CONF_OPTIONS: ["Option A", "Option B", "Option C"], - CONF_TYPE: 2, }, ], ): [ select.select_schema(DemoSelect).extend( { - cv.Required(CONF_TYPE): cv.enum(SELECT_TYPES, int=True), cv.Required(CONF_OPTIONS): cv.ensure_list(cv.string_strict), } ) @@ -560,6 +553,7 @@ CONFIG_SCHEMA = cv.Schema( async def to_code(config): for conf in config[CONF_ALARM_CONTROL_PANELS]: var = await alarm_control_panel.new_alarm_control_panel(conf) + cg.add(var.set_type(conf[CONF_TYPE])) await cg.register_component(var, conf) for conf in config[CONF_BINARY_SENSORS]: diff --git a/esphome/components/demo/demo_valve.h b/esphome/components/demo/demo_valve.h index 4cdf9dea67..55d457f176 100644 --- a/esphome/components/demo/demo_valve.h +++ b/esphome/components/demo/demo_valve.h @@ -27,19 +27,23 @@ class DemoValve : public valve::Valve { protected: void control(const valve::ValveCall &call) override { if (call.get_position().has_value()) { - this->publish_state(*call.get_position()); + this->position = *call.get_position(); + this->publish_state(); return; } else if (call.get_toggle().has_value()) { if (call.get_toggle().value()) { if (this->position == valve::VALVE_OPEN) { - this->publish_state(valve::VALVE_CLOSED); + this->position = valve::VALVE_CLOSED; + this->publish_state(); } else { - this->publish_state(valve::VALVE_OPEN); + this->position = valve::VALVE_OPEN; + this->publish_state(); } } return; } else if (call.get_stop()) { - this->publish_state(this->position); // Keep the current position + this->current_operation = valve::VALVE_OPERATION_IDLE; + this->publish_state(); // Keep the current position return; } }