mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-29 03:09:36 +00:00
Systematic audit after #357 ("can there be more bugs with this root cause?"): _vacMapId was the one remaining hard stub reachable from the eager View path. It runs inside willUpdate for every vacuum whose integration reports live telemetry (Tasshack, XCME, Valetudo), so on a cold tab the #337 stub threw there and the exception took the whole Lit update cycle with it — the card froze on its very first frame. The demo mower has no position attributes, telemetry resolved to null, and every existing smoke (warm and cold) sailed past the branch. The card now owns the implementation (both dependencies — _vacEntity and vacMapIdWithFallback — were already eager); the editor runtime delegates back to the host. The HP-1541-01 invariant (selected_map: 0 is a real map id, nullish not truthy) moves verbatim and is pinned by the new smoke. Hardened alongside (audit Lows): _decorShapeDown gets the same cold-tab guard its twin _decorShapeDbl received in #337 — decor shapes render in View and CSS pointer-events alone must not be what prevents a throw; the _vacCalConfirm dialog renders behind the same _editorRuntime gate as every other editor dialog instead of relying on the implicit "only the runtime ever sets it". smoke_cold_view_vacuum: cold tab, vacuum with vacuum_position and selected_map: 0 — the card commits three successive telemetry frames (willUpdate alive, not merely the first paint), map id resolves to '0', no editor chunk requested, a decor pointerdown is a quiet no-op. A registry mutant restores the delegation and is killed by that smoke. Issue: #358 User-Visible: yes
15 lines
3.7 KiB
JavaScript
15 lines
3.7 KiB
JavaScript
globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="c673cca61c08a44252a2303b34ba28b96411e9d5fddb18c938f79fbbc00ccd7f";import{c as e,l as o,t,c_ as s,A as a,c$ as i,d0 as l,d1 as n,E as r,b as c}from"./houseplan-card-CmrzFyoP.js";class h extends e{constructor(){super(...arguments),this._spaces=null,this._spacesLoading=!1,this._spacesAuthoritative=!1}setConfig(e){this._config=e}async _loadSpaces(){if(!this._spaces&&!this._spacesLoading&&this.hass){this._spacesLoading=!0;try{const e=await this.hass.callWS({type:"houseplan/config/get"});this._spaces=(e?.config?.spaces||[]).map(e=>({value:e.id,label:e.title||e.id})),this._spacesAuthoritative=!0}catch{this._spaces=[],this._spacesAuthoritative=!1}finally{this._spacesLoading=!1}}}get _lang(){return o(this.hass,this._config?.language)}get _floorToken(){const e=this._config?.floor;return"number"==typeof e?`__houseplan_yaml_floor_index__:${String(e)}`:null}get _formData(){const e={...this._config},o=this._floorToken;return o?e.floor=o:Object.prototype.hasOwnProperty.call(e,"floor")||(e.floor=""),e}get _schema(){const e=this._spaces||[],o=this._lang,a=[{value:"",label:t(o,"editor.floor_none")}],i=this._floorToken;i&&a.push({value:i,label:t(o,"editor.floor_index",{index:String(this._config?.floor)})});const l="string"==typeof this._config?.floor?this._config.floor:"";l&&!e.some(e=>e.value===l)&&a.push({value:l,label:l}),a.push(...e);const n="string"==typeof this._config?.default_floor?this._config.default_floor:"",r=[...e];return n&&!e.some(e=>e.value===n)&&r.unshift({value:n,label:n}),[{name:"title",selector:{text:{}}},{name:"floor",selector:{select:{mode:"dropdown",options:a}}},e.length?{name:"default_floor",selector:{select:{mode:"dropdown",options:r}}}:{name:"default_floor",selector:{text:{}}},{name:"language",selector:{select:{mode:"dropdown",options:s(t(o,"editor.lang_auto"),this._config?.language)}}},{name:"icon_size",selector:{number:{min:1,max:6,step:.1,mode:"box"}}},{name:"show_temperature",selector:{boolean:{}}},{name:"live_states",selector:{boolean:{}}},{name:"show_signal",selector:{boolean:{}}},{name:"kiosk",selector:{boolean:{}}},{name:"cycle",selector:{number:{min:0,max:3600,step:5,mode:"box"}}}]}render(){if(!this.hass||!this._config)return a;const e=i(this,l,o(this.hass,this._config.language));if("cold"===e)return n();if("warm"===e)return r;this._loadSpaces();const s=this._lang,h={title:t(s,"editor.title"),floor:t(s,"editor.floor"),default_floor:t(s,"editor.default_floor"),language:t(s,"editor.language"),icon_size:t(s,"editor.icon_size"),show_temperature:t(s,"editor.show_temperature"),live_states:t(s,"editor.live_states"),show_signal:t(s,"editor.show_signal"),kiosk:t(s,"editor.kiosk"),cycle:t(s,"editor.cycle")},f=this._schema,_=function(e,o,t){if(!t||null===o)return null;const s="string"==typeof e?.default_floor?e.default_floor:"";return!s||o.some(e=>e.value===s)?null:s}(this._config,this._spaces,this._spacesAuthoritative),d=e=>c`<ha-form
|
|
.hass=${this.hass}
|
|
.data=${this._formData}
|
|
.schema=${e}
|
|
.computeLabel=${e=>h[e.name]||e.name}
|
|
@value-changed=${this._valueChanged}
|
|
></ha-form>`;return c`
|
|
${d(f.slice(0,3))}
|
|
${_?c`<div class="default-floor-error" role="alert"
|
|
style="color:var(--error-color,#db4437);margin:-4px 0 12px;overflow-wrap:anywhere">
|
|
${t(s,"editor.default_floor_missing",{id:_})}
|
|
</div>`:a}
|
|
${d(f.slice(3))}
|
|
`}_valueChanged(e){const o={...this._config,...e.detail.value};""===o.floor?delete o.floor:o.floor===this._floorToken&&(o.floor=this._config?.floor);const t=new Event("config-changed",{bubbles:!0,composed:!0});t.detail={config:o},this.dispatchEvent(t)}}h.properties={hass:{attribute:!1},_config:{state:!0},_spaces:{state:!0}},customElements.get("houseplan-card-editor")||customElements.define("houseplan-card-editor",h);
|