Fix publish action skipping away: false and is_on: false

The walrus operator treats false as falsy, so publishing
away: false or is_on: false was silently ignored. Use key
presence check instead.
This commit is contained in:
J. Nick Koston
2026-02-10 06:06:54 -06:00
parent 22b038f6a4
commit 820afea83a

View File

@@ -156,12 +156,12 @@ async def water_heater_template_publish_to_code(
template_ = await cg.templatable(mode, args, water_heater.WaterHeaterMode)
cg.add(var.set_mode(template_))
if away := config.get(CONF_AWAY):
template_ = await cg.templatable(away, args, bool)
if CONF_AWAY in config:
template_ = await cg.templatable(config[CONF_AWAY], args, bool)
cg.add(var.set_away(template_))
if is_on := config.get(CONF_IS_ON):
template_ = await cg.templatable(is_on, args, bool)
if CONF_IS_ON in config:
template_ = await cg.templatable(config[CONF_IS_ON], args, bool)
cg.add(var.set_is_on(template_))
return var