mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
fixed default=0 not being set
This commit is contained in:
parent
7b812b8353
commit
0c480a6998
1 changed files with 10 additions and 7 deletions
|
@ -447,14 +447,17 @@ SENSORS = {
|
||||||
|
|
||||||
async def for_each_conf(config, vars, callback):
|
async def for_each_conf(config, vars, callback):
|
||||||
for section in vars:
|
for section in vars:
|
||||||
c = config[section] if section in config else config
|
if section is not None and section not in config:
|
||||||
|
continue
|
||||||
|
c = config[section] if section is not None else config
|
||||||
for args in vars[section]:
|
for args in vars[section]:
|
||||||
setter = "set_"
|
setter = "set_"
|
||||||
if section is not None and section != CONF_SENSOR:
|
if section is not None and section != CONF_SENSOR:
|
||||||
setter += section + "_"
|
setter += section + "_"
|
||||||
setter += args[0]
|
setter += args[0]
|
||||||
if cc := c.get(args[0]):
|
if args[0] in c:
|
||||||
await callback(cc, args, setter)
|
# print(setter + "(" + repr(c[args[0]]) + ")")
|
||||||
|
await callback(c[args[0]], args, setter)
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
|
@ -491,10 +494,10 @@ SetFrequencyAction = kt0803_ns.class_(
|
||||||
@automation.register_action(
|
@automation.register_action(
|
||||||
"kt0803.set_frequency", SetFrequencyAction, FREQUENCY_SCHEMA
|
"kt0803.set_frequency", SetFrequencyAction, FREQUENCY_SCHEMA
|
||||||
)
|
)
|
||||||
async def tune_frequency_action_to_code(config, action_id, template_arg, args):
|
async def set_frequency_action_to_code(config, action_id, template_arg, args):
|
||||||
var = cg.new_Pvariable(action_id, template_arg)
|
var = cg.new_Pvariable(action_id, template_arg)
|
||||||
await cg.register_parented(var, config[CONF_ID])
|
await cg.register_parented(var, config[CONF_ID])
|
||||||
if frequency := config.get(CONF_FREQUENCY):
|
frequency = config.get(CONF_FREQUENCY)
|
||||||
template_ = await cg.templatable(frequency, args, cg.float_)
|
template_ = await cg.templatable(frequency, args, cg.float_)
|
||||||
cg.add(var.set_frequency(template_))
|
cg.add(var.set_frequency(template_))
|
||||||
return var
|
return var
|
||||||
|
|
Loading…
Reference in a new issue