class SpaceWeather24hrMaxCard extends HTMLElement { constructor() { super(); this.attachShadow({mode: 'open'}); } setConfig(config) { this._config = config; } set hass(hass) { this._hass = hass; this.render(); } render() { if (!this.shadowRoot) return; this.shadowRoot.innerHTML = ` Space Weather 24-Hour Maximums ${this._getStateValue('sensor.space_weather_scale_r_24hr_max')} ${this._getStateValue('sensor.space_weather_scale_s_24hr_max')} ${this._getStateValue('sensor.space_weather_scale_g_24hr_max')} `; this._attachClickListeners(); } _getStateValue(entityId) { const state = this._hass.states[entityId]; return state ? state.state : ''; } _getStateAttribute(entityId, attribute) { const state = this._hass.states[entityId]; return state ? state.attributes[attribute] || '' : ''; } _getNumericState(entityId) { const stateValue = this._getStateValue(entityId); return stateValue.substring(1); } _attachClickListeners() { const scaleItems = this.shadowRoot.querySelectorAll('.scale-item'); scaleItems.forEach(item => { item.addEventListener('click', () => { const entityId = item.dataset.entityId; this._handleClick(entityId); }); }); } _handleClick(entityId) { const event = new Event('hass-more-info', {composed: true}); event.detail = {entityId}; this.dispatchEvent(event); } getCardSize() { return 3; } } customElements.define('space-weather-24hr-max', SpaceWeather24hrMaxCard);