From 819bb7b8ed50facef31cdf89d63d0695a82e9711 Mon Sep 17 00:00:00 2001 From: Long Vo Date: Tue, 19 Nov 2024 14:56:43 +0700 Subject: [PATCH] Fix lint + test --- esphome/components/mqtt/__init__.py | 1 + esphome/components/mqtt/mqtt_client.cpp | 4 +++- esphome/const.py | 2 +- tests/components/mqtt/common.yaml | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/esphome/components/mqtt/__init__.py b/esphome/components/mqtt/__init__.py index 12024820c4..e16144dc60 100644 --- a/esphome/components/mqtt/__init__.py +++ b/esphome/components/mqtt/__init__.py @@ -454,6 +454,7 @@ async def to_code(config): if CONF_PUBLISH_NAN_AS_NONE in config: cg.add(var.set_publish_nan_as_none(config[CONF_PUBLISH_NAN_AS_NONE])) + MQTT_PUBLISH_ACTION_SCHEMA = cv.Schema( { cv.GenerateID(): cv.use_id(MQTTClientComponent), diff --git a/esphome/components/mqtt/mqtt_client.cpp b/esphome/components/mqtt/mqtt_client.cpp index 9139dfdc00..c7ace505a8 100644 --- a/esphome/components/mqtt/mqtt_client.cpp +++ b/esphome/components/mqtt/mqtt_client.cpp @@ -608,7 +608,9 @@ void MQTTClientComponent::set_log_message_template(MQTTMessage &&message) { this const MQTTDiscoveryInfo &MQTTClientComponent::get_discovery_info() const { return this->discovery_info_; } void MQTTClientComponent::set_topic_prefix(const std::string &topic_prefix) { this->topic_prefix_ = topic_prefix; } const std::string &MQTTClientComponent::get_topic_prefix() const { return this->topic_prefix_; } -void MQTTClientComponent::set_publish_nan_as_none(bool publish_nan_as_none) { this->publish_nan_as_none_ = publish_nan_as_none; } +void MQTTClientComponent::set_publish_nan_as_none(bool publish_nan_as_none) { + this->publish_nan_as_none_ = publish_nan_as_none; +} bool MQTTClientComponent::is_publish_nan_as_none() const { return this->publish_nan_as_none_; } void MQTTClientComponent::disable_birth_message() { this->birth_message_.topic = ""; diff --git a/esphome/const.py b/esphome/const.py index 1546346898..bb3a5b0d0d 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -690,6 +690,7 @@ CONF_PRIORITY = "priority" CONF_PROJECT = "project" CONF_PROTOCOL = "protocol" CONF_PUBLISH_INITIAL_STATE = "publish_initial_state" +CONF_PUBLISH_NAN_AS_NONE = "publish_nan_as_none" CONF_PULL_MODE = "pull_mode" CONF_PULLDOWN = "pulldown" CONF_PULLUP = "pullup" @@ -955,7 +956,6 @@ CONF_X_GRID = "x_grid" CONF_Y_GRID = "y_grid" CONF_YEAR = "year" CONF_ZERO = "zero" -CONF_PUBLISH_NAN_AS_NONE = "publish_nan_as_none" TYPE_GIT = "git" TYPE_LOCAL = "local" diff --git a/tests/components/mqtt/common.yaml b/tests/components/mqtt/common.yaml index d22fe9579f..a4bdf58809 100644 --- a/tests/components/mqtt/common.yaml +++ b/tests/components/mqtt/common.yaml @@ -60,6 +60,7 @@ mqtt: - mqtt.publish: topic: some/topic payload: Good-bye + publish_nan_as_none: false binary_sensor: - platform: template