From 5870e2f7eed2b86498fce99020fa0db647e58808 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Sun, 17 May 2026 01:43:32 -0600 Subject: [PATCH] panel: inline AND-IF condition editor for compact-form programs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the read-only "conditions present but not editable" banner with a real editor for the cond / cond2 u16 fields on TIMED / EVENT / YEARLY programs. Compact-form conditions split into five families per clsText.GetConditionalText (clsText.cs:2224-2274): none — cond = 0 (no inline condition) misc — family 0x00, low nibble = enuMiscConditional (NONE / NEVER / LIGHT / DARK / PHONE_* / AC_POWER_* / BATTERY_* / ENERGY_COST_*) zone — family 0x04, low byte = zone, bit 0x0200 = NOT_READY unit — family 0x08, low 9 bits = unit, bit 0x0200 = ON time — family 0x0C, low byte = time-clock #, bit 0x0200 = enabled sec — family >= 0x10, bits 8-11 = area, bits 12-14 = security mode types.ts gains decodeCondition / encodeCondition + the MISC_CONDITIONALS / SECURITY_MODE_NAMES enums. Round-trip is exact: decode(encode(c)) === c for every supported family. UI: two condition slots per editor (matching the two u16 fields on the wire). Each slot has a family-picker dropdown that swaps the sub-fields (zone picker + secure/not-ready, unit picker + on/off, area picker + security mode, time-clock # + enabled/disabled, misc condition picker, or "none"). Picking a family seeds sensible defaults (NEVER for misc, first zone secure, first unit ON, area 1 disarmed, time clock 1 enabled). Object pickers reuse the same _bucketWithPreserve helper introduced for the action editor, so out-of-range zone/unit/area refs in inline conditions keep their original value with a "preserve" label. Live smoke test against the real panel: slot #1's actual condition "AND IF Time clock 4 is disabled" now decodes into the editor as Family=Time clock / # = 4 / Is = disabled — exactly the on-disk state. Frontend bundle: 63 KB minified (up from 56 KB with the new editor section + cond helpers). --- .../frontend/src/omni-panel-programs.ts | 223 +++++++++++++++++- .../omni_pca/frontend/src/types.ts | 129 ++++++++++ custom_components/omni_pca/www/panel.js | 158 +++++++++++-- .../screenshots/2026-05-16/01-overview.png | Bin 116497 -> 107128 bytes .../2026-05-16/08-side-panel-programs.png | Bin 300853 -> 301456 bytes .../2026-05-16/09-side-panel-detail.png | Bin 331989 -> 332541 bytes .../2026-05-16/10-side-panel-editor.png | Bin 361436 -> 364305 bytes 7 files changed, 479 insertions(+), 31 deletions(-) diff --git a/custom_components/omni_pca/frontend/src/omni-panel-programs.ts b/custom_components/omni_pca/frontend/src/omni-panel-programs.ts index 6b82bb6..b8cdee9 100644 --- a/custom_components/omni_pca/frontend/src/omni-panel-programs.ts +++ b/custom_components/omni_pca/frontend/src/omni-panel-programs.ts @@ -14,11 +14,14 @@ import { renderTokens } from "./token-renderer.js"; import { COMMAND_OPTIONS, CommandOption, + CondFamily, DAY_BITS, + DecodedCondition, DecodedEvent, EventCategory, FIXED_EVENTS, Hass, + MISC_CONDITIONALS, MONTH_NAMES, NamedObject, ObjectListResponse, @@ -29,8 +32,11 @@ import { ProgramFields, ProgramListResponse, ProgramRow, + SECURITY_MODE_NAMES, commandOptionFor, + decodeCondition, decodeEventId, + encodeCondition, encodeEventId, eventIdFromFields, packEventIdIntoFields, @@ -874,13 +880,7 @@ export class OmniPanelPrograms extends LitElement {
${this._renderTriggerSection(draft)} ${this._renderActionSection(draft)} - ${draft.cond || draft.cond2 ? html` -
- Inline conditions: - this program carries up to two inline AND-IF conditions on - the source record. They're preserved on save but editing - condition fields is not yet supported. -
` : ""} + ${this._renderConditionsSection(draft)}