Update cookcli-recipe-strategy.js

This commit is contained in:
TheThomaas 2026-09-25 17:09:26 +02:00
parent 206e64490e
commit 8e2b8ec632

View file

@ -449,17 +449,15 @@ class CookCliRecipeViewStrategy extends HTMLElement {
}); });
} }
if (config.timer_entity) { if (config.timer_entity && timers.length) {
const buttons = [];
for (const timer of timers) { for (const timer of timers) {
const seconds = this._parseDurationSeconds(timer.duration, timer.unit); const seconds = this._parseDurationSeconds(timer.duration, timer.unit);
if (!seconds) continue; if (!seconds) continue;
const label = `${timer.duration ?? ""} ${timer.unit ?? ""}`.trim(); const label = `${timer.duration ?? ""} ${timer.unit ?? ""}`.trim();
leftCards.push({ buttons.push({
type: "horizontal-stack",
cards: [
{
type: "button", type: "button",
name: `Démarrer ${label}`, name: label,
icon: "mdi:timer-outline", icon: "mdi:timer-outline",
tap_action: { tap_action: {
action: "perform-action", action: "perform-action",
@ -467,9 +465,16 @@ class CookCliRecipeViewStrategy extends HTMLElement {
target: { entity_id: config.timer_entity }, target: { entity_id: config.timer_entity },
data: { duration: this._secondsToHms(seconds) }, data: { duration: this._secondsToHms(seconds) },
}, },
}, });
{ type: "custom:circular-timer-card", entity: config.timer_entity }, }
],
if (buttons.length) {
leftCards.push({ type: "custom:circular-timer-card", entity: config.timer_entity });
leftCards.push({
type: "grid",
columns: Math.min(2, buttons.length),
square: false,
cards: buttons,
}); });
} }
} }