Every percentage and unit on the screens spaced like Home Assistant, also the tile values and YAML lambdas
The standard tile still joined a unit with a space, and the climate status, cover and light values and the slider overlay wrote their own "%": all go through screen_text::with_unit / percent now (54% in Spanish, 54 % in German). Found on the Guition in the end-to-end test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3164,7 +3164,7 @@ inline void render_slot(size_t slot) {
|
||||
else if (d == "media_player") value = tile_controls::media_state_text(t.state);
|
||||
// A measurement in the screen's number format ("21,5 °C" in Dutch), as Home Assistant writes a state with a unit; a
|
||||
// number without one (a code, a year) stays as it is, as there.
|
||||
else if (!t.unit.empty() && !watch) value = screen_text::localize(value) + " " + t.unit;
|
||||
else if (!t.unit.empty() && !watch) value = screen_text::with_unit(screen_text::localize(value), t.unit);
|
||||
else if (!t.unit.empty() || d == "number" || d == "input_number" || d == "counter") value = screen_text::localize(value);
|
||||
bool pending=t.loading(esphome::millis());
|
||||
if(d=="weather" && std::isfinite(t.current)) {value=screen_text::decimal(t.current,1);if(!watch)value=screen_text::with_unit(value,t.unit);}
|
||||
|
||||
@@ -691,9 +691,8 @@ script:
|
||||
// What the device does (Heating), else its mode (Heat); then the room.
|
||||
std::string status = off ? std::string(screen_text::tr(screen_text::txt::ha_off)) : std::string(tile_controls::climate_action_text(lower(id(active_climate_action))));
|
||||
if (status.empty()) status = tile_controls::climate_mode_text(mode);
|
||||
char part[32];
|
||||
if (std::isfinite(id(active_climate_current))) status += " · " + screen_text::fill(screen_text::txt::climate_now, "value", screen_text::decimal(id(active_climate_current), 1) + "°");
|
||||
if (id(active_climate_humidity) >= 0) { snprintf(part, sizeof(part), " · %d%%", id(active_climate_humidity)); status += part; }
|
||||
if (id(active_climate_humidity) >= 0) status += " · " + screen_text::percent(id(active_climate_humidity));
|
||||
lv_label_set_text(id(climate_current_label), status.c_str());
|
||||
|
||||
int target = id(active_climate_target_x10);
|
||||
|
||||
@@ -925,9 +925,8 @@ script:
|
||||
// What the device does (Heating), else its mode (Heat); then the room.
|
||||
std::string status = off ? std::string(screen_text::tr(screen_text::txt::ha_off)) : std::string(tile_controls::climate_action_text(lower(id(active_climate_action))));
|
||||
if (status.empty()) status = tile_controls::climate_mode_text(mode);
|
||||
char part[32];
|
||||
if (std::isfinite(id(active_climate_current))) status += " · " + screen_text::fill(screen_text::txt::climate_now, "value", screen_text::decimal(id(active_climate_current), 1) + "°");
|
||||
if (id(active_climate_humidity) >= 0) { snprintf(part, sizeof(part), " · %d%%", id(active_climate_humidity)); status += part; }
|
||||
if (id(active_climate_humidity) >= 0) status += " · " + screen_text::percent(id(active_climate_humidity));
|
||||
lv_label_set_text(id(climate_current_label), status.c_str());
|
||||
|
||||
int target = id(active_climate_target_x10);
|
||||
|
||||
+3
-7
@@ -3925,9 +3925,7 @@ script:
|
||||
} else if (pct >= 100) {
|
||||
value_text = open_label;
|
||||
} else {
|
||||
char buf[40];
|
||||
snprintf(buf, sizeof(buf), "%s - %d%%", open_label.c_str(), pct);
|
||||
value_text = buf;
|
||||
value_text = open_label + " - " + screen_text::percent(pct);
|
||||
}
|
||||
} else {
|
||||
if (pct <= 0) {
|
||||
@@ -4075,7 +4073,7 @@ script:
|
||||
if (mode == "none") return;
|
||||
|
||||
id(active_entity) = entity;
|
||||
id(active_value_suffix) = " %";
|
||||
id(active_value_suffix) = screen_text::percent_sign();
|
||||
id(active_label_off) = label_off;
|
||||
id(active_label_on) = label_on;
|
||||
id(active_title) = title;
|
||||
@@ -4184,9 +4182,7 @@ script:
|
||||
} else if (pct >= 100) {
|
||||
value_text = label_on;
|
||||
} else {
|
||||
char buf[40];
|
||||
snprintf(buf, sizeof(buf), "%s - %d%%", label_on.c_str(), pct);
|
||||
value_text = buf;
|
||||
value_text = label_on + " - " + screen_text::percent(pct);
|
||||
}
|
||||
} else {
|
||||
if (pct <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user