diff --git a/ops/home/plans/bathC-hero.png b/ops/home/plans/bathC-hero.png
index f139f9c..97d4df7 100644
Binary files a/ops/home/plans/bathC-hero.png and b/ops/home/plans/bathC-hero.png differ
diff --git a/ops/home/plans/house-web-v68.glb b/ops/home/plans/house-web-v68.glb
new file mode 100644
index 0000000..53a95c0
Binary files /dev/null and b/ops/home/plans/house-web-v68.glb differ
diff --git a/ops/home/plans/house-web-v69.glb b/ops/home/plans/house-web-v69.glb
new file mode 100644
index 0000000..eadb27e
Binary files /dev/null and b/ops/home/plans/house-web-v69.glb differ
diff --git a/ops/home/plans/house.glb b/ops/home/plans/house.glb
index 48518da..eadb27e 100644
Binary files a/ops/home/plans/house.glb and b/ops/home/plans/house.glb differ
diff --git a/ops/home/plans/house_full.py b/ops/home/plans/house_full.py
index ce01c7f..462d858 100644
--- a/ops/home/plans/house_full.py
+++ b/ops/home/plans/house_full.py
@@ -728,91 +728,89 @@ def main():
min(_ay, _by), max(_ay, _by), ZI, ZI + WHI, I_WALL.get(_rid, _wlight))
- # ================= ВАННАЯ C (по привязкам владельца) =================
- # C1 — дверь, C3 — робот, C4 — ванна (дерево), C6 — окно, C7 — раковина и шкафы
+ # ================= ВАННАЯ C (по проекту владельца) =================
_bw = mat_tex("B_Wood", os.path.join(TDIR, "tex_bath_wood.png"), 0.35)
_bd = mat_tex("B_Dark", os.path.join(TDIR, "tex_bath_dark.png"), 0.4)
- _white2 = mat("B_White", "F4F4F0", 0.25)
- _chrome = mat("B_Chrome", "B9C0C6", 0.25, 0.9)
- _blackm = mat("B_Black", "16181A", 0.35, 0.6)
- _bwood = mat("B_WoodCab", "8B5E3C", 0.45)
- _bstone = mat("B_Stone", "6E7679", 0.4)
- _gmat = mat("B_Mat", "C8B49A", 0.9)
+ _wh = mat("B_White", "F4F4F0", 0.25)
+ _chr = mat("B_Chrome", "B9C0C6", 0.25, 0.9)
+ _blk = mat("B_Black", "16181A", 0.35, 0.6)
+ _wood = mat("B_WoodCab", "8B5E3C", 0.45)
+ _st = mat("B_Stone", "6E7679", 0.4)
+ _ceil = mat("B_Ceil", "3A3E42", 0.8)
+ _lmp = mat("B_Spot", "F3F0E6", 0.3)
- # контур: L-образный (низ широкий, верх — узкая часть у окна)
_bx0, _bx1 = 3.38, 6.55
_by0, _by1 = 5.68, 8.60
- _nw = 5.15 # западная граница верхней части
- _ny = 7.25 # северная граница нижней части
+ _nw, _ny = 5.15, 7.25
+ # потолок тёмный
- _floor_poly("bath_floor", ROOMS_M["sanuzel"], ZI - 0.015, 0.03, mat("B_FloorDark", "23262A", 0.55))
-
- # стены: дерево — C4 (север нижней части) и C5 (запад верхней), остальное тёмное
+ _zf = bpy.data.objects.get("zone_sanuzel")
+ if _zf:
+ _zf.data.materials.clear()
+ _zf.data.materials.append(mat("B_FloorDark", "23262A", 0.55))
+ # стены: дерево C4/C5/C3, серый C1/C2/C6/C7
box("bath_c4", _bx0, _nw, _ny - 0.03, _ny, ZI, ZI + WHI, _bw)
box("bath_c5", _nw - 0.03, _nw, _ny, _by1, ZI, ZI + WHI, _bw)
+ box("bath_c3", _bx0, _bx0 + 0.03, _by0, _ny, ZI, ZI + WHI, _bw)
box("bath_c7", _bx1 - 0.03, _bx1, _by0, _by1, ZI, ZI + WHI, _bd)
box("bath_c6", _nw, _bx1, _by1 - 0.03, _by1, ZI, ZI + WHI, _bd)
- box("bath_c3", _bx0, _bx0 + 0.03, _by0, _ny, ZI, ZI + WHI, _bw)
- box("bath_c1a", 4.67, 5.75, _by0, _by0 + 0.03, ZI, ZI + WHI, _bd)
- box("bath_c1b", 6.45, _bx1, _by0, _by0 + 0.03, ZI, ZI + WHI, _bd)
- box("bath_c1_top", 5.75, 6.45, _by0, _by0 + 0.03, ZI + 2.05, ZI + WHI, _bd)
+ box("bath_c1a", 4.67, 5.10, _by0, _by0 + 0.03, ZI, ZI + WHI, _bd)
+ box("bath_c1_top", 5.10, 6.00, _by0, _by0 + 0.03, ZI + 2.05, ZI + WHI, _bd)
+ box("bath_c1b", 6.00, _bx1, _by0, _by0 + 0.03, ZI, ZI + WHI, _bd)
box("bath_c2", _bx0, 4.67, _by0, _by0 + 0.03, ZI, ZI + WHI, _bd)
# окно на C6
- box("bath_win", 5.45, 6.25, _by1 - 0.05, _by1 + 0.01, ZI + 1.35, ZI + 2.05, _chrome)
- box("bath_win_glass", 5.5, 6.2, _by1 - 0.03, _by1 - 0.01, ZI + 1.4, ZI + 2.0,
- mat("B_WinGlass", "C9D4DA", 0.1))
+ box("bath_win", 5.45, 6.25, _by1 - 0.05, _by1 - 0.01, ZI + 1.30, ZI + 2.00, _wh)
+ box("bath_win_g", 5.5, 6.2, _by1 - 0.03, _by1 - 0.001, ZI + 1.35, ZI + 1.95, mat("B_Win", "DCE3E6", 0.15))
- # ВАННА на C4 (дерево), вдоль стены
- _tx0, _tx1 = _bx0 + 0.1, _nw - 0.1
- _ty0, _ty1 = _ny - 0.82, _ny - 0.07
- box("bath_tub", _tx0, _tx1, _ty0, _ty1, ZI + 0.02, ZI + 0.58, _white2)
- box("bath_tub_in", _tx0 + 0.09, _tx1 - 0.09, _ty0 + 0.09, _ty1 - 0.09,
- ZI + 0.3, ZI + 0.62, _bd)
- box("bath_tub_front", _tx0, _tx1, _ty0 - 0.04, _ty0, ZI + 0.02, ZI + 0.6, _bwood)
- box("bath_glass", _tx1, _tx1 + 0.03, _ty0, _ty1, ZI + 0.6, ZI + 1.9, _chrome)
-
+ # ВАННА вдоль C4: тёмный подвесной фронт, белая чаша
+ _tx0, _tx1 = _bx0 + 0.12, _nw - 0.10
+ _ty0, _ty1 = _ny - 0.80, _ny - 0.06
+ box("bath_tub", _tx0, _tx1, _ty0, _ty1, ZI + 0.05, ZI + 0.58, _wh)
+ box("bath_tub_in", _tx0 + 0.09, _tx1 - 0.09, _ty0 + 0.09, _ty1 - 0.09, ZI + 0.28, ZI + 0.62, _st)
+ box("bath_tub_front", _tx0, _tx1, _ty0 - 0.05, _ty0, ZI, ZI + 0.62, mat("B_TubPanel", "4A4E52", 0.5))
+ # стеклянная перегородка на чёрном профиле (у изголовья)
+ box("bath_glass", _tx1, _tx1 + 0.02, _ty0, _ty1, ZI + 0.62, ZI + 1.95, mat("B_Glass", "AFC0C8", 0.1))
+ box("bath_glass_fr", _tx1 - 0.01, _tx1 + 0.03, _ty0, _ty1, ZI + 0.62, ZI + 0.66, _blk)
- # ДУШ: только стойка на C3 (по фото, без кабины)
- box("bath_shaft", _bx0 + 0.05, _bx0 + 0.09, 7.00, 7.04, ZI + 0.6, ZI + 2.2, _blackm)
- box("bath_rain", _bx0 + 0.05, _bx0 + 0.42, 6.99, 7.07, ZI + 2.1, ZI + 2.14, _blackm)
- box("bath_shower_mix", _bx0 + 0.05, _bx0 + 0.13, 7.05, 7.18, ZI + 1.0, ZI + 1.08, _blackm)
+ # ДУШ: стойка на C3 над ванной
+ box("bath_shaft", _bx0 + 0.05, _bx0 + 0.09, _ny - 0.22, _ny - 0.18, ZI + 0.7, ZI + 2.15, _blk)
+ box("bath_rain", _bx0 + 0.05, _bx0 + 0.45, _ny - 0.24, _ny - 0.16, ZI + 2.05, ZI + 2.09, _blk)
+ box("bath_mix", _bx0 + 0.05, _bx0 + 0.13, _ny - 0.17, _ny - 0.04, ZI + 1.05, ZI + 1.13, _blk)
- # РАКОВИНА и шкафы на C7
- _vx0, _vx1 = _bx1 - 0.55, _bx1 - 0.06
- _vy0, _vy1 = 5.95, 6.85
- box("bath_van", _vx0, _vx1, _vy0, _vy1, ZI + 0.32, ZI + 0.8, _bwood)
- box("bath_vtop", _vx0 - 0.02, _vx1 + 0.02, _vy0 - 0.02, _vy1 + 0.02, ZI + 0.8, ZI + 0.84, _bstone)
- box("bath_sink", _vx0 + 0.07, _vx1 - 0.07, _vy0 + 0.16, _vy1 - 0.16, ZI + 0.84, ZI + 0.98, _white2)
- box("bath_mirror", _bx1 - 0.07, _bx1 - 0.05, _vy0 + 0.18, _vy1 - 0.18, ZI + 1.2, ZI + 1.85, _chrome)
- box("bath_mirror_led", _bx1 - 0.06, _bx1 - 0.02, _vy0 + 0.02, _vy1 - 0.02, ZI + 1.12, ZI + 1.16, _lamp)
- # шкафы вдоль C7 выше раковины
- for _i, _z in enumerate((1.15, 1.55, 1.95)):
- box("bath_shelf7_%d" % _i, _bx1 - 0.27, _bx1 - 0.02, 7.50, 8.40, ZI + _z, ZI + _z + 0.04, _bwood)
- box("bath_side7", _bx1 - 0.29, _bx1 - 0.25, 7.50, 8.40, ZI + 1.1, ZI + 2.0, _bwood)
+ # УНИТАЗ на C7 у северного угла + деревянные полки рядом
+ box("bath_wc", 6.02, 6.42, 8.05, 8.50, ZI + 0.28, ZI + 0.70, _wh)
+ box("bath_wc_panel", 6.45, _bx1 - 0.03, 7.95, 8.52, ZI + 0.2, ZI + 1.05, _wood)
+ for _i, _z in enumerate((1.2, 1.6, 2.0)):
+ box("bath_cub_%d" % _i, 6.10, 6.45, 7.40, 7.90, ZI + _z, ZI + _z + 0.04, _wood)
+ box("bath_cub_side", 6.10, 6.14, 7.40, 7.90, ZI + 1.15, ZI + 2.04, _wood)
- # УНИТАЗ у окна (на C6)
- box("bath_wc", 5.86, 6.26, 8.00, 8.45, ZI, ZI + 0.38, _white2)
- box("bath_wc_t", 5.88, 6.24, 8.02, 8.43, ZI + 0.38, ZI + 0.41, _white2)
- box("bath_wc_panel", 5.86, 6.26, _by1 - 0.09, _by1 - 0.03, ZI + 0.3, ZI + 0.95, _bwood)
+ # ТУМБА + накладная раковина + подсвеченное зеркало на C7
+ _vx0, _vx1 = 6.05, 6.52
+ _vy0, _vy1 = 6.15, 7.05
+ box("bath_van", _vx0, _vx1, _vy0, _vy1, ZI + 0.35, ZI + 0.80, _wood)
+ box("bath_vtop", _vx0 - 0.02, _vx1 + 0.02, _vy0 - 0.02, _vy1 + 0.02, ZI + 0.80, ZI + 0.84, _blk)
+ box("bath_sink", _vx0 + 0.05, _vx1 - 0.05, _vy0 + 0.18, _vy1 - 0.18, ZI + 0.84, ZI + 1.00, _wh)
+ box("bath_mirror", _bx1 - 0.07, _bx1 - 0.05, _vy0 + 0.10, _vy1 - 0.10, ZI + 1.15, ZI + 1.95, _chr)
+ box("bath_mirror_led", _bx1 - 0.09, _bx1 - 0.02, _vy0 + 0.06, _vy1 - 0.06, ZI + 1.10, ZI + 1.15, _lmp)
- # полки с полотенцами над ванной на C4
- box("bath_shelf", 3.65, 4.25, _ny - 0.32, _ny - 0.05, ZI + 1.35, ZI + 1.39, _blackm)
- box("bath_towel1", 3.68, 4.22, _ny - 0.3, _ny - 0.08, ZI + 1.39, ZI + 1.55, _blackm)
- box("bath_towel2", 3.68, 4.22, _ny - 0.3, _ny - 0.08, ZI + 1.55, ZI + 1.7, _bd)
+ # ДВЕРЬ на C1 + полотенцесушитель рядом
+ box("bath_door", 5.10, 6.00, _by0 + 0.02, _by0 + 0.08, ZI + 0.02, ZI + 2.05, _wh)
+ box("bath_door_line", 5.10, 6.00, _by0 + 0.01, _by0 + 0.09, ZI + 1.02, ZI + 1.06, mat("B_DoorLine", "D8D2C4", 0.6))
+ for _i, _z in enumerate((0.95, 1.20, 1.45)):
+ box("bath_rad_%d" % _i, 4.20, 4.80, _by0 + 0.06, _by0 + 0.10, ZI + _z, ZI + _z + 0.04, _blk)
+ box("bath_rad_l", 4.18, 4.22, _by0 + 0.06, _by0 + 0.10, ZI + 0.9, ZI + 1.5, _blk)
+ box("bath_rad_r", 4.78, 4.82, _by0 + 0.06, _by0 + 0.10, ZI + 0.9, ZI + 1.5, _blk)
- # робот-пылесос у C3
- box("bath_robot", _bx0 + 0.15, _bx0 + 0.5, 6.45, 6.8, ZI, ZI + 0.32, _white2)
- box("bath_robot_d", _bx0 + 0.21, _bx0 + 0.44, 6.51, 6.74, ZI + 0.32, ZI + 0.34, _blackm)
+ # кресло у тумбы
+ box("bath_chair", 5.45, 5.85, 6.25, 6.65, ZI + 0.42, ZI + 0.46, mat("B_Chair", "6E7378", 0.7))
+ for _dx, _dy in ((0.02, 0.02), (0.36, 0.02), (0.02, 0.36), (0.36, 0.36)):
+ box("bath_chair_l_%s" % _dx, 5.45 + _dx, 5.50 + _dx, 6.25 + _dy, 6.30 + _dy, ZI, ZI + 0.42, _wood)
- # коврик и свет
- box("bath_mat", 4.9, 5.8, 5.95, 7.05, ZI + 0.005, ZI + 0.02, _gmat)
- box("bath_light", 5.2, 5.9, 7.0, 7.06, ZI + WHI - 0.05, ZI + WHI - 0.01, _lamp)
-
- # дверь на C1 (в холл)
- box("bath_door", 5.75, 6.45, _by0 + 0.02, _by0 + 0.08, ZI + 0.02, ZI + 2.05, _white)
- box("bath_door_stripe", 5.75, 6.45, _by0 + 0.01, _by0 + 0.09, ZI + 1.15, ZI + 1.3, _blackm)
- print("ванная C собрана по привязкам", flush=True)
+ # три точечных светильника на тёмном потолке
+ for _i, (_lx, _ly) in enumerate(((4.10, 6.30), (5.60, 6.30), (4.10, 7.70))):
+ box("bath_spot_%d" % _i, _lx, _lx + 0.12, _ly, _ly + 0.12, ZI + WHI - 0.10, ZI + WHI - 0.02, _lmp)
+ print("ванная C по проекту", flush=True)
# ================= /ВАННАЯ =================
# UV для текстур интерьера
diff --git a/ops/home/plans/render-front.png b/ops/home/plans/render-front.png
index 5d15740..a922941 100644
Binary files a/ops/home/plans/render-front.png and b/ops/home/plans/render-front.png differ
diff --git a/ops/home/plans/render-side.png b/ops/home/plans/render-side.png
index 5f202f6..d990b19 100644
Binary files a/ops/home/plans/render-side.png and b/ops/home/plans/render-side.png differ
diff --git a/ops/home/plans/render-terrace.png b/ops/home/plans/render-terrace.png
index c3164e5..de9d92b 100644
Binary files a/ops/home/plans/render-terrace.png and b/ops/home/plans/render-terrace.png differ
diff --git a/ops/home/plans/render-west-ortho.png b/ops/home/plans/render-west-ortho.png
index 85661df..1769f6c 100644
Binary files a/ops/home/plans/render-west-ortho.png and b/ops/home/plans/render-west-ortho.png differ
diff --git a/ops/home/rooms-card.js b/ops/home/rooms-card.js
index 3af058f..483ea39 100644
--- a/ops/home/rooms-card.js
+++ b/ops/home/rooms-card.js
@@ -1,451 +1,486 @@
-/* Покомнатная панель: подложка-план + обводка комнат мышью (сохранение + экспорт). */
-const PLAN_W = 916, PLAN_H = 768;
-/* стартовые контуры (в пикселях подложки), сняты ориентировочно */
-const START = {
- terrasa: [[180,173],[283,173],[283,524],[180,524]],
- kitchen: [[291,173],[425,173],[425,294],[441,294],[441,348],[441,524],[291,524]],
- postirochnaia: [[425,114],[499,114],[499,229],[425,229]],
- sanuzel: [[499,173],[499,229],[425,229],[425,294],[479,294],[558,294],[558,173]],
- tualet: [[558,229],[609,229],[609,294],[558,294]],
- garderob: [[558,173],[558,229],[656,229],[656,173]],
- kladovaia: [[609,229],[656,229],[656,294],[609,294]],
- koridor: [[441,294],[441,348],[684,348],[684,294]],
- prihozhaya: [[441,348],[516,348],[516,442],[441,442]],
- tambur: [[441,442],[516,442],[516,524],[441,524]],
- kabinet: [[656,173],[656,294],[684,294],[684,348],[787,348],[787,173],[656,173]],
- danina_komnata: [[516,348],[633,348],[633,524],[516,524]],
- spalnia: [[633,348],[787,348],[787,524],[633,524]],
- kryltso: [[441,524],[441,593],[516,593],[516,524]],
-};
-const KEY_DOMAINS = ["light", "switch", "climate", "media_player", "cover", "fan"];
-const SENSOR_HINT = /temperature|humidity|co2|illuminance/;
-const ROOM_TITLES = {
- "terrasa": "Терраса",
- "kitchen": "Кухня-гостиная",
- "postirochnaia": "Тех.пом.",
- "sanuzel": "СУ",
- "tualet": "СУ 2",
- "garderob": "Гардеробная",
- "kladovaia": "Кладовая",
- "koridor": "Холл",
- "prihozhaya": "Прихожая",
- "tambur": "Тамбур",
- "kabinet": "Кабинет",
- "danina_komnata": "Данина комната",
- "spalnia": "Спальня",
- "kryltso": "Крыльцо"
-};
-const STORE = "house3d_room_px_v2";
-
-class RoomsCard extends HTMLElement {
- constructor() {
- super();
- this._areas = [];
- this._ent2area = {};
- this._selected = null;
- this._loaded = false;
- this._mode = "plan";
- this._draw = false;
- this._drawRoom = null;
- this._tmp = [];
- this._polys = JSON.parse(JSON.stringify(START));
- try {
- const saved = JSON.parse(localStorage.getItem(STORE) || "null");
- if (saved && typeof saved === "object") this._polys = saved;
- } catch (e) { /* ignore */ }
- this.attachShadow({ mode: "open" });
- }
-
- connectedCallback() {
- this._on3d = (ev) => {
- const room = ev && ev.detail ? ev.detail.room : null;
- this._selected = room || null;
- this._mode = "plan";
- this._render();
- // клик по дому — показываем план этой комнаты
- window.setTimeout(() => {
- const w = this.shadowRoot.querySelector(".plan-wrap");
- if (w && w.scrollIntoView) w.scrollIntoView({ behavior: "smooth", block: "center" });
- }, 60);
- };
- document.addEventListener("house3d-room", this._on3d);
- }
-
- disconnectedCallback() {
- if (this._on3d) document.removeEventListener("house3d-room", this._on3d);
- }
-
- setConfig(config) { this._config = config || {}; }
- set hass(hass) {
- this._hass = hass;
- if (!this._loaded) { this._loaded = true; this._loadRegistries(); }
- else if (!this._busy) this._render();
- }
-
- async _loadRegistries() {
- try {
- const [areas, devices, entities] = await Promise.all([
- this._hass.callWS({ type: "config/area_registry/list" }),
- this._hass.callWS({ type: "config/device_registry/list" }),
- this._hass.callWS({ type: "config/entity_registry/list" }),
- ]);
- this._areas = areas;
- const devArea = {};
- for (const d of devices) if (d.area_id) devArea[d.id] = d.area_id;
- this._ent2area = {};
- for (const e of entities) {
- const a = e.area_id || devArea[e.device_id];
- if (a) this._ent2area[e.entity_id] = a;
- }
- } catch (err) { this._error = String(err); }
- this._render();
- }
-
- _roomList() {
- const names = {
- terrasa: "Терраса", kitchen: "Кухня-гостиная", postirochnaia: "Тех.пом.",
- sanuzel: "Санузел", tualet: "Туалет", garderob: "Гардероб", kladovaia: "Кладовая",
- koridor: "Холл", prihozhaya: "Прихожая", tambur: "Тамбур",
- kabinet: "Спальня", danina_komnata: "Кабинет",
- spalnia: "Данина комната", kryltso: "Крыльцо",
- };
- return Object.keys(START).map((id) => ({ id, name: names[id] || id }));
- }
-
- _entitiesOf(areaId) {
- if (!areaId) return [];
- return Object.entries(this._ent2area).filter(([, a]) => a === areaId)
- .map(([e]) => e).filter((e) => this._hass.states[e]);
- }
- _domain(e) { return e.split(".")[0]; }
- _on(id) {
- return this._entitiesOf(id).filter((e) => {
- const st = this._hass.states[e];
- return (this._domain(e) === "light" || this._domain(e) === "switch") && st.state === "on";
- }).length;
- }
- _sensors(id) {
- const out = [];
- for (const e of this._entitiesOf(id)) {
- if (this._domain(e) !== "sensor" || !SENSOR_HINT.test(e)) continue;
- const st = this._hass.states[e];
- out.push(`${(st.attributes.friendly_name || e).split(" ").slice(-1)[0]}: ${st.state}${st.attributes.unit_of_measurement || ""}`);
- }
- return out.slice(0, 2);
- }
- _toggle(e) {
- const d = this._domain(e);
- if (d === "light" || d === "switch") this._hass.callService(d, "toggle", { entity_id: e });
- }
-
- _wallsSvg() {
- const seen = {};
- const out = [];
- for (const r of ROOMS) {
- const poly = this._polys[ROOMS.indexOf(r)] || r.poly;
- for (let i = 0; i < poly.length; i++) {
- const a = poly[i];
- const b = poly[(i + 1) % poly.length];
- const k1 = a[0] + "," + a[1] + "-" + b[0] + "," + b[1];
- const k2 = b[0] + "," + b[1] + "-" + a[0] + "," + a[1];
- if (seen[k1] || seen[k2]) continue;
- seen[k1] = true;
- out.push(``);
- }
- }
- return out.join("");
- }
-
- _planSvg(areaId) {
- let shapes = "", labels = "", tmp = "";
- for (const r of this._roomList()) {
- const poly = this._polys[r.id] || [];
- if (!poly.length) continue;
- const sel = r.id === areaId;
- shapes += `${r.name}`;
- // на подложке уже есть подписи — свои не рисуем, только подсказку
-
- }
- if (this._tmp.length) {
- tmp = ``;
- this._tmp.forEach(([x, y]) => {
- tmp += ``;
- });
- }
- return `
-
`;
- }
-
- _bindDraw() {
- const svg = this.shadowRoot.querySelector("svg.layer");
- if (!svg) return;
- svg.addEventListener("click", (ev) => {
- if (!this._draw) return;
- const pt = svg.createSVGPoint();
- pt.x = ev.clientX; pt.y = ev.clientY;
- const loc = pt.matrixTransform(svg.getScreenCTM().inverse());
- this._tmp.push([Math.round(loc.x), Math.round(loc.y)]);
- this._render();
- });
- }
-
- _entityRow(e, dom) {
- const st = this._hass.states[e];
- const nm = st.attributes.friendly_name || e;
- const on = st.state === "on";
- if (dom === "light") {
- const br = st.attributes.brightness;
- const pct = br ? Math.round((br / 255) * 100) : 0;
- return `${nm}
-
- ${on ? "вкл" : "выкл"}
`;
- }
- if (dom === "climate") {
- const cur = st.attributes.current_temperature;
- const tgt = st.attributes.temperature;
- return `${nm}
- ${cur !== undefined ? cur + "°" : ""} → ${tgt !== undefined ? tgt + "°" : ""}
- −
- +
`;
- }
- if (dom === "media_player") {
- const playing = st.state === "playing";
- return `${nm}${st.state}
- ${playing ? "⏸" : "▶"}
`;
- }
- if (dom === "cover") {
- return `${nm}${st.state}
- ↑
- ■
- ↓
`;
- }
- const val = st.state + (st.attributes.unit_of_measurement || "");
- const act = dom === "switch"
- ? `${on ? "вкл" : "выкл"}` : "";
- return `${nm}${val}${act}
`;
- }
-
- _render() {
- if (!this._hass) return;
- const areaId = this._selected;
- const tiles = this._roomList().map((r) => {
- const ens = this._entitiesOf(r.id);
- const on = this._on(r.id);
- const sensors = this._sensors(r.id).join(" · ");
- return ``;
- }).join("");
-
- const list = this._roomList();
- const jsonStr = this._jsonPx();
- const drawBar = this._draw ? `
-
- кликайте по углам комнаты на плане (${this._tmp.length} точек)
-
-
-
-
-
-
-
- если «Скопировать» не сработало — нажмите в поле и Ctrl+A, Ctrl+C, или скачайте файл
` : "";
-
- let detail = "";
- if (areaId) {
- const ens = this._entitiesOf(areaId);
- const groups = {};
- for (const e of ens) (groups[this._domain(e)] ||= []).push(e);
- const rows = Object.keys(groups).sort((a, b) => {
- const ia = KEY_DOMAINS.includes(a) ? KEY_DOMAINS.indexOf(a) : 60 + a.charCodeAt(0);
- const ib = KEY_DOMAINS.includes(b) ? KEY_DOMAINS.indexOf(b) : 60 + b.charCodeAt(0);
- return ia - ib;
- }).map((dom) => {
- const items = groups[dom].map((e) => this._entityRow(e, dom)).join("");
- return `${dom} · ${groups[dom].length}
${items}
`;
- }).join("");
- detail = `${(list.find((r) => r.id === areaId) || {}).name || areaId}
-
${rows || "
устройств пока нет
"}
`;
- }
-
- this.shadowRoot.innerHTML = `
-
-
-
-
-
- ${this._mode === "plan" ? this._planSvg(areaId) + drawBar : `${tiles}
`}
- ${detail}`;
-
- this.shadowRoot.querySelectorAll("[data-mode]").forEach((b) =>
- b.addEventListener("click", () => { this._mode = b.dataset.mode; this._render(); }));
- const db = this.shadowRoot.querySelector("[data-draw]");
- if (db) db.addEventListener("click", () => {
- this._draw = !this._draw;
- this._tmp = [];
- this._drawRoom = this._drawRoom || "terrasa";
- this._render();
- });
- if (this._mode === "plan") {
- this.shadowRoot.querySelectorAll(".zone").forEach((el) =>
- el.addEventListener("click", (ev) => {
- if (this._draw) { return; }
- this._selected = this._selected === el.dataset.a ? null : el.dataset.a;
- this._render();
- }));
- if (this._draw) this._bindDraw();
- }
- const sel = this.shadowRoot.querySelector(".sel");
- if (sel) sel.addEventListener("change", () => { this._drawRoom = sel.value; this._tmp = []; this._render(); });
- const finish = this.shadowRoot.querySelector("[data-act=finish]");
- if (finish) finish.addEventListener("click", () => {
- if (this._tmp.length >= 3 && this._drawRoom) {
- this._polys[this._drawRoom] = this._tmp.slice();
- try { localStorage.setItem(STORE, JSON.stringify(this._polys)); } catch (e) { /* ignore */ }
- }
- this._tmp = [];
- this._render();
- });
- const cancel = this.shadowRoot.querySelector("[data-act=cancel]");
- if (cancel) cancel.addEventListener("click", () => { this._tmp = []; this._render(); });
- const clear = this.shadowRoot.querySelector("[data-act=clear]");
- if (clear) clear.addEventListener("click", () => {
- delete this._polys[this._drawRoom];
- try { localStorage.setItem(STORE, JSON.stringify(this._polys)); } catch (e) { /* ignore */ }
- this._tmp = [];
- this._render();
- });
- const copy = this.shadowRoot.querySelector("[data-act=copy]");
- if (copy) copy.addEventListener("click", async () => {
- const txt = this._jsonPx();
- let ok = false;
- try {
- if (navigator.clipboard && window.isSecureContext) {
- await navigator.clipboard.writeText(txt);
- ok = true;
- }
- } catch (e) { ok = false; }
- if (!ok) {
- try {
- const ta = this.shadowRoot.querySelector(".json");
- ta.focus(); ta.select();
- ok = document.execCommand("copy");
- } catch (e) { ok = false; }
- }
- copy.textContent = ok ? "Скопировано ✓" : "Выделите поле и Ctrl+C";
- });
- const dl = this.shadowRoot.querySelector("[data-act=download]");
- if (dl) dl.addEventListener("click", () => this._download());
- this.shadowRoot.querySelectorAll(".tile").forEach((el) =>
- el.addEventListener("click", () => {
- this._selected = this._selected === el.dataset.a ? null : el.dataset.a;
- window.setTimeout(() => { const w = this.shadowRoot.querySelector('.plan-wrap'); if (w && w.scrollIntoView) w.scrollIntoView({ behavior: 'smooth', block: 'center' }); }, 50);
- document.dispatchEvent(new CustomEvent("house3d-select",
- { detail: { room: this._selected ? "zone_" + this._selected : null } }));
- this._render();
- }));
- this.shadowRoot.querySelectorAll(".sw").forEach((s) =>
- s.addEventListener("click", (ev) => { ev.stopPropagation(); this._toggle(s.dataset.e); }));
- this.shadowRoot.querySelectorAll(".br").forEach((el) =>
- el.addEventListener("change", (ev) => {
- ev.stopPropagation();
- const pct = parseInt(ev.target.value, 10);
- this._hass.callService("light", "turn_on", {
- entity_id: ev.target.dataset.e, brightness_pct: pct,
- });
- }));
- this.shadowRoot.querySelectorAll("[data-clim]").forEach((el) =>
- el.addEventListener("click", (ev) => {
- ev.stopPropagation();
- const eid = el.dataset.clim;
- const st = this._hass.states[eid];
- const cur = st.attributes.temperature || 20;
- this._hass.callService("climate", "set_temperature", {
- entity_id: eid, temperature: Math.round((cur + parseFloat(el.dataset.d)) * 2) / 2,
- });
- }));
- this.shadowRoot.querySelectorAll("[data-media]").forEach((el) =>
- el.addEventListener("click", (ev) => {
- ev.stopPropagation();
- this._hass.callService("media_player", el.dataset.a, { entity_id: el.dataset.media });
- }));
- this.shadowRoot.querySelectorAll("[data-cover]").forEach((el) =>
- el.addEventListener("click", (ev) => {
- ev.stopPropagation();
- this._hass.callService("cover", el.dataset.a, { entity_id: el.dataset.cover });
- }));
- const close = this.shadowRoot.querySelector(".close");
- if (close) close.addEventListener("click", () => { this._selected = null; this._render(); });
- }
-
- _jsonPx() {
- try { return JSON.stringify(this._polys); } catch (e) { return "{}"; }
- }
-
- _download() {
- try {
- const blob = new Blob([this._jsonPx()], { type: "application/json" });
- const a = document.createElement("a");
- a.href = URL.createObjectURL(blob);
- a.download = "room-zones.json";
- a.click();
- setTimeout(() => URL.revokeObjectURL(a.href), 2000);
- } catch (e) { /* ignore */ }
- }
-
- getCardSize() { return 14; }
-}
-
-customElements.define("rooms-card", RoomsCard);
+/* Покомнатная панель: подложка-план + обводка комнат мышью (сохранение + экспорт). */
+const PLAN_W = 916, PLAN_H = 768;
+/* стартовые контуры (в пикселях подложки), сняты ориентировочно */
+const START = {
+ terrasa: [[180,173],[283,173],[283,524],[180,524]],
+ kitchen: [[291,173],[425,173],[425,294],[441,294],[441,348],[441,524],[291,524]],
+ postirochnaia: [[425,114],[499,114],[499,229],[425,229]],
+ sanuzel: [[499,173],[499,229],[425,229],[425,294],[479,294],[558,294],[558,173]],
+ tualet: [[558,229],[609,229],[609,294],[558,294]],
+ garderob: [[558,173],[558,229],[656,229],[656,173]],
+ kladovaia: [[609,229],[656,229],[656,294],[609,294]],
+ koridor: [[441,294],[441,348],[684,348],[684,294]],
+ prihozhaya: [[441,348],[516,348],[516,442],[441,442]],
+ tambur: [[441,442],[516,442],[516,524],[441,524]],
+ kabinet: [[656,173],[656,294],[684,294],[684,348],[787,348],[787,173],[656,173]],
+ danina_komnata: [[516,348],[633,348],[633,524],[516,524]],
+ spalnia: [[633,348],[787,348],[787,524],[633,524]],
+ kryltso: [[441,524],[441,593],[516,593],[516,524]],
+};
+const KEY_DOMAINS = ["light", "switch", "climate", "media_player", "cover", "fan"];
+const SENSOR_HINT = /temperature|humidity|co2|illuminance/;
+const ROOM_TITLES = {
+ "terrasa": "Терраса",
+ "kitchen": "Кухня-гостиная",
+ "postirochnaia": "Тех.пом.",
+ "sanuzel": "СУ",
+ "tualet": "СУ 2",
+ "garderob": "Гардеробная",
+ "kladovaia": "Кладовая",
+ "koridor": "Холл",
+ "prihozhaya": "Прихожая",
+ "tambur": "Тамбур",
+ "kabinet": "Кабинет",
+ "danina_komnata": "Данина комната",
+ "spalnia": "Спальня",
+ "kryltso": "Крыльцо"
+};
+const STORE = "house3d_room_px_v2";
+
+class RoomsCard extends HTMLElement {
+ constructor() {
+ super();
+ this._areas = [];
+ this._ent2area = {};
+ this._selected = null;
+ this._loaded = false;
+ this._mode = "plan";
+ this._draw = false;
+ this._drawRoom = null;
+ this._tmp = [];
+ this._polys = JSON.parse(JSON.stringify(START));
+ try {
+ const saved = JSON.parse(localStorage.getItem(STORE) || "null");
+ if (saved && typeof saved === "object") this._polys = saved;
+ } catch (e) { /* ignore */ }
+ this.attachShadow({ mode: "open" });
+ }
+
+ connectedCallback() {
+ this._on3d = (ev) => {
+ const room = ev && ev.detail ? ev.detail.room : null;
+ this._selected = room || null;
+ this._mode = "plan";
+ this._render();
+ // клик по дому — показываем план этой комнаты
+ window.setTimeout(() => {
+ const w = this.shadowRoot.querySelector(".plan-wrap");
+ if (w && w.scrollIntoView) w.scrollIntoView({ behavior: "smooth", block: "center" });
+ }, 60);
+ };
+ document.addEventListener("house3d-room", this._on3d);
+ }
+
+ disconnectedCallback() {
+ if (this._on3d) document.removeEventListener("house3d-room", this._on3d);
+ }
+
+ setConfig(config) { this._config = config || {}; }
+ set hass(hass) {
+ this._hass = hass;
+ if (!this._loaded) { this._loaded = true; this._loadRegistries(); }
+ else if (!this._busy) this._render();
+ }
+
+ async _loadRegistries() {
+ try {
+ const [areas, devices, entities] = await Promise.all([
+ this._hass.callWS({ type: "config/area_registry/list" }),
+ this._hass.callWS({ type: "config/device_registry/list" }),
+ this._hass.callWS({ type: "config/entity_registry/list" }),
+ ]);
+ this._areas = areas;
+ const devArea = {};
+ for (const d of devices) if (d.area_id) devArea[d.id] = d.area_id;
+ this._ent2area = {};
+ for (const e of entities) {
+ const a = e.area_id || devArea[e.device_id];
+ if (a) this._ent2area[e.entity_id] = a;
+ }
+ } catch (err) { this._error = String(err); }
+ this._render();
+ }
+
+ _roomList() {
+ const names = {
+ terrasa: "Терраса", kitchen: "Кухня-гостиная", postirochnaia: "Тех.пом.",
+ sanuzel: "Санузел", tualet: "Туалет", garderob: "Гардероб", kladovaia: "Кладовая",
+ koridor: "Холл", prihozhaya: "Прихожая", tambur: "Тамбур",
+ kabinet: "Спальня", danina_komnata: "Кабинет",
+ spalnia: "Данина комната", kryltso: "Крыльцо",
+ };
+ return Object.keys(START).map((id) => ({ id, name: names[id] || id }));
+ }
+
+ _entitiesOf(areaId) {
+ if (!areaId) return [];
+ return Object.entries(this._ent2area).filter(([, a]) => a === areaId)
+ .map(([e]) => e).filter((e) => this._hass.states[e]);
+ }
+ _domain(e) { return e.split(".")[0]; }
+ _on(id) {
+ return this._entitiesOf(id).filter((e) => {
+ const st = this._hass.states[e];
+ return (this._domain(e) === "light" || this._domain(e) === "switch") && st.state === "on";
+ }).length;
+ }
+ _sensors(id) {
+ const out = [];
+ for (const e of this._entitiesOf(id)) {
+ if (this._domain(e) !== "sensor" || !SENSOR_HINT.test(e)) continue;
+ const st = this._hass.states[e];
+ out.push(`${(st.attributes.friendly_name || e).split(" ").slice(-1)[0]}: ${st.state}${st.attributes.unit_of_measurement || ""}`);
+ }
+ return out.slice(0, 2);
+ }
+ _toggle(e) {
+ const d = this._domain(e);
+ if (d === "light" || d === "switch") this._hass.callService(d, "toggle", { entity_id: e });
+ }
+
+ _wallsSvg() {
+ const seen = {};
+ const out = [];
+ for (const r of ROOMS) {
+ const poly = this._polys[ROOMS.indexOf(r)] || r.poly;
+ for (let i = 0; i < poly.length; i++) {
+ const a = poly[i];
+ const b = poly[(i + 1) % poly.length];
+ const k1 = a[0] + "," + a[1] + "-" + b[0] + "," + b[1];
+ const k2 = b[0] + "," + b[1] + "-" + a[0] + "," + a[1];
+ if (seen[k1] || seen[k2]) continue;
+ seen[k1] = true;
+ out.push(``);
+ }
+ }
+ return out.join("");
+ }
+
+ _planSvg(areaId) {
+ let shapes = "", labels = "", tmp = "";
+ for (const r of this._roomList()) {
+ const poly = this._polys[r.id] || [];
+ if (!poly.length) continue;
+ const sel = r.id === areaId;
+ shapes += `${r.name}`;
+ // на подложке уже есть подписи — свои не рисуем, только подсказку
+
+ }
+ if (this._tmp.length) {
+ tmp = ``;
+ this._tmp.forEach(([x, y]) => {
+ tmp += ``;
+ });
+ }
+ return `
+
`;
+ }
+
+ _bindDraw() {
+ const svg = this.shadowRoot.querySelector("svg.layer");
+ if (!svg) return;
+ svg.addEventListener("click", (ev) => {
+ if (!this._draw) return;
+ const pt = svg.createSVGPoint();
+ pt.x = ev.clientX; pt.y = ev.clientY;
+ const loc = pt.matrixTransform(svg.getScreenCTM().inverse());
+ this._tmp.push([Math.round(loc.x), Math.round(loc.y)]);
+ this._render();
+ });
+ }
+
+ _entityRow(e, dom) {
+ const st = this._hass.states[e];
+ const nm = st.attributes.friendly_name || e;
+ const on = st.state === "on";
+ if (dom === "light") {
+ const br = st.attributes.brightness;
+ const pct = br ? Math.round((br / 255) * 100) : 0;
+ return `${nm}
+
+ ${on ? "вкл" : "выкл"}
`;
+ }
+ if (dom === "climate") {
+ const cur = st.attributes.current_temperature;
+ const tgt = st.attributes.temperature;
+ return `${nm}
+ ${cur !== undefined ? cur + "°" : ""} → ${tgt !== undefined ? tgt + "°" : ""}
+ −
+ +
`;
+ }
+ if (dom === "media_player") {
+ const playing = st.state === "playing";
+ return `${nm}${st.state}
+ ${playing ? "⏸" : "▶"}
`;
+ }
+ if (dom === "cover") {
+ return `${nm}${st.state}
+ ↑
+ ■
+ ↓
`;
+ }
+ const val = st.state + (st.attributes.unit_of_measurement || "");
+ const act = dom === "switch"
+ ? `${on ? "вкл" : "выкл"}` : "";
+ return `${nm}${val}${act}
`;
+ }
+
+ _render() {
+ if (!this._hass) return;
+ const areaId = this._selected;
+ const tiles = this._roomList().map((r) => {
+ const ens = this._entitiesOf(r.id);
+ const on = this._on(r.id);
+ const sensors = this._sensors(r.id).join(" · ");
+ return ``;
+ }).join("");
+
+ const list = this._roomList();
+ const jsonStr = this._jsonPx();
+ const drawBar = this._draw ? `
+
+ кликайте по углам комнаты на плане (${this._tmp.length} точек)
+
+
+
+
+
+
+
+ если «Скопировать» не сработало — нажмите в поле и Ctrl+A, Ctrl+C, или скачайте файл
` : "";
+
+ let detail = "";
+ if (areaId) {
+ const ens = this._entitiesOf(areaId);
+ const groups = {};
+ for (const e of ens) (groups[this._domain(e)] ||= []).push(e);
+ const rows = Object.keys(groups).sort((a, b) => {
+ const ia = KEY_DOMAINS.includes(a) ? KEY_DOMAINS.indexOf(a) : 60 + a.charCodeAt(0);
+ const ib = KEY_DOMAINS.includes(b) ? KEY_DOMAINS.indexOf(b) : 60 + b.charCodeAt(0);
+ return ia - ib;
+ }).map((dom) => {
+ const items = groups[dom].map((e) => this._entityRow(e, dom)).join("");
+ return `${dom} · ${groups[dom].length}
${items}
`;
+ }).join("");
+ // пассивная информация: температура, влажность и прочие датчики
+ const passive = ens.filter((e) => /^(sensor|binary_sensor)\./.test(e));
+ const rank = (e) => {
+ const d = (this._hass.states[e] || {}).attributes.device_class || "";
+ if (d === "temperature") return 0;
+ if (d === "humidity") return 1;
+ if (/^(sensor)\./.test(e)) return 2;
+ return 3;
+ };
+ passive.sort((a, b) => rank(a) - rank(b));
+ const metric = (e) => {
+ const st = this._hass.states[e];
+ if (!st) return "";
+ const u = st.attributes.unit_of_measurement || "";
+ const nm = (st.attributes.friendly_name || e).replace(/^.*?: /, "");
+ const val = st.state;
+ return `${val}${u ? " " + u : ""}
${nm}
`;
+ };
+ const metrics = passive.length
+ ? `${passive.slice(0, 8).map(metric).join("")}
`
+ : `Датчиков температуры/влажности в этой комнате пока нет
`;
+ const photoKey = { sanuzel: "sanuzel" }[areaId] || null;
+ const photos = photoKey
+ ? [1, 2, 3].map((n) => `
`).join("")
+ : "";
+ detail = `${(list.find((r) => r.id === areaId) || {}).name || areaId}
+
+ ${photos ? `
${photos}
` : ""}${metrics}
+ ${rows || "
устройств пока нет
"}
`;
+ }
+
+ this.shadowRoot.innerHTML = `
+
+
+
+
+
+ ${this._mode === "plan" ? this._planSvg(areaId) + drawBar : `${tiles}
`}
+ ${detail}`;
+
+ this.shadowRoot.querySelectorAll("[data-mode]").forEach((b) =>
+ b.addEventListener("click", () => { this._mode = b.dataset.mode; this._render(); }));
+ const db = this.shadowRoot.querySelector("[data-draw]");
+ if (db) db.addEventListener("click", () => {
+ this._draw = !this._draw;
+ this._tmp = [];
+ this._drawRoom = this._drawRoom || "terrasa";
+ this._render();
+ });
+ if (this._mode === "plan") {
+ this.shadowRoot.querySelectorAll(".zone").forEach((el) =>
+ el.addEventListener("click", (ev) => {
+ if (this._draw) { return; }
+ this._selected = this._selected === el.dataset.a ? null : el.dataset.a;
+ this._render();
+ }));
+ if (this._draw) this._bindDraw();
+ }
+ const sel = this.shadowRoot.querySelector(".sel");
+ if (sel) sel.addEventListener("change", () => { this._drawRoom = sel.value; this._tmp = []; this._render(); });
+ const finish = this.shadowRoot.querySelector("[data-act=finish]");
+ if (finish) finish.addEventListener("click", () => {
+ if (this._tmp.length >= 3 && this._drawRoom) {
+ this._polys[this._drawRoom] = this._tmp.slice();
+ try { localStorage.setItem(STORE, JSON.stringify(this._polys)); } catch (e) { /* ignore */ }
+ }
+ this._tmp = [];
+ this._render();
+ });
+ const cancel = this.shadowRoot.querySelector("[data-act=cancel]");
+ if (cancel) cancel.addEventListener("click", () => { this._tmp = []; this._render(); });
+ const clear = this.shadowRoot.querySelector("[data-act=clear]");
+ if (clear) clear.addEventListener("click", () => {
+ delete this._polys[this._drawRoom];
+ try { localStorage.setItem(STORE, JSON.stringify(this._polys)); } catch (e) { /* ignore */ }
+ this._tmp = [];
+ this._render();
+ });
+ const copy = this.shadowRoot.querySelector("[data-act=copy]");
+ if (copy) copy.addEventListener("click", async () => {
+ const txt = this._jsonPx();
+ let ok = false;
+ try {
+ if (navigator.clipboard && window.isSecureContext) {
+ await navigator.clipboard.writeText(txt);
+ ok = true;
+ }
+ } catch (e) { ok = false; }
+ if (!ok) {
+ try {
+ const ta = this.shadowRoot.querySelector(".json");
+ ta.focus(); ta.select();
+ ok = document.execCommand("copy");
+ } catch (e) { ok = false; }
+ }
+ copy.textContent = ok ? "Скопировано ✓" : "Выделите поле и Ctrl+C";
+ });
+ const dl = this.shadowRoot.querySelector("[data-act=download]");
+ if (dl) dl.addEventListener("click", () => this._download());
+ this.shadowRoot.querySelectorAll(".tile").forEach((el) =>
+ el.addEventListener("click", () => {
+ this._selected = this._selected === el.dataset.a ? null : el.dataset.a;
+ window.setTimeout(() => { const w = this.shadowRoot.querySelector('.plan-wrap'); if (w && w.scrollIntoView) w.scrollIntoView({ behavior: 'smooth', block: 'center' }); }, 50);
+ document.dispatchEvent(new CustomEvent("house3d-select",
+ { detail: { room: this._selected ? "zone_" + this._selected : null } }));
+ this._render();
+ }));
+ this.shadowRoot.querySelectorAll(".sw").forEach((s) =>
+ s.addEventListener("click", (ev) => { ev.stopPropagation(); this._toggle(s.dataset.e); }));
+ this.shadowRoot.querySelectorAll(".br").forEach((el) =>
+ el.addEventListener("change", (ev) => {
+ ev.stopPropagation();
+ const pct = parseInt(ev.target.value, 10);
+ this._hass.callService("light", "turn_on", {
+ entity_id: ev.target.dataset.e, brightness_pct: pct,
+ });
+ }));
+ this.shadowRoot.querySelectorAll("[data-clim]").forEach((el) =>
+ el.addEventListener("click", (ev) => {
+ ev.stopPropagation();
+ const eid = el.dataset.clim;
+ const st = this._hass.states[eid];
+ const cur = st.attributes.temperature || 20;
+ this._hass.callService("climate", "set_temperature", {
+ entity_id: eid, temperature: Math.round((cur + parseFloat(el.dataset.d)) * 2) / 2,
+ });
+ }));
+ this.shadowRoot.querySelectorAll("[data-media]").forEach((el) =>
+ el.addEventListener("click", (ev) => {
+ ev.stopPropagation();
+ this._hass.callService("media_player", el.dataset.a, { entity_id: el.dataset.media });
+ }));
+ this.shadowRoot.querySelectorAll("[data-cover]").forEach((el) =>
+ el.addEventListener("click", (ev) => {
+ ev.stopPropagation();
+ this._hass.callService("cover", el.dataset.a, { entity_id: el.dataset.cover });
+ }));
+ const close = this.shadowRoot.querySelector(".close");
+ if (close) close.addEventListener("click", () => { this._selected = null; this._render(); });
+ }
+
+ _jsonPx() {
+ try { return JSON.stringify(this._polys); } catch (e) { return "{}"; }
+ }
+
+ _download() {
+ try {
+ const blob = new Blob([this._jsonPx()], { type: "application/json" });
+ const a = document.createElement("a");
+ a.href = URL.createObjectURL(blob);
+ a.download = "room-zones.json";
+ a.click();
+ setTimeout(() => URL.revokeObjectURL(a.href), 2000);
+ } catch (e) { /* ignore */ }
+ }
+
+ getCardSize() { return 14; }
+}
+
+customElements.define("rooms-card", RoomsCard);