diff --git a/README.md b/README.md index 93bef44..09970f5 100644 --- a/README.md +++ b/README.md @@ -29,26 +29,30 @@ Erstelle als nächstes ein hpsu-dashboard-card als ein Fullscreen - **Panel** mi cards: - type: custom:hpsu-dashboard-card entities: - t_aussen_1: sensor.rotex_aussentemperatur - t_aussen_2: sensor.rotex_t_aussen - expansions_ventil: sensor.rotex_expansionsventil - kondensat: sensor.rotex_temperatur_fl_ssigkeitsleitung - umwaelzpumpe: sensor.rotex_umwaelzpumpe - umwaelzpumpe_an_aus: binary_sensor.rotex_status_kesselpumpe - durchfluss: sensor.rotex_durchfluss - ruecklauf_1: sensor.rotex_ruecklauftemperatur_heizung - ruecklauf_2: sensor.rotex_r_cklauftemperatur - verdampfer: sensor.rotex_lamellenw_rmetauscher_temperatur - vorlauf_1: sensor.rotex_heizkreis_vorlauf_tv - vorlauf_2: sensor.rotex_vorlauftemeratur_tv - vorlauf_soll: sensor.rotex_vorlauf_soll - wasserdruck: sensor.rotex_wasserdruck - vorlauf_bh_1: sensor.rotex_vorlauftemperatur_heizung_tvbh - vorlauf_bh_2: sensor.rotex_vorlauftemeratur_tvbh - kompressor_an_aus: binary_sensor.rotex_status_kompressor - luefter: sensor.rotex_ventilatordrehzahl - verdichter: sensor.rotex_kompressor_drehzahl - speicher: sensor.rotex_warmwassertemperatur - speicher_soll: select.rotex_t_ww_soll1 - mischer: sensor.rotex_dhw_mischer_position - bypass: sensor.rotex_bpv + aussen_temperatur: sensor.hpsu_can_aussentemperatur + t_aussen: sensor.hpsu_can_t_aussen + expansions_ventil: sensor.hpsu_uart_expansionsventil + kondensat: sensor.hpsu_uart_temperatur_fl_ssigkeitsleitung + umwaelzpumpe: sensor.hpsu_can_umwaelzpumpe + umwaelzpumpe_an_aus: binary_sensor.hpsu_can_status_kesselpumpe + durchfluss: sensor.hpsu_can_durchfluss + ruecklauf_1: sensor.hpsu_can_ruecklauftemperatur_heizung + ruecklauf_2: sensor.hpsu_uart_r_cklauftemperatur + verdampfer: sensor.hpsu_uart_lamellenw_rmetauscher_temperatur + vorlauf_1: sensor.hpsu_can_heizkreis_vorlauf_tv + vorlauf_2: sensor.hpsu_uart_vorlauftemeratur_tv + vorlauf_soll: sensor.hpsu_can_vorlauf_soll + wasserdruck: sensor.hpsu_can_wasserdruck + vorlauf_bh_1: sensor.hpsu_can_vorlauftemperatur_heizung_tvbh + vorlauf_bh_2: sensor.hpsu_uart_vorlauftemeratur_tvbh + kompressor_an_aus: binary_sensor.hpsu_can_status_kompressor + luefter: sensor.hpsu_uart_ventilatordrehzahl + verdichter: sensor.hpsu_uart_kompressor_drehzahl + speicher: sensor.hpsu_can_warmwassertemperatur + speicher_soll: select.hpsu_can_t_ww_soll1 + mischer: sensor.hpsu_can_dhw_mischer_position + bypass: sensor.hpsu_can_bpv + betriebsmodus: select.hpsu_can_betriebsmodus + thermische_leistung: sensor.hpsu_can_thermische_leistung + betriebsart: sensor.hpsu_can_betriebsart + diff --git a/dist/hpsu-dashboard-card-editor.js b/dist/hpsu-dashboard-card-editor.js deleted file mode 100644 index a505d39..0000000 --- a/dist/hpsu-dashboard-card-editor.js +++ /dev/null @@ -1,136 +0,0 @@ -//import { LitElement, html, css } from "lit"; -import { LitElement, html, css } from "https://unpkg.com/lit-element@2.0.1/lit-element.js?module"; - -class HpsuDashboardCardEditor extends LitElement { - - static get properties() { - return { - config: { type: Object }, - entities: { type: Array } - }; - } - - constructor() { - super(); - this.entities = []; // Initialisiere das Array für die Entities - } - - async setConfig(config) { - const cardHelpers = await window.loadCardHelpers(); - const entitiesCard = await cardHelpers.createCardElement({ type: "entities", entities: [] }); - - // Lade den Editor über die statische Methode getConfigElement - const editorElement = entitiesCard.constructor.getConfigElement(); - - this.entities_configuration = await this.loadModule(); - this.entities_configuration = this.entities_configuration.map( - (entity) => { - entity.entityId = config.entities[entity.id]; - return entity; - } - ); - this.config = config; - - // Füge den Editor dem DOM hinzu - //this.shadowRoot.appendChild(editorElement); - } - - render() { - if (!this.config) return html``; - - return html` - ${this.entities_configuration.map( - (entity) => { - return html` - ${(entity.category) ? html`

${entity.category}

` : ""} - `; - } - )} - `; - } - - _entityChanged(event) { - event.stopPropagation(); - - const entityId = event.target.getAttribute("data-id"); - this.config.entities[entityId] = event.detail.value; - this.dispatchEvent(new CustomEvent('config-changed', { detail: { config: this.config } })); - } - - static get styles() { - return css` - .card-config { - display: flex; - flex-direction: column; - padding: 16px; - } - h2 { - font-size: 20px; - margin-bottom: 16px; - } - paper-input { - margin-bottom: 16px; /* Abstand zwischen den Eingabefeldern */ - } - `; - } - - isNumeric(value) { - return /^-?\d+$/.test(value); - } - - makeURL(filename) { - const scriptUrl = import.meta.url; - const urlParams = new URLSearchParams(scriptUrl.split('?')[1]); - const hacsTag = urlParams.get('hacstag'); - - console.log("hacsTag: " + hacsTag); - console.log("isNumeric: " + this.isNumeric(hacsTag)); - - const url = this.isNumeric(hacsTag) ? `/hacsfiles/daikin-rotex-hpsu-dashboard/${filename}?${hacsTag}`: - `/local/daikin-rotex-hpsu-dashboard/${filename}?${new Date().getTime()}`; - console.log(url); - return url; - } - - async loadModule() { - console.log(">> loadModule"); - try { - const url = this.makeURL("modules.js"); - const module = await import(url); - return module.entities_configuration; - } catch (error) { - console.error("Modul konnte nicht geladen werden:", error); - } - } - - getKyeByValue(map, searchValue) { - for (let [key, value] of map.entries()) { - if (value === searchValue) { - return key; - } - } - return null; - } -} - -customElements.define('hpsu-dashboard-card-editor', HpsuDashboardCardEditor); - -window.customCards = window.customCards || []; -window.customCards.push({ - type: 'hpsu-dashboard-card', - name: 'HPSU Dashboard Card', - description: 'Eine Karte für das HPSU Dashboard.', - editor: 'hpsu-dashboard-card-editor' -}); diff --git a/dist/hpsu-dashboard-card.js b/dist/hpsu-dashboard-card.js index 206bc17..021f33e 100644 --- a/dist/hpsu-dashboard-card.js +++ b/dist/hpsu-dashboard-card.js @@ -1,3 +1,40 @@ +//import { LitElement, html, css } from "lit"; +import { LitElement, html, css } from "https://unpkg.com/lit-element@2.0.1/lit-element.js?module"; + + +const entities_configuration = [ + { id: "aussen_temperatur", label: "Außentemperatur", type: "sensor", rectId: "aussentemp_val", offset: 6, category: "Reihe 1", unit: "°C" }, + { id: "t_aussen", label: "T-Außen", type: "sensor", rectId: "taussen_val", offset: 6, unit: "°C" }, + { id: "expansions_ventil", label: "Elektonisches Expansionsventil", type: "sensor", rectId: "eev_val", offset: 6, unit: "%" }, + { id: "kondensat", label: "Kondensat", type: "sensor", rectId: "Kondensat-Value", offset: 6, unit: "°C" }, + { id: "umwaelzpumpe", label: "Umwälzpumpe", type: "sensor", rectId: "Umwaelzpumpe-Value", offset: 6, unit: "%" }, + { id: "umwaelzpumpe_an_aus", label: "Status Umwälzpumpe", type: "binary_sensor", rectId: "circ_pump_rect", offset: 2, fontSize: "30px" }, + { id: "durchfluss", label: "Durchfluss", type: "sensor", rectId: "Durchfluss-Value", offset: 6 }, + { id: "ruecklauf_1", label: "Rücklauf CAN", type: "sensor", rectId: "Ruecklauf-1-Value", offset: 6, unit: "°C" }, + { id: "ruecklauf_2", label: "Rücklauf UART", type: "sensor", rectId: "Ruecklauf-2-Value", offset: 6, unit: "°C" }, + { id: "verdampfer", label: "Verdampfer", type: "sensor", rectId: "Verdampfer-Value", offset: 6, category: "Reihe 2", unit: "°C" }, + { id: "vorlauf_1", label: "Vorlauf CAN", type: "sensor", rectId: "Vorlauf-1-Value", offset: 6, unit: "°C" }, + { id: "vorlauf_2", label: "Vorlauf UART", type: "sensor", rectId: "Vorlauf-2-Value", offset: 6, unit: "°C" }, + { id: "vorlauf_soll", label: "Vorlauf Soll", type: "sensor", rectId: "Vorlauf-Soll-Value", offset: 6, unit: "°C" }, + { id: "wasserdruck", label: "Wasserdruck", type: "sensor", rectId: "Druck-Value", offset: 6 }, + { id: "vorlauf_bh_1", label: "VorlaufBH CAN", type: "sensor", rectId: "Vorlauf-BH-1-Value", offset: 6, unit: "°C" }, + { id: "vorlauf_bh_2", label: "VorlaufBH UART", type: "sensor", rectId: "Vorlauf-BH-2-Value", offset: 6, unit: "°C" }, + { id: "kompressor_an_aus", label: "Status Kompressor", type: "binary_sensor", rectId: "comp_rect", offset: 2, fontSize: "40px" }, + { id: "luefter", label: "Lüfter", type: "sensor", rectId: "Luefter-Value", offset: 6, category: "Reihe 3", unit: "RPM" }, + { id: "verdichter", label: "Verdichter", type: "sensor", rectId: "Verdichter-Value", offset: 6, unit: "RPM" }, + { id: "speicher", label: "Speicher Ist", type: "sensor", rectId: "Speicher-Value", offset: 6, unit: "°C" }, + { id: "speicher_soll", label: "Speicher Soll", type: "select", rectId: "Speicher-Soll-Value", offset: 6, unit: "°C" }, + { id: "mischer", label: "Mischer", type: "sensor", rectId: "DHW-Mixer-Value", offset: 6, unit: "%", fontSize: "40px" }, + { id: "bypass", label: "Bypass", type: "sensor", rectId: "Bypass-Value", offset: 6, unit: "%", fontSize: "40px" }, + { id: "betriebsmodus", label: "Betriebsmodus", type: "select", rectId: "info_1", offset: 6, fontSize: "40px", align: "left", "suffix": "Modus: " }, + { id: "betriebsart", label: "Betriebsart", type: "text_sensor", rectId: "info_2", offset: 6, fontSize: "40px", align: "left", "suffix": "Betriebsart: " }, + { id: "thermische_leistung", label: "Thermische Leistung", type: "sensor", rectId: "info_3", offset: 6, fontSize: "40px", align: "left", "suffix": "Therm. Leistung: " } +]; + +////////////////////////////////////////////////////////////////// +/////////////////////// HPSUDashboardCard //////////////////////// +////////////////////////////////////////////////////////////////// + class HPSUDashboardCard extends HTMLElement { inititialized = false; @@ -7,7 +44,7 @@ class HPSUDashboardCard extends HTMLElement { throw new Error("Required entities field is missing"); } - this.entities_configuration = await this.loadModule(); + this.entities_configuration = entities_configuration; this.entities_configuration = this.entities_configuration.map( (entity) => { entity.entityId = config.entities[entity.id]; @@ -312,17 +349,115 @@ class HPSUDashboardCard extends HTMLElement { console.log(url); return url; } +} + +////////////////////////////////////////////////////////////////// +//////////////////// HpsuDashboardCardEditor ///////////////////// +////////////////////////////////////////////////////////////////// + +class HpsuDashboardCardEditor extends LitElement { + + static get properties() { + return { + config: { type: Object }, + entities: { type: Array } + }; + } + + constructor() { + super(); + this.entities = []; // Initialisiere das Array für die Entities + } + + async setConfig(config) { + const cardHelpers = await window.loadCardHelpers(); + const entitiesCard = await cardHelpers.createCardElement({ type: "entities", entities: [] }); + + // Lade den Editor über die statische Methode getConfigElement + const editorElement = entitiesCard.constructor.getConfigElement(); + + this.entities_configuration = entities_configuration; + this.entities_configuration = this.entities_configuration.map( + (entity) => { + entity.entityId = config.entities[entity.id]; + return entity; + } + ); + this.config = config; - async loadModule() { - console.log(">> loadModule"); - try { - const url = this.makeURL("modules.js"); - const module = await import(url); - return module.entities_configuration; - } catch (error) { - console.error("Modul konnte nicht geladen werden:", error); + // Füge den Editor dem DOM hinzu + //this.shadowRoot.appendChild(editorElement); + } + + render() { + if (!this.config) return html``; + + return html` + ${this.entities_configuration.map( + (entity) => { + return html` + ${(entity.category) ? html`

${entity.category}

` : ""} + `; + } + )} + `; + } + + _entityChanged(event) { + event.stopPropagation(); + + const entityId = event.target.getAttribute("data-id"); + this.config.entities[entityId] = event.detail.value; + this.dispatchEvent(new CustomEvent('config-changed', { detail: { config: this.config } })); + } + + static get styles() { + return css` + .card-config { + display: flex; + flex-direction: column; + padding: 16px; + } + h2 { + font-size: 20px; + margin-bottom: 16px; + } + paper-input { + margin-bottom: 16px; /* Abstand zwischen den Eingabefeldern */ + } + `; + } + + getKyeByValue(map, searchValue) { + for (let [key, value] of map.entries()) { + if (value === searchValue) { + return key; + } } + return null; } } -customElements.define("hpsu-dashboard-card", HPSUDashboardCard); \ No newline at end of file + +customElements.define("hpsu-dashboard-card", HPSUDashboardCard); +customElements.define('hpsu-dashboard-card-editor', HpsuDashboardCardEditor); + +window.customCards = window.customCards || []; +window.customCards.push({ + type: 'hpsu-dashboard-card', + name: 'HPSU Dashboard Card', + description: 'Eine Karte für das HPSU Dashboard.', + editor: 'hpsu-dashboard-card-editor' +}); diff --git a/dist/modules.js b/dist/modules.js deleted file mode 100644 index ab888cd..0000000 --- a/dist/modules.js +++ /dev/null @@ -1,32 +0,0 @@ -export const entities_configuration = [ - { id: "t_aussen_1", label: "Außentemperatur", type: "sensor", rectId: "aussentemp_val", offset: 6, category: "Reihe 1", unit: "°C" }, - { id: "t_aussen_2", label: "T-Außen", type: "sensor", rectId: "taussen_val", offset: 6, unit: "°C" }, - { id: "expansions_ventil", label: "Elektonisches Expansionsventil", type: "sensor", rectId: "eev_val", offset: 6, unit: "%" }, - { id: "kondensat", label: "Kondensat", type: "sensor", rectId: "Kondensat-Value", offset: 6, unit: "°C" }, - { id: "umwaelzpumpe", label: "Umwälzpumpe", type: "sensor", rectId: "Umwaelzpumpe-Value", offset: 6, unit: "%" }, - { id: "umwaelzpumpe_an_aus", label: "Status Umwälzpumpe", type: "binary_sensor", rectId: "circ_pump_rect", offset: 2, fontSize: "30px" }, - { id: "durchfluss", label: "Durchfluss", type: "sensor", rectId: "Durchfluss-Value", offset: 6 }, - { id: "ruecklauf_1", label: "Rücklauf CAN", type: "sensor", rectId: "Ruecklauf-1-Value", offset: 6, unit: "°C" }, - { id: "ruecklauf_2", label: "Rücklauf UART", type: "sensor", rectId: "Ruecklauf-2-Value", offset: 6, unit: "°C" }, - { id: "verdampfer", label: "Verdampfer", type: "sensor", rectId: "Verdampfer-Value", offset: 6, category: "Reihe 2", unit: "°C" }, - { id: "vorlauf_1", label: "Vorlauf CAN", type: "sensor", rectId: "Vorlauf-1-Value", offset: 6, unit: "°C" }, - { id: "vorlauf_2", label: "Vorlauf UART", type: "sensor", rectId: "Vorlauf-2-Value", offset: 6, unit: "°C" }, - { id: "vorlauf_soll", label: "Vorlauf Soll", type: "sensor", rectId: "Vorlauf-Soll-Value", offset: 6, unit: "°C" }, - { id: "wasserdruck", label: "Wasserdruck", type: "sensor", rectId: "Druck-Value", offset: 6 }, - { id: "vorlauf_bh_1", label: "VorlaufBH CAN", type: "sensor", rectId: "Vorlauf-BH-1-Value", offset: 6, unit: "°C" }, - { id: "vorlauf_bh_2", label: "VorlaufBH UART", type: "sensor", rectId: "Vorlauf-BH-2-Value", offset: 6, unit: "°C" }, - { id: "kompressor_an_aus", label: "Status Kompressor", type: "binary_sensor", rectId: "comp_rect", offset: 2, fontSize: "40px" }, - { id: "luefter", label: "Lüfter", type: "sensor", rectId: "Luefter-Value", offset: 6, category: "Reihe 3", unit: "RPM" }, - { id: "verdichter", label: "Verdichter", type: "sensor", rectId: "Verdichter-Value", offset: 6, unit: "RPM" }, - { id: "speicher", label: "Speicher Ist", type: "sensor", rectId: "Speicher-Value", offset: 6, unit: "°C" }, - { id: "speicher_soll", label: "Speicher Soll", type: "select", rectId: "Speicher-Soll-Value", offset: 6, unit: "°C" }, - { id: "mischer", label: "Mischer", type: "sensor", rectId: "DHW-Mixer-Value", offset: 6, unit: "%", fontSize: "40px" }, - { id: "bypass", label: "Bypass", type: "sensor", rectId: "Bypass-Value", offset: 6, unit: "%", fontSize: "40px" }, - { id: "betriebsmodus", label: "Betriebsmodus", type: "select", rectId: "info_1", offset: 6, fontSize: "40px", align: "left", "suffix": "Modus: " }, - { id: "betriebsart", label: "Betriebsart", type: "text_sensor", rectId: "info_2", offset: 6, fontSize: "40px", align: "left", "suffix": "Betriebsart: " }, - { id: "thermische_leistung", label: "Thermische Leistung", type: "sensor", rectId: "info_3", offset: 6, fontSize: "40px", align: "left", "suffix": "Therm. Leistung: " } -]; - -function getConfig() { - return "config"; -} \ No newline at end of file diff --git a/hacs.json b/hacs.json index 51c26af..a9a52f4 100644 --- a/hacs.json +++ b/hacs.json @@ -2,14 +2,8 @@ "name": "Daikin/Rotext - HPSU Dashboard", "render_readme": true, "filename": "hpsu-dashboard-card.js", - "extra_module": [ - "hpsu-dashboard-card-editor.js", - "modules.js" - ], "resources": [ - "/hacsfiles/daikin-rotex-hpsu-dashboard/hpsu-dashboard-card.js", - "/hacsfiles/daikin-rotex-hpsu-dashboard/hpsu-dashboard-card-editor.js", - "/hacsfiles/daikin-rotex-hpsu-dashboard/modules.js" + "/hacsfiles/daikin-rotex-hpsu-dashboard/hpsu-dashboard-card.js" ], "content_in_root": false } \ No newline at end of file