Skip to content
  • Home
  • Aktuell
  • Tags
  • 0 Ungelesen 0
  • Kategorien
  • Unreplied
  • Beliebt
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Standard: (Kein Skin)
  • Kein Skin
Einklappen
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Tester
  4. Test PV Forecast Adapter

NEWS

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    8.5k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    13
    1
    2.0k

  • Neues Video "KI im Smart Home" - ioBroker plus n8n
    BluefoxB
    Bluefox
    16
    1
    2.7k

Test PV Forecast Adapter

Geplant Angeheftet Gesperrt Verschoben Tester
forecastphotovoltaik
881 Beiträge 114 Kommentatoren 286.3k Aufrufe 108 Watching
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • DiginixD Diginix

    @Meistertr Da nun von solcast nur einmal 1 Uhr am Tag abgerufen wird, ist der Vorhersagewert für tomorrow im Laufe des Tages doch recht "veraltet". Wäre es denkbar/machbar nur diesen über den Tag verteilt noch weiter zu aktualisieren?
    Oder ändert sich da bei solcast eh nichts bis zum Beginn des eigentlichen Tages?
    Auf der solcast Seite bekomme ich über die API nur die Stundenwerte, aber habe nicht gefunden wo man den Gesamt Ertrag für heute und morgen sehen kann. Aktuell ist der Wert für morgen doch recht hoch und ich denke dass er heute im Laufe des Tages sicher schon nach unten korrigiert wäre, so denn die solcast API das hergibt.

    Edit: Habe mir eben nochmal die Werte mit der vom Adapter verwendeten URL von solcast für morgen geholt und summiert und da kommt weiterhin der selbe Wert heraus wie der von 1 Uhr heute morgen. Also wird bei solcast tomorrow im Laufe des Tages anscheinend nicht weiter verfeinert sondert bleibt über den Tag fix.

    MeistertrM Offline
    MeistertrM Offline
    Meistertr
    Developer
    schrieb am zuletzt editiert von
    #307

    @diginix schau ich mir heute mal an, ist mir auch schon aufgefallen, dass da irgendwas nicht stimmt

    DiginixD 1 Antwort Letzte Antwort
    0
    • MeistertrM Meistertr

      @diginix schau ich mir heute mal an, ist mir auch schon aufgefallen, dass da irgendwas nicht stimmt

      DiginixD Offline
      DiginixD Offline
      Diginix
      schrieb am zuletzt editiert von Diginix
      #308

      @meistertr Gestern war ab 1 Uhr die Prognose für heute 36 kWh, aber auch mit den solcast Werten von gestern Abend 20 Uhr ergab sich summiert 36 kWh für heute. Heute morgen 1 Uhr ist der Wert dann auf 26 kWh reduziert worden.
      Real erwarte ich heute keine 10 kWh. Die Prognose vom Plenticore Adapter waren gestern 7 Uhr schon nur 13 kWh für heute und heute 7 Uhr dann nur noch 8 kWh. Was auch immer @StrathCole da für wahnsinnige Formeln gebaut hat, sie passen für tomorrow deutlich besser.

      @bastian-m Mit derart daneben liegenden Vorhersagen für tomorrow ist eine Entscheidung ob ein Verbraucher heute oder besser morgen läuft komplett sinnlos. Die Werte für den aktuellen Tag mögen z.T. noch ok sein, aber mit denen des Folgetages braucht man nicht ins Rennen gehen.

      Edit: Für morgen sagt solcast 49 kWh und Strathcoles Berechnung 13 kWh.

      ..:: So long! Tom ::..

      NUC7i3 (Ubuntu Proxmox VM) | Echo Dots 2+3. Gen | Xiaomi Sensoren | Mi Robot 1S | Yeelight | Sonoff | Shelly | H801 RGB | Gosund SP1 | NodeMCU+ESP32 | Kostal Plenticore PV+BYD | openWB

      P 1 Antwort Letzte Antwort
      0
      • DiginixD Diginix

        @meistertr Gestern war ab 1 Uhr die Prognose für heute 36 kWh, aber auch mit den solcast Werten von gestern Abend 20 Uhr ergab sich summiert 36 kWh für heute. Heute morgen 1 Uhr ist der Wert dann auf 26 kWh reduziert worden.
        Real erwarte ich heute keine 10 kWh. Die Prognose vom Plenticore Adapter waren gestern 7 Uhr schon nur 13 kWh für heute und heute 7 Uhr dann nur noch 8 kWh. Was auch immer @StrathCole da für wahnsinnige Formeln gebaut hat, sie passen für tomorrow deutlich besser.

        @bastian-m Mit derart daneben liegenden Vorhersagen für tomorrow ist eine Entscheidung ob ein Verbraucher heute oder besser morgen läuft komplett sinnlos. Die Werte für den aktuellen Tag mögen z.T. noch ok sein, aber mit denen des Folgetages braucht man nicht ins Rennen gehen.

        Edit: Für morgen sagt solcast 49 kWh und Strathcoles Berechnung 13 kWh.

        P Offline
        P Offline
        PatrickWalther
        Developer
        schrieb am zuletzt editiert von
        #309

        @diginix welche Formel? Hast du einen Link?

        DiginixD 1 Antwort Letzte Antwort
        0
        • BananaJoeB BananaJoe

          @PatrickWalther

          So, es ist vollbracht. Zwar durch die Brust ins Auge, aber es läuft (nebenbei habe ich aber wieder einmal viel gelernt).

          Ich habe nun die Vorhersage erfolgreich mit dem SQL-Adapter (und einer MySQL-Datenbank) und dem echarts-Adapter als Anzeige zum laufen bekommen:
          65f1abc8-bf77-43da-9914-17be824c2dcb-image.png
          gelb ist meine echte Tagesleistung, rot die aus diesem Adapter (auch wenn ich hier Äpfel mit Birnen vergleiche, gelb sind W und rot Wh, daran mache ich mich als nächstes).

          Als Vorrausetzung nehme ich einen installierten und funktionsfähigen SQL-Adapter an.
          Außerdem habt Ihr den pvforecast Adapter konfiguriert und am laufen so das es einen Datenpunkt mit der Vorhersage gibt. Meine Lösung nutzt den Datenpunkt JSONTable der Anlage. Meine Anlage heißt 600W und der Datenpunkt also

          pvforecast.0.600W.JSONTable
          

          ###################################################################

          Schritt 1: Datenpunkt erstellen, konfigurieren und initialisieren
          Es braucht einen Datenpunkt der Daten hält, ich habe hier diesen erstellt:

          0_userdata.0.Solaranlage.pvforecast
          

          Als Typ Number bzw. Nummer
          Dann habe ich ich SQL für den Datenpunkt eingeschaltet:
          ed032325-be5e-40ed-afdb-2da83d0824a2-image.png
          Entprellzeit auf 0 da die Daten in einem rutsch geschrieben werden

          Nun ist es wichtig im Objekte Explorer dort einmal einen Wert von Hand reinzuschreiben, z.B. eine 42:
          97f71f6a-a0a7-4718-86cd-199ad63c96e5-image.png
          Erst dann ist der Datenpunkt in der SQL-Datenbank auch angelegt. Das hat mich die ersten bestimmt 20 Minuten nerven gekostet bis ich darauf gekommen bin. Solange funktioniert nämlich das SendTo noch nicht.

          Schritt 2: Das Blockly Skript
          Ja ja, ich dachte ich könnte das mal eben mit Blockly zusammenklicken statt es direkt in JavaScript zu schreiben. Mach ich vielleicht noch. Nun ist es Blockly mit 3 JavaScript Funktionen weil der SendTo Block einfach nicht zu überreden war das ganze vernünftig zu senden.

          Im Spoiler der Blockly-Export

          <xml xmlns="https://developers.google.com/blockly/xml">
           <variables>
             <variable id="xr?C%:}F%HR,+baC%W8n">x</variable>
             <variable id="d/.bOP=7VlC5/[+=8g/u">myVAL</variable>
             <variable id="SL$d6/`ClO6iqfefh5LN">myTS</variable>
             <variable id="B$n_|Lt?V?dltG$1=%U!">JSONTable</variable>
             <variable id="zqSSt1.lPBrP!prtJp:[">JSONListe</variable>
             <variable id="[,noZ+!#R([v)Vli[JAC">counter</variable>
             <variable id="9[xS=sH).DKBS8oGN@cs">i</variable>
             <variable id="tkH#qcE=H5/_7~OttW5(">tempDatum</variable>
             <variable id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</variable>
           </variables>
           <block type="procedures_defcustomreturn" id="f5+e$i!@hdFdP7[JA1^`" x="288" y="-212">
             <mutation statements="false">
               <arg name="x" varid="xr?C%:}F%HR,+baC%W8n"></arg>
             </mutation>
             <field name="NAME">ReplaceHyphen</field>
             <field name="SCRIPT">cmV0dXJuIHgucmVwbGFjZSgiLy0vZyIsIi4iKTs=</field>
             <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
           </block>
           <block type="procedures_defcustomnoreturn" id="W?BjTQs!pguWw4HPwT)p" x="287" y="-162">
             <mutation statements="false">
               <arg name="myVAL" varid="d/.bOP=7VlC5/[+=8g/u"></arg>
               <arg name="myTS" varid="SL$d6/`ClO6iqfefh5LN"></arg>
             </mutation>
             <field name="NAME">SendTo_SQL_storeState</field>
             <field name="SCRIPT">Ly8gVW5kIHdlcnQgZXJzdGVsbGVuIHdpZSBnZXBsYW50DQpzZW5kVG8oInNxbC4wIiwgInN0b3JlU3RhdGUiLCB7DQogICAgImlkIjogJzBfdXNlcmRhdGEuMC5Tb2xhcmFubGFnZS5wdmZvcmVjYXN0JywNCiAgICAic3RhdGUiOiB7IA0KICAgICAgICAidmFsIjogbXlWQUwsIA0KICAgICAgICAidHMiOiBteVRTLA0KICAgICAgICAiYWNrIjogdHJ1ZQ0KICAgIH0NCn0sIGFzeW5jIGZ1bmN0aW9uIChyZXN1bHQpIHsNCiAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7</field>
             <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
           </block>
           <block type="procedures_defcustomnoreturn" id="m.]d6DR4hIR|rhM`P3KU" x="288" y="-112">
             <mutation statements="false"></mutation>
             <field name="NAME">SendTo_SQL_deleteAll</field>
             <field name="SCRIPT">Ly8gQWxsZXMgbMO2c2NoZW4NCnNlbmRUbygic3FsLjAiLCAiZGVsZXRlQWxsIiwgew0KICAgICJpZCI6ICcwX3VzZXJkYXRhLjAuU29sYXJhbmxhZ2UucHZmb3JlY2FzdCcsDQp9LCBhc3luYyBmdW5jdGlvbiAocmVzdWx0KSB7DQogICAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7DQo=</field>
             <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
           </block>
           <block type="comment" id="emF90N[xA].w:e$0a5`A" x="288" y="-62">
             <field name="COMMENT">Trigger auf den Datenpunkt JSONTable der</field>
             <next>
               <block type="comment" id="v|g5R@PBSlfR{}gqtWR1">
                 <field name="COMMENT">gewünschten Anlage</field>
                 <next>
                   <block type="on_ext" id="2}81gNSPn48mxt-C32N3">
                     <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
                     <field name="CONDITION">ne</field>
                     <field name="ACK_CONDITION"></field>
                     <value name="OID0">
                       <shadow type="field_oid" id="$fUC/kgh^7[pBZjds,[N">
                         <field name="oid">default</field>
                       </shadow>
                       <block type="text" id="Q~[~L7`?jff9w0!|{R!~">
                         <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                       </block>
                     </value>
                     <statement name="STATEMENT">
                       <block type="comment" id="xipk,Q4m/$Zbq(9xP]N;">
                         <field name="COMMENT">Den JSON in eine Variable als Objekt holen</field>
                         <next>
                           <block type="variables_set" id="9le8nB_}E+{=^zh:Futa" disabled="true">
                             <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                             <value name="VALUE">
                               <block type="convert_json2object" id="C^`)6e!W4atd.!+{(i`D">
                                 <value name="VALUE">
                                   <block type="get_value_var" id="CX?q]Gc8j[Ks2F4.yc=c">
                                     <field name="ATTR">val</field>
                                     <value name="OID">
                                       <shadow type="text" id="Y:eexHcUNi5aP`=sh5_;">
                                         <field name="TEXT"></field>
                                       </shadow>
                                       <block type="text" id="2yV92%k{c@aR$t@FV|VK">
                                         <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                       </block>
                                     </value>
                                   </block>
                                 </value>
                               </block>
                             </value>
                             <next>
                               <block type="variables_set" id="y:J|yOI69aKr_]e}X})q">
                                 <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                 <value name="VALUE">
                                   <block type="on_source" id="GDRdyJ%YUi4U{P:xhe%L">
                                     <field name="ATTR">state.val</field>
                                   </block>
                                 </value>
                                 <next>
                                   <block type="comment" id="78{/(q^zo:Vm3)}YeMKs">
                                     <field name="COMMENT">Den JSON nochmal als Liste</field>
                                     <next>
                                       <block type="variables_set" id="$C:;|F_ENe?Kc{f9E*tE" disabled="true">
                                         <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                         <value name="VALUE">
                                           <block type="lists_split" id=":4[[9BsVwSu-#SFS/qp#">
                                             <mutation mode="SPLIT"></mutation>
                                             <field name="MODE">SPLIT</field>
                                             <value name="INPUT">
                                               <block type="get_value_var" id="k${_LxJlQ~Jc%^8mQ;J3">
                                                 <field name="ATTR">val</field>
                                                 <value name="OID">
                                                   <shadow type="text">
                                                     <field name="TEXT"></field>
                                                   </shadow>
                                                   <block type="text" id="@(LLEO9DcZC_107PY7e;">
                                                     <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                   </block>
                                                 </value>
                                               </block>
                                             </value>
                                             <value name="DELIM">
                                               <shadow type="text" id="_=ir)--C~K.5!,@3!%@4">
                                                 <field name="TEXT">},</field>
                                               </shadow>
                                             </value>
                                           </block>
                                         </value>
                                         <next>
                                           <block type="variables_set" id="KTHIaej{MV5TTxsehu:h">
                                             <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                             <value name="VALUE">
                                               <block type="lists_split" id="`#[tp]8]y!L^LEp8OL)J">
                                                 <mutation mode="SPLIT"></mutation>
                                                 <field name="MODE">SPLIT</field>
                                                 <value name="INPUT">
                                                   <block type="on_source" id="c),q`)7dZyX)GtW;Oe0Y">
                                                     <field name="ATTR">state.val</field>
                                                   </block>
                                                 </value>
                                                 <value name="DELIM">
                                                   <shadow type="text" id="koPJuBu/Hm/D7+[$DR$`">
                                                     <field name="TEXT">},{</field>
                                                   </shadow>
                                                 </value>
                                               </block>
                                             </value>
                                             <next>
                                               <block type="comment" id="_dDWRwqorhv|K4r20+CF">
                                                 <field name="COMMENT">Zähler für die einzelnen Werte</field>
                                                 <next>
                                                   <block type="variables_set" id="w[HNQFZ(pKC;(LonsppG">
                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                     <value name="VALUE">
                                                       <block type="math_number" id="$YD#)Z6].!0wU8:!IFY-">
                                                         <field name="NUM">-1</field>
                                                       </block>
                                                     </value>
                                                     <next>
                                                       <block type="comment" id="nON/.IM*.X5L7BSfqn.j">
                                                         <field name="COMMENT">Vorherige Werte löschen</field>
                                                         <next>
                                                           <block type="procedures_callcustomnoreturn" id="MjjlAd,#02dH9;[91A:e">
                                                             <mutation name="SendTo_SQL_deleteAll"></mutation>
                                                             <next>
                                                               <block type="comment" id="+UxP]UFX*K*Ay8@+.3D(">
                                                                 <field name="COMMENT">Kurz warten ...</field>
                                                                 <next>
                                                                   <block type="timeouts_wait" id="b#[5BCU4#vD.+@RIgxwr">
                                                                     <field name="DELAY">2</field>
                                                                     <field name="UNIT">sec</field>
                                                                     <next>
                                                                       <block type="comment" id="?qlG@bV1nj7K%h8?`S-h">
                                                                         <field name="COMMENT">Die Werte abarbeiten:</field>
                                                                         <next>
                                                                           <block type="controls_forEach" id="sZ%NhNSxC10sAg@O]Kz6">
                                                                             <field name="VAR" id="9[xS=sH).DKBS8oGN@cs">i</field>
                                                                             <value name="LIST">
                                                                               <block type="variables_get" id="psB3RQ42dmHy[=aKrs!2">
                                                                                 <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                                               </block>
                                                                             </value>
                                                                             <statement name="DO">
                                                                               <block type="comment" id="0i?Xu2@hUv,g4?;i5Fhl">
                                                                                 <field name="COMMENT">Wird beim ersten mal 0 sein</field>
                                                                                 <next>
                                                                                   <block type="math_change" id="liet[5#L@~`I]t{8:/Es">
                                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                     <value name="DELTA">
                                                                                       <shadow type="math_number" id="986qLvCF[J2VK^no0@Rp">
                                                                                         <field name="NUM">1</field>
                                                                                       </shadow>
                                                                                     </value>
                                                                                     <next>
                                                                                       <block type="comment" id="}fPI/Q;fVu7V-uYuX2I+">
                                                                                         <field name="COMMENT">Wir arbeiten die Liste ab, nutzen aber das Objekt!</field>
                                                                                         <next>
                                                                                           <block type="variables_set" id="^w);@i_kdtjWWf?c}BcO">
                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                             <value name="VALUE">
                                                                                               <block type="get_attr" id="jTRbW_-wI4-}.!,5V(VJ">
                                                                                                 <value name="PATH">
                                                                                                   <shadow type="text" id="3r`W9/~ToEj{Abx:)agx">
                                                                                                     <field name="TEXT"></field>
                                                                                                   </shadow>
                                                                                                   <block type="text_join" id="xoFmSb~Y+xnD;cvM|g;-">
                                                                                                     <mutation items="2"></mutation>
                                                                                                     <value name="ADD0">
                                                                                                       <block type="variables_get" id="K9;4LQ$1S/`at#YY52.j">
                                                                                                         <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                       </block>
                                                                                                     </value>
                                                                                                     <value name="ADD1">
                                                                                                       <block type="text" id="Kkt8qVr.ykp~NV;@{Uas">
                                                                                                         <field name="TEXT">.Uhrzeit</field>
                                                                                                       </block>
                                                                                                     </value>
                                                                                                   </block>
                                                                                                 </value>
                                                                                                 <value name="OBJECT">
                                                                                                   <block type="variables_get" id="`-rw74I`kqylUWgeH*+(">
                                                                                                     <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                   </block>
                                                                                                 </value>
                                                                                               </block>
                                                                                             </value>
                                                                                             <next>
                                                                                               <block type="comment" id="b?]P+H9BwqfkDRv$/:j(">
                                                                                                 <field name="COMMENT">Die - in . umwandeln</field>
                                                                                                 <next>
                                                                                                   <block type="variables_set" id="k@v15A-cYpf/vbpRa;_z">
                                                                                                     <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                     <value name="VALUE">
                                                                                                       <block type="procedures_callcustomreturn" id="p[kw(;yI)pXBjjzD#D)~">
                                                                                                         <mutation name="ReplaceHyphen">
                                                                                                           <arg name="x"></arg>
                                                                                                         </mutation>
                                                                                                         <value name="ARG0">
                                                                                                           <block type="variables_get" id="N)h=(1TR`.9#96=m?A0Y">
                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                           </block>
                                                                                                         </value>
                                                                                                       </block>
                                                                                                     </value>
                                                                                                     <next>
                                                                                                       <block type="comment" id="I-6Pjzc2in5fU|/L@xLT">
                                                                                                         <field name="COMMENT">In ein Datum-Objekt umwandeln</field>
                                                                                                         <next>
                                                                                                           <block type="variables_set" id="FsILBORsaLrrazBi1L)J">
                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                             <value name="VALUE">
                                                                                                               <block type="convert_from_date" id="4bbw}ZJhpHe}e.*nJ0`M">
                                                                                                                 <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                                                                                 <field name="OPTION">object</field>
                                                                                                                 <value name="VALUE">
                                                                                                                   <block type="variables_get" id="RjC;=Ac;nPHFrHCNt$SG">
                                                                                                                     <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                               </block>
                                                                                                             </value>
                                                                                                             <next>
                                                                                                               <block type="comment" id="?/.AjS+{19mE_EhC6?{%">
                                                                                                                 <field name="COMMENT">Die Leistung holen (hier in Wh statt kWh)</field>
                                                                                                                 <next>
                                                                                                                   <block type="variables_set" id="7$e1=Z.||tt-}b}$`QUX">
                                                                                                                     <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                     <value name="VALUE">
                                                                                                                       <block type="math_arithmetic" id="czVYE)d?^hj;sB8tQW%c" inline="false">
                                                                                                                         <field name="OP">MULTIPLY</field>
                                                                                                                         <value name="A">
                                                                                                                           <shadow type="math_number" id="QXXI#nb51thU(gYujO7l">
                                                                                                                             <field name="NUM">1</field>
                                                                                                                           </shadow>
                                                                                                                           <block type="get_attr" id="!p(Q2{*u/U@(LdLaWO;s">
                                                                                                                             <value name="PATH">
                                                                                                                               <shadow type="text">
                                                                                                                                 <field name="TEXT"></field>
                                                                                                                               </shadow>
                                                                                                                               <block type="text_join" id="eO+Kc@J#5ncJexgCa;XG">
                                                                                                                                 <mutation items="2"></mutation>
                                                                                                                                 <value name="ADD0">
                                                                                                                                   <block type="variables_get" id="6h@/w;v+5fJ:2k^fRu$`">
                                                                                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                                   </block>
                                                                                                                                 </value>
                                                                                                                                 <value name="ADD1">
                                                                                                                                   <block type="text" id="u;lW,EMq1lo;0wl@^s~Z">
                                                                                                                                     <field name="TEXT">.Leistung</field>
                                                                                                                                   </block>
                                                                                                                                 </value>
                                                                                                                               </block>
                                                                                                                             </value>
                                                                                                                             <value name="OBJECT">
                                                                                                                               <block type="variables_get" id=":wC%m_*5#kUmjSCtRht*">
                                                                                                                                 <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                                               </block>
                                                                                                                             </value>
                                                                                                                           </block>
                                                                                                                         </value>
                                                                                                                         <value name="B">
                                                                                                                           <shadow type="math_number" id=".oUR!B4y8;}kLXv3HYVD">
                                                                                                                             <field name="NUM">1000</field>
                                                                                                                           </shadow>
                                                                                                                         </value>
                                                                                                                       </block>
                                                                                                                     </value>
                                                                                                                     <next>
                                                                                                                       <block type="comment" id=".r}c.6$[JDf=.|#00pZj">
                                                                                                                         <field name="COMMENT">Und in die Datenbank schreiben</field>
                                                                                                                         <next>
                                                                                                                           <block type="procedures_callcustomnoreturn" id="C,/_Emb0_,HXS0:;0?Cb">
                                                                                                                             <mutation name="SendTo_SQL_storeState">
                                                                                                                               <arg name="myVAL"></arg>
                                                                                                                               <arg name="myTS"></arg>
                                                                                                                             </mutation>
                                                                                                                             <value name="ARG0">
                                                                                                                               <block type="variables_get" id="ZX``,0~qVZ*H;d75IT!S">
                                                                                                                                 <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                               </block>
                                                                                                                             </value>
                                                                                                                             <value name="ARG1">
                                                                                                                               <block type="variables_get" id="2rC,dvFPd3*_,1)EOdkN">
                                                                                                                                 <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                               </block>
                                                                                                                             </value>
                                                                                                                           </block>
                                                                                                                         </next>
                                                                                                                       </block>
                                                                                                                     </next>
                                                                                                                   </block>
                                                                                                                 </next>
                                                                                                               </block>
                                                                                                             </next>
                                                                                                           </block>
                                                                                                         </next>
                                                                                                       </block>
                                                                                                     </next>
                                                                                                   </block>
                                                                                                 </next>
                                                                                               </block>
                                                                                             </next>
                                                                                           </block>
                                                                                         </next>
                                                                                       </block>
                                                                                     </next>
                                                                                   </block>
                                                                                 </next>
                                                                               </block>
                                                                             </statement>
                                                                           </block>
                                                                         </next>
                                                                       </block>
                                                                     </next>
                                                                   </block>
                                                                 </next>
                                                               </block>
                                                             </next>
                                                           </block>
                                                         </next>
                                                       </block>
                                                     </next>
                                                   </block>
                                                 </next>
                                               </block>
                                             </next>
                                           </block>
                                         </next>
                                       </block>
                                     </next>
                                   </block>
                                 </next>
                               </block>
                             </next>
                           </block>
                         </next>
                       </block>
                     </statement>
                   </block>
                 </next>
               </block>
             </next>
           </block>
          </xml>
          

          Anpassen müsst Ihr:

          In der JavaScript-Funktion SendTo_SQL_storeState den Namen des Ziel-Datenpunktes:
          40558805-14b2-4080-9681-84d67524a428-image.png
          gelb markiert:
          84a72c5c-f34e-4793-8174-a9eb2ee5e8ad-image.png

          Das gleiche in der JavaScript-Funktion SendTo_SQL_DeleteAll
          91c29379-c885-4fef-b5b4-c710f95d35ff-image.png

          Und im Kopf den Quellpfad zu eurer Anlage:
          46235a8d-a6ad-44ff-8668-09fe532644d5-image.png

          Und ob Ihr es in kWh oder Wh haben wollt:
          cdba127d-a976-408f-a313-22f6ba0d77e3-image.png
          (die x 1000 entfernen oder durch 1 Ersetzen bei kWh)

          Wenn Ihr das Skript startet passiert erst einmal nichts. Erst wenn neue Daten reinkämen.
          Zum Testen könntet Ihr

          • Im Trigger von wurde geändert auf wurde aktualisiert ändern
          • den pvforecast Adapter einmal neu starten. Zumindest bei mir holt er dann sofort einmal neue Daten

          und schon hat er uns die Werte schön in die Datenbank geschrieben:

          MariaDB [iobroker]> select * from ts_number where id = '95';
          +----+---------------+------+------+-------+------+
          | id | ts            | val  | ack  | _from | q    |
          +----+---------------+------+------+-------+------+
          | 95 | 1646287082001 |    0 |    1 |     0 |    0 |
          | 95 | 1646288940000 |   29 |    1 |     0 |    0 |
          | 95 | 1646290802000 |  146 |    1 |     0 |    0 |
          | 95 | 1646294400000 |  247 |    1 |     0 |    0 |
          | 95 | 1646298000000 |  377 |    1 |     0 |    0 |
          | 95 | 1646301600000 |  422 |    1 |     0 |    0 |
          | 95 | 1646305200000 |  428 |    1 |     0 |    0 |
          | 95 | 1646308800000 |  383 |    1 |     0 |    0 |
          | 95 | 1646312400000 |  317 |    1 |     0 |    0 |
          | 95 | 1646316000000 |  222 |    1 |     0 |    0 |
          | 95 | 1646319600000 |  113 |    1 |     0 |    0 |
          | 95 | 1646323200000 |   34 |    1 |     0 |    0 |
          | 95 | 1646326800000 |    8 |    1 |     0 |    0 |
          | 95 | 1646327160000 |    2 |    1 |     0 |    0 |
          | 95 | 1646327460000 |    0 |    1 |     0 |    0 |
          | 95 | 1646373360000 |    0 |    1 |     0 |    0 |
          | 95 | 1646375280000 |   36 |    1 |     0 |    0 |
          | 95 | 1646377200000 |  180 |    1 |     0 |    0 |
          | 95 | 1646380800000 |  284 |    1 |     0 |    0 |
          | 95 | 1646384400000 |  360 |    1 |     0 |    0 |
          | 95 | 1646388000000 |  401 |    1 |     0 |    0 |
          | 95 | 1646391600000 |  406 |    1 |     0 |    0 |
          | 95 | 1646395200000 |  372 |    1 |     0 |    0 |
          | 95 | 1646398800000 |  310 |    1 |     0 |    0 |
          | 95 | 1646402400000 |  218 |    1 |     0 |    0 |
          | 95 | 1646406000000 |  114 |    1 |     0 |    0 |
          | 95 | 1646409600000 |   35 |    1 |     0 |    0 |
          | 95 | 1646413200000 |    8 |    1 |     0 |    0 |
          | 95 | 1646413620000 |    2 |    1 |     0 |    0 |
          | 95 | 1646413980000 |    0 |    1 |     0 |    0 |
          +----+---------------+------+------+-------+------+
          30 rows in set (0.001 sec)
          
          

          Die kann man jetzt in echarts etc. verwenden.

          Woran ich noch verzweifle:

          // Alles löschen
          sendTo("sql.0", "deleteAll", {
              "id": '0_userdata.0.Solaranlage.pvforecast',
          }, async function (result) {
                console.log(result);
          });
          

          Wie schaffe ich es auch den Wert von id als Variable zu übergeben?
          Daran habe ich nämlich 90% der Zeit gesessen. Zuerst habe ich es vergeblich mit dem Blockly-SendTo Block versucht (aber der hat es immer falsch formatiert gesendet) und dann wie ich die festen Werte durch Variablen ersetze.

          P Offline
          P Offline
          PatrickWalther
          Developer
          schrieb am zuletzt editiert von
          #310

          @bananajoe Vielleicht kann das ja @Meistertr einbinden.

          1 Antwort Letzte Antwort
          0
          • P PatrickWalther

            @diginix welche Formel? Hast du einen Link?

            DiginixD Offline
            DiginixD Offline
            Diginix
            schrieb am zuletzt editiert von Diginix
            #311

            @patrickwalther Ich habe einfach alle 30min Werte addiert und durch 2 geteilt.
            Wenn 1h lang 2000 Watt prognostiziert sind, dann sind das 2 kWh. Wenn für 10 Uhr 1 kW und für 10:30 2 kW angesetzt sind, wären das entsprechend 0,5h x 1kW + 0,5h x 2kW = 1,5 kWh. Da solcast pro 30min einen Wert liefert ist es also die Summe aller x 0,5.

            Oder meinst du die Formel vom Plenticore Adapter von Strathcole? K.a. die ist logischerweise in seinem JS zu finden. Aber sicher nicht einfach übertragbar. Er nutzt glaube eine fertige Formel und hat diese weiter verfeinert bis es gut passte.
            Da laufen auch Wetterdaten von div. iob Adaptern und kachelmannwetter mit rein.

            ..:: So long! Tom ::..

            NUC7i3 (Ubuntu Proxmox VM) | Echo Dots 2+3. Gen | Xiaomi Sensoren | Mi Robot 1S | Yeelight | Sonoff | Shelly | H801 RGB | Gosund SP1 | NodeMCU+ESP32 | Kostal Plenticore PV+BYD | openWB

            P 1 Antwort Letzte Antwort
            0
            • DiginixD Diginix

              @patrickwalther Ich habe einfach alle 30min Werte addiert und durch 2 geteilt.
              Wenn 1h lang 2000 Watt prognostiziert sind, dann sind das 2 kWh. Wenn für 10 Uhr 1 kW und für 10:30 2 kW angesetzt sind, wären das entsprechend 0,5h x 1kW + 0,5h x 2kW = 1,5 kWh. Da solcast pro 30min einen Wert liefert ist es also die Summe aller x 0,5.

              Oder meinst du die Formel vom Plenticore Adapter von Strathcole? K.a. die ist logischerweise in seinem JS zu finden. Aber sicher nicht einfach übertragbar. Er nutzt glaube eine fertige Formel und hat diese weiter verfeinert bis es gut passte.
              Da laufen auch Wetterdaten von div. iob Adaptern und kachelmannwetter mit rein.

              P Offline
              P Offline
              PatrickWalther
              Developer
              schrieb am zuletzt editiert von
              #312

              @diginix okay wie heißt der Adapter von @StrathCole?

              DiginixD 1 Antwort Letzte Antwort
              0
              • P PatrickWalther

                @diginix okay wie heißt der Adapter von @StrathCole?

                DiginixD Offline
                DiginixD Offline
                Diginix
                schrieb am zuletzt editiert von Diginix
                #313

                @patrickwalther https://github.com/StrathCole/ioBroker.plenticore

                Der ist vorrangig für Kostal Wechselrichter und hat nur on top eine PV Prognose. Aber auch ohne WR sollte der Part funktionieren wenn man die Werte der PV Anlage hinterlegt. Evtl startet er nur nicht wenn keine IP für den WR eingetragen oder erreichbar ist.

                ..:: So long! Tom ::..

                NUC7i3 (Ubuntu Proxmox VM) | Echo Dots 2+3. Gen | Xiaomi Sensoren | Mi Robot 1S | Yeelight | Sonoff | Shelly | H801 RGB | Gosund SP1 | NodeMCU+ESP32 | Kostal Plenticore PV+BYD | openWB

                1 Antwort Letzte Antwort
                1
                • DiginixD Diginix

                  @bastian-m Wie machst du denn jetzt den ganzen Vergleich in deinem Skript mit einer (unbekannten) Menge an Objekten?

                  B Offline
                  B Offline
                  bastian-m
                  schrieb am zuletzt editiert von
                  #314

                  @diginix said in Test PV Forecast Adapter:

                  @bastian-m Wie machst du denn jetzt den ganzen Vergleich in deinem Skript mit einer (unbekannten) Menge an Objekten?

                  Mit einem Blocky des Todes ;-) Ich durchlaufe in einer Schleife alle 15-Min-Intervalle von 7 bis 18 Uhr und simuliere für jede dieser möglichen Einschaltzeiten, wie viel Eigenverbrauch der Verbraucher abgreifen würde und gebe dann die Startzeit mit dem höchsten Eigenverbrauch aus.
                  Ich muss mal ein bisschen JavaScript lernen...grundlegendes prozedurales Programmieren beherrsche ich schon...aber...naja...in den 90er im Informatik-LK hat man halt Pascal gelernt. Falls einer die Sprache noch kennt. ;-)

                  Ich nutze forecast.solar mit Abo und nicht solcast - ich habe die Prognosen noch nicht systematisch mit dem tatsächlichen Ertrag verglichen, aber so schlecht passen die nicht. Um zumindest grob zu entscheiden ober der Verbraucher die Nacht duchläuft oder am nächsten Tag, reicht das.

                  1 Antwort Letzte Antwort
                  1
                  • BananaJoeB BananaJoe

                    @PatrickWalther

                    So, es ist vollbracht. Zwar durch die Brust ins Auge, aber es läuft (nebenbei habe ich aber wieder einmal viel gelernt).

                    Ich habe nun die Vorhersage erfolgreich mit dem SQL-Adapter (und einer MySQL-Datenbank) und dem echarts-Adapter als Anzeige zum laufen bekommen:
                    65f1abc8-bf77-43da-9914-17be824c2dcb-image.png
                    gelb ist meine echte Tagesleistung, rot die aus diesem Adapter (auch wenn ich hier Äpfel mit Birnen vergleiche, gelb sind W und rot Wh, daran mache ich mich als nächstes).

                    Als Vorrausetzung nehme ich einen installierten und funktionsfähigen SQL-Adapter an.
                    Außerdem habt Ihr den pvforecast Adapter konfiguriert und am laufen so das es einen Datenpunkt mit der Vorhersage gibt. Meine Lösung nutzt den Datenpunkt JSONTable der Anlage. Meine Anlage heißt 600W und der Datenpunkt also

                    pvforecast.0.600W.JSONTable
                    

                    ###################################################################

                    Schritt 1: Datenpunkt erstellen, konfigurieren und initialisieren
                    Es braucht einen Datenpunkt der Daten hält, ich habe hier diesen erstellt:

                    0_userdata.0.Solaranlage.pvforecast
                    

                    Als Typ Number bzw. Nummer
                    Dann habe ich ich SQL für den Datenpunkt eingeschaltet:
                    ed032325-be5e-40ed-afdb-2da83d0824a2-image.png
                    Entprellzeit auf 0 da die Daten in einem rutsch geschrieben werden

                    Nun ist es wichtig im Objekte Explorer dort einmal einen Wert von Hand reinzuschreiben, z.B. eine 42:
                    97f71f6a-a0a7-4718-86cd-199ad63c96e5-image.png
                    Erst dann ist der Datenpunkt in der SQL-Datenbank auch angelegt. Das hat mich die ersten bestimmt 20 Minuten nerven gekostet bis ich darauf gekommen bin. Solange funktioniert nämlich das SendTo noch nicht.

                    Schritt 2: Das Blockly Skript
                    Ja ja, ich dachte ich könnte das mal eben mit Blockly zusammenklicken statt es direkt in JavaScript zu schreiben. Mach ich vielleicht noch. Nun ist es Blockly mit 3 JavaScript Funktionen weil der SendTo Block einfach nicht zu überreden war das ganze vernünftig zu senden.

                    Im Spoiler der Blockly-Export

                    <xml xmlns="https://developers.google.com/blockly/xml">
                     <variables>
                       <variable id="xr?C%:}F%HR,+baC%W8n">x</variable>
                       <variable id="d/.bOP=7VlC5/[+=8g/u">myVAL</variable>
                       <variable id="SL$d6/`ClO6iqfefh5LN">myTS</variable>
                       <variable id="B$n_|Lt?V?dltG$1=%U!">JSONTable</variable>
                       <variable id="zqSSt1.lPBrP!prtJp:[">JSONListe</variable>
                       <variable id="[,noZ+!#R([v)Vli[JAC">counter</variable>
                       <variable id="9[xS=sH).DKBS8oGN@cs">i</variable>
                       <variable id="tkH#qcE=H5/_7~OttW5(">tempDatum</variable>
                       <variable id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</variable>
                     </variables>
                     <block type="procedures_defcustomreturn" id="f5+e$i!@hdFdP7[JA1^`" x="288" y="-212">
                       <mutation statements="false">
                         <arg name="x" varid="xr?C%:}F%HR,+baC%W8n"></arg>
                       </mutation>
                       <field name="NAME">ReplaceHyphen</field>
                       <field name="SCRIPT">cmV0dXJuIHgucmVwbGFjZSgiLy0vZyIsIi4iKTs=</field>
                       <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                     </block>
                     <block type="procedures_defcustomnoreturn" id="W?BjTQs!pguWw4HPwT)p" x="287" y="-162">
                       <mutation statements="false">
                         <arg name="myVAL" varid="d/.bOP=7VlC5/[+=8g/u"></arg>
                         <arg name="myTS" varid="SL$d6/`ClO6iqfefh5LN"></arg>
                       </mutation>
                       <field name="NAME">SendTo_SQL_storeState</field>
                       <field name="SCRIPT">Ly8gVW5kIHdlcnQgZXJzdGVsbGVuIHdpZSBnZXBsYW50DQpzZW5kVG8oInNxbC4wIiwgInN0b3JlU3RhdGUiLCB7DQogICAgImlkIjogJzBfdXNlcmRhdGEuMC5Tb2xhcmFubGFnZS5wdmZvcmVjYXN0JywNCiAgICAic3RhdGUiOiB7IA0KICAgICAgICAidmFsIjogbXlWQUwsIA0KICAgICAgICAidHMiOiBteVRTLA0KICAgICAgICAiYWNrIjogdHJ1ZQ0KICAgIH0NCn0sIGFzeW5jIGZ1bmN0aW9uIChyZXN1bHQpIHsNCiAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7</field>
                       <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                     </block>
                     <block type="procedures_defcustomnoreturn" id="m.]d6DR4hIR|rhM`P3KU" x="288" y="-112">
                       <mutation statements="false"></mutation>
                       <field name="NAME">SendTo_SQL_deleteAll</field>
                       <field name="SCRIPT">Ly8gQWxsZXMgbMO2c2NoZW4NCnNlbmRUbygic3FsLjAiLCAiZGVsZXRlQWxsIiwgew0KICAgICJpZCI6ICcwX3VzZXJkYXRhLjAuU29sYXJhbmxhZ2UucHZmb3JlY2FzdCcsDQp9LCBhc3luYyBmdW5jdGlvbiAocmVzdWx0KSB7DQogICAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7DQo=</field>
                       <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                     </block>
                     <block type="comment" id="emF90N[xA].w:e$0a5`A" x="288" y="-62">
                       <field name="COMMENT">Trigger auf den Datenpunkt JSONTable der</field>
                       <next>
                         <block type="comment" id="v|g5R@PBSlfR{}gqtWR1">
                           <field name="COMMENT">gewünschten Anlage</field>
                           <next>
                             <block type="on_ext" id="2}81gNSPn48mxt-C32N3">
                               <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
                               <field name="CONDITION">ne</field>
                               <field name="ACK_CONDITION"></field>
                               <value name="OID0">
                                 <shadow type="field_oid" id="$fUC/kgh^7[pBZjds,[N">
                                   <field name="oid">default</field>
                                 </shadow>
                                 <block type="text" id="Q~[~L7`?jff9w0!|{R!~">
                                   <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                 </block>
                               </value>
                               <statement name="STATEMENT">
                                 <block type="comment" id="xipk,Q4m/$Zbq(9xP]N;">
                                   <field name="COMMENT">Den JSON in eine Variable als Objekt holen</field>
                                   <next>
                                     <block type="variables_set" id="9le8nB_}E+{=^zh:Futa" disabled="true">
                                       <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                       <value name="VALUE">
                                         <block type="convert_json2object" id="C^`)6e!W4atd.!+{(i`D">
                                           <value name="VALUE">
                                             <block type="get_value_var" id="CX?q]Gc8j[Ks2F4.yc=c">
                                               <field name="ATTR">val</field>
                                               <value name="OID">
                                                 <shadow type="text" id="Y:eexHcUNi5aP`=sh5_;">
                                                   <field name="TEXT"></field>
                                                 </shadow>
                                                 <block type="text" id="2yV92%k{c@aR$t@FV|VK">
                                                   <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                 </block>
                                               </value>
                                             </block>
                                           </value>
                                         </block>
                                       </value>
                                       <next>
                                         <block type="variables_set" id="y:J|yOI69aKr_]e}X})q">
                                           <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                           <value name="VALUE">
                                             <block type="on_source" id="GDRdyJ%YUi4U{P:xhe%L">
                                               <field name="ATTR">state.val</field>
                                             </block>
                                           </value>
                                           <next>
                                             <block type="comment" id="78{/(q^zo:Vm3)}YeMKs">
                                               <field name="COMMENT">Den JSON nochmal als Liste</field>
                                               <next>
                                                 <block type="variables_set" id="$C:;|F_ENe?Kc{f9E*tE" disabled="true">
                                                   <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                   <value name="VALUE">
                                                     <block type="lists_split" id=":4[[9BsVwSu-#SFS/qp#">
                                                       <mutation mode="SPLIT"></mutation>
                                                       <field name="MODE">SPLIT</field>
                                                       <value name="INPUT">
                                                         <block type="get_value_var" id="k${_LxJlQ~Jc%^8mQ;J3">
                                                           <field name="ATTR">val</field>
                                                           <value name="OID">
                                                             <shadow type="text">
                                                               <field name="TEXT"></field>
                                                             </shadow>
                                                             <block type="text" id="@(LLEO9DcZC_107PY7e;">
                                                               <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                             </block>
                                                           </value>
                                                         </block>
                                                       </value>
                                                       <value name="DELIM">
                                                         <shadow type="text" id="_=ir)--C~K.5!,@3!%@4">
                                                           <field name="TEXT">},</field>
                                                         </shadow>
                                                       </value>
                                                     </block>
                                                   </value>
                                                   <next>
                                                     <block type="variables_set" id="KTHIaej{MV5TTxsehu:h">
                                                       <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                       <value name="VALUE">
                                                         <block type="lists_split" id="`#[tp]8]y!L^LEp8OL)J">
                                                           <mutation mode="SPLIT"></mutation>
                                                           <field name="MODE">SPLIT</field>
                                                           <value name="INPUT">
                                                             <block type="on_source" id="c),q`)7dZyX)GtW;Oe0Y">
                                                               <field name="ATTR">state.val</field>
                                                             </block>
                                                           </value>
                                                           <value name="DELIM">
                                                             <shadow type="text" id="koPJuBu/Hm/D7+[$DR$`">
                                                               <field name="TEXT">},{</field>
                                                             </shadow>
                                                           </value>
                                                         </block>
                                                       </value>
                                                       <next>
                                                         <block type="comment" id="_dDWRwqorhv|K4r20+CF">
                                                           <field name="COMMENT">Zähler für die einzelnen Werte</field>
                                                           <next>
                                                             <block type="variables_set" id="w[HNQFZ(pKC;(LonsppG">
                                                               <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                               <value name="VALUE">
                                                                 <block type="math_number" id="$YD#)Z6].!0wU8:!IFY-">
                                                                   <field name="NUM">-1</field>
                                                                 </block>
                                                               </value>
                                                               <next>
                                                                 <block type="comment" id="nON/.IM*.X5L7BSfqn.j">
                                                                   <field name="COMMENT">Vorherige Werte löschen</field>
                                                                   <next>
                                                                     <block type="procedures_callcustomnoreturn" id="MjjlAd,#02dH9;[91A:e">
                                                                       <mutation name="SendTo_SQL_deleteAll"></mutation>
                                                                       <next>
                                                                         <block type="comment" id="+UxP]UFX*K*Ay8@+.3D(">
                                                                           <field name="COMMENT">Kurz warten ...</field>
                                                                           <next>
                                                                             <block type="timeouts_wait" id="b#[5BCU4#vD.+@RIgxwr">
                                                                               <field name="DELAY">2</field>
                                                                               <field name="UNIT">sec</field>
                                                                               <next>
                                                                                 <block type="comment" id="?qlG@bV1nj7K%h8?`S-h">
                                                                                   <field name="COMMENT">Die Werte abarbeiten:</field>
                                                                                   <next>
                                                                                     <block type="controls_forEach" id="sZ%NhNSxC10sAg@O]Kz6">
                                                                                       <field name="VAR" id="9[xS=sH).DKBS8oGN@cs">i</field>
                                                                                       <value name="LIST">
                                                                                         <block type="variables_get" id="psB3RQ42dmHy[=aKrs!2">
                                                                                           <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                                                         </block>
                                                                                       </value>
                                                                                       <statement name="DO">
                                                                                         <block type="comment" id="0i?Xu2@hUv,g4?;i5Fhl">
                                                                                           <field name="COMMENT">Wird beim ersten mal 0 sein</field>
                                                                                           <next>
                                                                                             <block type="math_change" id="liet[5#L@~`I]t{8:/Es">
                                                                                               <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                               <value name="DELTA">
                                                                                                 <shadow type="math_number" id="986qLvCF[J2VK^no0@Rp">
                                                                                                   <field name="NUM">1</field>
                                                                                                 </shadow>
                                                                                               </value>
                                                                                               <next>
                                                                                                 <block type="comment" id="}fPI/Q;fVu7V-uYuX2I+">
                                                                                                   <field name="COMMENT">Wir arbeiten die Liste ab, nutzen aber das Objekt!</field>
                                                                                                   <next>
                                                                                                     <block type="variables_set" id="^w);@i_kdtjWWf?c}BcO">
                                                                                                       <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                       <value name="VALUE">
                                                                                                         <block type="get_attr" id="jTRbW_-wI4-}.!,5V(VJ">
                                                                                                           <value name="PATH">
                                                                                                             <shadow type="text" id="3r`W9/~ToEj{Abx:)agx">
                                                                                                               <field name="TEXT"></field>
                                                                                                             </shadow>
                                                                                                             <block type="text_join" id="xoFmSb~Y+xnD;cvM|g;-">
                                                                                                               <mutation items="2"></mutation>
                                                                                                               <value name="ADD0">
                                                                                                                 <block type="variables_get" id="K9;4LQ$1S/`at#YY52.j">
                                                                                                                   <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                 </block>
                                                                                                               </value>
                                                                                                               <value name="ADD1">
                                                                                                                 <block type="text" id="Kkt8qVr.ykp~NV;@{Uas">
                                                                                                                   <field name="TEXT">.Uhrzeit</field>
                                                                                                                 </block>
                                                                                                               </value>
                                                                                                             </block>
                                                                                                           </value>
                                                                                                           <value name="OBJECT">
                                                                                                             <block type="variables_get" id="`-rw74I`kqylUWgeH*+(">
                                                                                                               <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                             </block>
                                                                                                           </value>
                                                                                                         </block>
                                                                                                       </value>
                                                                                                       <next>
                                                                                                         <block type="comment" id="b?]P+H9BwqfkDRv$/:j(">
                                                                                                           <field name="COMMENT">Die - in . umwandeln</field>
                                                                                                           <next>
                                                                                                             <block type="variables_set" id="k@v15A-cYpf/vbpRa;_z">
                                                                                                               <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                               <value name="VALUE">
                                                                                                                 <block type="procedures_callcustomreturn" id="p[kw(;yI)pXBjjzD#D)~">
                                                                                                                   <mutation name="ReplaceHyphen">
                                                                                                                     <arg name="x"></arg>
                                                                                                                   </mutation>
                                                                                                                   <value name="ARG0">
                                                                                                                     <block type="variables_get" id="N)h=(1TR`.9#96=m?A0Y">
                                                                                                                       <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                     </block>
                                                                                                                   </value>
                                                                                                                 </block>
                                                                                                               </value>
                                                                                                               <next>
                                                                                                                 <block type="comment" id="I-6Pjzc2in5fU|/L@xLT">
                                                                                                                   <field name="COMMENT">In ein Datum-Objekt umwandeln</field>
                                                                                                                   <next>
                                                                                                                     <block type="variables_set" id="FsILBORsaLrrazBi1L)J">
                                                                                                                       <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                       <value name="VALUE">
                                                                                                                         <block type="convert_from_date" id="4bbw}ZJhpHe}e.*nJ0`M">
                                                                                                                           <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                                                                                           <field name="OPTION">object</field>
                                                                                                                           <value name="VALUE">
                                                                                                                             <block type="variables_get" id="RjC;=Ac;nPHFrHCNt$SG">
                                                                                                                               <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                             </block>
                                                                                                                           </value>
                                                                                                                         </block>
                                                                                                                       </value>
                                                                                                                       <next>
                                                                                                                         <block type="comment" id="?/.AjS+{19mE_EhC6?{%">
                                                                                                                           <field name="COMMENT">Die Leistung holen (hier in Wh statt kWh)</field>
                                                                                                                           <next>
                                                                                                                             <block type="variables_set" id="7$e1=Z.||tt-}b}$`QUX">
                                                                                                                               <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                               <value name="VALUE">
                                                                                                                                 <block type="math_arithmetic" id="czVYE)d?^hj;sB8tQW%c" inline="false">
                                                                                                                                   <field name="OP">MULTIPLY</field>
                                                                                                                                   <value name="A">
                                                                                                                                     <shadow type="math_number" id="QXXI#nb51thU(gYujO7l">
                                                                                                                                       <field name="NUM">1</field>
                                                                                                                                     </shadow>
                                                                                                                                     <block type="get_attr" id="!p(Q2{*u/U@(LdLaWO;s">
                                                                                                                                       <value name="PATH">
                                                                                                                                         <shadow type="text">
                                                                                                                                           <field name="TEXT"></field>
                                                                                                                                         </shadow>
                                                                                                                                         <block type="text_join" id="eO+Kc@J#5ncJexgCa;XG">
                                                                                                                                           <mutation items="2"></mutation>
                                                                                                                                           <value name="ADD0">
                                                                                                                                             <block type="variables_get" id="6h@/w;v+5fJ:2k^fRu$`">
                                                                                                                                               <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                                             </block>
                                                                                                                                           </value>
                                                                                                                                           <value name="ADD1">
                                                                                                                                             <block type="text" id="u;lW,EMq1lo;0wl@^s~Z">
                                                                                                                                               <field name="TEXT">.Leistung</field>
                                                                                                                                             </block>
                                                                                                                                           </value>
                                                                                                                                         </block>
                                                                                                                                       </value>
                                                                                                                                       <value name="OBJECT">
                                                                                                                                         <block type="variables_get" id=":wC%m_*5#kUmjSCtRht*">
                                                                                                                                           <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                                                         </block>
                                                                                                                                       </value>
                                                                                                                                     </block>
                                                                                                                                   </value>
                                                                                                                                   <value name="B">
                                                                                                                                     <shadow type="math_number" id=".oUR!B4y8;}kLXv3HYVD">
                                                                                                                                       <field name="NUM">1000</field>
                                                                                                                                     </shadow>
                                                                                                                                   </value>
                                                                                                                                 </block>
                                                                                                                               </value>
                                                                                                                               <next>
                                                                                                                                 <block type="comment" id=".r}c.6$[JDf=.|#00pZj">
                                                                                                                                   <field name="COMMENT">Und in die Datenbank schreiben</field>
                                                                                                                                   <next>
                                                                                                                                     <block type="procedures_callcustomnoreturn" id="C,/_Emb0_,HXS0:;0?Cb">
                                                                                                                                       <mutation name="SendTo_SQL_storeState">
                                                                                                                                         <arg name="myVAL"></arg>
                                                                                                                                         <arg name="myTS"></arg>
                                                                                                                                       </mutation>
                                                                                                                                       <value name="ARG0">
                                                                                                                                         <block type="variables_get" id="ZX``,0~qVZ*H;d75IT!S">
                                                                                                                                           <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                         </block>
                                                                                                                                       </value>
                                                                                                                                       <value name="ARG1">
                                                                                                                                         <block type="variables_get" id="2rC,dvFPd3*_,1)EOdkN">
                                                                                                                                           <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                                         </block>
                                                                                                                                       </value>
                                                                                                                                     </block>
                                                                                                                                   </next>
                                                                                                                                 </block>
                                                                                                                               </next>
                                                                                                                             </block>
                                                                                                                           </next>
                                                                                                                         </block>
                                                                                                                       </next>
                                                                                                                     </block>
                                                                                                                   </next>
                                                                                                                 </block>
                                                                                                               </next>
                                                                                                             </block>
                                                                                                           </next>
                                                                                                         </block>
                                                                                                       </next>
                                                                                                     </block>
                                                                                                   </next>
                                                                                                 </block>
                                                                                               </next>
                                                                                             </block>
                                                                                           </next>
                                                                                         </block>
                                                                                       </statement>
                                                                                     </block>
                                                                                   </next>
                                                                                 </block>
                                                                               </next>
                                                                             </block>
                                                                           </next>
                                                                         </block>
                                                                       </next>
                                                                     </block>
                                                                   </next>
                                                                 </block>
                                                               </next>
                                                             </block>
                                                           </next>
                                                         </block>
                                                       </next>
                                                     </block>
                                                   </next>
                                                 </block>
                                               </next>
                                             </block>
                                           </next>
                                         </block>
                                       </next>
                                     </block>
                                   </next>
                                 </block>
                               </statement>
                             </block>
                           </next>
                         </block>
                       </next>
                     </block>
                    </xml>
                    

                    Anpassen müsst Ihr:

                    In der JavaScript-Funktion SendTo_SQL_storeState den Namen des Ziel-Datenpunktes:
                    40558805-14b2-4080-9681-84d67524a428-image.png
                    gelb markiert:
                    84a72c5c-f34e-4793-8174-a9eb2ee5e8ad-image.png

                    Das gleiche in der JavaScript-Funktion SendTo_SQL_DeleteAll
                    91c29379-c885-4fef-b5b4-c710f95d35ff-image.png

                    Und im Kopf den Quellpfad zu eurer Anlage:
                    46235a8d-a6ad-44ff-8668-09fe532644d5-image.png

                    Und ob Ihr es in kWh oder Wh haben wollt:
                    cdba127d-a976-408f-a313-22f6ba0d77e3-image.png
                    (die x 1000 entfernen oder durch 1 Ersetzen bei kWh)

                    Wenn Ihr das Skript startet passiert erst einmal nichts. Erst wenn neue Daten reinkämen.
                    Zum Testen könntet Ihr

                    • Im Trigger von wurde geändert auf wurde aktualisiert ändern
                    • den pvforecast Adapter einmal neu starten. Zumindest bei mir holt er dann sofort einmal neue Daten

                    und schon hat er uns die Werte schön in die Datenbank geschrieben:

                    MariaDB [iobroker]> select * from ts_number where id = '95';
                    +----+---------------+------+------+-------+------+
                    | id | ts            | val  | ack  | _from | q    |
                    +----+---------------+------+------+-------+------+
                    | 95 | 1646287082001 |    0 |    1 |     0 |    0 |
                    | 95 | 1646288940000 |   29 |    1 |     0 |    0 |
                    | 95 | 1646290802000 |  146 |    1 |     0 |    0 |
                    | 95 | 1646294400000 |  247 |    1 |     0 |    0 |
                    | 95 | 1646298000000 |  377 |    1 |     0 |    0 |
                    | 95 | 1646301600000 |  422 |    1 |     0 |    0 |
                    | 95 | 1646305200000 |  428 |    1 |     0 |    0 |
                    | 95 | 1646308800000 |  383 |    1 |     0 |    0 |
                    | 95 | 1646312400000 |  317 |    1 |     0 |    0 |
                    | 95 | 1646316000000 |  222 |    1 |     0 |    0 |
                    | 95 | 1646319600000 |  113 |    1 |     0 |    0 |
                    | 95 | 1646323200000 |   34 |    1 |     0 |    0 |
                    | 95 | 1646326800000 |    8 |    1 |     0 |    0 |
                    | 95 | 1646327160000 |    2 |    1 |     0 |    0 |
                    | 95 | 1646327460000 |    0 |    1 |     0 |    0 |
                    | 95 | 1646373360000 |    0 |    1 |     0 |    0 |
                    | 95 | 1646375280000 |   36 |    1 |     0 |    0 |
                    | 95 | 1646377200000 |  180 |    1 |     0 |    0 |
                    | 95 | 1646380800000 |  284 |    1 |     0 |    0 |
                    | 95 | 1646384400000 |  360 |    1 |     0 |    0 |
                    | 95 | 1646388000000 |  401 |    1 |     0 |    0 |
                    | 95 | 1646391600000 |  406 |    1 |     0 |    0 |
                    | 95 | 1646395200000 |  372 |    1 |     0 |    0 |
                    | 95 | 1646398800000 |  310 |    1 |     0 |    0 |
                    | 95 | 1646402400000 |  218 |    1 |     0 |    0 |
                    | 95 | 1646406000000 |  114 |    1 |     0 |    0 |
                    | 95 | 1646409600000 |   35 |    1 |     0 |    0 |
                    | 95 | 1646413200000 |    8 |    1 |     0 |    0 |
                    | 95 | 1646413620000 |    2 |    1 |     0 |    0 |
                    | 95 | 1646413980000 |    0 |    1 |     0 |    0 |
                    +----+---------------+------+------+-------+------+
                    30 rows in set (0.001 sec)
                    
                    

                    Die kann man jetzt in echarts etc. verwenden.

                    Woran ich noch verzweifle:

                    // Alles löschen
                    sendTo("sql.0", "deleteAll", {
                        "id": '0_userdata.0.Solaranlage.pvforecast',
                    }, async function (result) {
                          console.log(result);
                    });
                    

                    Wie schaffe ich es auch den Wert von id als Variable zu übergeben?
                    Daran habe ich nämlich 90% der Zeit gesessen. Zuerst habe ich es vergeblich mit dem Blockly-SendTo Block versucht (aber der hat es immer falsch formatiert gesendet) und dann wie ich die festen Werte durch Variablen ersetze.

                    sonnenscheinS Offline
                    sonnenscheinS Offline
                    sonnenschein
                    schrieb am zuletzt editiert von
                    #315

                    @bananajoe
                    Hallo !

                    Ich habe jetzt schon ne ganze weile versucht das Thema Forecast per script zu erledigen da ja SQL schreiben aus dem Adapter nicht verfügbar ist. Bin aber nicht final fertig geworden.
                    Evtl. hilft dir dieser Schnipsel weiter.
                    Nicht wundern die Variablen sind alle zum "Spielen" damit ich den sendto überhaupt fehlerfrei bekommen habe.
                    Auch ob die variable als var, let oder const definiert werden muß habe ich noch nicht ganz verstanden

                    //Mit iobroker Javascript sql abfragen ID ermittel und dann in SQL per ID schreiben
                    var zielid = "0_userdata.0.WriteSQL.05:00:00"; // ID von meinem Testdatenpunkt unter "ziel"
                    var ziel = "0_userdata.0.WriteSQL.WertAna01"; // Datenpunkt als Ziel
                    var quell = "pvforecast.1.summary.JSONTable"; // Quelle aus dem JSON String
                    var werttype = 0; // if datapoints type number set 0; string set 1; boolean set 2
                    var wert = 4321; // Testwert der geschrieben werden soll
                    var datenbank = "iobroker"; // name der datenbank des sql server
                    var dbtabelle = '.datapoints'; // hier sthen die Dataenpunkte druin und man kann die ID dazu finden
                    var sqlInstanz = "sql.0"; // aktuelle INstanznummer meines SQL Adapters
                    var zieltabelle = '.ts_number'; // das ist die tabelle mit den Werten der Datenpunkt ID
                    var ack = 1 // bestätigungsbit in der datenbantabelle
                    let tabfrom = 5;// von wo kommen die Daten 5 ist java adapter
                    let q = 0;
                    const zeitpunkt = new Date(); // aktuellen zeitpunkt
                    let unixzeitpunkt = zeitpunkt.getTime();// Spukt mir einen Unixzeitstempel aus!
                    console.log("Aktueller Zeitpunkt ist Kir:" + unixzeitpunkt);
                    let tswert = 1646066415926
                    // SQL Abfrage
                    // ----------- in Tab Datapoint die ID finden, steht dann in result.result.[0], damit dann in die tab ts_number schreiben will 
                        sendTo(sqlInstanz, 'query', ('SELECT id FROM' + ' ' + datenbank + dbtabelle + ' ' + 'WHERE name =\'' + zielid + '\''), function (result) {  
                    if (result.error) { 
                    console.error(result.error);
                    }
                    else{
                       sendTo(sqlInstanz, 'query', 'INSERT INTO' + ' ' + datenbank + zieltabelle + ' ' + '(id, ts, val, ack, _from, q)' + ' VALUES(' + result.result[0].id + ', '+ unixzeitpunkt + ', '+ wert + ', '+ ack + ', ' + tabfrom + ', ' + q);
                    }
                    });
                    

                    PlatformBetriebssystem:linux Architektur:arm64 CPUs:4 Geschwindigkeit:1800 MHz Modell:Cortex-A72
                    RAM:3.7 GB System-Betriebszeit:00:19:02 Node.js:v20.18.0
                    _nodeCurrent:20.18.0
                    _npmCurrent:10.8.2
                    Operating System: Debian GNU/Linux 12 (bookworm) Kernel: Linux 6.6.57-v8+

                    1 Antwort Letzte Antwort
                    0
                    • BananaJoeB BananaJoe

                      @PatrickWalther

                      So, es ist vollbracht. Zwar durch die Brust ins Auge, aber es läuft (nebenbei habe ich aber wieder einmal viel gelernt).

                      Ich habe nun die Vorhersage erfolgreich mit dem SQL-Adapter (und einer MySQL-Datenbank) und dem echarts-Adapter als Anzeige zum laufen bekommen:
                      65f1abc8-bf77-43da-9914-17be824c2dcb-image.png
                      gelb ist meine echte Tagesleistung, rot die aus diesem Adapter (auch wenn ich hier Äpfel mit Birnen vergleiche, gelb sind W und rot Wh, daran mache ich mich als nächstes).

                      Als Vorrausetzung nehme ich einen installierten und funktionsfähigen SQL-Adapter an.
                      Außerdem habt Ihr den pvforecast Adapter konfiguriert und am laufen so das es einen Datenpunkt mit der Vorhersage gibt. Meine Lösung nutzt den Datenpunkt JSONTable der Anlage. Meine Anlage heißt 600W und der Datenpunkt also

                      pvforecast.0.600W.JSONTable
                      

                      ###################################################################

                      Schritt 1: Datenpunkt erstellen, konfigurieren und initialisieren
                      Es braucht einen Datenpunkt der Daten hält, ich habe hier diesen erstellt:

                      0_userdata.0.Solaranlage.pvforecast
                      

                      Als Typ Number bzw. Nummer
                      Dann habe ich ich SQL für den Datenpunkt eingeschaltet:
                      ed032325-be5e-40ed-afdb-2da83d0824a2-image.png
                      Entprellzeit auf 0 da die Daten in einem rutsch geschrieben werden

                      Nun ist es wichtig im Objekte Explorer dort einmal einen Wert von Hand reinzuschreiben, z.B. eine 42:
                      97f71f6a-a0a7-4718-86cd-199ad63c96e5-image.png
                      Erst dann ist der Datenpunkt in der SQL-Datenbank auch angelegt. Das hat mich die ersten bestimmt 20 Minuten nerven gekostet bis ich darauf gekommen bin. Solange funktioniert nämlich das SendTo noch nicht.

                      Schritt 2: Das Blockly Skript
                      Ja ja, ich dachte ich könnte das mal eben mit Blockly zusammenklicken statt es direkt in JavaScript zu schreiben. Mach ich vielleicht noch. Nun ist es Blockly mit 3 JavaScript Funktionen weil der SendTo Block einfach nicht zu überreden war das ganze vernünftig zu senden.

                      Im Spoiler der Blockly-Export

                      <xml xmlns="https://developers.google.com/blockly/xml">
                       <variables>
                         <variable id="xr?C%:}F%HR,+baC%W8n">x</variable>
                         <variable id="d/.bOP=7VlC5/[+=8g/u">myVAL</variable>
                         <variable id="SL$d6/`ClO6iqfefh5LN">myTS</variable>
                         <variable id="B$n_|Lt?V?dltG$1=%U!">JSONTable</variable>
                         <variable id="zqSSt1.lPBrP!prtJp:[">JSONListe</variable>
                         <variable id="[,noZ+!#R([v)Vli[JAC">counter</variable>
                         <variable id="9[xS=sH).DKBS8oGN@cs">i</variable>
                         <variable id="tkH#qcE=H5/_7~OttW5(">tempDatum</variable>
                         <variable id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</variable>
                       </variables>
                       <block type="procedures_defcustomreturn" id="f5+e$i!@hdFdP7[JA1^`" x="288" y="-212">
                         <mutation statements="false">
                           <arg name="x" varid="xr?C%:}F%HR,+baC%W8n"></arg>
                         </mutation>
                         <field name="NAME">ReplaceHyphen</field>
                         <field name="SCRIPT">cmV0dXJuIHgucmVwbGFjZSgiLy0vZyIsIi4iKTs=</field>
                         <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                       </block>
                       <block type="procedures_defcustomnoreturn" id="W?BjTQs!pguWw4HPwT)p" x="287" y="-162">
                         <mutation statements="false">
                           <arg name="myVAL" varid="d/.bOP=7VlC5/[+=8g/u"></arg>
                           <arg name="myTS" varid="SL$d6/`ClO6iqfefh5LN"></arg>
                         </mutation>
                         <field name="NAME">SendTo_SQL_storeState</field>
                         <field name="SCRIPT">Ly8gVW5kIHdlcnQgZXJzdGVsbGVuIHdpZSBnZXBsYW50DQpzZW5kVG8oInNxbC4wIiwgInN0b3JlU3RhdGUiLCB7DQogICAgImlkIjogJzBfdXNlcmRhdGEuMC5Tb2xhcmFubGFnZS5wdmZvcmVjYXN0JywNCiAgICAic3RhdGUiOiB7IA0KICAgICAgICAidmFsIjogbXlWQUwsIA0KICAgICAgICAidHMiOiBteVRTLA0KICAgICAgICAiYWNrIjogdHJ1ZQ0KICAgIH0NCn0sIGFzeW5jIGZ1bmN0aW9uIChyZXN1bHQpIHsNCiAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7</field>
                         <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                       </block>
                       <block type="procedures_defcustomnoreturn" id="m.]d6DR4hIR|rhM`P3KU" x="288" y="-112">
                         <mutation statements="false"></mutation>
                         <field name="NAME">SendTo_SQL_deleteAll</field>
                         <field name="SCRIPT">Ly8gQWxsZXMgbMO2c2NoZW4NCnNlbmRUbygic3FsLjAiLCAiZGVsZXRlQWxsIiwgew0KICAgICJpZCI6ICcwX3VzZXJkYXRhLjAuU29sYXJhbmxhZ2UucHZmb3JlY2FzdCcsDQp9LCBhc3luYyBmdW5jdGlvbiAocmVzdWx0KSB7DQogICAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7DQo=</field>
                         <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                       </block>
                       <block type="comment" id="emF90N[xA].w:e$0a5`A" x="288" y="-62">
                         <field name="COMMENT">Trigger auf den Datenpunkt JSONTable der</field>
                         <next>
                           <block type="comment" id="v|g5R@PBSlfR{}gqtWR1">
                             <field name="COMMENT">gewünschten Anlage</field>
                             <next>
                               <block type="on_ext" id="2}81gNSPn48mxt-C32N3">
                                 <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
                                 <field name="CONDITION">ne</field>
                                 <field name="ACK_CONDITION"></field>
                                 <value name="OID0">
                                   <shadow type="field_oid" id="$fUC/kgh^7[pBZjds,[N">
                                     <field name="oid">default</field>
                                   </shadow>
                                   <block type="text" id="Q~[~L7`?jff9w0!|{R!~">
                                     <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                   </block>
                                 </value>
                                 <statement name="STATEMENT">
                                   <block type="comment" id="xipk,Q4m/$Zbq(9xP]N;">
                                     <field name="COMMENT">Den JSON in eine Variable als Objekt holen</field>
                                     <next>
                                       <block type="variables_set" id="9le8nB_}E+{=^zh:Futa" disabled="true">
                                         <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                         <value name="VALUE">
                                           <block type="convert_json2object" id="C^`)6e!W4atd.!+{(i`D">
                                             <value name="VALUE">
                                               <block type="get_value_var" id="CX?q]Gc8j[Ks2F4.yc=c">
                                                 <field name="ATTR">val</field>
                                                 <value name="OID">
                                                   <shadow type="text" id="Y:eexHcUNi5aP`=sh5_;">
                                                     <field name="TEXT"></field>
                                                   </shadow>
                                                   <block type="text" id="2yV92%k{c@aR$t@FV|VK">
                                                     <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                   </block>
                                                 </value>
                                               </block>
                                             </value>
                                           </block>
                                         </value>
                                         <next>
                                           <block type="variables_set" id="y:J|yOI69aKr_]e}X})q">
                                             <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                             <value name="VALUE">
                                               <block type="on_source" id="GDRdyJ%YUi4U{P:xhe%L">
                                                 <field name="ATTR">state.val</field>
                                               </block>
                                             </value>
                                             <next>
                                               <block type="comment" id="78{/(q^zo:Vm3)}YeMKs">
                                                 <field name="COMMENT">Den JSON nochmal als Liste</field>
                                                 <next>
                                                   <block type="variables_set" id="$C:;|F_ENe?Kc{f9E*tE" disabled="true">
                                                     <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                     <value name="VALUE">
                                                       <block type="lists_split" id=":4[[9BsVwSu-#SFS/qp#">
                                                         <mutation mode="SPLIT"></mutation>
                                                         <field name="MODE">SPLIT</field>
                                                         <value name="INPUT">
                                                           <block type="get_value_var" id="k${_LxJlQ~Jc%^8mQ;J3">
                                                             <field name="ATTR">val</field>
                                                             <value name="OID">
                                                               <shadow type="text">
                                                                 <field name="TEXT"></field>
                                                               </shadow>
                                                               <block type="text" id="@(LLEO9DcZC_107PY7e;">
                                                                 <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                               </block>
                                                             </value>
                                                           </block>
                                                         </value>
                                                         <value name="DELIM">
                                                           <shadow type="text" id="_=ir)--C~K.5!,@3!%@4">
                                                             <field name="TEXT">},</field>
                                                           </shadow>
                                                         </value>
                                                       </block>
                                                     </value>
                                                     <next>
                                                       <block type="variables_set" id="KTHIaej{MV5TTxsehu:h">
                                                         <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                         <value name="VALUE">
                                                           <block type="lists_split" id="`#[tp]8]y!L^LEp8OL)J">
                                                             <mutation mode="SPLIT"></mutation>
                                                             <field name="MODE">SPLIT</field>
                                                             <value name="INPUT">
                                                               <block type="on_source" id="c),q`)7dZyX)GtW;Oe0Y">
                                                                 <field name="ATTR">state.val</field>
                                                               </block>
                                                             </value>
                                                             <value name="DELIM">
                                                               <shadow type="text" id="koPJuBu/Hm/D7+[$DR$`">
                                                                 <field name="TEXT">},{</field>
                                                               </shadow>
                                                             </value>
                                                           </block>
                                                         </value>
                                                         <next>
                                                           <block type="comment" id="_dDWRwqorhv|K4r20+CF">
                                                             <field name="COMMENT">Zähler für die einzelnen Werte</field>
                                                             <next>
                                                               <block type="variables_set" id="w[HNQFZ(pKC;(LonsppG">
                                                                 <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                 <value name="VALUE">
                                                                   <block type="math_number" id="$YD#)Z6].!0wU8:!IFY-">
                                                                     <field name="NUM">-1</field>
                                                                   </block>
                                                                 </value>
                                                                 <next>
                                                                   <block type="comment" id="nON/.IM*.X5L7BSfqn.j">
                                                                     <field name="COMMENT">Vorherige Werte löschen</field>
                                                                     <next>
                                                                       <block type="procedures_callcustomnoreturn" id="MjjlAd,#02dH9;[91A:e">
                                                                         <mutation name="SendTo_SQL_deleteAll"></mutation>
                                                                         <next>
                                                                           <block type="comment" id="+UxP]UFX*K*Ay8@+.3D(">
                                                                             <field name="COMMENT">Kurz warten ...</field>
                                                                             <next>
                                                                               <block type="timeouts_wait" id="b#[5BCU4#vD.+@RIgxwr">
                                                                                 <field name="DELAY">2</field>
                                                                                 <field name="UNIT">sec</field>
                                                                                 <next>
                                                                                   <block type="comment" id="?qlG@bV1nj7K%h8?`S-h">
                                                                                     <field name="COMMENT">Die Werte abarbeiten:</field>
                                                                                     <next>
                                                                                       <block type="controls_forEach" id="sZ%NhNSxC10sAg@O]Kz6">
                                                                                         <field name="VAR" id="9[xS=sH).DKBS8oGN@cs">i</field>
                                                                                         <value name="LIST">
                                                                                           <block type="variables_get" id="psB3RQ42dmHy[=aKrs!2">
                                                                                             <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                                                           </block>
                                                                                         </value>
                                                                                         <statement name="DO">
                                                                                           <block type="comment" id="0i?Xu2@hUv,g4?;i5Fhl">
                                                                                             <field name="COMMENT">Wird beim ersten mal 0 sein</field>
                                                                                             <next>
                                                                                               <block type="math_change" id="liet[5#L@~`I]t{8:/Es">
                                                                                                 <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                 <value name="DELTA">
                                                                                                   <shadow type="math_number" id="986qLvCF[J2VK^no0@Rp">
                                                                                                     <field name="NUM">1</field>
                                                                                                   </shadow>
                                                                                                 </value>
                                                                                                 <next>
                                                                                                   <block type="comment" id="}fPI/Q;fVu7V-uYuX2I+">
                                                                                                     <field name="COMMENT">Wir arbeiten die Liste ab, nutzen aber das Objekt!</field>
                                                                                                     <next>
                                                                                                       <block type="variables_set" id="^w);@i_kdtjWWf?c}BcO">
                                                                                                         <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                         <value name="VALUE">
                                                                                                           <block type="get_attr" id="jTRbW_-wI4-}.!,5V(VJ">
                                                                                                             <value name="PATH">
                                                                                                               <shadow type="text" id="3r`W9/~ToEj{Abx:)agx">
                                                                                                                 <field name="TEXT"></field>
                                                                                                               </shadow>
                                                                                                               <block type="text_join" id="xoFmSb~Y+xnD;cvM|g;-">
                                                                                                                 <mutation items="2"></mutation>
                                                                                                                 <value name="ADD0">
                                                                                                                   <block type="variables_get" id="K9;4LQ$1S/`at#YY52.j">
                                                                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                                 <value name="ADD1">
                                                                                                                   <block type="text" id="Kkt8qVr.ykp~NV;@{Uas">
                                                                                                                     <field name="TEXT">.Uhrzeit</field>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                               </block>
                                                                                                             </value>
                                                                                                             <value name="OBJECT">
                                                                                                               <block type="variables_get" id="`-rw74I`kqylUWgeH*+(">
                                                                                                                 <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                               </block>
                                                                                                             </value>
                                                                                                           </block>
                                                                                                         </value>
                                                                                                         <next>
                                                                                                           <block type="comment" id="b?]P+H9BwqfkDRv$/:j(">
                                                                                                             <field name="COMMENT">Die - in . umwandeln</field>
                                                                                                             <next>
                                                                                                               <block type="variables_set" id="k@v15A-cYpf/vbpRa;_z">
                                                                                                                 <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                 <value name="VALUE">
                                                                                                                   <block type="procedures_callcustomreturn" id="p[kw(;yI)pXBjjzD#D)~">
                                                                                                                     <mutation name="ReplaceHyphen">
                                                                                                                       <arg name="x"></arg>
                                                                                                                     </mutation>
                                                                                                                     <value name="ARG0">
                                                                                                                       <block type="variables_get" id="N)h=(1TR`.9#96=m?A0Y">
                                                                                                                         <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                       </block>
                                                                                                                     </value>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                                 <next>
                                                                                                                   <block type="comment" id="I-6Pjzc2in5fU|/L@xLT">
                                                                                                                     <field name="COMMENT">In ein Datum-Objekt umwandeln</field>
                                                                                                                     <next>
                                                                                                                       <block type="variables_set" id="FsILBORsaLrrazBi1L)J">
                                                                                                                         <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                         <value name="VALUE">
                                                                                                                           <block type="convert_from_date" id="4bbw}ZJhpHe}e.*nJ0`M">
                                                                                                                             <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                                                                                             <field name="OPTION">object</field>
                                                                                                                             <value name="VALUE">
                                                                                                                               <block type="variables_get" id="RjC;=Ac;nPHFrHCNt$SG">
                                                                                                                                 <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                               </block>
                                                                                                                             </value>
                                                                                                                           </block>
                                                                                                                         </value>
                                                                                                                         <next>
                                                                                                                           <block type="comment" id="?/.AjS+{19mE_EhC6?{%">
                                                                                                                             <field name="COMMENT">Die Leistung holen (hier in Wh statt kWh)</field>
                                                                                                                             <next>
                                                                                                                               <block type="variables_set" id="7$e1=Z.||tt-}b}$`QUX">
                                                                                                                                 <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                 <value name="VALUE">
                                                                                                                                   <block type="math_arithmetic" id="czVYE)d?^hj;sB8tQW%c" inline="false">
                                                                                                                                     <field name="OP">MULTIPLY</field>
                                                                                                                                     <value name="A">
                                                                                                                                       <shadow type="math_number" id="QXXI#nb51thU(gYujO7l">
                                                                                                                                         <field name="NUM">1</field>
                                                                                                                                       </shadow>
                                                                                                                                       <block type="get_attr" id="!p(Q2{*u/U@(LdLaWO;s">
                                                                                                                                         <value name="PATH">
                                                                                                                                           <shadow type="text">
                                                                                                                                             <field name="TEXT"></field>
                                                                                                                                           </shadow>
                                                                                                                                           <block type="text_join" id="eO+Kc@J#5ncJexgCa;XG">
                                                                                                                                             <mutation items="2"></mutation>
                                                                                                                                             <value name="ADD0">
                                                                                                                                               <block type="variables_get" id="6h@/w;v+5fJ:2k^fRu$`">
                                                                                                                                                 <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                             <value name="ADD1">
                                                                                                                                               <block type="text" id="u;lW,EMq1lo;0wl@^s~Z">
                                                                                                                                                 <field name="TEXT">.Leistung</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                         <value name="OBJECT">
                                                                                                                                           <block type="variables_get" id=":wC%m_*5#kUmjSCtRht*">
                                                                                                                                             <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                       </block>
                                                                                                                                     </value>
                                                                                                                                     <value name="B">
                                                                                                                                       <shadow type="math_number" id=".oUR!B4y8;}kLXv3HYVD">
                                                                                                                                         <field name="NUM">1000</field>
                                                                                                                                       </shadow>
                                                                                                                                     </value>
                                                                                                                                   </block>
                                                                                                                                 </value>
                                                                                                                                 <next>
                                                                                                                                   <block type="comment" id=".r}c.6$[JDf=.|#00pZj">
                                                                                                                                     <field name="COMMENT">Und in die Datenbank schreiben</field>
                                                                                                                                     <next>
                                                                                                                                       <block type="procedures_callcustomnoreturn" id="C,/_Emb0_,HXS0:;0?Cb">
                                                                                                                                         <mutation name="SendTo_SQL_storeState">
                                                                                                                                           <arg name="myVAL"></arg>
                                                                                                                                           <arg name="myTS"></arg>
                                                                                                                                         </mutation>
                                                                                                                                         <value name="ARG0">
                                                                                                                                           <block type="variables_get" id="ZX``,0~qVZ*H;d75IT!S">
                                                                                                                                             <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                         <value name="ARG1">
                                                                                                                                           <block type="variables_get" id="2rC,dvFPd3*_,1)EOdkN">
                                                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                       </block>
                                                                                                                                     </next>
                                                                                                                                   </block>
                                                                                                                                 </next>
                                                                                                                               </block>
                                                                                                                             </next>
                                                                                                                           </block>
                                                                                                                         </next>
                                                                                                                       </block>
                                                                                                                     </next>
                                                                                                                   </block>
                                                                                                                 </next>
                                                                                                               </block>
                                                                                                             </next>
                                                                                                           </block>
                                                                                                         </next>
                                                                                                       </block>
                                                                                                     </next>
                                                                                                   </block>
                                                                                                 </next>
                                                                                               </block>
                                                                                             </next>
                                                                                           </block>
                                                                                         </statement>
                                                                                       </block>
                                                                                     </next>
                                                                                   </block>
                                                                                 </next>
                                                                               </block>
                                                                             </next>
                                                                           </block>
                                                                         </next>
                                                                       </block>
                                                                     </next>
                                                                   </block>
                                                                 </next>
                                                               </block>
                                                             </next>
                                                           </block>
                                                         </next>
                                                       </block>
                                                     </next>
                                                   </block>
                                                 </next>
                                               </block>
                                             </next>
                                           </block>
                                         </next>
                                       </block>
                                     </next>
                                   </block>
                                 </statement>
                               </block>
                             </next>
                           </block>
                         </next>
                       </block>
                      </xml>
                      

                      Anpassen müsst Ihr:

                      In der JavaScript-Funktion SendTo_SQL_storeState den Namen des Ziel-Datenpunktes:
                      40558805-14b2-4080-9681-84d67524a428-image.png
                      gelb markiert:
                      84a72c5c-f34e-4793-8174-a9eb2ee5e8ad-image.png

                      Das gleiche in der JavaScript-Funktion SendTo_SQL_DeleteAll
                      91c29379-c885-4fef-b5b4-c710f95d35ff-image.png

                      Und im Kopf den Quellpfad zu eurer Anlage:
                      46235a8d-a6ad-44ff-8668-09fe532644d5-image.png

                      Und ob Ihr es in kWh oder Wh haben wollt:
                      cdba127d-a976-408f-a313-22f6ba0d77e3-image.png
                      (die x 1000 entfernen oder durch 1 Ersetzen bei kWh)

                      Wenn Ihr das Skript startet passiert erst einmal nichts. Erst wenn neue Daten reinkämen.
                      Zum Testen könntet Ihr

                      • Im Trigger von wurde geändert auf wurde aktualisiert ändern
                      • den pvforecast Adapter einmal neu starten. Zumindest bei mir holt er dann sofort einmal neue Daten

                      und schon hat er uns die Werte schön in die Datenbank geschrieben:

                      MariaDB [iobroker]> select * from ts_number where id = '95';
                      +----+---------------+------+------+-------+------+
                      | id | ts            | val  | ack  | _from | q    |
                      +----+---------------+------+------+-------+------+
                      | 95 | 1646287082001 |    0 |    1 |     0 |    0 |
                      | 95 | 1646288940000 |   29 |    1 |     0 |    0 |
                      | 95 | 1646290802000 |  146 |    1 |     0 |    0 |
                      | 95 | 1646294400000 |  247 |    1 |     0 |    0 |
                      | 95 | 1646298000000 |  377 |    1 |     0 |    0 |
                      | 95 | 1646301600000 |  422 |    1 |     0 |    0 |
                      | 95 | 1646305200000 |  428 |    1 |     0 |    0 |
                      | 95 | 1646308800000 |  383 |    1 |     0 |    0 |
                      | 95 | 1646312400000 |  317 |    1 |     0 |    0 |
                      | 95 | 1646316000000 |  222 |    1 |     0 |    0 |
                      | 95 | 1646319600000 |  113 |    1 |     0 |    0 |
                      | 95 | 1646323200000 |   34 |    1 |     0 |    0 |
                      | 95 | 1646326800000 |    8 |    1 |     0 |    0 |
                      | 95 | 1646327160000 |    2 |    1 |     0 |    0 |
                      | 95 | 1646327460000 |    0 |    1 |     0 |    0 |
                      | 95 | 1646373360000 |    0 |    1 |     0 |    0 |
                      | 95 | 1646375280000 |   36 |    1 |     0 |    0 |
                      | 95 | 1646377200000 |  180 |    1 |     0 |    0 |
                      | 95 | 1646380800000 |  284 |    1 |     0 |    0 |
                      | 95 | 1646384400000 |  360 |    1 |     0 |    0 |
                      | 95 | 1646388000000 |  401 |    1 |     0 |    0 |
                      | 95 | 1646391600000 |  406 |    1 |     0 |    0 |
                      | 95 | 1646395200000 |  372 |    1 |     0 |    0 |
                      | 95 | 1646398800000 |  310 |    1 |     0 |    0 |
                      | 95 | 1646402400000 |  218 |    1 |     0 |    0 |
                      | 95 | 1646406000000 |  114 |    1 |     0 |    0 |
                      | 95 | 1646409600000 |   35 |    1 |     0 |    0 |
                      | 95 | 1646413200000 |    8 |    1 |     0 |    0 |
                      | 95 | 1646413620000 |    2 |    1 |     0 |    0 |
                      | 95 | 1646413980000 |    0 |    1 |     0 |    0 |
                      +----+---------------+------+------+-------+------+
                      30 rows in set (0.001 sec)
                      
                      

                      Die kann man jetzt in echarts etc. verwenden.

                      Woran ich noch verzweifle:

                      // Alles löschen
                      sendTo("sql.0", "deleteAll", {
                          "id": '0_userdata.0.Solaranlage.pvforecast',
                      }, async function (result) {
                            console.log(result);
                      });
                      

                      Wie schaffe ich es auch den Wert von id als Variable zu übergeben?
                      Daran habe ich nämlich 90% der Zeit gesessen. Zuerst habe ich es vergeblich mit dem Blockly-SendTo Block versucht (aber der hat es immer falsch formatiert gesendet) und dann wie ich die festen Werte durch Variablen ersetze.

                      sonnenscheinS Offline
                      sonnenscheinS Offline
                      sonnenschein
                      schrieb am zuletzt editiert von
                      #316

                      @bananajoe sagte in Test PV Forecast Adapter:

                      @PatrickWalther

                      So, es ist vollbracht. Zwar durch die Brust ins Auge, aber es läuft (nebenbei habe ich aber wieder einmal viel gelernt).

                      Ich habe nun die Vorhersage erfolgreich mit dem SQL-Adapter (und einer MySQL-Datenbank) und dem echarts-Adapter als Anzeige zum laufen bekommen:
                      65f1abc8-bf77-43da-9914-17be824c2dcb-image.png
                      gelb ist meine echte Tagesleistung, rot die aus diesem Adapter (auch wenn ich hier Äpfel mit Birnen vergleiche, gelb sind W und rot Wh, daran mache ich mich als nächstes).

                      Als Vorrausetzung nehme ich einen installierten und funktionsfähigen SQL-Adapter an.
                      Außerdem habt Ihr den pvforecast Adapter konfiguriert und am laufen so das es einen Datenpunkt mit der Vorhersage gibt. Meine Lösung nutzt den Datenpunkt JSONTable der Anlage. Meine Anlage heißt 600W und der Datenpunkt also

                      pvforecast.0.600W.JSONTable
                      

                      ###################################################################

                      Schritt 1: Datenpunkt erstellen, konfigurieren und initialisieren
                      Es braucht einen Datenpunkt der Daten hält, ich habe hier diesen erstellt:

                      0_userdata.0.Solaranlage.pvforecast
                      

                      Als Typ Number bzw. Nummer
                      Dann habe ich ich SQL für den Datenpunkt eingeschaltet:
                      ed032325-be5e-40ed-afdb-2da83d0824a2-image.png
                      Entprellzeit auf 0 da die Daten in einem rutsch geschrieben werden

                      Nun ist es wichtig im Objekte Explorer dort einmal einen Wert von Hand reinzuschreiben, z.B. eine 42:
                      97f71f6a-a0a7-4718-86cd-199ad63c96e5-image.png
                      Erst dann ist der Datenpunkt in der SQL-Datenbank auch angelegt. Das hat mich die ersten bestimmt 20 Minuten nerven gekostet bis ich darauf gekommen bin. Solange funktioniert nämlich das SendTo noch nicht.

                      Schritt 2: Das Blockly Skript
                      Ja ja, ich dachte ich könnte das mal eben mit Blockly zusammenklicken statt es direkt in JavaScript zu schreiben. Mach ich vielleicht noch. Nun ist es Blockly mit 3 JavaScript Funktionen weil der SendTo Block einfach nicht zu überreden war das ganze vernünftig zu senden.

                      Im Spoiler der Blockly-Export

                      <xml xmlns="https://developers.google.com/blockly/xml">
                       <variables>
                         <variable id="xr?C%:}F%HR,+baC%W8n">x</variable>
                         <variable id="d/.bOP=7VlC5/[+=8g/u">myVAL</variable>
                         <variable id="SL$d6/`ClO6iqfefh5LN">myTS</variable>
                         <variable id="B$n_|Lt?V?dltG$1=%U!">JSONTable</variable>
                         <variable id="zqSSt1.lPBrP!prtJp:[">JSONListe</variable>
                         <variable id="[,noZ+!#R([v)Vli[JAC">counter</variable>
                         <variable id="9[xS=sH).DKBS8oGN@cs">i</variable>
                         <variable id="tkH#qcE=H5/_7~OttW5(">tempDatum</variable>
                         <variable id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</variable>
                       </variables>
                       <block type="procedures_defcustomreturn" id="f5+e$i!@hdFdP7[JA1^`" x="288" y="-212">
                         <mutation statements="false">
                           <arg name="x" varid="xr?C%:}F%HR,+baC%W8n"></arg>
                         </mutation>
                         <field name="NAME">ReplaceHyphen</field>
                         <field name="SCRIPT">cmV0dXJuIHgucmVwbGFjZSgiLy0vZyIsIi4iKTs=</field>
                         <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                       </block>
                       <block type="procedures_defcustomnoreturn" id="W?BjTQs!pguWw4HPwT)p" x="287" y="-162">
                         <mutation statements="false">
                           <arg name="myVAL" varid="d/.bOP=7VlC5/[+=8g/u"></arg>
                           <arg name="myTS" varid="SL$d6/`ClO6iqfefh5LN"></arg>
                         </mutation>
                         <field name="NAME">SendTo_SQL_storeState</field>
                         <field name="SCRIPT">Ly8gVW5kIHdlcnQgZXJzdGVsbGVuIHdpZSBnZXBsYW50DQpzZW5kVG8oInNxbC4wIiwgInN0b3JlU3RhdGUiLCB7DQogICAgImlkIjogJzBfdXNlcmRhdGEuMC5Tb2xhcmFubGFnZS5wdmZvcmVjYXN0JywNCiAgICAic3RhdGUiOiB7IA0KICAgICAgICAidmFsIjogbXlWQUwsIA0KICAgICAgICAidHMiOiBteVRTLA0KICAgICAgICAiYWNrIjogdHJ1ZQ0KICAgIH0NCn0sIGFzeW5jIGZ1bmN0aW9uIChyZXN1bHQpIHsNCiAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7</field>
                         <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                       </block>
                       <block type="procedures_defcustomnoreturn" id="m.]d6DR4hIR|rhM`P3KU" x="288" y="-112">
                         <mutation statements="false"></mutation>
                         <field name="NAME">SendTo_SQL_deleteAll</field>
                         <field name="SCRIPT">Ly8gQWxsZXMgbMO2c2NoZW4NCnNlbmRUbygic3FsLjAiLCAiZGVsZXRlQWxsIiwgew0KICAgICJpZCI6ICcwX3VzZXJkYXRhLjAuU29sYXJhbmxhZ2UucHZmb3JlY2FzdCcsDQp9LCBhc3luYyBmdW5jdGlvbiAocmVzdWx0KSB7DQogICAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7DQo=</field>
                         <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                       </block>
                       <block type="comment" id="emF90N[xA].w:e$0a5`A" x="288" y="-62">
                         <field name="COMMENT">Trigger auf den Datenpunkt JSONTable der</field>
                         <next>
                           <block type="comment" id="v|g5R@PBSlfR{}gqtWR1">
                             <field name="COMMENT">gewünschten Anlage</field>
                             <next>
                               <block type="on_ext" id="2}81gNSPn48mxt-C32N3">
                                 <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
                                 <field name="CONDITION">ne</field>
                                 <field name="ACK_CONDITION"></field>
                                 <value name="OID0">
                                   <shadow type="field_oid" id="$fUC/kgh^7[pBZjds,[N">
                                     <field name="oid">default</field>
                                   </shadow>
                                   <block type="text" id="Q~[~L7`?jff9w0!|{R!~">
                                     <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                   </block>
                                 </value>
                                 <statement name="STATEMENT">
                                   <block type="comment" id="xipk,Q4m/$Zbq(9xP]N;">
                                     <field name="COMMENT">Den JSON in eine Variable als Objekt holen</field>
                                     <next>
                                       <block type="variables_set" id="9le8nB_}E+{=^zh:Futa" disabled="true">
                                         <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                         <value name="VALUE">
                                           <block type="convert_json2object" id="C^`)6e!W4atd.!+{(i`D">
                                             <value name="VALUE">
                                               <block type="get_value_var" id="CX?q]Gc8j[Ks2F4.yc=c">
                                                 <field name="ATTR">val</field>
                                                 <value name="OID">
                                                   <shadow type="text" id="Y:eexHcUNi5aP`=sh5_;">
                                                     <field name="TEXT"></field>
                                                   </shadow>
                                                   <block type="text" id="2yV92%k{c@aR$t@FV|VK">
                                                     <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                   </block>
                                                 </value>
                                               </block>
                                             </value>
                                           </block>
                                         </value>
                                         <next>
                                           <block type="variables_set" id="y:J|yOI69aKr_]e}X})q">
                                             <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                             <value name="VALUE">
                                               <block type="on_source" id="GDRdyJ%YUi4U{P:xhe%L">
                                                 <field name="ATTR">state.val</field>
                                               </block>
                                             </value>
                                             <next>
                                               <block type="comment" id="78{/(q^zo:Vm3)}YeMKs">
                                                 <field name="COMMENT">Den JSON nochmal als Liste</field>
                                                 <next>
                                                   <block type="variables_set" id="$C:;|F_ENe?Kc{f9E*tE" disabled="true">
                                                     <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                     <value name="VALUE">
                                                       <block type="lists_split" id=":4[[9BsVwSu-#SFS/qp#">
                                                         <mutation mode="SPLIT"></mutation>
                                                         <field name="MODE">SPLIT</field>
                                                         <value name="INPUT">
                                                           <block type="get_value_var" id="k${_LxJlQ~Jc%^8mQ;J3">
                                                             <field name="ATTR">val</field>
                                                             <value name="OID">
                                                               <shadow type="text">
                                                                 <field name="TEXT"></field>
                                                               </shadow>
                                                               <block type="text" id="@(LLEO9DcZC_107PY7e;">
                                                                 <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                               </block>
                                                             </value>
                                                           </block>
                                                         </value>
                                                         <value name="DELIM">
                                                           <shadow type="text" id="_=ir)--C~K.5!,@3!%@4">
                                                             <field name="TEXT">},</field>
                                                           </shadow>
                                                         </value>
                                                       </block>
                                                     </value>
                                                     <next>
                                                       <block type="variables_set" id="KTHIaej{MV5TTxsehu:h">
                                                         <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                         <value name="VALUE">
                                                           <block type="lists_split" id="`#[tp]8]y!L^LEp8OL)J">
                                                             <mutation mode="SPLIT"></mutation>
                                                             <field name="MODE">SPLIT</field>
                                                             <value name="INPUT">
                                                               <block type="on_source" id="c),q`)7dZyX)GtW;Oe0Y">
                                                                 <field name="ATTR">state.val</field>
                                                               </block>
                                                             </value>
                                                             <value name="DELIM">
                                                               <shadow type="text" id="koPJuBu/Hm/D7+[$DR$`">
                                                                 <field name="TEXT">},{</field>
                                                               </shadow>
                                                             </value>
                                                           </block>
                                                         </value>
                                                         <next>
                                                           <block type="comment" id="_dDWRwqorhv|K4r20+CF">
                                                             <field name="COMMENT">Zähler für die einzelnen Werte</field>
                                                             <next>
                                                               <block type="variables_set" id="w[HNQFZ(pKC;(LonsppG">
                                                                 <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                 <value name="VALUE">
                                                                   <block type="math_number" id="$YD#)Z6].!0wU8:!IFY-">
                                                                     <field name="NUM">-1</field>
                                                                   </block>
                                                                 </value>
                                                                 <next>
                                                                   <block type="comment" id="nON/.IM*.X5L7BSfqn.j">
                                                                     <field name="COMMENT">Vorherige Werte löschen</field>
                                                                     <next>
                                                                       <block type="procedures_callcustomnoreturn" id="MjjlAd,#02dH9;[91A:e">
                                                                         <mutation name="SendTo_SQL_deleteAll"></mutation>
                                                                         <next>
                                                                           <block type="comment" id="+UxP]UFX*K*Ay8@+.3D(">
                                                                             <field name="COMMENT">Kurz warten ...</field>
                                                                             <next>
                                                                               <block type="timeouts_wait" id="b#[5BCU4#vD.+@RIgxwr">
                                                                                 <field name="DELAY">2</field>
                                                                                 <field name="UNIT">sec</field>
                                                                                 <next>
                                                                                   <block type="comment" id="?qlG@bV1nj7K%h8?`S-h">
                                                                                     <field name="COMMENT">Die Werte abarbeiten:</field>
                                                                                     <next>
                                                                                       <block type="controls_forEach" id="sZ%NhNSxC10sAg@O]Kz6">
                                                                                         <field name="VAR" id="9[xS=sH).DKBS8oGN@cs">i</field>
                                                                                         <value name="LIST">
                                                                                           <block type="variables_get" id="psB3RQ42dmHy[=aKrs!2">
                                                                                             <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                                                           </block>
                                                                                         </value>
                                                                                         <statement name="DO">
                                                                                           <block type="comment" id="0i?Xu2@hUv,g4?;i5Fhl">
                                                                                             <field name="COMMENT">Wird beim ersten mal 0 sein</field>
                                                                                             <next>
                                                                                               <block type="math_change" id="liet[5#L@~`I]t{8:/Es">
                                                                                                 <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                 <value name="DELTA">
                                                                                                   <shadow type="math_number" id="986qLvCF[J2VK^no0@Rp">
                                                                                                     <field name="NUM">1</field>
                                                                                                   </shadow>
                                                                                                 </value>
                                                                                                 <next>
                                                                                                   <block type="comment" id="}fPI/Q;fVu7V-uYuX2I+">
                                                                                                     <field name="COMMENT">Wir arbeiten die Liste ab, nutzen aber das Objekt!</field>
                                                                                                     <next>
                                                                                                       <block type="variables_set" id="^w);@i_kdtjWWf?c}BcO">
                                                                                                         <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                         <value name="VALUE">
                                                                                                           <block type="get_attr" id="jTRbW_-wI4-}.!,5V(VJ">
                                                                                                             <value name="PATH">
                                                                                                               <shadow type="text" id="3r`W9/~ToEj{Abx:)agx">
                                                                                                                 <field name="TEXT"></field>
                                                                                                               </shadow>
                                                                                                               <block type="text_join" id="xoFmSb~Y+xnD;cvM|g;-">
                                                                                                                 <mutation items="2"></mutation>
                                                                                                                 <value name="ADD0">
                                                                                                                   <block type="variables_get" id="K9;4LQ$1S/`at#YY52.j">
                                                                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                                 <value name="ADD1">
                                                                                                                   <block type="text" id="Kkt8qVr.ykp~NV;@{Uas">
                                                                                                                     <field name="TEXT">.Uhrzeit</field>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                               </block>
                                                                                                             </value>
                                                                                                             <value name="OBJECT">
                                                                                                               <block type="variables_get" id="`-rw74I`kqylUWgeH*+(">
                                                                                                                 <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                               </block>
                                                                                                             </value>
                                                                                                           </block>
                                                                                                         </value>
                                                                                                         <next>
                                                                                                           <block type="comment" id="b?]P+H9BwqfkDRv$/:j(">
                                                                                                             <field name="COMMENT">Die - in . umwandeln</field>
                                                                                                             <next>
                                                                                                               <block type="variables_set" id="k@v15A-cYpf/vbpRa;_z">
                                                                                                                 <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                 <value name="VALUE">
                                                                                                                   <block type="procedures_callcustomreturn" id="p[kw(;yI)pXBjjzD#D)~">
                                                                                                                     <mutation name="ReplaceHyphen">
                                                                                                                       <arg name="x"></arg>
                                                                                                                     </mutation>
                                                                                                                     <value name="ARG0">
                                                                                                                       <block type="variables_get" id="N)h=(1TR`.9#96=m?A0Y">
                                                                                                                         <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                       </block>
                                                                                                                     </value>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                                 <next>
                                                                                                                   <block type="comment" id="I-6Pjzc2in5fU|/L@xLT">
                                                                                                                     <field name="COMMENT">In ein Datum-Objekt umwandeln</field>
                                                                                                                     <next>
                                                                                                                       <block type="variables_set" id="FsILBORsaLrrazBi1L)J">
                                                                                                                         <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                         <value name="VALUE">
                                                                                                                           <block type="convert_from_date" id="4bbw}ZJhpHe}e.*nJ0`M">
                                                                                                                             <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                                                                                             <field name="OPTION">object</field>
                                                                                                                             <value name="VALUE">
                                                                                                                               <block type="variables_get" id="RjC;=Ac;nPHFrHCNt$SG">
                                                                                                                                 <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                               </block>
                                                                                                                             </value>
                                                                                                                           </block>
                                                                                                                         </value>
                                                                                                                         <next>
                                                                                                                           <block type="comment" id="?/.AjS+{19mE_EhC6?{%">
                                                                                                                             <field name="COMMENT">Die Leistung holen (hier in Wh statt kWh)</field>
                                                                                                                             <next>
                                                                                                                               <block type="variables_set" id="7$e1=Z.||tt-}b}$`QUX">
                                                                                                                                 <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                 <value name="VALUE">
                                                                                                                                   <block type="math_arithmetic" id="czVYE)d?^hj;sB8tQW%c" inline="false">
                                                                                                                                     <field name="OP">MULTIPLY</field>
                                                                                                                                     <value name="A">
                                                                                                                                       <shadow type="math_number" id="QXXI#nb51thU(gYujO7l">
                                                                                                                                         <field name="NUM">1</field>
                                                                                                                                       </shadow>
                                                                                                                                       <block type="get_attr" id="!p(Q2{*u/U@(LdLaWO;s">
                                                                                                                                         <value name="PATH">
                                                                                                                                           <shadow type="text">
                                                                                                                                             <field name="TEXT"></field>
                                                                                                                                           </shadow>
                                                                                                                                           <block type="text_join" id="eO+Kc@J#5ncJexgCa;XG">
                                                                                                                                             <mutation items="2"></mutation>
                                                                                                                                             <value name="ADD0">
                                                                                                                                               <block type="variables_get" id="6h@/w;v+5fJ:2k^fRu$`">
                                                                                                                                                 <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                             <value name="ADD1">
                                                                                                                                               <block type="text" id="u;lW,EMq1lo;0wl@^s~Z">
                                                                                                                                                 <field name="TEXT">.Leistung</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                         <value name="OBJECT">
                                                                                                                                           <block type="variables_get" id=":wC%m_*5#kUmjSCtRht*">
                                                                                                                                             <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                       </block>
                                                                                                                                     </value>
                                                                                                                                     <value name="B">
                                                                                                                                       <shadow type="math_number" id=".oUR!B4y8;}kLXv3HYVD">
                                                                                                                                         <field name="NUM">1000</field>
                                                                                                                                       </shadow>
                                                                                                                                     </value>
                                                                                                                                   </block>
                                                                                                                                 </value>
                                                                                                                                 <next>
                                                                                                                                   <block type="comment" id=".r}c.6$[JDf=.|#00pZj">
                                                                                                                                     <field name="COMMENT">Und in die Datenbank schreiben</field>
                                                                                                                                     <next>
                                                                                                                                       <block type="procedures_callcustomnoreturn" id="C,/_Emb0_,HXS0:;0?Cb">
                                                                                                                                         <mutation name="SendTo_SQL_storeState">
                                                                                                                                           <arg name="myVAL"></arg>
                                                                                                                                           <arg name="myTS"></arg>
                                                                                                                                         </mutation>
                                                                                                                                         <value name="ARG0">
                                                                                                                                           <block type="variables_get" id="ZX``,0~qVZ*H;d75IT!S">
                                                                                                                                             <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                         <value name="ARG1">
                                                                                                                                           <block type="variables_get" id="2rC,dvFPd3*_,1)EOdkN">
                                                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                       </block>
                                                                                                                                     </next>
                                                                                                                                   </block>
                                                                                                                                 </next>
                                                                                                                               </block>
                                                                                                                             </next>
                                                                                                                           </block>
                                                                                                                         </next>
                                                                                                                       </block>
                                                                                                                     </next>
                                                                                                                   </block>
                                                                                                                 </next>
                                                                                                               </block>
                                                                                                             </next>
                                                                                                           </block>
                                                                                                         </next>
                                                                                                       </block>
                                                                                                     </next>
                                                                                                   </block>
                                                                                                 </next>
                                                                                               </block>
                                                                                             </next>
                                                                                           </block>
                                                                                         </statement>
                                                                                       </block>
                                                                                     </next>
                                                                                   </block>
                                                                                 </next>
                                                                               </block>
                                                                             </next>
                                                                           </block>
                                                                         </next>
                                                                       </block>
                                                                     </next>
                                                                   </block>
                                                                 </next>
                                                               </block>
                                                             </next>
                                                           </block>
                                                         </next>
                                                       </block>
                                                     </next>
                                                   </block>
                                                 </next>
                                               </block>
                                             </next>
                                           </block>
                                         </next>
                                       </block>
                                     </next>
                                   </block>
                                 </statement>
                               </block>
                             </next>
                           </block>
                         </next>
                       </block>
                      </xml>
                      

                      Anpassen müsst Ihr:

                      In der JavaScript-Funktion SendTo_SQL_storeState den Namen des Ziel-Datenpunktes:
                      40558805-14b2-4080-9681-84d67524a428-image.png
                      gelb markiert:
                      84a72c5c-f34e-4793-8174-a9eb2ee5e8ad-image.png

                      Das gleiche in der JavaScript-Funktion SendTo_SQL_DeleteAll
                      91c29379-c885-4fef-b5b4-c710f95d35ff-image.png

                      Und im Kopf den Quellpfad zu eurer Anlage:
                      46235a8d-a6ad-44ff-8668-09fe532644d5-image.png

                      Und ob Ihr es in kWh oder Wh haben wollt:
                      cdba127d-a976-408f-a313-22f6ba0d77e3-image.png
                      (die x 1000 entfernen oder durch 1 Ersetzen bei kWh)

                      Wenn Ihr das Skript startet passiert erst einmal nichts. Erst wenn neue Daten reinkämen.
                      Zum Testen könntet Ihr

                      • Im Trigger von wurde geändert auf wurde aktualisiert ändern
                      • den pvforecast Adapter einmal neu starten. Zumindest bei mir holt er dann sofort einmal neue Daten

                      und schon hat er uns die Werte schön in die Datenbank geschrieben:

                      MariaDB [iobroker]> select * from ts_number where id = '95';
                      +----+---------------+------+------+-------+------+
                      | id | ts            | val  | ack  | _from | q    |
                      +----+---------------+------+------+-------+------+
                      | 95 | 1646287082001 |    0 |    1 |     0 |    0 |
                      | 95 | 1646288940000 |   29 |    1 |     0 |    0 |
                      | 95 | 1646290802000 |  146 |    1 |     0 |    0 |
                      | 95 | 1646294400000 |  247 |    1 |     0 |    0 |
                      | 95 | 1646298000000 |  377 |    1 |     0 |    0 |
                      | 95 | 1646301600000 |  422 |    1 |     0 |    0 |
                      | 95 | 1646305200000 |  428 |    1 |     0 |    0 |
                      | 95 | 1646308800000 |  383 |    1 |     0 |    0 |
                      | 95 | 1646312400000 |  317 |    1 |     0 |    0 |
                      | 95 | 1646316000000 |  222 |    1 |     0 |    0 |
                      | 95 | 1646319600000 |  113 |    1 |     0 |    0 |
                      | 95 | 1646323200000 |   34 |    1 |     0 |    0 |
                      | 95 | 1646326800000 |    8 |    1 |     0 |    0 |
                      | 95 | 1646327160000 |    2 |    1 |     0 |    0 |
                      | 95 | 1646327460000 |    0 |    1 |     0 |    0 |
                      | 95 | 1646373360000 |    0 |    1 |     0 |    0 |
                      | 95 | 1646375280000 |   36 |    1 |     0 |    0 |
                      | 95 | 1646377200000 |  180 |    1 |     0 |    0 |
                      | 95 | 1646380800000 |  284 |    1 |     0 |    0 |
                      | 95 | 1646384400000 |  360 |    1 |     0 |    0 |
                      | 95 | 1646388000000 |  401 |    1 |     0 |    0 |
                      | 95 | 1646391600000 |  406 |    1 |     0 |    0 |
                      | 95 | 1646395200000 |  372 |    1 |     0 |    0 |
                      | 95 | 1646398800000 |  310 |    1 |     0 |    0 |
                      | 95 | 1646402400000 |  218 |    1 |     0 |    0 |
                      | 95 | 1646406000000 |  114 |    1 |     0 |    0 |
                      | 95 | 1646409600000 |   35 |    1 |     0 |    0 |
                      | 95 | 1646413200000 |    8 |    1 |     0 |    0 |
                      | 95 | 1646413620000 |    2 |    1 |     0 |    0 |
                      | 95 | 1646413980000 |    0 |    1 |     0 |    0 |
                      +----+---------------+------+------+-------+------+
                      30 rows in set (0.001 sec)
                      
                      

                      Die kann man jetzt in echarts etc. verwenden.

                      Woran ich noch verzweifle:

                      // Alles löschen
                      sendTo("sql.0", "deleteAll", {
                          "id": '0_userdata.0.Solaranlage.pvforecast',
                      }, async function (result) {
                            console.log(result);
                      });
                      

                      Wie schaffe ich es auch den Wert von id als Variable zu übergeben?
                      Daran habe ich nämlich 90% der Zeit gesessen. Zuerst habe ich es vergeblich mit dem Blockly-SendTo Block versucht (aber der hat es immer falsch formatiert gesendet) und dann wie ich die festen Werte durch Variablen ersetze.

                      @bananajoe sagte in Test PV Forecast Adapter:

                      @PatrickWalther

                      So, es ist vollbracht. Zwar durch die Brust ins Auge, aber es läuft (nebenbei habe ich aber wieder einmal viel gelernt).

                      Ich habe nun die Vorhersage erfolgreich mit dem SQL-Adapter (und einer MySQL-Datenbank) und dem echarts-Adapter als Anzeige zum laufen bekommen:
                      65f1abc8-bf77-43da-9914-17be824c2dcb-image.png
                      gelb ist meine echte Tagesleistung, rot die aus diesem Adapter (auch wenn ich hier Äpfel mit Birnen vergleiche, gelb sind W und rot Wh, daran mache ich mich als nächstes).

                      Als Vorrausetzung nehme ich einen installierten und funktionsfähigen SQL-Adapter an.
                      Außerdem habt Ihr den pvforecast Adapter konfiguriert und am laufen so das es einen Datenpunkt mit der Vorhersage gibt. Meine Lösung nutzt den Datenpunkt JSONTable der Anlage. Meine Anlage heißt 600W und der Datenpunkt also

                      pvforecast.0.600W.JSONTable
                      

                      ###################################################################

                      Schritt 1: Datenpunkt erstellen, konfigurieren und initialisieren
                      Es braucht einen Datenpunkt der Daten hält, ich habe hier diesen erstellt:

                      0_userdata.0.Solaranlage.pvforecast
                      

                      Als Typ Number bzw. Nummer
                      Dann habe ich ich SQL für den Datenpunkt eingeschaltet:
                      ed032325-be5e-40ed-afdb-2da83d0824a2-image.png
                      Entprellzeit auf 0 da die Daten in einem rutsch geschrieben werden

                      Nun ist es wichtig im Objekte Explorer dort einmal einen Wert von Hand reinzuschreiben, z.B. eine 42:
                      97f71f6a-a0a7-4718-86cd-199ad63c96e5-image.png
                      Erst dann ist der Datenpunkt in der SQL-Datenbank auch angelegt. Das hat mich die ersten bestimmt 20 Minuten nerven gekostet bis ich darauf gekommen bin. Solange funktioniert nämlich das SendTo noch nicht.

                      Schritt 2: Das Blockly Skript
                      Ja ja, ich dachte ich könnte das mal eben mit Blockly zusammenklicken statt es direkt in JavaScript zu schreiben. Mach ich vielleicht noch. Nun ist es Blockly mit 3 JavaScript Funktionen weil der SendTo Block einfach nicht zu überreden war das ganze vernünftig zu senden.

                      Im Spoiler der Blockly-Export

                      <xml xmlns="https://developers.google.com/blockly/xml">
                       <variables>
                         <variable id="xr?C%:}F%HR,+baC%W8n">x</variable>
                         <variable id="d/.bOP=7VlC5/[+=8g/u">myVAL</variable>
                         <variable id="SL$d6/`ClO6iqfefh5LN">myTS</variable>
                         <variable id="B$n_|Lt?V?dltG$1=%U!">JSONTable</variable>
                         <variable id="zqSSt1.lPBrP!prtJp:[">JSONListe</variable>
                         <variable id="[,noZ+!#R([v)Vli[JAC">counter</variable>
                         <variable id="9[xS=sH).DKBS8oGN@cs">i</variable>
                         <variable id="tkH#qcE=H5/_7~OttW5(">tempDatum</variable>
                         <variable id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</variable>
                       </variables>
                       <block type="procedures_defcustomreturn" id="f5+e$i!@hdFdP7[JA1^`" x="288" y="-212">
                         <mutation statements="false">
                           <arg name="x" varid="xr?C%:}F%HR,+baC%W8n"></arg>
                         </mutation>
                         <field name="NAME">ReplaceHyphen</field>
                         <field name="SCRIPT">cmV0dXJuIHgucmVwbGFjZSgiLy0vZyIsIi4iKTs=</field>
                         <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                       </block>
                       <block type="procedures_defcustomnoreturn" id="W?BjTQs!pguWw4HPwT)p" x="287" y="-162">
                         <mutation statements="false">
                           <arg name="myVAL" varid="d/.bOP=7VlC5/[+=8g/u"></arg>
                           <arg name="myTS" varid="SL$d6/`ClO6iqfefh5LN"></arg>
                         </mutation>
                         <field name="NAME">SendTo_SQL_storeState</field>
                         <field name="SCRIPT">Ly8gVW5kIHdlcnQgZXJzdGVsbGVuIHdpZSBnZXBsYW50DQpzZW5kVG8oInNxbC4wIiwgInN0b3JlU3RhdGUiLCB7DQogICAgImlkIjogJzBfdXNlcmRhdGEuMC5Tb2xhcmFubGFnZS5wdmZvcmVjYXN0JywNCiAgICAic3RhdGUiOiB7IA0KICAgICAgICAidmFsIjogbXlWQUwsIA0KICAgICAgICAidHMiOiBteVRTLA0KICAgICAgICAiYWNrIjogdHJ1ZQ0KICAgIH0NCn0sIGFzeW5jIGZ1bmN0aW9uIChyZXN1bHQpIHsNCiAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7</field>
                         <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                       </block>
                       <block type="procedures_defcustomnoreturn" id="m.]d6DR4hIR|rhM`P3KU" x="288" y="-112">
                         <mutation statements="false"></mutation>
                         <field name="NAME">SendTo_SQL_deleteAll</field>
                         <field name="SCRIPT">Ly8gQWxsZXMgbMO2c2NoZW4NCnNlbmRUbygic3FsLjAiLCAiZGVsZXRlQWxsIiwgew0KICAgICJpZCI6ICcwX3VzZXJkYXRhLjAuU29sYXJhbmxhZ2UucHZmb3JlY2FzdCcsDQp9LCBhc3luYyBmdW5jdGlvbiAocmVzdWx0KSB7DQogICAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7DQo=</field>
                         <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                       </block>
                       <block type="comment" id="emF90N[xA].w:e$0a5`A" x="288" y="-62">
                         <field name="COMMENT">Trigger auf den Datenpunkt JSONTable der</field>
                         <next>
                           <block type="comment" id="v|g5R@PBSlfR{}gqtWR1">
                             <field name="COMMENT">gewünschten Anlage</field>
                             <next>
                               <block type="on_ext" id="2}81gNSPn48mxt-C32N3">
                                 <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
                                 <field name="CONDITION">ne</field>
                                 <field name="ACK_CONDITION"></field>
                                 <value name="OID0">
                                   <shadow type="field_oid" id="$fUC/kgh^7[pBZjds,[N">
                                     <field name="oid">default</field>
                                   </shadow>
                                   <block type="text" id="Q~[~L7`?jff9w0!|{R!~">
                                     <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                   </block>
                                 </value>
                                 <statement name="STATEMENT">
                                   <block type="comment" id="xipk,Q4m/$Zbq(9xP]N;">
                                     <field name="COMMENT">Den JSON in eine Variable als Objekt holen</field>
                                     <next>
                                       <block type="variables_set" id="9le8nB_}E+{=^zh:Futa" disabled="true">
                                         <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                         <value name="VALUE">
                                           <block type="convert_json2object" id="C^`)6e!W4atd.!+{(i`D">
                                             <value name="VALUE">
                                               <block type="get_value_var" id="CX?q]Gc8j[Ks2F4.yc=c">
                                                 <field name="ATTR">val</field>
                                                 <value name="OID">
                                                   <shadow type="text" id="Y:eexHcUNi5aP`=sh5_;">
                                                     <field name="TEXT"></field>
                                                   </shadow>
                                                   <block type="text" id="2yV92%k{c@aR$t@FV|VK">
                                                     <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                   </block>
                                                 </value>
                                               </block>
                                             </value>
                                           </block>
                                         </value>
                                         <next>
                                           <block type="variables_set" id="y:J|yOI69aKr_]e}X})q">
                                             <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                             <value name="VALUE">
                                               <block type="on_source" id="GDRdyJ%YUi4U{P:xhe%L">
                                                 <field name="ATTR">state.val</field>
                                               </block>
                                             </value>
                                             <next>
                                               <block type="comment" id="78{/(q^zo:Vm3)}YeMKs">
                                                 <field name="COMMENT">Den JSON nochmal als Liste</field>
                                                 <next>
                                                   <block type="variables_set" id="$C:;|F_ENe?Kc{f9E*tE" disabled="true">
                                                     <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                     <value name="VALUE">
                                                       <block type="lists_split" id=":4[[9BsVwSu-#SFS/qp#">
                                                         <mutation mode="SPLIT"></mutation>
                                                         <field name="MODE">SPLIT</field>
                                                         <value name="INPUT">
                                                           <block type="get_value_var" id="k${_LxJlQ~Jc%^8mQ;J3">
                                                             <field name="ATTR">val</field>
                                                             <value name="OID">
                                                               <shadow type="text">
                                                                 <field name="TEXT"></field>
                                                               </shadow>
                                                               <block type="text" id="@(LLEO9DcZC_107PY7e;">
                                                                 <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                               </block>
                                                             </value>
                                                           </block>
                                                         </value>
                                                         <value name="DELIM">
                                                           <shadow type="text" id="_=ir)--C~K.5!,@3!%@4">
                                                             <field name="TEXT">},</field>
                                                           </shadow>
                                                         </value>
                                                       </block>
                                                     </value>
                                                     <next>
                                                       <block type="variables_set" id="KTHIaej{MV5TTxsehu:h">
                                                         <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                         <value name="VALUE">
                                                           <block type="lists_split" id="`#[tp]8]y!L^LEp8OL)J">
                                                             <mutation mode="SPLIT"></mutation>
                                                             <field name="MODE">SPLIT</field>
                                                             <value name="INPUT">
                                                               <block type="on_source" id="c),q`)7dZyX)GtW;Oe0Y">
                                                                 <field name="ATTR">state.val</field>
                                                               </block>
                                                             </value>
                                                             <value name="DELIM">
                                                               <shadow type="text" id="koPJuBu/Hm/D7+[$DR$`">
                                                                 <field name="TEXT">},{</field>
                                                               </shadow>
                                                             </value>
                                                           </block>
                                                         </value>
                                                         <next>
                                                           <block type="comment" id="_dDWRwqorhv|K4r20+CF">
                                                             <field name="COMMENT">Zähler für die einzelnen Werte</field>
                                                             <next>
                                                               <block type="variables_set" id="w[HNQFZ(pKC;(LonsppG">
                                                                 <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                 <value name="VALUE">
                                                                   <block type="math_number" id="$YD#)Z6].!0wU8:!IFY-">
                                                                     <field name="NUM">-1</field>
                                                                   </block>
                                                                 </value>
                                                                 <next>
                                                                   <block type="comment" id="nON/.IM*.X5L7BSfqn.j">
                                                                     <field name="COMMENT">Vorherige Werte löschen</field>
                                                                     <next>
                                                                       <block type="procedures_callcustomnoreturn" id="MjjlAd,#02dH9;[91A:e">
                                                                         <mutation name="SendTo_SQL_deleteAll"></mutation>
                                                                         <next>
                                                                           <block type="comment" id="+UxP]UFX*K*Ay8@+.3D(">
                                                                             <field name="COMMENT">Kurz warten ...</field>
                                                                             <next>
                                                                               <block type="timeouts_wait" id="b#[5BCU4#vD.+@RIgxwr">
                                                                                 <field name="DELAY">2</field>
                                                                                 <field name="UNIT">sec</field>
                                                                                 <next>
                                                                                   <block type="comment" id="?qlG@bV1nj7K%h8?`S-h">
                                                                                     <field name="COMMENT">Die Werte abarbeiten:</field>
                                                                                     <next>
                                                                                       <block type="controls_forEach" id="sZ%NhNSxC10sAg@O]Kz6">
                                                                                         <field name="VAR" id="9[xS=sH).DKBS8oGN@cs">i</field>
                                                                                         <value name="LIST">
                                                                                           <block type="variables_get" id="psB3RQ42dmHy[=aKrs!2">
                                                                                             <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                                                           </block>
                                                                                         </value>
                                                                                         <statement name="DO">
                                                                                           <block type="comment" id="0i?Xu2@hUv,g4?;i5Fhl">
                                                                                             <field name="COMMENT">Wird beim ersten mal 0 sein</field>
                                                                                             <next>
                                                                                               <block type="math_change" id="liet[5#L@~`I]t{8:/Es">
                                                                                                 <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                 <value name="DELTA">
                                                                                                   <shadow type="math_number" id="986qLvCF[J2VK^no0@Rp">
                                                                                                     <field name="NUM">1</field>
                                                                                                   </shadow>
                                                                                                 </value>
                                                                                                 <next>
                                                                                                   <block type="comment" id="}fPI/Q;fVu7V-uYuX2I+">
                                                                                                     <field name="COMMENT">Wir arbeiten die Liste ab, nutzen aber das Objekt!</field>
                                                                                                     <next>
                                                                                                       <block type="variables_set" id="^w);@i_kdtjWWf?c}BcO">
                                                                                                         <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                         <value name="VALUE">
                                                                                                           <block type="get_attr" id="jTRbW_-wI4-}.!,5V(VJ">
                                                                                                             <value name="PATH">
                                                                                                               <shadow type="text" id="3r`W9/~ToEj{Abx:)agx">
                                                                                                                 <field name="TEXT"></field>
                                                                                                               </shadow>
                                                                                                               <block type="text_join" id="xoFmSb~Y+xnD;cvM|g;-">
                                                                                                                 <mutation items="2"></mutation>
                                                                                                                 <value name="ADD0">
                                                                                                                   <block type="variables_get" id="K9;4LQ$1S/`at#YY52.j">
                                                                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                                 <value name="ADD1">
                                                                                                                   <block type="text" id="Kkt8qVr.ykp~NV;@{Uas">
                                                                                                                     <field name="TEXT">.Uhrzeit</field>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                               </block>
                                                                                                             </value>
                                                                                                             <value name="OBJECT">
                                                                                                               <block type="variables_get" id="`-rw74I`kqylUWgeH*+(">
                                                                                                                 <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                               </block>
                                                                                                             </value>
                                                                                                           </block>
                                                                                                         </value>
                                                                                                         <next>
                                                                                                           <block type="comment" id="b?]P+H9BwqfkDRv$/:j(">
                                                                                                             <field name="COMMENT">Die - in . umwandeln</field>
                                                                                                             <next>
                                                                                                               <block type="variables_set" id="k@v15A-cYpf/vbpRa;_z">
                                                                                                                 <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                 <value name="VALUE">
                                                                                                                   <block type="procedures_callcustomreturn" id="p[kw(;yI)pXBjjzD#D)~">
                                                                                                                     <mutation name="ReplaceHyphen">
                                                                                                                       <arg name="x"></arg>
                                                                                                                     </mutation>
                                                                                                                     <value name="ARG0">
                                                                                                                       <block type="variables_get" id="N)h=(1TR`.9#96=m?A0Y">
                                                                                                                         <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                       </block>
                                                                                                                     </value>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                                 <next>
                                                                                                                   <block type="comment" id="I-6Pjzc2in5fU|/L@xLT">
                                                                                                                     <field name="COMMENT">In ein Datum-Objekt umwandeln</field>
                                                                                                                     <next>
                                                                                                                       <block type="variables_set" id="FsILBORsaLrrazBi1L)J">
                                                                                                                         <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                         <value name="VALUE">
                                                                                                                           <block type="convert_from_date" id="4bbw}ZJhpHe}e.*nJ0`M">
                                                                                                                             <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                                                                                             <field name="OPTION">object</field>
                                                                                                                             <value name="VALUE">
                                                                                                                               <block type="variables_get" id="RjC;=Ac;nPHFrHCNt$SG">
                                                                                                                                 <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                               </block>
                                                                                                                             </value>
                                                                                                                           </block>
                                                                                                                         </value>
                                                                                                                         <next>
                                                                                                                           <block type="comment" id="?/.AjS+{19mE_EhC6?{%">
                                                                                                                             <field name="COMMENT">Die Leistung holen (hier in Wh statt kWh)</field>
                                                                                                                             <next>
                                                                                                                               <block type="variables_set" id="7$e1=Z.||tt-}b}$`QUX">
                                                                                                                                 <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                 <value name="VALUE">
                                                                                                                                   <block type="math_arithmetic" id="czVYE)d?^hj;sB8tQW%c" inline="false">
                                                                                                                                     <field name="OP">MULTIPLY</field>
                                                                                                                                     <value name="A">
                                                                                                                                       <shadow type="math_number" id="QXXI#nb51thU(gYujO7l">
                                                                                                                                         <field name="NUM">1</field>
                                                                                                                                       </shadow>
                                                                                                                                       <block type="get_attr" id="!p(Q2{*u/U@(LdLaWO;s">
                                                                                                                                         <value name="PATH">
                                                                                                                                           <shadow type="text">
                                                                                                                                             <field name="TEXT"></field>
                                                                                                                                           </shadow>
                                                                                                                                           <block type="text_join" id="eO+Kc@J#5ncJexgCa;XG">
                                                                                                                                             <mutation items="2"></mutation>
                                                                                                                                             <value name="ADD0">
                                                                                                                                               <block type="variables_get" id="6h@/w;v+5fJ:2k^fRu$`">
                                                                                                                                                 <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                             <value name="ADD1">
                                                                                                                                               <block type="text" id="u;lW,EMq1lo;0wl@^s~Z">
                                                                                                                                                 <field name="TEXT">.Leistung</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                         <value name="OBJECT">
                                                                                                                                           <block type="variables_get" id=":wC%m_*5#kUmjSCtRht*">
                                                                                                                                             <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                       </block>
                                                                                                                                     </value>
                                                                                                                                     <value name="B">
                                                                                                                                       <shadow type="math_number" id=".oUR!B4y8;}kLXv3HYVD">
                                                                                                                                         <field name="NUM">1000</field>
                                                                                                                                       </shadow>
                                                                                                                                     </value>
                                                                                                                                   </block>
                                                                                                                                 </value>
                                                                                                                                 <next>
                                                                                                                                   <block type="comment" id=".r}c.6$[JDf=.|#00pZj">
                                                                                                                                     <field name="COMMENT">Und in die Datenbank schreiben</field>
                                                                                                                                     <next>
                                                                                                                                       <block type="procedures_callcustomnoreturn" id="C,/_Emb0_,HXS0:;0?Cb">
                                                                                                                                         <mutation name="SendTo_SQL_storeState">
                                                                                                                                           <arg name="myVAL"></arg>
                                                                                                                                           <arg name="myTS"></arg>
                                                                                                                                         </mutation>
                                                                                                                                         <value name="ARG0">
                                                                                                                                           <block type="variables_get" id="ZX``,0~qVZ*H;d75IT!S">
                                                                                                                                             <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                         <value name="ARG1">
                                                                                                                                           <block type="variables_get" id="2rC,dvFPd3*_,1)EOdkN">
                                                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                       </block>
                                                                                                                                     </next>
                                                                                                                                   </block>
                                                                                                                                 </next>
                                                                                                                               </block>
                                                                                                                             </next>
                                                                                                                           </block>
                                                                                                                         </next>
                                                                                                                       </block>
                                                                                                                     </next>
                                                                                                                   </block>
                                                                                                                 </next>
                                                                                                               </block>
                                                                                                             </next>
                                                                                                           </block>
                                                                                                         </next>
                                                                                                       </block>
                                                                                                     </next>
                                                                                                   </block>
                                                                                                 </next>
                                                                                               </block>
                                                                                             </next>
                                                                                           </block>
                                                                                         </statement>
                                                                                       </block>
                                                                                     </next>
                                                                                   </block>
                                                                                 </next>
                                                                               </block>
                                                                             </next>
                                                                           </block>
                                                                         </next>
                                                                       </block>
                                                                     </next>
                                                                   </block>
                                                                 </next>
                                                               </block>
                                                             </next>
                                                           </block>
                                                         </next>
                                                       </block>
                                                     </next>
                                                   </block>
                                                 </next>
                                               </block>
                                             </next>
                                           </block>
                                         </next>
                                       </block>
                                     </next>
                                   </block>
                                 </statement>
                               </block>
                             </next>
                           </block>
                         </next>
                       </block>
                      </xml>
                      

                      Anpassen müsst Ihr:

                      In der JavaScript-Funktion SendTo_SQL_storeState den Namen des Ziel-Datenpunktes:
                      40558805-14b2-4080-9681-84d67524a428-image.png
                      gelb markiert:
                      84a72c5c-f34e-4793-8174-a9eb2ee5e8ad-image.png

                      Das gleiche in der JavaScript-Funktion SendTo_SQL_DeleteAll
                      91c29379-c885-4fef-b5b4-c710f95d35ff-image.png

                      Und im Kopf den Quellpfad zu eurer Anlage:
                      46235a8d-a6ad-44ff-8668-09fe532644d5-image.png

                      Und ob Ihr es in kWh oder Wh haben wollt:
                      cdba127d-a976-408f-a313-22f6ba0d77e3-image.png
                      (die x 1000 entfernen oder durch 1 Ersetzen bei kWh)

                      Wenn Ihr das Skript startet passiert erst einmal nichts. Erst wenn neue Daten reinkämen.
                      Zum Testen könntet Ihr

                      • Im Trigger von wurde geändert auf wurde aktualisiert ändern
                      • den pvforecast Adapter einmal neu starten. Zumindest bei mir holt er dann sofort einmal neue Daten

                      und schon hat er uns die Werte schön in die Datenbank geschrieben:

                      MariaDB [iobroker]> select * from ts_number where id = '95';
                      +----+---------------+------+------+-------+------+
                      | id | ts            | val  | ack  | _from | q    |
                      +----+---------------+------+------+-------+------+
                      | 95 | 1646287082001 |    0 |    1 |     0 |    0 |
                      | 95 | 1646288940000 |   29 |    1 |     0 |    0 |
                      | 95 | 1646290802000 |  146 |    1 |     0 |    0 |
                      | 95 | 1646294400000 |  247 |    1 |     0 |    0 |
                      | 95 | 1646298000000 |  377 |    1 |     0 |    0 |
                      | 95 | 1646301600000 |  422 |    1 |     0 |    0 |
                      | 95 | 1646305200000 |  428 |    1 |     0 |    0 |
                      | 95 | 1646308800000 |  383 |    1 |     0 |    0 |
                      | 95 | 1646312400000 |  317 |    1 |     0 |    0 |
                      | 95 | 1646316000000 |  222 |    1 |     0 |    0 |
                      | 95 | 1646319600000 |  113 |    1 |     0 |    0 |
                      | 95 | 1646323200000 |   34 |    1 |     0 |    0 |
                      | 95 | 1646326800000 |    8 |    1 |     0 |    0 |
                      | 95 | 1646327160000 |    2 |    1 |     0 |    0 |
                      | 95 | 1646327460000 |    0 |    1 |     0 |    0 |
                      | 95 | 1646373360000 |    0 |    1 |     0 |    0 |
                      | 95 | 1646375280000 |   36 |    1 |     0 |    0 |
                      | 95 | 1646377200000 |  180 |    1 |     0 |    0 |
                      | 95 | 1646380800000 |  284 |    1 |     0 |    0 |
                      | 95 | 1646384400000 |  360 |    1 |     0 |    0 |
                      | 95 | 1646388000000 |  401 |    1 |     0 |    0 |
                      | 95 | 1646391600000 |  406 |    1 |     0 |    0 |
                      | 95 | 1646395200000 |  372 |    1 |     0 |    0 |
                      | 95 | 1646398800000 |  310 |    1 |     0 |    0 |
                      | 95 | 1646402400000 |  218 |    1 |     0 |    0 |
                      | 95 | 1646406000000 |  114 |    1 |     0 |    0 |
                      | 95 | 1646409600000 |   35 |    1 |     0 |    0 |
                      | 95 | 1646413200000 |    8 |    1 |     0 |    0 |
                      | 95 | 1646413620000 |    2 |    1 |     0 |    0 |
                      | 95 | 1646413980000 |    0 |    1 |     0 |    0 |
                      +----+---------------+------+------+-------+------+
                      30 rows in set (0.001 sec)
                      
                      

                      Die kann man jetzt in echarts etc. verwenden.

                      Woran ich noch verzweifle:

                      // Alles löschen
                      sendTo("sql.0", "deleteAll", {
                          "id": '0_userdata.0.Solaranlage.pvforecast',
                      }, async function (result) {
                            console.log(result);
                      });
                      

                      Wie schaffe ich es auch den Wert von id als Variable zu übergeben?
                      Daran habe ich nämlich 90% der Zeit gesessen. Zuerst habe ich es vergeblich mit dem Blockly-SendTo Block versucht (aber der hat es immer falsch formatiert gesendet) und dann wie ich die festen Werte durch Variablen ersetze.

                      Wenn auch durch die Brust ins Auge, damit konnte ich endlich ein funktionierendes Grafana Diagramm erstellen.
                      Danke für die Lösung.
                      Inhaltlich muß ich die Werte mal die nächsten Tage checken ob das alles so zu meiner Anlage paßt.

                      2022_03_05 16_40_52-vis.png

                      PlatformBetriebssystem:linux Architektur:arm64 CPUs:4 Geschwindigkeit:1800 MHz Modell:Cortex-A72
                      RAM:3.7 GB System-Betriebszeit:00:19:02 Node.js:v20.18.0
                      _nodeCurrent:20.18.0
                      _npmCurrent:10.8.2
                      Operating System: Debian GNU/Linux 12 (bookworm) Kernel: Linux 6.6.57-v8+

                      BananaJoeB 1 Antwort Letzte Antwort
                      0
                      • B Offline
                        B Offline
                        bastian-m
                        schrieb am zuletzt editiert von
                        #317

                        Ich habe zum Vergleich der Vorhersagequalität von Forecast.Solar und Solcast zwei Adapterinstanzen aufgesetzt, in beiden die identische PV-Anlagen-Konfiguration hinterlegt und die eine Instanz mit Forecast.Solar und den anderen mit Solcast gekoppelt. (Für Forecast.Solar habe ich ein Abo und deshalb stehen mir die Vorhersagen in 15min-Auflösung zur Verfügung, für Solcast alle 30min). Ich werde in den nächsten Tagen die protokollierte tatsächliche Erzeugung meiner PV-Anlage mit den Prognosedaten der beiden Dienste vergleichen.

                        Ein entsprechendes Dashboard in Grafana ist eingerichtet:
                        Vorhersage-Vergleich.png
                        Für Solcast liegt die Prognose erst ab dem Zeitpunkt der Einrichtung der zweiten Adapter-Instanz vor, daher fehlt die Vorhersage für heute Vormittag.

                        Ich werde im Verlauf berichten. Interessant werden die Prognosen natürich erst an Tagen mit unterschiedlicher Bewölkung - für die aktuell sehr sonnigen Tage stimmt es natürlich am ehesten noch.

                        Schönen Sonntag!
                        Bastian

                        1 Antwort Letzte Antwort
                        0
                        • sonnenscheinS sonnenschein

                          @bananajoe sagte in Test PV Forecast Adapter:

                          @PatrickWalther

                          So, es ist vollbracht. Zwar durch die Brust ins Auge, aber es läuft (nebenbei habe ich aber wieder einmal viel gelernt).

                          Ich habe nun die Vorhersage erfolgreich mit dem SQL-Adapter (und einer MySQL-Datenbank) und dem echarts-Adapter als Anzeige zum laufen bekommen:
                          65f1abc8-bf77-43da-9914-17be824c2dcb-image.png
                          gelb ist meine echte Tagesleistung, rot die aus diesem Adapter (auch wenn ich hier Äpfel mit Birnen vergleiche, gelb sind W und rot Wh, daran mache ich mich als nächstes).

                          Als Vorrausetzung nehme ich einen installierten und funktionsfähigen SQL-Adapter an.
                          Außerdem habt Ihr den pvforecast Adapter konfiguriert und am laufen so das es einen Datenpunkt mit der Vorhersage gibt. Meine Lösung nutzt den Datenpunkt JSONTable der Anlage. Meine Anlage heißt 600W und der Datenpunkt also

                          pvforecast.0.600W.JSONTable
                          

                          ###################################################################

                          Schritt 1: Datenpunkt erstellen, konfigurieren und initialisieren
                          Es braucht einen Datenpunkt der Daten hält, ich habe hier diesen erstellt:

                          0_userdata.0.Solaranlage.pvforecast
                          

                          Als Typ Number bzw. Nummer
                          Dann habe ich ich SQL für den Datenpunkt eingeschaltet:
                          ed032325-be5e-40ed-afdb-2da83d0824a2-image.png
                          Entprellzeit auf 0 da die Daten in einem rutsch geschrieben werden

                          Nun ist es wichtig im Objekte Explorer dort einmal einen Wert von Hand reinzuschreiben, z.B. eine 42:
                          97f71f6a-a0a7-4718-86cd-199ad63c96e5-image.png
                          Erst dann ist der Datenpunkt in der SQL-Datenbank auch angelegt. Das hat mich die ersten bestimmt 20 Minuten nerven gekostet bis ich darauf gekommen bin. Solange funktioniert nämlich das SendTo noch nicht.

                          Schritt 2: Das Blockly Skript
                          Ja ja, ich dachte ich könnte das mal eben mit Blockly zusammenklicken statt es direkt in JavaScript zu schreiben. Mach ich vielleicht noch. Nun ist es Blockly mit 3 JavaScript Funktionen weil der SendTo Block einfach nicht zu überreden war das ganze vernünftig zu senden.

                          Im Spoiler der Blockly-Export

                          <xml xmlns="https://developers.google.com/blockly/xml">
                           <variables>
                             <variable id="xr?C%:}F%HR,+baC%W8n">x</variable>
                             <variable id="d/.bOP=7VlC5/[+=8g/u">myVAL</variable>
                             <variable id="SL$d6/`ClO6iqfefh5LN">myTS</variable>
                             <variable id="B$n_|Lt?V?dltG$1=%U!">JSONTable</variable>
                             <variable id="zqSSt1.lPBrP!prtJp:[">JSONListe</variable>
                             <variable id="[,noZ+!#R([v)Vli[JAC">counter</variable>
                             <variable id="9[xS=sH).DKBS8oGN@cs">i</variable>
                             <variable id="tkH#qcE=H5/_7~OttW5(">tempDatum</variable>
                             <variable id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</variable>
                           </variables>
                           <block type="procedures_defcustomreturn" id="f5+e$i!@hdFdP7[JA1^`" x="288" y="-212">
                             <mutation statements="false">
                               <arg name="x" varid="xr?C%:}F%HR,+baC%W8n"></arg>
                             </mutation>
                             <field name="NAME">ReplaceHyphen</field>
                             <field name="SCRIPT">cmV0dXJuIHgucmVwbGFjZSgiLy0vZyIsIi4iKTs=</field>
                             <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                           </block>
                           <block type="procedures_defcustomnoreturn" id="W?BjTQs!pguWw4HPwT)p" x="287" y="-162">
                             <mutation statements="false">
                               <arg name="myVAL" varid="d/.bOP=7VlC5/[+=8g/u"></arg>
                               <arg name="myTS" varid="SL$d6/`ClO6iqfefh5LN"></arg>
                             </mutation>
                             <field name="NAME">SendTo_SQL_storeState</field>
                             <field name="SCRIPT">Ly8gVW5kIHdlcnQgZXJzdGVsbGVuIHdpZSBnZXBsYW50DQpzZW5kVG8oInNxbC4wIiwgInN0b3JlU3RhdGUiLCB7DQogICAgImlkIjogJzBfdXNlcmRhdGEuMC5Tb2xhcmFubGFnZS5wdmZvcmVjYXN0JywNCiAgICAic3RhdGUiOiB7IA0KICAgICAgICAidmFsIjogbXlWQUwsIA0KICAgICAgICAidHMiOiBteVRTLA0KICAgICAgICAiYWNrIjogdHJ1ZQ0KICAgIH0NCn0sIGFzeW5jIGZ1bmN0aW9uIChyZXN1bHQpIHsNCiAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7</field>
                             <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                           </block>
                           <block type="procedures_defcustomnoreturn" id="m.]d6DR4hIR|rhM`P3KU" x="288" y="-112">
                             <mutation statements="false"></mutation>
                             <field name="NAME">SendTo_SQL_deleteAll</field>
                             <field name="SCRIPT">Ly8gQWxsZXMgbMO2c2NoZW4NCnNlbmRUbygic3FsLjAiLCAiZGVsZXRlQWxsIiwgew0KICAgICJpZCI6ICcwX3VzZXJkYXRhLjAuU29sYXJhbmxhZ2UucHZmb3JlY2FzdCcsDQp9LCBhc3luYyBmdW5jdGlvbiAocmVzdWx0KSB7DQogICAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7DQo=</field>
                             <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                           </block>
                           <block type="comment" id="emF90N[xA].w:e$0a5`A" x="288" y="-62">
                             <field name="COMMENT">Trigger auf den Datenpunkt JSONTable der</field>
                             <next>
                               <block type="comment" id="v|g5R@PBSlfR{}gqtWR1">
                                 <field name="COMMENT">gewünschten Anlage</field>
                                 <next>
                                   <block type="on_ext" id="2}81gNSPn48mxt-C32N3">
                                     <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
                                     <field name="CONDITION">ne</field>
                                     <field name="ACK_CONDITION"></field>
                                     <value name="OID0">
                                       <shadow type="field_oid" id="$fUC/kgh^7[pBZjds,[N">
                                         <field name="oid">default</field>
                                       </shadow>
                                       <block type="text" id="Q~[~L7`?jff9w0!|{R!~">
                                         <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                       </block>
                                     </value>
                                     <statement name="STATEMENT">
                                       <block type="comment" id="xipk,Q4m/$Zbq(9xP]N;">
                                         <field name="COMMENT">Den JSON in eine Variable als Objekt holen</field>
                                         <next>
                                           <block type="variables_set" id="9le8nB_}E+{=^zh:Futa" disabled="true">
                                             <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                             <value name="VALUE">
                                               <block type="convert_json2object" id="C^`)6e!W4atd.!+{(i`D">
                                                 <value name="VALUE">
                                                   <block type="get_value_var" id="CX?q]Gc8j[Ks2F4.yc=c">
                                                     <field name="ATTR">val</field>
                                                     <value name="OID">
                                                       <shadow type="text" id="Y:eexHcUNi5aP`=sh5_;">
                                                         <field name="TEXT"></field>
                                                       </shadow>
                                                       <block type="text" id="2yV92%k{c@aR$t@FV|VK">
                                                         <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                       </block>
                                                     </value>
                                                   </block>
                                                 </value>
                                               </block>
                                             </value>
                                             <next>
                                               <block type="variables_set" id="y:J|yOI69aKr_]e}X})q">
                                                 <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                 <value name="VALUE">
                                                   <block type="on_source" id="GDRdyJ%YUi4U{P:xhe%L">
                                                     <field name="ATTR">state.val</field>
                                                   </block>
                                                 </value>
                                                 <next>
                                                   <block type="comment" id="78{/(q^zo:Vm3)}YeMKs">
                                                     <field name="COMMENT">Den JSON nochmal als Liste</field>
                                                     <next>
                                                       <block type="variables_set" id="$C:;|F_ENe?Kc{f9E*tE" disabled="true">
                                                         <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                         <value name="VALUE">
                                                           <block type="lists_split" id=":4[[9BsVwSu-#SFS/qp#">
                                                             <mutation mode="SPLIT"></mutation>
                                                             <field name="MODE">SPLIT</field>
                                                             <value name="INPUT">
                                                               <block type="get_value_var" id="k${_LxJlQ~Jc%^8mQ;J3">
                                                                 <field name="ATTR">val</field>
                                                                 <value name="OID">
                                                                   <shadow type="text">
                                                                     <field name="TEXT"></field>
                                                                   </shadow>
                                                                   <block type="text" id="@(LLEO9DcZC_107PY7e;">
                                                                     <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                                   </block>
                                                                 </value>
                                                               </block>
                                                             </value>
                                                             <value name="DELIM">
                                                               <shadow type="text" id="_=ir)--C~K.5!,@3!%@4">
                                                                 <field name="TEXT">},</field>
                                                               </shadow>
                                                             </value>
                                                           </block>
                                                         </value>
                                                         <next>
                                                           <block type="variables_set" id="KTHIaej{MV5TTxsehu:h">
                                                             <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                             <value name="VALUE">
                                                               <block type="lists_split" id="`#[tp]8]y!L^LEp8OL)J">
                                                                 <mutation mode="SPLIT"></mutation>
                                                                 <field name="MODE">SPLIT</field>
                                                                 <value name="INPUT">
                                                                   <block type="on_source" id="c),q`)7dZyX)GtW;Oe0Y">
                                                                     <field name="ATTR">state.val</field>
                                                                   </block>
                                                                 </value>
                                                                 <value name="DELIM">
                                                                   <shadow type="text" id="koPJuBu/Hm/D7+[$DR$`">
                                                                     <field name="TEXT">},{</field>
                                                                   </shadow>
                                                                 </value>
                                                               </block>
                                                             </value>
                                                             <next>
                                                               <block type="comment" id="_dDWRwqorhv|K4r20+CF">
                                                                 <field name="COMMENT">Zähler für die einzelnen Werte</field>
                                                                 <next>
                                                                   <block type="variables_set" id="w[HNQFZ(pKC;(LonsppG">
                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                     <value name="VALUE">
                                                                       <block type="math_number" id="$YD#)Z6].!0wU8:!IFY-">
                                                                         <field name="NUM">-1</field>
                                                                       </block>
                                                                     </value>
                                                                     <next>
                                                                       <block type="comment" id="nON/.IM*.X5L7BSfqn.j">
                                                                         <field name="COMMENT">Vorherige Werte löschen</field>
                                                                         <next>
                                                                           <block type="procedures_callcustomnoreturn" id="MjjlAd,#02dH9;[91A:e">
                                                                             <mutation name="SendTo_SQL_deleteAll"></mutation>
                                                                             <next>
                                                                               <block type="comment" id="+UxP]UFX*K*Ay8@+.3D(">
                                                                                 <field name="COMMENT">Kurz warten ...</field>
                                                                                 <next>
                                                                                   <block type="timeouts_wait" id="b#[5BCU4#vD.+@RIgxwr">
                                                                                     <field name="DELAY">2</field>
                                                                                     <field name="UNIT">sec</field>
                                                                                     <next>
                                                                                       <block type="comment" id="?qlG@bV1nj7K%h8?`S-h">
                                                                                         <field name="COMMENT">Die Werte abarbeiten:</field>
                                                                                         <next>
                                                                                           <block type="controls_forEach" id="sZ%NhNSxC10sAg@O]Kz6">
                                                                                             <field name="VAR" id="9[xS=sH).DKBS8oGN@cs">i</field>
                                                                                             <value name="LIST">
                                                                                               <block type="variables_get" id="psB3RQ42dmHy[=aKrs!2">
                                                                                                 <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                                                               </block>
                                                                                             </value>
                                                                                             <statement name="DO">
                                                                                               <block type="comment" id="0i?Xu2@hUv,g4?;i5Fhl">
                                                                                                 <field name="COMMENT">Wird beim ersten mal 0 sein</field>
                                                                                                 <next>
                                                                                                   <block type="math_change" id="liet[5#L@~`I]t{8:/Es">
                                                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                     <value name="DELTA">
                                                                                                       <shadow type="math_number" id="986qLvCF[J2VK^no0@Rp">
                                                                                                         <field name="NUM">1</field>
                                                                                                       </shadow>
                                                                                                     </value>
                                                                                                     <next>
                                                                                                       <block type="comment" id="}fPI/Q;fVu7V-uYuX2I+">
                                                                                                         <field name="COMMENT">Wir arbeiten die Liste ab, nutzen aber das Objekt!</field>
                                                                                                         <next>
                                                                                                           <block type="variables_set" id="^w);@i_kdtjWWf?c}BcO">
                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                             <value name="VALUE">
                                                                                                               <block type="get_attr" id="jTRbW_-wI4-}.!,5V(VJ">
                                                                                                                 <value name="PATH">
                                                                                                                   <shadow type="text" id="3r`W9/~ToEj{Abx:)agx">
                                                                                                                     <field name="TEXT"></field>
                                                                                                                   </shadow>
                                                                                                                   <block type="text_join" id="xoFmSb~Y+xnD;cvM|g;-">
                                                                                                                     <mutation items="2"></mutation>
                                                                                                                     <value name="ADD0">
                                                                                                                       <block type="variables_get" id="K9;4LQ$1S/`at#YY52.j">
                                                                                                                         <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                       </block>
                                                                                                                     </value>
                                                                                                                     <value name="ADD1">
                                                                                                                       <block type="text" id="Kkt8qVr.ykp~NV;@{Uas">
                                                                                                                         <field name="TEXT">.Uhrzeit</field>
                                                                                                                       </block>
                                                                                                                     </value>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                                 <value name="OBJECT">
                                                                                                                   <block type="variables_get" id="`-rw74I`kqylUWgeH*+(">
                                                                                                                     <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                               </block>
                                                                                                             </value>
                                                                                                             <next>
                                                                                                               <block type="comment" id="b?]P+H9BwqfkDRv$/:j(">
                                                                                                                 <field name="COMMENT">Die - in . umwandeln</field>
                                                                                                                 <next>
                                                                                                                   <block type="variables_set" id="k@v15A-cYpf/vbpRa;_z">
                                                                                                                     <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                     <value name="VALUE">
                                                                                                                       <block type="procedures_callcustomreturn" id="p[kw(;yI)pXBjjzD#D)~">
                                                                                                                         <mutation name="ReplaceHyphen">
                                                                                                                           <arg name="x"></arg>
                                                                                                                         </mutation>
                                                                                                                         <value name="ARG0">
                                                                                                                           <block type="variables_get" id="N)h=(1TR`.9#96=m?A0Y">
                                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                           </block>
                                                                                                                         </value>
                                                                                                                       </block>
                                                                                                                     </value>
                                                                                                                     <next>
                                                                                                                       <block type="comment" id="I-6Pjzc2in5fU|/L@xLT">
                                                                                                                         <field name="COMMENT">In ein Datum-Objekt umwandeln</field>
                                                                                                                         <next>
                                                                                                                           <block type="variables_set" id="FsILBORsaLrrazBi1L)J">
                                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                             <value name="VALUE">
                                                                                                                               <block type="convert_from_date" id="4bbw}ZJhpHe}e.*nJ0`M">
                                                                                                                                 <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                                                                                                 <field name="OPTION">object</field>
                                                                                                                                 <value name="VALUE">
                                                                                                                                   <block type="variables_get" id="RjC;=Ac;nPHFrHCNt$SG">
                                                                                                                                     <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                                   </block>
                                                                                                                                 </value>
                                                                                                                               </block>
                                                                                                                             </value>
                                                                                                                             <next>
                                                                                                                               <block type="comment" id="?/.AjS+{19mE_EhC6?{%">
                                                                                                                                 <field name="COMMENT">Die Leistung holen (hier in Wh statt kWh)</field>
                                                                                                                                 <next>
                                                                                                                                   <block type="variables_set" id="7$e1=Z.||tt-}b}$`QUX">
                                                                                                                                     <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                     <value name="VALUE">
                                                                                                                                       <block type="math_arithmetic" id="czVYE)d?^hj;sB8tQW%c" inline="false">
                                                                                                                                         <field name="OP">MULTIPLY</field>
                                                                                                                                         <value name="A">
                                                                                                                                           <shadow type="math_number" id="QXXI#nb51thU(gYujO7l">
                                                                                                                                             <field name="NUM">1</field>
                                                                                                                                           </shadow>
                                                                                                                                           <block type="get_attr" id="!p(Q2{*u/U@(LdLaWO;s">
                                                                                                                                             <value name="PATH">
                                                                                                                                               <shadow type="text">
                                                                                                                                                 <field name="TEXT"></field>
                                                                                                                                               </shadow>
                                                                                                                                               <block type="text_join" id="eO+Kc@J#5ncJexgCa;XG">
                                                                                                                                                 <mutation items="2"></mutation>
                                                                                                                                                 <value name="ADD0">
                                                                                                                                                   <block type="variables_get" id="6h@/w;v+5fJ:2k^fRu$`">
                                                                                                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                                                   </block>
                                                                                                                                                 </value>
                                                                                                                                                 <value name="ADD1">
                                                                                                                                                   <block type="text" id="u;lW,EMq1lo;0wl@^s~Z">
                                                                                                                                                     <field name="TEXT">.Leistung</field>
                                                                                                                                                   </block>
                                                                                                                                                 </value>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                             <value name="OBJECT">
                                                                                                                                               <block type="variables_get" id=":wC%m_*5#kUmjSCtRht*">
                                                                                                                                                 <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                         <value name="B">
                                                                                                                                           <shadow type="math_number" id=".oUR!B4y8;}kLXv3HYVD">
                                                                                                                                             <field name="NUM">1000</field>
                                                                                                                                           </shadow>
                                                                                                                                         </value>
                                                                                                                                       </block>
                                                                                                                                     </value>
                                                                                                                                     <next>
                                                                                                                                       <block type="comment" id=".r}c.6$[JDf=.|#00pZj">
                                                                                                                                         <field name="COMMENT">Und in die Datenbank schreiben</field>
                                                                                                                                         <next>
                                                                                                                                           <block type="procedures_callcustomnoreturn" id="C,/_Emb0_,HXS0:;0?Cb">
                                                                                                                                             <mutation name="SendTo_SQL_storeState">
                                                                                                                                               <arg name="myVAL"></arg>
                                                                                                                                               <arg name="myTS"></arg>
                                                                                                                                             </mutation>
                                                                                                                                             <value name="ARG0">
                                                                                                                                               <block type="variables_get" id="ZX``,0~qVZ*H;d75IT!S">
                                                                                                                                                 <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                             <value name="ARG1">
                                                                                                                                               <block type="variables_get" id="2rC,dvFPd3*_,1)EOdkN">
                                                                                                                                                 <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                           </block>
                                                                                                                                         </next>
                                                                                                                                       </block>
                                                                                                                                     </next>
                                                                                                                                   </block>
                                                                                                                                 </next>
                                                                                                                               </block>
                                                                                                                             </next>
                                                                                                                           </block>
                                                                                                                         </next>
                                                                                                                       </block>
                                                                                                                     </next>
                                                                                                                   </block>
                                                                                                                 </next>
                                                                                                               </block>
                                                                                                             </next>
                                                                                                           </block>
                                                                                                         </next>
                                                                                                       </block>
                                                                                                     </next>
                                                                                                   </block>
                                                                                                 </next>
                                                                                               </block>
                                                                                             </statement>
                                                                                           </block>
                                                                                         </next>
                                                                                       </block>
                                                                                     </next>
                                                                                   </block>
                                                                                 </next>
                                                                               </block>
                                                                             </next>
                                                                           </block>
                                                                         </next>
                                                                       </block>
                                                                     </next>
                                                                   </block>
                                                                 </next>
                                                               </block>
                                                             </next>
                                                           </block>
                                                         </next>
                                                       </block>
                                                     </next>
                                                   </block>
                                                 </next>
                                               </block>
                                             </next>
                                           </block>
                                         </next>
                                       </block>
                                     </statement>
                                   </block>
                                 </next>
                               </block>
                             </next>
                           </block>
                          </xml>
                          

                          Anpassen müsst Ihr:

                          In der JavaScript-Funktion SendTo_SQL_storeState den Namen des Ziel-Datenpunktes:
                          40558805-14b2-4080-9681-84d67524a428-image.png
                          gelb markiert:
                          84a72c5c-f34e-4793-8174-a9eb2ee5e8ad-image.png

                          Das gleiche in der JavaScript-Funktion SendTo_SQL_DeleteAll
                          91c29379-c885-4fef-b5b4-c710f95d35ff-image.png

                          Und im Kopf den Quellpfad zu eurer Anlage:
                          46235a8d-a6ad-44ff-8668-09fe532644d5-image.png

                          Und ob Ihr es in kWh oder Wh haben wollt:
                          cdba127d-a976-408f-a313-22f6ba0d77e3-image.png
                          (die x 1000 entfernen oder durch 1 Ersetzen bei kWh)

                          Wenn Ihr das Skript startet passiert erst einmal nichts. Erst wenn neue Daten reinkämen.
                          Zum Testen könntet Ihr

                          • Im Trigger von wurde geändert auf wurde aktualisiert ändern
                          • den pvforecast Adapter einmal neu starten. Zumindest bei mir holt er dann sofort einmal neue Daten

                          und schon hat er uns die Werte schön in die Datenbank geschrieben:

                          MariaDB [iobroker]> select * from ts_number where id = '95';
                          +----+---------------+------+------+-------+------+
                          | id | ts            | val  | ack  | _from | q    |
                          +----+---------------+------+------+-------+------+
                          | 95 | 1646287082001 |    0 |    1 |     0 |    0 |
                          | 95 | 1646288940000 |   29 |    1 |     0 |    0 |
                          | 95 | 1646290802000 |  146 |    1 |     0 |    0 |
                          | 95 | 1646294400000 |  247 |    1 |     0 |    0 |
                          | 95 | 1646298000000 |  377 |    1 |     0 |    0 |
                          | 95 | 1646301600000 |  422 |    1 |     0 |    0 |
                          | 95 | 1646305200000 |  428 |    1 |     0 |    0 |
                          | 95 | 1646308800000 |  383 |    1 |     0 |    0 |
                          | 95 | 1646312400000 |  317 |    1 |     0 |    0 |
                          | 95 | 1646316000000 |  222 |    1 |     0 |    0 |
                          | 95 | 1646319600000 |  113 |    1 |     0 |    0 |
                          | 95 | 1646323200000 |   34 |    1 |     0 |    0 |
                          | 95 | 1646326800000 |    8 |    1 |     0 |    0 |
                          | 95 | 1646327160000 |    2 |    1 |     0 |    0 |
                          | 95 | 1646327460000 |    0 |    1 |     0 |    0 |
                          | 95 | 1646373360000 |    0 |    1 |     0 |    0 |
                          | 95 | 1646375280000 |   36 |    1 |     0 |    0 |
                          | 95 | 1646377200000 |  180 |    1 |     0 |    0 |
                          | 95 | 1646380800000 |  284 |    1 |     0 |    0 |
                          | 95 | 1646384400000 |  360 |    1 |     0 |    0 |
                          | 95 | 1646388000000 |  401 |    1 |     0 |    0 |
                          | 95 | 1646391600000 |  406 |    1 |     0 |    0 |
                          | 95 | 1646395200000 |  372 |    1 |     0 |    0 |
                          | 95 | 1646398800000 |  310 |    1 |     0 |    0 |
                          | 95 | 1646402400000 |  218 |    1 |     0 |    0 |
                          | 95 | 1646406000000 |  114 |    1 |     0 |    0 |
                          | 95 | 1646409600000 |   35 |    1 |     0 |    0 |
                          | 95 | 1646413200000 |    8 |    1 |     0 |    0 |
                          | 95 | 1646413620000 |    2 |    1 |     0 |    0 |
                          | 95 | 1646413980000 |    0 |    1 |     0 |    0 |
                          +----+---------------+------+------+-------+------+
                          30 rows in set (0.001 sec)
                          
                          

                          Die kann man jetzt in echarts etc. verwenden.

                          Woran ich noch verzweifle:

                          // Alles löschen
                          sendTo("sql.0", "deleteAll", {
                              "id": '0_userdata.0.Solaranlage.pvforecast',
                          }, async function (result) {
                                console.log(result);
                          });
                          

                          Wie schaffe ich es auch den Wert von id als Variable zu übergeben?
                          Daran habe ich nämlich 90% der Zeit gesessen. Zuerst habe ich es vergeblich mit dem Blockly-SendTo Block versucht (aber der hat es immer falsch formatiert gesendet) und dann wie ich die festen Werte durch Variablen ersetze.

                          @bananajoe sagte in Test PV Forecast Adapter:

                          @PatrickWalther

                          So, es ist vollbracht. Zwar durch die Brust ins Auge, aber es läuft (nebenbei habe ich aber wieder einmal viel gelernt).

                          Ich habe nun die Vorhersage erfolgreich mit dem SQL-Adapter (und einer MySQL-Datenbank) und dem echarts-Adapter als Anzeige zum laufen bekommen:
                          65f1abc8-bf77-43da-9914-17be824c2dcb-image.png
                          gelb ist meine echte Tagesleistung, rot die aus diesem Adapter (auch wenn ich hier Äpfel mit Birnen vergleiche, gelb sind W und rot Wh, daran mache ich mich als nächstes).

                          Als Vorrausetzung nehme ich einen installierten und funktionsfähigen SQL-Adapter an.
                          Außerdem habt Ihr den pvforecast Adapter konfiguriert und am laufen so das es einen Datenpunkt mit der Vorhersage gibt. Meine Lösung nutzt den Datenpunkt JSONTable der Anlage. Meine Anlage heißt 600W und der Datenpunkt also

                          pvforecast.0.600W.JSONTable
                          

                          ###################################################################

                          Schritt 1: Datenpunkt erstellen, konfigurieren und initialisieren
                          Es braucht einen Datenpunkt der Daten hält, ich habe hier diesen erstellt:

                          0_userdata.0.Solaranlage.pvforecast
                          

                          Als Typ Number bzw. Nummer
                          Dann habe ich ich SQL für den Datenpunkt eingeschaltet:
                          ed032325-be5e-40ed-afdb-2da83d0824a2-image.png
                          Entprellzeit auf 0 da die Daten in einem rutsch geschrieben werden

                          Nun ist es wichtig im Objekte Explorer dort einmal einen Wert von Hand reinzuschreiben, z.B. eine 42:
                          97f71f6a-a0a7-4718-86cd-199ad63c96e5-image.png
                          Erst dann ist der Datenpunkt in der SQL-Datenbank auch angelegt. Das hat mich die ersten bestimmt 20 Minuten nerven gekostet bis ich darauf gekommen bin. Solange funktioniert nämlich das SendTo noch nicht.

                          Schritt 2: Das Blockly Skript
                          Ja ja, ich dachte ich könnte das mal eben mit Blockly zusammenklicken statt es direkt in JavaScript zu schreiben. Mach ich vielleicht noch. Nun ist es Blockly mit 3 JavaScript Funktionen weil der SendTo Block einfach nicht zu überreden war das ganze vernünftig zu senden.

                          Im Spoiler der Blockly-Export

                          <xml xmlns="https://developers.google.com/blockly/xml">
                           <variables>
                             <variable id="xr?C%:}F%HR,+baC%W8n">x</variable>
                             <variable id="d/.bOP=7VlC5/[+=8g/u">myVAL</variable>
                             <variable id="SL$d6/`ClO6iqfefh5LN">myTS</variable>
                             <variable id="B$n_|Lt?V?dltG$1=%U!">JSONTable</variable>
                             <variable id="zqSSt1.lPBrP!prtJp:[">JSONListe</variable>
                             <variable id="[,noZ+!#R([v)Vli[JAC">counter</variable>
                             <variable id="9[xS=sH).DKBS8oGN@cs">i</variable>
                             <variable id="tkH#qcE=H5/_7~OttW5(">tempDatum</variable>
                             <variable id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</variable>
                           </variables>
                           <block type="procedures_defcustomreturn" id="f5+e$i!@hdFdP7[JA1^`" x="288" y="-212">
                             <mutation statements="false">
                               <arg name="x" varid="xr?C%:}F%HR,+baC%W8n"></arg>
                             </mutation>
                             <field name="NAME">ReplaceHyphen</field>
                             <field name="SCRIPT">cmV0dXJuIHgucmVwbGFjZSgiLy0vZyIsIi4iKTs=</field>
                             <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                           </block>
                           <block type="procedures_defcustomnoreturn" id="W?BjTQs!pguWw4HPwT)p" x="287" y="-162">
                             <mutation statements="false">
                               <arg name="myVAL" varid="d/.bOP=7VlC5/[+=8g/u"></arg>
                               <arg name="myTS" varid="SL$d6/`ClO6iqfefh5LN"></arg>
                             </mutation>
                             <field name="NAME">SendTo_SQL_storeState</field>
                             <field name="SCRIPT">Ly8gVW5kIHdlcnQgZXJzdGVsbGVuIHdpZSBnZXBsYW50DQpzZW5kVG8oInNxbC4wIiwgInN0b3JlU3RhdGUiLCB7DQogICAgImlkIjogJzBfdXNlcmRhdGEuMC5Tb2xhcmFubGFnZS5wdmZvcmVjYXN0JywNCiAgICAic3RhdGUiOiB7IA0KICAgICAgICAidmFsIjogbXlWQUwsIA0KICAgICAgICAidHMiOiBteVRTLA0KICAgICAgICAiYWNrIjogdHJ1ZQ0KICAgIH0NCn0sIGFzeW5jIGZ1bmN0aW9uIChyZXN1bHQpIHsNCiAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7</field>
                             <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                           </block>
                           <block type="procedures_defcustomnoreturn" id="m.]d6DR4hIR|rhM`P3KU" x="288" y="-112">
                             <mutation statements="false"></mutation>
                             <field name="NAME">SendTo_SQL_deleteAll</field>
                             <field name="SCRIPT">Ly8gQWxsZXMgbMO2c2NoZW4NCnNlbmRUbygic3FsLjAiLCAiZGVsZXRlQWxsIiwgew0KICAgICJpZCI6ICcwX3VzZXJkYXRhLjAuU29sYXJhbmxhZ2UucHZmb3JlY2FzdCcsDQp9LCBhc3luYyBmdW5jdGlvbiAocmVzdWx0KSB7DQogICAgICBjb25zb2xlLmxvZyhyZXN1bHQpOw0KfSk7DQo=</field>
                             <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                           </block>
                           <block type="comment" id="emF90N[xA].w:e$0a5`A" x="288" y="-62">
                             <field name="COMMENT">Trigger auf den Datenpunkt JSONTable der</field>
                             <next>
                               <block type="comment" id="v|g5R@PBSlfR{}gqtWR1">
                                 <field name="COMMENT">gewünschten Anlage</field>
                                 <next>
                                   <block type="on_ext" id="2}81gNSPn48mxt-C32N3">
                                     <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
                                     <field name="CONDITION">ne</field>
                                     <field name="ACK_CONDITION"></field>
                                     <value name="OID0">
                                       <shadow type="field_oid" id="$fUC/kgh^7[pBZjds,[N">
                                         <field name="oid">default</field>
                                       </shadow>
                                       <block type="text" id="Q~[~L7`?jff9w0!|{R!~">
                                         <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                       </block>
                                     </value>
                                     <statement name="STATEMENT">
                                       <block type="comment" id="xipk,Q4m/$Zbq(9xP]N;">
                                         <field name="COMMENT">Den JSON in eine Variable als Objekt holen</field>
                                         <next>
                                           <block type="variables_set" id="9le8nB_}E+{=^zh:Futa" disabled="true">
                                             <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                             <value name="VALUE">
                                               <block type="convert_json2object" id="C^`)6e!W4atd.!+{(i`D">
                                                 <value name="VALUE">
                                                   <block type="get_value_var" id="CX?q]Gc8j[Ks2F4.yc=c">
                                                     <field name="ATTR">val</field>
                                                     <value name="OID">
                                                       <shadow type="text" id="Y:eexHcUNi5aP`=sh5_;">
                                                         <field name="TEXT"></field>
                                                       </shadow>
                                                       <block type="text" id="2yV92%k{c@aR$t@FV|VK">
                                                         <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                       </block>
                                                     </value>
                                                   </block>
                                                 </value>
                                               </block>
                                             </value>
                                             <next>
                                               <block type="variables_set" id="y:J|yOI69aKr_]e}X})q">
                                                 <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                 <value name="VALUE">
                                                   <block type="on_source" id="GDRdyJ%YUi4U{P:xhe%L">
                                                     <field name="ATTR">state.val</field>
                                                   </block>
                                                 </value>
                                                 <next>
                                                   <block type="comment" id="78{/(q^zo:Vm3)}YeMKs">
                                                     <field name="COMMENT">Den JSON nochmal als Liste</field>
                                                     <next>
                                                       <block type="variables_set" id="$C:;|F_ENe?Kc{f9E*tE" disabled="true">
                                                         <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                         <value name="VALUE">
                                                           <block type="lists_split" id=":4[[9BsVwSu-#SFS/qp#">
                                                             <mutation mode="SPLIT"></mutation>
                                                             <field name="MODE">SPLIT</field>
                                                             <value name="INPUT">
                                                               <block type="get_value_var" id="k${_LxJlQ~Jc%^8mQ;J3">
                                                                 <field name="ATTR">val</field>
                                                                 <value name="OID">
                                                                   <shadow type="text">
                                                                     <field name="TEXT"></field>
                                                                   </shadow>
                                                                   <block type="text" id="@(LLEO9DcZC_107PY7e;">
                                                                     <field name="TEXT">pvforecast.0.600W.JSONTable</field>
                                                                   </block>
                                                                 </value>
                                                               </block>
                                                             </value>
                                                             <value name="DELIM">
                                                               <shadow type="text" id="_=ir)--C~K.5!,@3!%@4">
                                                                 <field name="TEXT">},</field>
                                                               </shadow>
                                                             </value>
                                                           </block>
                                                         </value>
                                                         <next>
                                                           <block type="variables_set" id="KTHIaej{MV5TTxsehu:h">
                                                             <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                             <value name="VALUE">
                                                               <block type="lists_split" id="`#[tp]8]y!L^LEp8OL)J">
                                                                 <mutation mode="SPLIT"></mutation>
                                                                 <field name="MODE">SPLIT</field>
                                                                 <value name="INPUT">
                                                                   <block type="on_source" id="c),q`)7dZyX)GtW;Oe0Y">
                                                                     <field name="ATTR">state.val</field>
                                                                   </block>
                                                                 </value>
                                                                 <value name="DELIM">
                                                                   <shadow type="text" id="koPJuBu/Hm/D7+[$DR$`">
                                                                     <field name="TEXT">},{</field>
                                                                   </shadow>
                                                                 </value>
                                                               </block>
                                                             </value>
                                                             <next>
                                                               <block type="comment" id="_dDWRwqorhv|K4r20+CF">
                                                                 <field name="COMMENT">Zähler für die einzelnen Werte</field>
                                                                 <next>
                                                                   <block type="variables_set" id="w[HNQFZ(pKC;(LonsppG">
                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                     <value name="VALUE">
                                                                       <block type="math_number" id="$YD#)Z6].!0wU8:!IFY-">
                                                                         <field name="NUM">-1</field>
                                                                       </block>
                                                                     </value>
                                                                     <next>
                                                                       <block type="comment" id="nON/.IM*.X5L7BSfqn.j">
                                                                         <field name="COMMENT">Vorherige Werte löschen</field>
                                                                         <next>
                                                                           <block type="procedures_callcustomnoreturn" id="MjjlAd,#02dH9;[91A:e">
                                                                             <mutation name="SendTo_SQL_deleteAll"></mutation>
                                                                             <next>
                                                                               <block type="comment" id="+UxP]UFX*K*Ay8@+.3D(">
                                                                                 <field name="COMMENT">Kurz warten ...</field>
                                                                                 <next>
                                                                                   <block type="timeouts_wait" id="b#[5BCU4#vD.+@RIgxwr">
                                                                                     <field name="DELAY">2</field>
                                                                                     <field name="UNIT">sec</field>
                                                                                     <next>
                                                                                       <block type="comment" id="?qlG@bV1nj7K%h8?`S-h">
                                                                                         <field name="COMMENT">Die Werte abarbeiten:</field>
                                                                                         <next>
                                                                                           <block type="controls_forEach" id="sZ%NhNSxC10sAg@O]Kz6">
                                                                                             <field name="VAR" id="9[xS=sH).DKBS8oGN@cs">i</field>
                                                                                             <value name="LIST">
                                                                                               <block type="variables_get" id="psB3RQ42dmHy[=aKrs!2">
                                                                                                 <field name="VAR" id="zqSSt1.lPBrP!prtJp:[">JSONListe</field>
                                                                                               </block>
                                                                                             </value>
                                                                                             <statement name="DO">
                                                                                               <block type="comment" id="0i?Xu2@hUv,g4?;i5Fhl">
                                                                                                 <field name="COMMENT">Wird beim ersten mal 0 sein</field>
                                                                                                 <next>
                                                                                                   <block type="math_change" id="liet[5#L@~`I]t{8:/Es">
                                                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                     <value name="DELTA">
                                                                                                       <shadow type="math_number" id="986qLvCF[J2VK^no0@Rp">
                                                                                                         <field name="NUM">1</field>
                                                                                                       </shadow>
                                                                                                     </value>
                                                                                                     <next>
                                                                                                       <block type="comment" id="}fPI/Q;fVu7V-uYuX2I+">
                                                                                                         <field name="COMMENT">Wir arbeiten die Liste ab, nutzen aber das Objekt!</field>
                                                                                                         <next>
                                                                                                           <block type="variables_set" id="^w);@i_kdtjWWf?c}BcO">
                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                             <value name="VALUE">
                                                                                                               <block type="get_attr" id="jTRbW_-wI4-}.!,5V(VJ">
                                                                                                                 <value name="PATH">
                                                                                                                   <shadow type="text" id="3r`W9/~ToEj{Abx:)agx">
                                                                                                                     <field name="TEXT"></field>
                                                                                                                   </shadow>
                                                                                                                   <block type="text_join" id="xoFmSb~Y+xnD;cvM|g;-">
                                                                                                                     <mutation items="2"></mutation>
                                                                                                                     <value name="ADD0">
                                                                                                                       <block type="variables_get" id="K9;4LQ$1S/`at#YY52.j">
                                                                                                                         <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                       </block>
                                                                                                                     </value>
                                                                                                                     <value name="ADD1">
                                                                                                                       <block type="text" id="Kkt8qVr.ykp~NV;@{Uas">
                                                                                                                         <field name="TEXT">.Uhrzeit</field>
                                                                                                                       </block>
                                                                                                                     </value>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                                 <value name="OBJECT">
                                                                                                                   <block type="variables_get" id="`-rw74I`kqylUWgeH*+(">
                                                                                                                     <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                                   </block>
                                                                                                                 </value>
                                                                                                               </block>
                                                                                                             </value>
                                                                                                             <next>
                                                                                                               <block type="comment" id="b?]P+H9BwqfkDRv$/:j(">
                                                                                                                 <field name="COMMENT">Die - in . umwandeln</field>
                                                                                                                 <next>
                                                                                                                   <block type="variables_set" id="k@v15A-cYpf/vbpRa;_z">
                                                                                                                     <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                     <value name="VALUE">
                                                                                                                       <block type="procedures_callcustomreturn" id="p[kw(;yI)pXBjjzD#D)~">
                                                                                                                         <mutation name="ReplaceHyphen">
                                                                                                                           <arg name="x"></arg>
                                                                                                                         </mutation>
                                                                                                                         <value name="ARG0">
                                                                                                                           <block type="variables_get" id="N)h=(1TR`.9#96=m?A0Y">
                                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                           </block>
                                                                                                                         </value>
                                                                                                                       </block>
                                                                                                                     </value>
                                                                                                                     <next>
                                                                                                                       <block type="comment" id="I-6Pjzc2in5fU|/L@xLT">
                                                                                                                         <field name="COMMENT">In ein Datum-Objekt umwandeln</field>
                                                                                                                         <next>
                                                                                                                           <block type="variables_set" id="FsILBORsaLrrazBi1L)J">
                                                                                                                             <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                             <value name="VALUE">
                                                                                                                               <block type="convert_from_date" id="4bbw}ZJhpHe}e.*nJ0`M">
                                                                                                                                 <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                                                                                                 <field name="OPTION">object</field>
                                                                                                                                 <value name="VALUE">
                                                                                                                                   <block type="variables_get" id="RjC;=Ac;nPHFrHCNt$SG">
                                                                                                                                     <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                                   </block>
                                                                                                                                 </value>
                                                                                                                               </block>
                                                                                                                             </value>
                                                                                                                             <next>
                                                                                                                               <block type="comment" id="?/.AjS+{19mE_EhC6?{%">
                                                                                                                                 <field name="COMMENT">Die Leistung holen (hier in Wh statt kWh)</field>
                                                                                                                                 <next>
                                                                                                                                   <block type="variables_set" id="7$e1=Z.||tt-}b}$`QUX">
                                                                                                                                     <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                     <value name="VALUE">
                                                                                                                                       <block type="math_arithmetic" id="czVYE)d?^hj;sB8tQW%c" inline="false">
                                                                                                                                         <field name="OP">MULTIPLY</field>
                                                                                                                                         <value name="A">
                                                                                                                                           <shadow type="math_number" id="QXXI#nb51thU(gYujO7l">
                                                                                                                                             <field name="NUM">1</field>
                                                                                                                                           </shadow>
                                                                                                                                           <block type="get_attr" id="!p(Q2{*u/U@(LdLaWO;s">
                                                                                                                                             <value name="PATH">
                                                                                                                                               <shadow type="text">
                                                                                                                                                 <field name="TEXT"></field>
                                                                                                                                               </shadow>
                                                                                                                                               <block type="text_join" id="eO+Kc@J#5ncJexgCa;XG">
                                                                                                                                                 <mutation items="2"></mutation>
                                                                                                                                                 <value name="ADD0">
                                                                                                                                                   <block type="variables_get" id="6h@/w;v+5fJ:2k^fRu$`">
                                                                                                                                                     <field name="VAR" id="[,noZ+!#R([v)Vli[JAC">counter</field>
                                                                                                                                                   </block>
                                                                                                                                                 </value>
                                                                                                                                                 <value name="ADD1">
                                                                                                                                                   <block type="text" id="u;lW,EMq1lo;0wl@^s~Z">
                                                                                                                                                     <field name="TEXT">.Leistung</field>
                                                                                                                                                   </block>
                                                                                                                                                 </value>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                             <value name="OBJECT">
                                                                                                                                               <block type="variables_get" id=":wC%m_*5#kUmjSCtRht*">
                                                                                                                                                 <field name="VAR" id="B$n_|Lt?V?dltG$1=%U!">JSONTable</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                           </block>
                                                                                                                                         </value>
                                                                                                                                         <value name="B">
                                                                                                                                           <shadow type="math_number" id=".oUR!B4y8;}kLXv3HYVD">
                                                                                                                                             <field name="NUM">1000</field>
                                                                                                                                           </shadow>
                                                                                                                                         </value>
                                                                                                                                       </block>
                                                                                                                                     </value>
                                                                                                                                     <next>
                                                                                                                                       <block type="comment" id=".r}c.6$[JDf=.|#00pZj">
                                                                                                                                         <field name="COMMENT">Und in die Datenbank schreiben</field>
                                                                                                                                         <next>
                                                                                                                                           <block type="procedures_callcustomnoreturn" id="C,/_Emb0_,HXS0:;0?Cb">
                                                                                                                                             <mutation name="SendTo_SQL_storeState">
                                                                                                                                               <arg name="myVAL"></arg>
                                                                                                                                               <arg name="myTS"></arg>
                                                                                                                                             </mutation>
                                                                                                                                             <value name="ARG0">
                                                                                                                                               <block type="variables_get" id="ZX``,0~qVZ*H;d75IT!S">
                                                                                                                                                 <field name="VAR" id="f=MX5bxXCe`#`$z~HXcG">tempLeistung</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                             <value name="ARG1">
                                                                                                                                               <block type="variables_get" id="2rC,dvFPd3*_,1)EOdkN">
                                                                                                                                                 <field name="VAR" id="tkH#qcE=H5/_7~OttW5(">tempDatum</field>
                                                                                                                                               </block>
                                                                                                                                             </value>
                                                                                                                                           </block>
                                                                                                                                         </next>
                                                                                                                                       </block>
                                                                                                                                     </next>
                                                                                                                                   </block>
                                                                                                                                 </next>
                                                                                                                               </block>
                                                                                                                             </next>
                                                                                                                           </block>
                                                                                                                         </next>
                                                                                                                       </block>
                                                                                                                     </next>
                                                                                                                   </block>
                                                                                                                 </next>
                                                                                                               </block>
                                                                                                             </next>
                                                                                                           </block>
                                                                                                         </next>
                                                                                                       </block>
                                                                                                     </next>
                                                                                                   </block>
                                                                                                 </next>
                                                                                               </block>
                                                                                             </statement>
                                                                                           </block>
                                                                                         </next>
                                                                                       </block>
                                                                                     </next>
                                                                                   </block>
                                                                                 </next>
                                                                               </block>
                                                                             </next>
                                                                           </block>
                                                                         </next>
                                                                       </block>
                                                                     </next>
                                                                   </block>
                                                                 </next>
                                                               </block>
                                                             </next>
                                                           </block>
                                                         </next>
                                                       </block>
                                                     </next>
                                                   </block>
                                                 </next>
                                               </block>
                                             </next>
                                           </block>
                                         </next>
                                       </block>
                                     </statement>
                                   </block>
                                 </next>
                               </block>
                             </next>
                           </block>
                          </xml>
                          

                          Anpassen müsst Ihr:

                          In der JavaScript-Funktion SendTo_SQL_storeState den Namen des Ziel-Datenpunktes:
                          40558805-14b2-4080-9681-84d67524a428-image.png
                          gelb markiert:
                          84a72c5c-f34e-4793-8174-a9eb2ee5e8ad-image.png

                          Das gleiche in der JavaScript-Funktion SendTo_SQL_DeleteAll
                          91c29379-c885-4fef-b5b4-c710f95d35ff-image.png

                          Und im Kopf den Quellpfad zu eurer Anlage:
                          46235a8d-a6ad-44ff-8668-09fe532644d5-image.png

                          Und ob Ihr es in kWh oder Wh haben wollt:
                          cdba127d-a976-408f-a313-22f6ba0d77e3-image.png
                          (die x 1000 entfernen oder durch 1 Ersetzen bei kWh)

                          Wenn Ihr das Skript startet passiert erst einmal nichts. Erst wenn neue Daten reinkämen.
                          Zum Testen könntet Ihr

                          • Im Trigger von wurde geändert auf wurde aktualisiert ändern
                          • den pvforecast Adapter einmal neu starten. Zumindest bei mir holt er dann sofort einmal neue Daten

                          und schon hat er uns die Werte schön in die Datenbank geschrieben:

                          MariaDB [iobroker]> select * from ts_number where id = '95';
                          +----+---------------+------+------+-------+------+
                          | id | ts            | val  | ack  | _from | q    |
                          +----+---------------+------+------+-------+------+
                          | 95 | 1646287082001 |    0 |    1 |     0 |    0 |
                          | 95 | 1646288940000 |   29 |    1 |     0 |    0 |
                          | 95 | 1646290802000 |  146 |    1 |     0 |    0 |
                          | 95 | 1646294400000 |  247 |    1 |     0 |    0 |
                          | 95 | 1646298000000 |  377 |    1 |     0 |    0 |
                          | 95 | 1646301600000 |  422 |    1 |     0 |    0 |
                          | 95 | 1646305200000 |  428 |    1 |     0 |    0 |
                          | 95 | 1646308800000 |  383 |    1 |     0 |    0 |
                          | 95 | 1646312400000 |  317 |    1 |     0 |    0 |
                          | 95 | 1646316000000 |  222 |    1 |     0 |    0 |
                          | 95 | 1646319600000 |  113 |    1 |     0 |    0 |
                          | 95 | 1646323200000 |   34 |    1 |     0 |    0 |
                          | 95 | 1646326800000 |    8 |    1 |     0 |    0 |
                          | 95 | 1646327160000 |    2 |    1 |     0 |    0 |
                          | 95 | 1646327460000 |    0 |    1 |     0 |    0 |
                          | 95 | 1646373360000 |    0 |    1 |     0 |    0 |
                          | 95 | 1646375280000 |   36 |    1 |     0 |    0 |
                          | 95 | 1646377200000 |  180 |    1 |     0 |    0 |
                          | 95 | 1646380800000 |  284 |    1 |     0 |    0 |
                          | 95 | 1646384400000 |  360 |    1 |     0 |    0 |
                          | 95 | 1646388000000 |  401 |    1 |     0 |    0 |
                          | 95 | 1646391600000 |  406 |    1 |     0 |    0 |
                          | 95 | 1646395200000 |  372 |    1 |     0 |    0 |
                          | 95 | 1646398800000 |  310 |    1 |     0 |    0 |
                          | 95 | 1646402400000 |  218 |    1 |     0 |    0 |
                          | 95 | 1646406000000 |  114 |    1 |     0 |    0 |
                          | 95 | 1646409600000 |   35 |    1 |     0 |    0 |
                          | 95 | 1646413200000 |    8 |    1 |     0 |    0 |
                          | 95 | 1646413620000 |    2 |    1 |     0 |    0 |
                          | 95 | 1646413980000 |    0 |    1 |     0 |    0 |
                          +----+---------------+------+------+-------+------+
                          30 rows in set (0.001 sec)
                          
                          

                          Die kann man jetzt in echarts etc. verwenden.

                          Woran ich noch verzweifle:

                          // Alles löschen
                          sendTo("sql.0", "deleteAll", {
                              "id": '0_userdata.0.Solaranlage.pvforecast',
                          }, async function (result) {
                                console.log(result);
                          });
                          

                          Wie schaffe ich es auch den Wert von id als Variable zu übergeben?
                          Daran habe ich nämlich 90% der Zeit gesessen. Zuerst habe ich es vergeblich mit dem Blockly-SendTo Block versucht (aber der hat es immer falsch formatiert gesendet) und dann wie ich die festen Werte durch Variablen ersetze.

                          Wenn auch durch die Brust ins Auge, damit konnte ich endlich ein funktionierendes Grafana Diagramm erstellen.
                          Danke für die Lösung.
                          Inhaltlich muß ich die Werte mal die nächsten Tage checken ob das alles so zu meiner Anlage paßt.

                          2022_03_05 16_40_52-vis.png

                          BananaJoeB Offline
                          BananaJoeB Offline
                          BananaJoe
                          Most Active
                          schrieb am zuletzt editiert von BananaJoe
                          #318

                          @sonnenschein

                          ich vergleiche bei mir ja immer noch Äpfel (Wh aus dem Forecast) mit Birnen (W vom Shelly 1PM hinter der Anlage), aber sieht zumindest gut (und nicht ganz falsch) aus:

                          fc111205-a835-46b5-8f0f-7c2aaf373c67-image.png

                          Aus meinen W Werten Wh Werte für den direkten Vergleich zu machen, daran arbeite ich noch. Als Versuch schreibe ich nun stündlich die erzeugten Wh in einen eigenen Datenpunkt

                          @PatrickWalther ich glaube der große Knackpunkt war/ist das es nicht reicht das SQL an einem Datenpunkt einzuschalten - man muss auch einmal einen Wert gesetzt haben. Erst dann werden die Einträge in der SQL-Datenbank für diesen Datenpunkt erstellt - und erst dann lässt sich dieser Datenpunkt auch mit SendTo ansprechen.
                          Ich glaube ich mache dazu mal ein Ticket bei dem SQL-Adapter auf.

                          Nachtrag: gibt es schon:
                          https://github.com/ioBroker/ioBroker.sql/issues/214

                          ioBroker@Ubuntu 24.04 LTS (VMware) für: >260 Geräte, 5 Switche, 7 AP, 9 IP-Cam, 1 NAS 42TB, 1 ESXi 15TB, 4 Proxmox 1TB, 1 Hyper-V 48TB, 14 x Echo, 5x FireTV, 5 x Tablett/Handy VIS || >=160 Tasmota/Shelly || >=95 ZigBee || PV 8.1kW / Akku 14kWh || 2x USV 750W kaskadiert || Creality CR-10 SE 3D-Drucker

                          1 Antwort Letzte Antwort
                          0
                          • P Offline
                            P Offline
                            PatrickWalther
                            Developer
                            schrieb am zuletzt editiert von
                            #319

                            @bananajoe danke für Info. Kann auch der Grund sein warum es bei mir geklappt hat und bei euch nicht.

                            mcBirneM 1 Antwort Letzte Antwort
                            0
                            • P PatrickWalther

                              @bananajoe danke für Info. Kann auch der Grund sein warum es bei mir geklappt hat und bei euch nicht.

                              mcBirneM Offline
                              mcBirneM Offline
                              mcBirne
                              schrieb am zuletzt editiert von
                              #320

                              @patrickwalther

                              Hallo,
                              es gibt ja einen jsongraph. Wie kann ich den in vis einbinden damit ich so eine Darstellung erhalte?

                              1 Antwort Letzte Antwort
                              0
                              • P Offline
                                P Offline
                                PatrickWalther
                                Developer
                                schrieb am zuletzt editiert von
                                #321

                                @mcbirne schau bitte in die Doku da gibt es auch ein Beispiel import. Denke bitte daran das du dafür den Materializ Adapter brauchst.

                                mcBirneM 1 Antwort Letzte Antwort
                                0
                                • mcBirneM Offline
                                  mcBirneM Offline
                                  mcBirne
                                  schrieb am zuletzt editiert von
                                  #322

                                  @patrickwalther
                                  OK, woher bekomme ich den Materializ Adapter, ich kann ihn nicht finden.

                                  GlasfaserG 1 Antwort Letzte Antwort
                                  0
                                  • mcBirneM mcBirne

                                    @patrickwalther
                                    OK, woher bekomme ich den Materializ Adapter, ich kann ihn nicht finden.

                                    GlasfaserG Offline
                                    GlasfaserG Offline
                                    Glasfaser
                                    schrieb am zuletzt editiert von
                                    #323

                                    @mcbirne sagte in Test PV Forecast Adapter:

                                    ich kann ihn nicht finden.

                                    .... ist nur unter latest zu bekommen :

                                    be122807-9530-4a69-bc39-a26033b00314-grafik.png

                                    Synology 918+ 16GB - ioBroker in Docker v9 , VISO auf Trekstor Primebook C13 13,3" , Hikvision Domkameras mit Surveillance Station .. CCU RaspberryMatic in Synology VM .. Zigbee CC2538+CC2592 .. Sonoff .. KNX .. Modbus ..

                                    1 Antwort Letzte Antwort
                                    0
                                    • mcBirneM Offline
                                      mcBirneM Offline
                                      mcBirne
                                      schrieb am zuletzt editiert von
                                      #324

                                      @glasfaser
                                      danke, inzwischen habe ich ein Diagramm hinbekommen. Kann man die beschriftung an dem Balken auch noch ausblenden? Diese Option finde ich irgendwie nicht.

                                      GlasfaserG 1 Antwort Letzte Antwort
                                      0
                                      • mcBirneM mcBirne

                                        @glasfaser
                                        danke, inzwischen habe ich ein Diagramm hinbekommen. Kann man die beschriftung an dem Balken auch noch ausblenden? Diese Option finde ich irgendwie nicht.

                                        GlasfaserG Offline
                                        GlasfaserG Offline
                                        Glasfaser
                                        schrieb am zuletzt editiert von
                                        #325

                                        @mcbirne sagte in Test PV Forecast Adapter:

                                        beschriftung an dem Balken ...ausblenden
                                        finde ich irgendwie nicht.

                                        Dies ist im json vorhanden , das kann nur von @PatrickWalther beeinflusst werden .

                                        Synology 918+ 16GB - ioBroker in Docker v9 , VISO auf Trekstor Primebook C13 13,3" , Hikvision Domkameras mit Surveillance Station .. CCU RaspberryMatic in Synology VM .. Zigbee CC2538+CC2592 .. Sonoff .. KNX .. Modbus ..

                                        1 Antwort Letzte Antwort
                                        0
                                        • P PatrickWalther

                                          @mcbirne schau bitte in die Doku da gibt es auch ein Beispiel import. Denke bitte daran das du dafür den Materializ Adapter brauchst.

                                          mcBirneM Offline
                                          mcBirneM Offline
                                          mcBirne
                                          schrieb am zuletzt editiert von
                                          #326

                                          @patrickwalther
                                          es wäre super, wenn man einstellen kann, dass im json-Diagramm keine Zahlen angezeigt werden.
                                          637a2314-b89c-4492-bda3-3c50c1bf4be9-image.png

                                          P 1 Antwort Letzte Antwort
                                          0
                                          Antworten
                                          • In einem neuen Thema antworten
                                          Anmelden zum Antworten
                                          • Älteste zuerst
                                          • Neuste zuerst
                                          • Meiste Stimmen


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          808

                                          Online

                                          32.4k

                                          Benutzer

                                          81.4k

                                          Themen

                                          1.3m

                                          Beiträge
                                          Community
                                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                                          ioBroker Community 2014-2025
                                          logo
                                          • Anmelden

                                          • Du hast noch kein Konto? Registrieren

                                          • Anmelden oder registrieren, um zu suchen
                                          • Erster Beitrag
                                            Letzter Beitrag
                                          0
                                          • Home
                                          • Aktuell
                                          • Tags
                                          • Ungelesen 0
                                          • Kategorien
                                          • Unreplied
                                          • Beliebt
                                          • GitHub
                                          • Docu
                                          • Hilfe