diff --git a/components/panasonic_heatpump/number/__init__.py b/components/panasonic_heatpump/number/__init__.py index c7637c3..a0d736a 100644 --- a/components/panasonic_heatpump/number/__init__.py +++ b/components/panasonic_heatpump/number/__init__.py @@ -292,12 +292,11 @@ CONFIG_SCHEMA = cv.Schema( async def to_code(config): hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_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): - index = TYPES.index(key) 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_PANASONIC_HEATPUMP_ID]) cg.add(getattr(hub, f"set_{key}_number")(var)) diff --git a/components/panasonic_heatpump/select/__init__.py b/components/panasonic_heatpump/select/__init__.py index 712d455..780aeaa 100644 --- a/components/panasonic_heatpump/select/__init__.py +++ b/components/panasonic_heatpump/select/__init__.py @@ -25,8 +25,7 @@ TYPES = [ CONF_SELECTS = [ [ "Off mode", "Quiet mode 1", "Quiet mode 2", "Quiet mode 3", ], - [ "off", "30min", "60min", "90min", ], - [ "off", "30min", "60min", "90min", ], + [ "Off", "30min", "60min", "90min", ], [ "Heat only", "Cool only", "Auto", "DHW only", "Heat+DHW", "Cool+DHW", "Auto + DHW", ], [ "Zone 1", "Zone2", "Zone1 and Zone2", ], [ "Disabled", "Type-A", "Type-B" ], @@ -68,12 +67,11 @@ CONFIG_SCHEMA = cv.Schema( async def to_code(config): hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_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): - index = TYPES.index(key) var = await select.new_select(child_config, options=CONF_SELECTS[index]) await cg.register_parented(var, parent_config[CONF_PANASONIC_HEATPUMP_ID]) cg.add(getattr(hub, f"set_{key}_select")(var))