-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
173 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,40 @@ | ||
//import { LitElement, html, css } from "lit"; | ||
import { LitElement, html, css } from "https://unpkg.com/[email protected]/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`<h2>${entity.category}</h2>` : ""} | ||
<ha-entity-picker | ||
allow-custom-entity | ||
data-id=${entity.id} | ||
label=${entity.label} | ||
.value=${entity.entityId} | ||
.curValue=${entity.entityId} | ||
.hass=${this.hass} | ||
.includeDomains=${entity.type} | ||
.includeUnitOfMeasurement=${entity.unit} | ||
.disabled=false | ||
.createDomains=false | ||
@value-changed=${this._entityChanged} | ||
></ha-entity-picker>`; | ||
} | ||
)} | ||
`; | ||
} | ||
|
||
_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); | ||
|
||
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' | ||
}); |
Oops, something went wrong.