Hallo,
für die Feiertage hatte ich mir vorgenommen, mal ein eigenes Widget für die PV Visualisierung zu schreiben. Genauer der Energiefluss. Leider scheitert es bei mir an der Verbindung zwischen "Standard HTML / SVG" und smartVISU. Ach ja, die Idee habe ich aus dem SMA Portal.
Ich weiß auch, dass es schon Versuche gibt, aber wie es so ist, hat man eigene Vorstellungen.
Vielleicht könnte Ihr mir auf dem Weg helfen die technischen Hürden zu lösen.
Zum Vorgehen. Ich habe ein großes SVG für die fünf Mitspieler: PV, Grid, Home, Vehicle und Battery. Es gibt Energyfluss zwischen fast allen Elementen:
grafik.png
(Hier nur Screenshot, SVG wollte er nicht hochladen. Die Schwarzen Boxen werden durch Icon ersetzt)
Darüber habe ich jetzt zum Testen vier Eingabefelder für die momentaten Leistungswerte. Bei Buttonklick schalte ich per jQuery die Sichtbarkeiten der Pfeile.
(Der Code ich leider schon länger, als HTML abspeichern reicht aber zum ausführen)
=> Wie kriege ich das jetzt mit den Items für die Werte verbunden, geupdated und als Teil von smartVisu bei mir verteilt?
für die Feiertage hatte ich mir vorgenommen, mal ein eigenes Widget für die PV Visualisierung zu schreiben. Genauer der Energiefluss. Leider scheitert es bei mir an der Verbindung zwischen "Standard HTML / SVG" und smartVISU. Ach ja, die Idee habe ich aus dem SMA Portal.
Ich weiß auch, dass es schon Versuche gibt, aber wie es so ist, hat man eigene Vorstellungen.
Vielleicht könnte Ihr mir auf dem Weg helfen die technischen Hürden zu lösen.
Zum Vorgehen. Ich habe ein großes SVG für die fünf Mitspieler: PV, Grid, Home, Vehicle und Battery. Es gibt Energyfluss zwischen fast allen Elementen:
grafik.png
(Hier nur Screenshot, SVG wollte er nicht hochladen. Die Schwarzen Boxen werden durch Icon ersetzt)
Darüber habe ich jetzt zum Testen vier Eingabefelder für die momentaten Leistungswerte. Bei Buttonklick schalte ich per jQuery die Sichtbarkeiten der Pfeile.
(Der Code ich leider schon länger, als HTML abspeichern reicht aber zum ausführen)
=> Wie kriege ich das jetzt mit den Items für die Werte verbunden, geupdated und als Teil von smartVisu bei mir verteilt?
HTML-Code:
<html> <body> <label>PV</label> <input type="number" id="pv" name="pv"><br><br> <label>Grid</label> <input type="number" id="grid" name="grid"><br><br> <label>Vehicle</label> <input type="number" id="vehicle" name="vehicle"><br><br> <label>Battery</label> <input type="number" id="battery" name="battery"><br><br> <button onclick="myFunction()">Click me</button> <svg width="500" height="500" xmlns="http://www.w3.org/2000/svg"> <defs> <path id="pathPvToGrid" d="M212.5,110 v80 a20,20 0 0 1 -20,20 h-82.5"/> <linearGradient id="pathPvToGridColor" x1="100%" y1="0%" x2="0%" y2="100%"> <stop offset="0" stop-color="orange" /> <stop offset="1" stop-color="#00aa00" /> </linearGradient> <path id="pathPvToHome" d="M237.5,110 v100 a20,20 0 0 1 -20,20 h-22.5 a20,20 0 0 0 -20, 20 v140"/> <linearGradient id="pathPvToHomeColor" x1="0%" y1="0%" x2="0%" y2="100%"> <stop offset="0" stop-color="orange" /> <stop offset="1" stop-color="black" /> </linearGradient> <path id="pathPvToVehicle" d="M262.5,110 v100 a20,20 0 0 0 20,20 h22.5 a20,20 0 0 1 20, 20 v140"/> <linearGradient id="pathPvToVehicleColor" x1="0%" y1="0%" x2="0%" y2="100%"> <stop offset="0" stop-color="orange" /> <stop offset="1" stop-color="#cccccc" /> </linearGradient> <path id="pathPvToBattery" d="M287.5,110 v82.5 a20,20 0 0 0 20,20 h82.5"/> <linearGradient id="pathPvToBatteryColor" x1="0%" y1="0%" x2="100%" y2="100%"> <stop offset="0" stop-color="orange" /> <stop offset="1" stop-color="#00ffff" /> </linearGradient> <path id="pathGridToBattery" d="M110,230 L390,230.002"/> <linearGradient id="pathGridToBatteryColor" x1="0%" y1="0%" x2="100%" y2="0%"> <stop offset="0" stop-color="red" /> <stop offset="1" stop-color="#00ffff" /> </linearGradient> <path id="pathBatteryToGrid" d="M390,250 L110,250.002"/> <linearGradient id="pathBatteryToGridColor" x1="100%" y1="0%" x2="0%" y2="0%"> <stop offset="0" stop-color="#ffff00" /> <stop offset="1" stop-color="#00aa00" /> </linearGradient> <path id="pathGridToHome" d="M110,290 h11.667 a20,20 0 0 1 20,20 v80"/> <linearGradient id="pathGridToHomeColor" x1="0%" y1="0%" x2="100%" y2="100%"> <stop offset="0" stop-color="red" /> <stop offset="1" stop-color="black" /> </linearGradient> <path id="pathGridToVehicle" d="M110,270 h161.667 a20,20 0 0 1 20,20 v100"/> <linearGradient id="pathGridToVehicleColor" x1="0%" y1="0%" x2="100%" y2="100%"> <stop offset="0" stop-color="red" /> <stop offset="1" stop-color="#cccccc" /> </linearGradient> <path id="pathBatteryToHome" d="M390,270 h-161.667 a20,20 0 0 0 -20,20 v100"/> <linearGradient id="pathBatteryToHomeColor" x1="100%" y1="0%" x2="0%" y2="100%"> <stop offset="0" stop-color="#ffff00" /> <stop offset="1" stop-color="black" /> </linearGradient> <path id="pathBatteryToVehicle" d="M390,290 h-11.667 a20,20 0 0 0 -20,20 v80"/> <linearGradient id="pathBatteryToVehicleColor" x1="100%" y1="0%" x2="0%" y2="100%"> <stop offset="0" stop-color="#ffff00" /> <stop offset="1" stop-color="#cccccc" /> </linearGradient> <marker id="arrowGrid" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="5" markerHeight="5" orient="auto"> <path d="M 0 0 L 10 5 L 0 10" stroke="#00aa00" fill="transparent" stroke-width="2" /> </marker> <marker id="arrowHome" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="5" markerHeight="5" orient="auto"> <path d="M 0 0 L 10 5 L 0 10" stroke="black" fill="transparent" stroke-width="2" /> </marker> <marker id="arrowVehicle" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="5" markerHeight="5" orient="auto"> <path d="M 0 0 L 10 5 L 0 10" stroke="#cccccc" fill="transparent" stroke-width="2" /> </marker> <marker id="arrowBattery" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="5" markerHeight="5" orient="auto"> <path d="M 0 0 L 10 5 L 0 10" stroke="#00ffff" fill="transparent" stroke-width="2" /> </marker> </defs> <rect x="0" y="0" width="500" height="500" fill="#666" /> <rect x="200" y="0" width="100" height="100"/> <rect x="0" y="200" width="100" height="100"/> <rect x="400" y="200" width="100" height="100"/> <rect x="125" y="400" width="100" height="100"/> <rect x="275" y="400" width="100" height="100"/> <g id="pvToGrid"> <use href="#pathPvToGrid" fill="none" stroke="url('#pathPvToGridColor')" stroke-width="2" marker-end='url(#arrowGrid)'/> <circle cx="0" cy="0" r="5"> <animateMotion begin="0s" dur="3s" repeatCount="indefinite" > <mpath href="#pathPvToGrid"/> </animateMotion> <animate attributeName="fill" from="orange" to="#00aa00" dur="3s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="4"> <animateMotion begin="0.25s" dur="3s" repeatCount="indefinite" > <mpath href="#pathPvToGrid"/> </animateMotion> <animate attributeName="fill" from="orange" to="#00aa00" begin="0.25s" dur="3s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="3"> <animateMotion begin="0.5s" dur="3s" repeatCount="indefinite" > <mpath href="#pathPvToGrid"/> </animateMotion> <animate attributeName="fill" from="orange" to="#00aa00" begin="0.5s" dur="3s" repeatCount="indefinite" /> </circle> </g> <g id="pvToHome"> <use href="#pathPvToHome" fill="none" stroke="url('#pathPvToHomeColor')" stroke-width="2" marker-end='url(#arrowHome)'/> <circle cx="0" cy="0" r="5"> <animateMotion begin="0s" dur="5s" repeatCount="indefinite" > <mpath href="#pathPvToHome"/> </animateMotion> <animate attributeName="fill" from="orange" to="black" dur="5s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="4"> <animateMotion begin="0.25s" dur="5s" repeatCount="indefinite" > <mpath href="#pathPvToHome"/> </animateMotion> <animate attributeName="fill" from="orange" to="black" begin="0.25s" dur="5s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="3"> <animateMotion begin="0.5s" dur="5s" repeatCount="indefinite" > <mpath href="#pathPvToHome"/> </animateMotion> <animate attributeName="fill" from="orange" to="black" begin="0.5s" dur="5s" repeatCount="indefinite" /> </circle> </g> <g id="pvToVehicle"> <use href="#pathPvToVehicle" fill="none" stroke="url('#pathPvToVehicleColor')" stroke-width="2" marker-end='url(#arrowVehicle)'/> <circle cx="0" cy="0" r="5"> <animateMotion begin="0s" dur="5s" repeatCount="indefinite" > <mpath href="#pathPvToVehicle"/> </animateMotion> <animate attributeName="fill" from="orange" to="#cccccc" dur="5s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="4"> <animateMotion begin="0.25s" dur="5s" repeatCount="indefinite" > <mpath href="#pathPvToVehicle"/> </animateMotion> <animate attributeName="fill" from="orange" to="#cccccc" begin="0.25s" dur="5s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="3"> <animateMotion begin="0.5s" dur="5s" repeatCount="indefinite" > <mpath href="#pathPvToVehicle"/> </animateMotion> <animate attributeName="fill" from="orange" to="#cccccc" begin="0.5s" dur="5s" repeatCount="indefinite" /> </circle> </g> <g id="pvToBattery"> <use href="#pathPvToBattery" fill="none" stroke="url('#pathPvToBatteryColor')" stroke-width="2" marker-end='url(#arrowBattery)'/> <circle cx="0" cy="0" r="5"> <animateMotion begin="0s" dur="3s" repeatCount="indefinite" > <mpath href="#pathPvToBattery"/> </animateMotion> <animate attributeName="fill" from="orange" to="#00ffff" dur="3s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="4"> <animateMotion begin="0.25s" dur="3s" repeatCount="indefinite" > <mpath href="#pathPvToBattery"/> </animateMotion> <animate attributeName="fill" from="orange" to="#00ffff" begin="0.25s" dur="3s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="3"> <animateMotion begin="0.5s" dur="3s" repeatCount="indefinite" > <mpath href="#pathPvToBattery"/> </animateMotion> <animate attributeName="fill" from="orange" to="#00ffff" begin="0.5s" dur="3s" repeatCount="indefinite" /> </circle> </g> <g id="gridToBattery"> <use href="#pathGridToBattery" fill="none" stroke="url(#pathGridToBatteryColor)" stroke-width="2" marker-end='url(#arrowBattery)'/> <circle cx="0" cy="0" r="5"> <animateMotion begin="0s" dur="4s" repeatCount="indefinite" > <mpath href="#pathGridToBattery"/> </animateMotion> <animate attributeName="fill" from="red" to="#00ffff" dur="4s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="4"> <animateMotion begin="0.25s" dur="4s" repeatCount="indefinite" > <mpath href="#pathGridToBattery"/> </animateMotion> <animate attributeName="fill" from="red" to="#00ffff" begin="0.25s" dur="4s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="3"> <animateMotion begin="0.5s" dur="4s" repeatCount="indefinite" > <mpath href="#pathGridToBattery"/> </animateMotion> <animate attributeName="fill" from="red" to="#00ffff" begin="0.5s" dur="4s" repeatCount="indefinite" /> </circle> </g> <g id="batteryToGrid"> <use href="#pathBatteryToGrid" fill="none" stroke="url(#pathBatteryToGridColor)" stroke-width="2" marker-end='url(#arrowGrid)'/> <circle cx="0" cy="0" r="5"> <animateMotion begin="0s" dur="4s" repeatCount="indefinite" > <mpath href="#pathBatteryToGrid"/> </animateMotion> <animate attributeName="fill" from="#ffff00" to="#00aa00" dur="4s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="4"> <animateMotion begin="0.25s" dur="4s" repeatCount="indefinite" > <mpath href="#pathBatteryToGrid"/> </animateMotion> <animate attributeName="fill" from="#ffff00" to="#00aa00" begin="0.25s" dur="4s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="3"> <animateMotion begin="0.5s" dur="4s" repeatCount="indefinite" > <mpath href="#pathBatteryToGrid"/> </animateMotion> <animate attributeName="fill" from="#ffff00" to="#00aa00" begin="0.5s" dur="4s" repeatCount="indefinite" /> </circle> </g> <g id="gridToHome"> <use href="#pathGridToHome" fill="none" stroke="url(#pathGridToHomeColor)" stroke-width="2" marker-end='url(#arrowHome)'/> <circle cx="0" cy="0" r="5"> <animateMotion begin="0s" dur="2s" repeatCount="indefinite" > <mpath href="#pathGridToHome"/> </animateMotion> <animate attributeName="fill" from="red" to="black" dur="2s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="4"> <animateMotion begin="0.25s" dur="2s" repeatCount="indefinite" > <mpath href="#pathGridToHome"/> </animateMotion> <animate attributeName="fill" from="red" to="black" begin="0.25s" dur="2s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="3"> <animateMotion begin="0.5s" dur="2s" repeatCount="indefinite" > <mpath href="#pathGridToHome"/> </animateMotion> <animate attributeName="fill" from="red" to="black" begin="0.5s" dur="2s" repeatCount="indefinite" /> </circle> </g> <g id="gridToVehicle"> <use href="#pathGridToVehicle" fill="none" stroke="url(#pathGridToVehicleColor)" stroke-width="2" marker-end='url(#arrowVehicle)'/> <circle cx="0" cy="0" r="5"> <animateMotion begin="0s" dur="4s" repeatCount="indefinite" > <mpath href="#pathGridToVehicle"/> </animateMotion> <animate attributeName="fill" from="red" to="#cccccc" dur="4s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="4"> <animateMotion begin="0.25s" dur="4s" repeatCount="indefinite" > <mpath href="#pathGridToVehicle"/> </animateMotion> <animate attributeName="fill" from="red" to="#cccccc" begin="0.25s" dur="4s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="3"> <animateMotion begin="0.5s" dur="4s" repeatCount="indefinite" > <mpath href="#pathGridToVehicle"/> </animateMotion> <animate attributeName="fill" from="red" to="#cccccc" begin="0.5s" dur="4s" repeatCount="indefinite" /> </circle> </g> <g id="batteryToHome"> <use href="#pathBatteryToHome" fill="none" stroke="url(#pathBatteryToHomeColor)" stroke-width="2" marker-end='url(#arrowHome)'/> <circle cx="0" cy="0" r="5"> <animateMotion begin="0s" dur="4s" repeatCount="indefinite" > <mpath href="#pathBatteryToHome"/> </animateMotion> <animate attributeName="fill" from="#ffff00" to="black" dur="4s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="4"> <animateMotion begin="0.25s" dur="4s" repeatCount="indefinite" > <mpath href="#pathBatteryToHome"/> </animateMotion> <animate attributeName="fill" from="#ffff00" to="black" begin="0.25s" dur="4s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="3"> <animateMotion begin="0.5s" dur="4s" repeatCount="indefinite" > <mpath href="#pathBatteryToHome"/> </animateMotion> <animate attributeName="fill" from="#ffff00" to="black" begin="0.5s" dur="4s" repeatCount="indefinite" /> </circle> </g> <g id="batteryToVehicle"> <use href="#pathBatteryToVehicle" fill="none" stroke="url(#pathBatteryToVehicleColor)" stroke-width="2" marker-end='url(#arrowVehicle)'/> <circle cx="0" cy="0" r="5"> <animateMotion begin="0s" dur="2s" repeatCount="indefinite" > <mpath href="#pathBatteryToVehicle"/> </animateMotion> <animate attributeName="fill" from="#ffff00" to="#cccccc" dur="2s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="4"> <animateMotion begin="0.25s" dur="2s" repeatCount="indefinite" > <mpath href="#pathBatteryToVehicle"/> </animateMotion> <animate attributeName="fill" from="#ffff00" to="#cccccc" begin="0.25s" dur="2s" repeatCount="indefinite" /> </circle> <circle cx="0" cy="0" r="3"> <animateMotion begin="0.5s" dur="2s" repeatCount="indefinite" > <mpath href="#pathBatteryToVehicle"/> </animateMotion> <animate attributeName="fill" from="#ffff00" to="#cccccc" begin="0.5s" dur="2s" repeatCount="indefinite" /> </circle> </g> </svg> </body> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> function myFunction() { let pv = $("#pv").val(); let grid = $("#grid").val(); let vehicle = $("#vehicle").val(); let battery = $("#battery").val(); update(pv, grid, vehicle, battery); }; function update(pv, grid, vehicle, battery) { let home = - pv - grid - vehicle - battery; $('#pvToGrid').toggle(pv > 0 && grid < 0); $('#pvToHome').toggle(pv > 0 && home < 0); $('#pvToVehicle').toggle(pv > 0 && vehicle < 0); $('#pvToBattery').toggle(pv > 0 && battery < 0); $('#gridToHome').toggle(grid > 0 && home < 0); $('#gridToVehicle').toggle(grid > 0 && vehicle < 0); $('#gridToBattery').toggle(grid > 0 && battery < 0); $('#batteryToGrid').toggle(battery > 0 && grid < 0); $('#batteryToHome').toggle(battery > 0 && home < 0); $('#batteryToVehicle').toggle(battery > 0 && vehicle < 0); }; </script> </html>
Kommentar