Ich hab mich mal versucht die Solaredge visualisierung aus der App in Grafana nachzubauen - vielleicht gehts hier ein paar Leuten ähnlich.
Ich habe dazu das plotly panel plugin verwendet (Achtung da gibts 3 verschiedene - nur eins funktioniert wirklich (https://grafana.com/grafana/plugins/nline-plotlyjs-panel/).
Die Werte basieren auf der gesamten Vorarbeit von @hennerich - ich habe nur den Gesamtverbrauch noch im iobroker per Skript berechnet.
Json anbei:
{
"id": 34,
"gridPos": {
"x": 12,
"y": 3,
"w": 7,
"h": 8
},
"type": "nline-plotlyjs-panel",
"title": "PV Tagesübersicht",
"datasource": {
"type": "influxdb",
"uid": "hYAYl-zRz"
},
"options": {
"data": [
{
"hoverinfo": "y",
"type": "bar"
},
{
"hoverinfo": "y",
"type": "bar"
},
{
"hoverinfo": "y",
"type": "bar"
},
{
"hoverinfo": "y",
"type": "bar"
}
],
"layout": "",
"config": "",
"script": "//let aArray = data.series[0].fields[0].values.buffer; //Timestamp von Wert 1\nlet arrayeig = data.series[0].fields[1].values.buffer; //Wert 1 zb Eigenverbrauch\n//let xArray = data.series[1].fields[0].values.buffer; //Timestamp von Wert 2\nlet arrayexp = data.series[1].fields[1].values.buffer; //Wert 2 zb Export\n\nlet arrayerz = data.series[2].fields[1].values.buffer;\n\nlet arrayimp = data.series[3].fields[1].values.buffer;\nlet arrayges = data.series[4].fields[1].values.buffer;\n\n//Letzten Wert in Datenbank herausfinden (Höchster Wert des Tages)\nlet werteig=arrayeig[arrayeig.length-1]\nwerteig = werteig.toFixed(2); //Runden auf 2 Nachkommastellen\nlet wertexp=arrayexp[arrayexp.length-1]\nwertexp = wertexp.toFixed(2); //Runden auf 2 Nachkommastellen\nlet werterz=arrayerz[arrayerz.length-1]\nwerterz = werterz.toFixed(2); //Runden auf 2 Nachkommastellen\nlet wertimp=arrayimp[arrayimp.length-1]\nwertimp = wertimp.toFixed(2); //Runden auf 2 Nachkommastellen\nlet wertges=arrayges[arrayges.length-1]\nwertges = wertges.toFixed(2); //Runden auf 2 Nachkommastellen\n\n//prozente ausrechnen und auf 2 stellen runden\nlet perceig = ((werteig/werterz)*100).toFixed(1)\nlet percexp = ((wertexp/werterz)*100).toFixed(1)\nlet percprod = ((werteig/wertges)*100).toFixed(1)\nlet percimp = ((wertimp/wertges)*100).toFixed(1)\n\n/* (debug - test)\nconsole.log(lastaItem) \nconsole.log(lastbItem)\nconsole.log(lastxItem)\nconsole.log(lastyItem)\n*/\n\n//let valueerzeugung = [werteig, wertexp, werteig ,wertimp] // Letzte Werte aus array in daten für grafik übergeben \n//let beschreibung = ['Eigenverbrauch', 'Export', \"Eigenverbrauch\", \"Import\"]\n//var ultimateColors = [ 'rgb(5, 131, 70)','rgb(32, 100, 65)','rgb(31, 96, 196)', 'rgb(242, 73, 92)']; //Farben für Eigenverbrauch/Export\n\n\nvar data = [\n/*\n {\n y: valueerzeugung,\n x: [1,1,2,2],\n //name: \"Eigenverbrauch\",\n type:'bar',\n textposition: 'auto',\n //hoverinfo: 'label+percent+value',\n //textinfo: 'percent+value',\n marker: {\n color: ultimateColors\n },\n*/ \n {\n y: [werteig],\n x: [1],\n name: \"Eigenverbrauch\",\n text: \"Eigenverbrauch \" + werteig +\" kWh \" + perceig + \"%\",\n type:'bar',\n textposition: 'auto',\n marker: {\n color: 'rgb(5, 131, 70)',\n hoverinfo: wertimp,\n showlegend: false\n }\n },\n {\n y: [wertexp],\n x: [1],\n name: \"Export\",\n text: \"Export \" + wertexp +\" kWh \" + percexp + \"%\",\n type:'bar',\n textposition: 'auto',\n marker: {\n color: 'rgb(32, 100, 65)',\n hoverinfo: wertimp,\n showlegend: false\n },\n },\n {\n y: [werteig],\n x: [2],\n name: \"PV Produktion\",\n text: \"PV \"+ werteig +\" kWh \" + percprod + \"%\",\n type:'bar',\n textposition: 'auto',\n marker: {\n color: 'rgb(31, 96, 196)',\n hoverinfo: wertimp,\n showlegend: false\n },\n },\n {\n y: [wertimp],\n x: [2],\n name: \"Import\",\n text: \"Import \" + wertimp +\" kWh \" + percimp + \"%\",\n type:'bar',\n textposition: 'auto',\n marker: {\n color: 'rgb(242, 73, 92)',\n hoverinfo: wertimp,\n showlegend: false\n },\n }\n];\n \nvar layout = {\n barmode:'stack',\n\n margin: {\"t\": 0, \"b\": 0, \"l\": 0, \"r\": 0},\n\n showlegend: false,\n //legend: {\"orientation\": \"h\"},\n\n annotations: [\n {\n font: {\n //size: 15,\n color: '#ffffff'\n },\n x: 1,\n y: -0.5,\n xref: 'x',\n yref: 'y',\n text: \"Produktion \" + werterz + \" kWh\",\n showarrow: false,\n //arrowhead: 7,\n //ax: 0,\n //ay: -40\n },\n {\n font: {\n //size: 15,\n color: '#ffffff'\n },\n x: 2,\n y: -0.5,\n xref: 'x',\n yref: 'y',\n text: \"Verbrauch \" + wertges + \" kWh\",\n showarrow: false,\n //arrowhead: 7,\n //ax: 0,\n //ay: -40\n }\n\n ],\n xaxis: {\n\n showgrid: false,\n zeroline: false,\n showline: false,\n showticklabels: false,\n //mirror: 'ticks',\n //gridcolor: '#bdbdbd',\n //gridwidth: 2,\n //zerolinecolor: '#969696',\n //zerolinewidth: 4,\n //linecolor: '#636363',\n //linewidth: 6\n\n },\n\n yaxis: {\n\n showgrid: false,\n zeroline: true,\n showline: false,\n showticklabels: false,\n //mirror: 'ticks',\n //gridcolor: '#bdbdbd',\n //gridwidth: 2,\n zerolinecolor: '#ffffff',\n //zerolinewidth: 4,\n //linecolor: '#636363',\n //linewidth: 6\n }\n\n};\n\nvar config = {responsive: true};\n\nreturn {data, layout};",
"onclick": "// console.log(data);\n// window.updateVariables({query:{'var-project':'test'}, partial: true})"
},
"targets": [
{
"alias": "Eigenverbrauch",
"datasource": {
"type": "influxdb",
"uid": "hYAYl-zRz"
},
"groupBy": [
{
"params": [
"10m"
],
"type": "time"
},
{
"params": [
"previous"
],
"type": "fill"
}
],
"measurement": "0_userdata.0.Solar_vars.PV_Eigenverbrauch",
"orderByTime": "ASC",
"policy": "default",
"query": "SELECT last(\"value\") FROM \"0_userdata.0.Solar_vars.PV_Eigenverbrauch\" WHERE $timeFilter GROUP BY time(10m) fill(previous)",
"rawQuery": false,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Export",
"datasource": {
"type": "influxdb",
"uid": "hYAYl-zRz"
},
"groupBy": [
{
"params": [
"10m"
],
"type": "time"
},
{
"params": [
"previous"
],
"type": "fill"
}
],
"hide": false,
"measurement": "0_userdata.0.Solar_vars.PV_Exportiere_Energie",
"orderByTime": "ASC",
"policy": "default",
"query": "SELECT last(\"value\") FROM \"0_userdata.0.Solar_vars.PV_Eigenverbrauch\" WHERE $timeFilter GROUP BY time(10m) fill(previous)",
"rawQuery": false,
"refId": "B",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Erzeugung",
"datasource": {
"type": "influxdb",
"uid": "hYAYl-zRz"
},
"groupBy": [
{
"params": [
"10m"
],
"type": "time"
},
{
"params": [
"previous"
],
"type": "fill"
}
],
"hide": false,
"measurement": "0_userdata.0.Solar_vars.PV_Erzeugte_Energie",
"orderByTime": "ASC",
"policy": "default",
"query": "SELECT last(\"value\") FROM \"0_userdata.0.Solar_vars.PV_Eigenverbrauch\" WHERE $timeFilter GROUP BY time(10m) fill(previous)",
"rawQuery": false,
"refId": "C",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Import",
"datasource": {
"type": "influxdb",
"uid": "hYAYl-zRz"
},
"groupBy": [
{
"params": [
"10m"
],
"type": "time"
},
{
"params": [
"previous"
],
"type": "fill"
}
],
"hide": false,
"measurement": "0_userdata.0.Solar_vars.PV_Importierte_Energie",
"orderByTime": "ASC",
"policy": "default",
"query": "SELECT last(\"value\") FROM \"0_userdata.0.Solar_vars.PV_Eigenverbrauch\" WHERE $timeFilter GROUP BY time(10m) fill(previous)",
"rawQuery": false,
"refId": "D",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Gesamt",
"datasource": {
"type": "influxdb",
"uid": "hYAYl-zRz"
},
"groupBy": [
{
"params": [
"10m"
],
"type": "time"
},
{
"params": [
"previous"
],
"type": "fill"
}
],
"hide": false,
"measurement": "0_userdata.0.Solar_vars.PV_Gesamtverbrauch",
"orderByTime": "ASC",
"policy": "default",
"query": "SELECT last(\"value\") FROM \"0_userdata.0.Solar_vars.PV_Eigenverbrauch\" WHERE $timeFilter GROUP BY time(10m) fill(previous)",
"rawQuery": false,
"refId": "E",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
]
}
Falls hier jemand ist der js wirklich kann - ich bräuchte da Hilfe um den Fehler abzufangen wenn einer der Werte noch 0 ist.