Fill a blind's slider with its closed part, like its card and Home Assistant's cover dialog (0.2.79)

On the tile (and the strip of a full-page blind) the small slider filled with the open part, while the blind's card
draws the blind hanging from the top: a closed blind looked open on one and closed on the other. Now both fill with
the closed part and dragging right closes; the text still gives the position (open %). The editor's mockup follows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Max Gramser
2026-09-18 17:28:36 +02:00
parent 1a6308aba7
commit 788f42da65
13 changed files with 49 additions and 11 deletions
+2 -1
View File
@@ -61,7 +61,8 @@ const fill = computed(() => {
const a = c.a || {};
if (domain.value === "light") return c.state === "on" ? (a.brightness !== undefined ? Math.round((a.brightness / 255) * 100) : 100) : 0;
if (domain.value === "fan") return c.state === "on" ? (a.percentage ?? 100) : 0;
if (domain.value === "cover") return a.current_position ?? (c.state === "open" ? 100 : 0);
// A blind's bar fills with its closed part, as on the screen (firmware 0.2.66+) and in Home Assistant's cover dialog.
if (domain.value === "cover") return 100 - (a.current_position ?? (c.state === "open" ? 100 : 0));
if (domain.value === "media_player") return Math.round((a.volume_level ?? 0) * 100);
if (domain.value === "number" || domain.value === "input_number") {
const value = Number(c.state), min = Number(a.min ?? 0), max = Number(a.max ?? 100);
+5
View File
@@ -59,6 +59,11 @@ describe("TileCard", () => {
expect(lamp.find(".ic").classes()).toContain("lit");
expect(lamp.find(".mini-slider").attributes("style")).toContain("50%");
});
it("fills a blind's bar with its closed part, like the screen and its card", () => {
state.liveStates["cover.c"] = { state: "open", word: "Open", a: { current_position: 30 } };
const blind = placed({ entity: "cover.c", name: "", slot: 2, options: { inline: "slider" } });
expect(blind.find(".mini-slider").attributes("style")).toContain("70%");
});
it("draws the large value, the wide card's toggle and an unavailable entity in grey", () => {
state.liveStates["sensor.t"] = { state: "1249", word: null, a: { unit_of_measurement: "W" } };
const big = placed({ entity: "sensor.t", name: "Power", slot: 0, options: { display: "watch" } });