[at581x][canbus] Fix walrus operator skipping falsy config values (#15390)

This commit is contained in:
Jonathan Swoboda
2026-04-02 16:32:10 -04:00
committed by GitHub
parent 1e72f0ee5a
commit 4134763f34
2 changed files with 3 additions and 3 deletions

View File

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

View File

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