Rename variable to align number with switch config generator
This commit is contained in:
parent
d4103ee755
commit
fe475ebd4d
|
@ -35,8 +35,8 @@ numbers = [
|
||||||
]
|
]
|
||||||
|
|
||||||
schema={cv.GenerateID(): cv.use_id(tw7100)}
|
schema={cv.GenerateID(): cv.use_id(tw7100)}
|
||||||
for number_name,icon in numbers:
|
for name,icon in numbers:
|
||||||
schema.update({cv.Optional(number_name): number.number_schema(tw7100Number, icon=icon)})
|
schema.update({cv.Optional(name): number.number_schema(tw7100Number, icon=icon)})
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.Schema(schema)
|
CONFIG_SCHEMA = cv.Schema(schema)
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ CONFIG_SCHEMA = cv.Schema(schema)
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
parent = await cg.get_variable(config[CONF_ID])
|
parent = await cg.get_variable(config[CONF_ID])
|
||||||
|
|
||||||
for number_name,icon in numbers:
|
for name,icon in numbers:
|
||||||
if number_name in config:
|
if name in config:
|
||||||
number_ = await number.new_number(config[number_name], min_value=0, max_value=255, step=1)
|
number_ = await number.new_number(config[name], min_value=0, max_value=255, step=1)
|
||||||
cg.add(number_.set_cmd(number_name))
|
cg.add(number_.set_cmd(name))
|
||||||
cg.add(number_.set_tw7100_parent(parent))
|
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_))
|
||||||
|
|
Loading…
Reference in a new issue