Rename variable to align number with switch config generator

This commit is contained in:
sqozz 2024-09-19 00:50:45 +02:00
parent d4103ee755
commit fe475ebd4d

View file

@ -35,8 +35,8 @@ numbers = [
]
schema={cv.GenerateID(): cv.use_id(tw7100)}
for number_name,icon in numbers:
schema.update({cv.Optional(number_name): number.number_schema(tw7100Number, icon=icon)})
for name,icon in numbers:
schema.update({cv.Optional(name): number.number_schema(tw7100Number, icon=icon)})
CONFIG_SCHEMA = cv.Schema(schema)
@ -44,9 +44,9 @@ CONFIG_SCHEMA = cv.Schema(schema)
async def to_code(config):
parent = await cg.get_variable(config[CONF_ID])
for number_name,icon in numbers:
if number_name in config:
number_ = await number.new_number(config[number_name], min_value=0, max_value=255, step=1)
cg.add(number_.set_cmd(number_name))
for name,icon in numbers:
if name in config:
number_ = await number.new_number(config[name], min_value=0, max_value=255, step=1)
cg.add(number_.set_cmd(name))
cg.add(number_.set_tw7100_parent(parent))
cg.add(getattr(parent, "set_set_{}".format(number_name.lower()))(number_))
cg.add(getattr(parent, "set_set_{}".format(name.lower()))(number_))