-
-
-
☀️ Solar
-
${solarState.state}
-
-
- ${pv1State && pv1State.state
- ? html`
-
-
☀️ PV1
-
${pv1State ? pv1State.state : "N/A"}
-
-
`
- : null
- }
-
-
☀️ PV2
-
${pv2State ? pv2State.state : "N/A"}
-
-
-
-
☀️ PV3
-
${pv3State ? pv3State.state : "N/A"}
-
-
-
-
-
⚡ Haus
-
${consumptionState ? consumptionState.state : "N/A"}
-
-
-
-
- reihe 2
-
-
- `;
- }
-
- firstUpdated() {
- this._updatePolyline();
- }
- updated() {
- this._updatePolyline();
- }
- _updatePolyline() {
- // Get references to the boxes
- const solarBox = this.shadowRoot.getElementById("solar");
- const pv1Box = this.shadowRoot.getElementById("pv1");
- const pv3Box = this.shadowRoot.getElementById("pv3");
-
- // Get the SVG polyline
- const polyline1 = this.shadowRoot.getElementById("connection-line-1");
- const polyline2 = this.shadowRoot.getElementById("connection-line-2");
-
- // Function to get the center of a box
- function getBox(box) {
- const rect = box.getBoundingClientRect();
- return {
- lx: rect.left,
- ly: rect.top + rect.height / 2,
- tx: rect.left + rect.width / 2,
- ty: rect.top,
- rx: rect.right,
- ry: rect.top + rect.height / 2,
- dx: rect.left + rect.width / 2,
- dy: rect.bottom,
- };
- }
- // Get the center of the Solar and PV1 boxes
- const solarPol = getBox(solarBox);
- const pv1Pol = getBox(pv1Box);
- const pv3Pol = getBox(pv3Box);
-
- // Create the right-angle points for the polyline
- const intermediateX1 = pv1Pol.tx; // Move horizontally to the same x-coordinate as PV1
- const intermediateY1 = solarPol.ly; // Keep the y-coordinate the same as Solar
- polyline1.setAttribute("points", `${solarPol.lx},${solarPol.ly} ${intermediateX1},${intermediateY1} ${pv1Pol.tx},${pv1Pol.ty}`);
- // Set the polyline points for a 90° connection from Solar to PV1
-
- const intermediateX2 = pv3Pol.tx; // Move horizontally to the same x-coordinate as PV1
- const intermediateY2 = solarPol.ly; // Keep the y-coordinate the same as Solar
- polyline2.setAttribute("points", `${solarPol.rx},${solarPol.ry} ${intermediateX2},${intermediateY2} ${pv3Pol.tx},${pv3Pol.ty}`);
- // Set the polyline points for a 90° connection from Solar to PV1
-
- }
-}
-customElements.define('custom-energy-card', CustomEnergyCard);
-
-window.customCards = window.customCards || [];
-window.customCards.push({
- type: "custom-energy-card",
- name: "CustomEnergyCard",
- description: "Mein Testversuch!" // optional
-});
diff --git a/package-lock.json b/package-lock.json
index 301e39f..dbf7b35 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4,6 +4,9 @@
"requires": true,
"packages": {
"": {
+ "dependencies": {
+ "lit": "^3.2.1"
+ },
"devDependencies": {
"parcel": "^2.13.2"
}
@@ -50,6 +53,21 @@
"@lezer/common": "^1.0.0"
}
},
+ "node_modules/@lit-labs/ssr-dom-shim": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.1.tgz",
+ "integrity": "sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@lit/reactive-element": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-2.0.4.tgz",
+ "integrity": "sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@lit-labs/ssr-dom-shim": "^1.2.0"
+ }
+ },
"node_modules/@lmdb/lmdb-darwin-arm64": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/@lmdb/lmdb-darwin-arm64/-/lmdb-darwin-arm64-2.8.5.tgz",
@@ -1953,6 +1971,12 @@
"@swc/counter": "^0.1.3"
}
},
+ "node_modules/@types/trusted-types": {
+ "version": "2.0.7",
+ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
+ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
+ "license": "MIT"
+ },
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
@@ -2775,6 +2799,37 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/lit": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/lit/-/lit-3.2.1.tgz",
+ "integrity": "sha512-1BBa1E/z0O9ye5fZprPtdqnc0BFzxIxTTOO/tQFmyC/hj1O3jL4TfmLBw0WEwjAokdLwpclkvGgDJwTIh0/22w==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@lit/reactive-element": "^2.0.4",
+ "lit-element": "^4.1.0",
+ "lit-html": "^3.2.0"
+ }
+ },
+ "node_modules/lit-element": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-4.1.1.tgz",
+ "integrity": "sha512-HO9Tkkh34QkTeUmEdNYhMT8hzLid7YlMlATSi1q4q17HE5d9mrrEHJ/o8O2D0cMi182zK1F3v7x0PWFjrhXFew==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@lit-labs/ssr-dom-shim": "^1.2.0",
+ "@lit/reactive-element": "^2.0.4",
+ "lit-html": "^3.2.0"
+ }
+ },
+ "node_modules/lit-html": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-3.2.1.tgz",
+ "integrity": "sha512-qI/3lziaPMSKsrwlxH/xMgikhQ0EGOX2ICU73Bi/YHFvz2j/yMCIrw4+puF2IpQ4+upd3EWbvnHM9+PnJn48YA==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@types/trusted-types": "^2.0.2"
+ }
+ },
"node_modules/lmdb": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/lmdb/-/lmdb-2.8.5.tgz",
diff --git a/package.json b/package.json
index 40099d2..a5be096 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,8 @@
{
"devDependencies": {
"parcel": "^2.13.2"
+ },
+ "dependencies": {
+ "lit": "^3.2.1"
}
}
diff --git a/custom-energy-card.js b/src/custom-energy-card.js
similarity index 100%
rename from custom-energy-card.js
rename to src/custom-energy-card.js