From 60f505f195896ca27d45d8b114675331d42168f7 Mon Sep 17 00:00:00 2001 From: kbullet Date: Thu, 21 Nov 2024 09:38:05 +0700 Subject: [PATCH] Apply suggestions from code review Updated Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/mqtt/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/esphome/components/mqtt/__init__.py b/esphome/components/mqtt/__init__.py index e16144dc60..2b0d941220 100644 --- a/esphome/components/mqtt/__init__.py +++ b/esphome/components/mqtt/__init__.py @@ -297,7 +297,7 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_QOS, default=0): cv.mqtt_qos, } ), - cv.Optional(CONF_PUBLISH_NAN_AS_NONE): cv.boolean, + cv.Optional(CONF_PUBLISH_NAN_AS_NONE, default=False): cv.boolean, } ), validate_config, @@ -451,8 +451,7 @@ async def to_code(config): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) await automation.build_automation(trigger, [], conf) - if CONF_PUBLISH_NAN_AS_NONE in config: - cg.add(var.set_publish_nan_as_none(config[CONF_PUBLISH_NAN_AS_NONE])) + cg.add(var.set_publish_nan_as_none(config[CONF_PUBLISH_NAN_AS_NONE])) MQTT_PUBLISH_ACTION_SCHEMA = cv.Schema(