const LUMA_VACUUM_VERSION = '0.1.0'; class LumaVacuumCard extends HTMLElement { set hass(hass) { this._hass = hass; this._render(); } setConfig(config) { if (!config.entity) throw new Error('Entity is required'); this._config = { entity: config.entity, name: config.name || '', size: config.size || '1x1', accent_color: config.accent_color || '', icon: config.icon || '', tap_action: config.tap_action || { action: 'more-info' }, hold_action: config.hold_action || { action: 'more-info' }, ...config }; this._render(); } getCardSize() { return 2; } static getStubConfig() { return { entity: '', name: '', size: '1x1' }; } connectedCallback() { if (!this.shadowRoot) this.attachShadow({ mode: 'open' }); this._render(); } _getState() { return this._hass?.states?.[this._config?.entity]; } _getAccent() { if (this._config?.accent_color) return this._config.accent_color; const s = this._getState(); if (!s) return 'rgba(187,187,187,0.5)'; switch (s.state) { case 'cleaning': return '#7EB8DA'; case 'returning': return '#f0a060'; default: return 'rgba(187,187,187,0.5)'; } } _isActive() { const s = this._getState(); return s && (s.state === 'cleaning' || s.state === 'returning'); } _handleClick() { if (!this._hass || !this._config) return; const ev = new Event('hass-more-info', { composed: true }); ev.detail = { entityId: this._config.entity }; this.dispatchEvent(ev); } _render() { if (!this.shadowRoot || !this._config) return; const s = this._getState(); const isActive = this._isActive(); const accent = this._getAccent(); const name = this._config.name || s?.attributes?.friendly_name || ''; const icon = this._config.icon || 'mdi:robot-vacuum'; const status = s?.state || 'unavailable'; const displayStatus = { cleaning: 'Cleaning', returning: 'Returning', docked: 'Docked', idle: 'Idle', paused: 'Paused' }[status] || status; const fillColor = status === 'cleaning' ? 'rgba(126,184,218,0.25)' : status === 'returning' ? 'rgba(240,160,96,0.20)' : 'transparent'; const fillPct = status === 'cleaning' ? 60 : status === 'returning' ? 30 : 0; this.shadowRoot.innerHTML = `