1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-08 22:32:21 +01:00

Number and Template Number updates (#2036)

Co-authored-by: Otto winter <otto@otto-winter.com>
This commit is contained in:
Jesse Hills
2021-07-20 08:22:49 +12:00
committed by GitHub
parent 2e49fd7b48
commit 71d9d64a02
9 changed files with 148 additions and 153 deletions

View File

@@ -614,8 +614,9 @@ void WebServer::handle_number_request(AsyncWebServerRequest *request, const UrlM
std::string WebServer::number_json(number::Number *obj, float value) {
return json::build_json([obj, value](JsonObject &root) {
root["id"] = "number-" + obj->get_object_id();
std::string state = value_accuracy_to_string(value, obj->get_accuracy_decimals());
root["state"] = state;
char buffer[64];
snprintf(buffer, sizeof(buffer), "%f", value);
root["state"] = buffer;
root["value"] = value;
});
}