Implement unit_of_measurement for number component (#2804)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
puuu
2021-12-01 00:20:59 +09:00
committed by GitHub
parent b32b918936
commit b5a0e8b2c0
9 changed files with 37 additions and 0 deletions
+2
View File
@@ -43,6 +43,8 @@ void MQTTNumberComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryCo
root[MQTT_MIN] = traits.get_min_value();
root[MQTT_MAX] = traits.get_max_value();
root[MQTT_STEP] = traits.get_step();
if (!this->number_->traits.get_unit_of_measurement().empty())
root[MQTT_UNIT_OF_MEASUREMENT] = this->number_->traits.get_unit_of_measurement();
config.command_topic = true;
}