Colour the sliders of playing media players, covers and numbers (0.2.60)

Since firmware 0.2.42 a slider showed the tile's colour only while
Tile::active() held, which is never true for a playing, paused or idle
media player, a cover or a number, so their volume, position and value
sliders stayed grey like a light that is off.

Tile::slider_active() follows Home Assistant's tile sliders instead: grey
for an unavailable entity, a light or fan that is off and a media player
that is off or in standby; a closed cover keeps its colour as in HA's
cover position feature, and a number with a value is active. The sliders
of direct controls on wide tiles and the small sliders use it;
Tile::active() and its other uses are unchanged.

Checked with 282 Python and 15 C++ tests, generate_packages --check, ESP32
builds of both check profiles and host renders of both boards.
Firmware 0.2.52.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Max Gramser
2026-09-17 08:15:56 +02:00
parent 4f81c7952d
commit 87b2082f81
12 changed files with 115 additions and 10 deletions
+11
View File
@@ -156,6 +156,17 @@ struct Tile {
return state == "on" || state == "cleaning" || state == "active" || (domain() == "person" && state == "home") ||
(domain() == "sun" && state == "above_horizon") || (domain() == "climate" && available() && state != "off");
}
// A slider shows the card's colour like Home Assistant's tile sliders: grey only while stateActive()
// (frontend src/common/entity/state_active.ts) calls the entity inactive, such as an off light or fan and a
// media player that is off or in standby. A number with a value is active there, and a closed cover's
// position slider keeps the cover's colour so it never looks disabled (hui-cover-position-card-feature.ts).
bool slider_active() const {
if (!available()) return false;
auto d = domain();
if (d == "media_player") return state != "off" && state != "standby";
if (d == "cover" || d == "number" || d == "input_number") return true;
return active();
}
};
// Slot position of a tile within the fixed two-column, three-row pages.
struct Placement { uint8_t page = 0, slot = 0; };