// I Used weather-card-editor.js from Weather Card as template // https://github.com/bramkragten/weather-card // 2023-02-25 card editor is likely broken as it doesn't show entities, const fireEvent = (node, type, detail, options) => { options = options || {}; detail = detail === null || detail === undefined ? {} : detail; const event = new Event(type, { bubbles: options.bubbles === undefined ? true : options.bubbles, cancelable: Boolean(options.cancelable), composed: options.composed === undefined ? true : options.composed, }); event.detail = detail; node.dispatchEvent(event); return event; }; if ( !customElements.get("ha-switch") && customElements.get("paper-toggle-button") ) { customElements.define("ha-switch", customElements.get("paper-toggle-button")); } const LitElement = customElements.get("hui-masonry-view") ? Object.getPrototypeOf(customElements.get("hui-masonry-view")) : Object.getPrototypeOf(customElements.get("hui-view")); const html = LitElement.prototype.html; const css = LitElement.prototype.css; const HELPERS = window.loadCardHelpers(); export class AirVisualCardEditor extends LitElement { setConfig(config) { this._config = { ...config }; } static get properties() { return { hass: {}, _config: {} }; } get _air_pollution_level() { return this._config.air_pollution_level || "sensor.u_s_air_pollution_level"; } get _air_quality_index() { return this._config.air_quality_index || "sensor.u_s_air_quality_index"; } get _main_pollutant() { return this._config.main_pollutant || "sensor.u_s_main_pollutant"; } get _country() { return this._config.country || ""; } get _city() { return this._config.city || ""; } get _icons() { return this._config.icons || "/hacsfiles/air-visual-card"; } get _weather() { return this._config.weather || "weather.home"; } get _speed_unit() { return this._config.speed_unit || "mp/h"; } get _unit_of_measurement() { return this._config.unit_of_measurement || "AQI"; } get _hide_title() { return this._config.hide_title !== false; } get _hide_face() { return this._config.hide_face !== true; } get _hide_weather() { return this._config.hide_weather !== false; } // WHAT DOES THIS DO? firstUpdated() { HELPERS.then(help => { if (help.importMoreInfoControl) { help.importMoreInfoControl("fan"); } }) } render() { if (!this.hass) { return html``; } // WHAT DOES THIS DO? const entities = Object.keys(this.hass.states).filter( (eid) => eid.substr(0, eid.indexOf(".")) === "sensor" ); return html`