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:
@@ -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;
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user