diff --git a/components/maidsite_desk/maidsite_desk.cpp b/components/maidsite_desk/maidsite_desk.cpp index 28f2caf..7b29dce 100644 --- a/components/maidsite_desk/maidsite_desk.cpp +++ b/components/maidsite_desk/maidsite_desk.cpp @@ -47,19 +47,12 @@ namespace esphome void MaidsiteDeskComponent::setup() { - ESP_LOGCONFIG(TAG, "Setting up maidsite Desk ..."); + ESP_LOGCONFIG(TAG, "Setting up Maidsite Desk ..."); delay(10); - - height_abs_number_->traits.set_min_value(0); - height_abs_number_->traits.set_max_value(120); - height_abs_number_->traits.set_step(.2); - height_pct_number_->traits.set_min_value(0); - height_pct_number_->traits.set_max_value(120); - height_pct_number_->traits.set_step(.1); - - request_physical_limits(); - request_limits(); - request_settings(); + this->check_uart_settings(9600); + this->request_physical_limits(); + this->request_limits(); + this->request_settings(); } void MaidsiteDeskComponent::loop() diff --git a/components/maidsite_desk/number/__init__.py b/components/maidsite_desk/number/__init__.py index 6243c7c..e9926f3 100644 --- a/components/maidsite_desk/number/__init__.py +++ b/components/maidsite_desk/number/__init__.py @@ -16,6 +16,11 @@ TYPES = [ CONF_HEIGHT_PCT, ] +CONF_NUMBERS = [ + [ 0, 120, .2, ], + [ 0, 100, .1, ], +] + MaidsiteDeskNumber = maidsite_desk_ns.class_("MaidsiteDeskNumber", number.Number) CONFIG_SCHEMA = cv.Schema( @@ -35,11 +40,11 @@ CONFIG_SCHEMA = cv.Schema( async def to_code(config): hub = await cg.get_variable(config[CONF_MAIDSITE_DESK_ID]) - for key in TYPES: - await setup_conf(config, key, hub) + for index, key in enumerate(TYPES): + await setup_conf(config, key, index, hub) -async def setup_conf(parent_config, key, hub): +async def setup_conf(parent_config, key, index, hub): if child_config := parent_config.get(key): - var = await number.new_number(child_config, min_value=0, max_value=100, step=.1) + var = await number.new_number(child_config, min_value=CONF_NUMBERS[index][0], max_value=CONF_NUMBERS[index][1], step=CONF_NUMBERS[index][2]) await cg.register_parented(var, parent_config[CONF_MAIDSITE_DESK_ID]) cg.add(getattr(hub, f"set_{key}_number")(var))