From cf8d9311760fec086cccef104a171fb186b19cc7 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:13:30 +1300 Subject: [PATCH] Update esphome/components/mqtt/mqtt_sensor.cpp --- esphome/components/mqtt/mqtt_sensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/mqtt/mqtt_sensor.cpp b/esphome/components/mqtt/mqtt_sensor.cpp index add02e7b9c..50c41beaa1 100644 --- a/esphome/components/mqtt/mqtt_sensor.cpp +++ b/esphome/components/mqtt/mqtt_sensor.cpp @@ -69,9 +69,9 @@ bool MQTTSensorComponent::send_initial_state() { } } bool MQTTSensorComponent::publish_state(float value) { - int8_t accuracy = this->sensor_->get_accuracy_decimals(); if (std::isnan(value)) return this->publish(this->get_state_topic_(), "None"); + int8_t accuracy = this->sensor_->get_accuracy_decimals(); return this->publish(this->get_state_topic_(), value_accuracy_to_string(value, accuracy)); } std::string MQTTSensorComponent::unique_id() { return this->sensor_->unique_id(); }