Minor changes

This commit is contained in:
ElVit 2025-02-03 15:25:26 +01:00
parent 92f1516d12
commit 6842884167
2 changed files with 7 additions and 10 deletions

View File

@ -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))

View File

@ -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))