`;
+ h += `${ic}${p.attrs.friendly_name || p.id}`;
+ h += `${p.pct}%${ti}`;
+ h += `
`;
+ });
+ }
+
+ // Тренды
+ h += `
`;
+ h += `📉 Хуже: ${worse}📈 Лучше: ${better}`;
+ h += `
`;
+ h += `
`;
+ return h;
+ ]]]
+ styles:
+ card:
+ - padding: 0
+ - background: var(--card-background-color)
+ custom_fields:
+ card:
+ - padding: 0
+ - margin: 0
+
+ # ═══ Группы по комнатам ═══
+ # Каждая комната — отдельная collapsible секция с auto-entities
+ # Фильтр по атрибуту area. Сортировка: проблемные комнаты первые.
+
+ - type: custom:auto-entities
+ card:
+ type: vertical-stack
+ filter:
+ include:
+ - entity_id: "sensor.avail_area_*"
+ exclude: []
+ sort:
+ method: state
+ numeric: true
+ card_param: cards
+ card_template:
+ type: conditional
+ conditions: &area_cond
+ - entity: "[[entity.entity_id]]"
+ state_not: "0" # always show
+ row: {} # placeholder
+ # We can't easily do nested auto-entities per area in Lovelace.
+ # Instead, render each area as a section header + its devices.
+
+ # ═══ Альтернативный подход: все устройства одной auto-entities ═══
+ # Группировка по area — визуальная через JavaScript в button-card
+
+ - type: custom:auto-entities
+ card:
+ type: vertical-stack
+ filter:
+ include:
+ - entity_id: "sensor.avail_area_*"
+ options:
+ type: custom:button-card
+ entity: "[[entity.entity_id]]"
+ show_name: false
+ show_state: false
+ show_icon: false
+ tap_action:
+ action: none
+ custom_fields:
+ area: |
+ [[[
+ const pct = parseFloat(entity.state);
+ const a = entity.attributes;
+ const clr = pct < 90 ? 'var(--error-color)' : pct < 95 ? 'var(--warning-color)' : pct < 99 ? '#f0c040' : 'var(--success-color)';
+ const iconMap = {'спальня':'🛏️','кухня':'🍳','ванная':'🚿','гостиная':'🛋️','прихожая':'🚪','дом':'🏠','улица':'🌳','гараж':'🚗','подвал':'🏚️','балкон':'🌅','кабинет':'💼','детская':'🧸'};
+ const name = a.friendly_name || '';
+ const ic = iconMap[name.toLowerCase()] || '📍';
+ let h = `
`;
+ h += `${ic}`;
+ h += `${name}`;
+ h += `${pct}%`;
+ h += `${a.device_count||'?'} устр.`;
+ if (a.problem_count > 0) {
+ h += `${a.problem_count}`;
+ }
+ h += `