From 2fc2d5839fabdd47fdf2154d4d216a9a8adc5b2b Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 17 Apr 2024 18:22:52 +1200 Subject: [PATCH] Housecleaning: Use walrus operator in text (#6560) --- esphome/components/text/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/text/__init__.py b/esphome/components/text/__init__.py index 21c23ce73b..c0140ff082 100644 --- a/esphome/components/text/__init__.py +++ b/esphome/components/text/__init__.py @@ -73,8 +73,8 @@ async def setup_text_core_( trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) await automation.build_automation(trigger, [(cg.std_string, "x")], conf) - if CONF_MQTT_ID in config: - mqtt_ = cg.new_Pvariable(config[CONF_MQTT_ID], var) + if (mqtt_id := config.get(CONF_MQTT_ID)) is not None: + mqtt_ = cg.new_Pvariable(mqtt_id, var) await mqtt.register_mqtt_component(mqtt_, config)