mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 16:20:42 +00:00
[at581x][canbus] Fix walrus operator skipping falsy config values (#15390)
This commit is contained in:
@@ -177,7 +177,7 @@ async def at581x_settings_to_code(config, action_id, template_arg, args):
|
||||
template_ = int(template_ / 1000000)
|
||||
cg.add(var.set_frequency(template_))
|
||||
|
||||
if sens_dist := config.get(CONF_SENSING_DISTANCE):
|
||||
if (sens_dist := config.get(CONF_SENSING_DISTANCE)) is not None:
|
||||
template_ = await cg.templatable(sens_dist, args, int)
|
||||
cg.add(var.set_sensing_distance(template_))
|
||||
|
||||
@@ -209,7 +209,7 @@ async def at581x_settings_to_code(config, action_id, template_arg, args):
|
||||
template_ = int(template_)
|
||||
cg.add(var.set_trigger_keep(template_))
|
||||
|
||||
if stage_gain := config.get(CONF_STAGE_GAIN):
|
||||
if (stage_gain := config.get(CONF_STAGE_GAIN)) is not None:
|
||||
template_ = await cg.templatable(stage_gain, args, int)
|
||||
cg.add(var.set_stage_gain(template_))
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ async def canbus_action_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_CANBUS_ID])
|
||||
|
||||
if can_id := config.get(CONF_CAN_ID):
|
||||
if (can_id := config.get(CONF_CAN_ID)) is not None:
|
||||
can_id = await cg.templatable(can_id, args, cg.uint32)
|
||||
cg.add(var.set_can_id(can_id))
|
||||
cg.add(var.set_use_extended_id(config[CONF_USE_EXTENDED_ID]))
|
||||
|
||||
Reference in New Issue
Block a user