Shelly Gesamtverbrauch je Kanal speichern

  • Nachdem Stefan die Auswertung freundlicherweise zur Verfügung gestellt hat habe ich mir schnell in Blockly was zusammengeklickt um die Verbrauchsdaten auch dauerhaft zu speichern.

    Bin kein Programmierer, gibt sicherlich Optimierungspotential, aber es funktioniert. (Zumindest bei mir ^^)

    pasted-from-clipboard.png

    Es wird natürlich die Systemvariable aus der CCU benötigt (hier Shelly_01_0_Leistung_Gesamt) und ein eigener Datenpunkt (hier Shelly_01_0_Gesamtleistung). Die restlichen Variablen sind nur lokal.

    Sollte der Wert nach Reboot auf Null stehen wird im Blockly darauf entsprechend reagiert. Umrechnung mit Faktor 1000 ist nur drin, da ich das ganze in Wh und nicht in kWh aus der CCU ziehe.

    Debug Blöcke können natürlich gelöscht werden.

    Spoiler anzeigen

    <xml xmlns="http://www.w3.org/1999/xhtml">

    <variables>

    <variable type="" id="Eu2@bzi[[11h}TN_TA!2">Altwert</variable>

    <variable type="" id="Eh7T_L{pkFat9n;Ghv6Q">Update</variable>

    <variable type="" id=")Q%S6h%+g,MDalQqYmH!">Addition</variable>

    <variable type="" id="k/M.S@PD(Ai*KpM),iFW">Neuwert</variable>

    </variables>

    <block type="variables_set" id="JH2fATyOr-Yz=5@O[l7-" x="62" y="-62">

    <field name="VAR" id="Eu2@bzi[[11h}TN_TA!2" variabletype="">Altwert</field>

    <value name="VALUE">

    <block type="math_arithmetic" id="/wX+.F40Qqc1bN-Eb@Y}">

    <field name="OP">MULTIPLY</field>

    <value name="A">

    <shadow type="math_number" id="%Rvt(:O4Gi8NsLBk_o([">

    <field name="NUM">1</field>

    </shadow>

    <block type="get_value" id="A~N2m(wB|avp+%!)OHoO">

    <field name="ATTR">val</field>

    <field name="OID">Own.0.Datenpunkte.Shelly_01_0_Gesamtleistung</field>

    </block>

    </value>

    <value name="B">

    <shadow type="math_number" id="wvbN!ag50}If.?AW9uMB">

    <field name="NUM">1000</field>

    </shadow>

    </value>

    </block>

    </value>

    <next>

    <block type="variables_set" id="4j}!PSp}?q4vF?7D5@T-">

    <field name="VAR" id="Eh7T_L{pkFat9n;Ghv6Q" variabletype="">Update</field>

    <value name="VALUE">

    <block type="math_number" id="fLtBF_r!J*$5z@SIT_Ds">

    <field name="NUM">0</field>

    </block>

    </value>

    <next>

    <block type="variables_set" id="V(MWm:b`v0:RF~8DUb*}">

    <field name="VAR" id=")Q%S6h%+g,MDalQqYmH!" variabletype="">Addition</field>

    <value name="VALUE">

    <block type="math_number" id="Q!9Pf|/uawPw+[-ej-RZ">

    <field name="NUM">0</field>

    </block>

    </value>

    <next>

    <block type="on_ext" id="sW.m7Mnv*#Q]1{GE+6~0">

    <mutation items="1"></mutation>

    <field name="CONDITION">any</field>

    <field name="ACK_CONDITION"></field>

    <value name="OID0">

    <shadow type="field_oid" id="J~|Kwlq6~ML^Z=Je1=,X">

    <field name="oid">hm-rega.0.10646</field>

    </shadow>

    </value>

    <statement name="STATEMENT">

    <block type="variables_set" id="0G|BV/XTOYD1j87.444e">

    <field name="VAR" id="k/M.S@PD(Ai*KpM),iFW" variabletype="">Neuwert</field>

    <value name="VALUE">

    <block type="get_value" id="pArH::oVd{hM/H%mv{iJ">

    <field name="ATTR">val</field>

    <field name="OID">hm-rega.0.10646</field>

    </block>

    </value>

    <next>

    <block type="controls_if" id="a-b|Dj6^^:v/3H2Z]Y8P">

    <mutation elseif="1"></mutation>

    <value name="IF0">

    <block type="logic_compare" id="9l9tWQh[!3vR|@eygI,=">

    <field name="OP">GT</field>

    <value name="A">

    <block type="variables_get" id="3z$%j^W.1jw9-5?s6:4J">

    <field name="VAR" id="k/M.S@PD(Ai*KpM),iFW" variabletype="">Neuwert</field>

    </block>

    </value>

    <value name="B">

    <block type="variables_get" id="]9{lK8oM=9?:]5bN3fxc">

    <field name="VAR" id="Eu2@bzi[[11h}TN_TA!2" variabletype="">Altwert</field>

    </block>

    </value>

    </block>

    </value>

    <statement name="DO0">

    <block type="variables_set" id="cjyTWi)|2!-N.vG%vIP-">

    <field name="VAR" id=")Q%S6h%+g,MDalQqYmH!" variabletype="">Addition</field>

    <value name="VALUE">

    <block type="math_arithmetic" id="lu04q6B_tUyJiMKgRw|Z">

    <field name="OP">MINUS</field>

    <value name="A">

    <shadow type="math_number" id=")u{:jo9Hcz6ER.urzw]d">

    <field name="NUM">1</field>

    </shadow>

    <block type="variables_get" id="kO#?_8N$xh1/Dsd+c$;-">

    <field name="VAR" id="k/M.S@PD(Ai*KpM),iFW" variabletype="">Neuwert</field>

    </block>

    </value>

    <value name="B">

    <shadow type="math_number" id="coFf6:nR|xyxqqx},G{V">

    <field name="NUM">1</field>

    </shadow>

    <block type="variables_get" id="-a5fb{^Qt@opNAZ/sJt=">

    <field name="VAR" id="Eu2@bzi[[11h}TN_TA!2" variabletype="">Altwert</field>

    </block>

    </value>

    </block>

    </value>

    <next>

    <block type="debug" id="HLcrw`Ngv.S{(MvJc)Ci">

    <field name="Severity">debug</field>

    <value name="TEXT">

    <shadow type="text" id="+`~wTO#f/Z^u1V!JA8c4">

    <field name="TEXT">test</field>

    </shadow>

    <block type="text_join" id="a=KA|-FoL}AqAJwEQl^9">

    <mutation items="2"></mutation>

    <value name="ADD0">

    <block type="variables_get" id="6[?Hc)tak4d{vCzn3mg{">

    <field name="VAR" id=")Q%S6h%+g,MDalQqYmH!" variabletype="">Addition</field>

    </block>

    </value>

    <value name="ADD1">

    <block type="text" id="/[sM=@SeXiO@o$xQ`S1K">

    <field name="TEXT">Addition</field>

    </block>

    </value>

    </block>

    </value>

    <next>

    <block type="variables_set" id="2EYvW=+mcQ(!9pVt$UhO">

    <field name="VAR" id="Eh7T_L{pkFat9n;Ghv6Q" variabletype="">Update</field>

    <value name="VALUE">

    <block type="math_arithmetic" id="~8}JTULrj]F3lt@wU#HY">

    <field name="OP">DIVIDE</field>

    <value name="A">

    <shadow type="math_number" id="N/q=Rs^XUb$uqg%ksZn3">

    <field name="NUM">1</field>

    </shadow>

    <block type="variables_get" id="$D]PC[gh^y*f$P0RR;%D">

    <field name="VAR" id=")Q%S6h%+g,MDalQqYmH!" variabletype="">Addition</field>

    </block>

    </value>

    <value name="B">

    <shadow type="math_number" id="5.4~CpQLP,B?`bmi*/gf">

    <field name="NUM">1000</field>

    </shadow>

    </value>

    </block>

    </value>

    <next>

    <block type="debug" id="hlvhW8xrRkxY2|aYgj?o">

    <field name="Severity">debug</field>

    <value name="TEXT">

    <shadow type="text" id="+`~wTO#f/Z^u1V!JA8c4">

    <field name="TEXT">test</field>

    </shadow>

    <block type="text_join" id="sa+SMyO$.|So28~!YjaA">

    <mutation items="2"></mutation>

    <value name="ADD0">

    <block type="variables_get" id="JRP=ll5kP5DB8BK%$23x">

    <field name="VAR" id="Eh7T_L{pkFat9n;Ghv6Q" variabletype="">Update</field>

    </block>

    </value>

    <value name="ADD1">

    <block type="text" id="w=}zAvhcGXbtfW){,sG+">

    <field name="TEXT">Update</field>

    </block>

    </value>

    </block>

    </value>

    <next>

    <block type="update" id="=J0#MO-Phl3ZsKN@ap8n">

    <mutation delay_input="false"></mutation>

    <field name="OID">Own.0.Datenpunkte.Shelly_01_0_Gesamtleistung</field>

    <field name="WITH_DELAY">FALSE</field>

    <value name="VALUE">

    <block type="math_arithmetic" id="-fL3yJkp2$vBD*,]4f=U">

    <field name="OP">ADD</field>

    <value name="A">

    <shadow type="math_number" id="*@%p/H_dMyh0G1s(qVdF">

    <field name="NUM">1</field>

    </shadow>

    <block type="get_value" id="f_tLK+dYRrg-Qr0T.s;W">

    <field name="ATTR">val</field>

    <field name="OID">Own.0.Datenpunkte.Shelly_01_0_Gesamtleistung</field>

    </block>

    </value>

    <value name="B">

    <shadow type="math_number" id="H+be63;fTjyJrTt!)Fy*">

    <field name="NUM">1</field>

    </shadow>

    <block type="variables_get" id="x^#6g?fpLcB?N?T;Wf.B">

    <field name="VAR" id="Eh7T_L{pkFat9n;Ghv6Q" variabletype="">Update</field>

    </block>

    </value>

    </block>

    </value>

    <next>

    <block type="variables_set" id="T/UowD=cN8Y;Drw75N?q">

    <field name="VAR" id="Eu2@bzi[[11h}TN_TA!2" variabletype="">Altwert</field>

    <value name="VALUE">

    <block type="variables_get" id="G+A#)`gwNT0mH,3HxP$E">

    <field name="VAR" id="k/M.S@PD(Ai*KpM),iFW" variabletype="">Neuwert</field>

    </block>

    </value>

    </block>

    </next>

    </block>

    </next>

    </block>

    </next>

    </block>

    </next>

    </block>

    </next>

    </block>

    </statement>

    <value name="IF1">

    <block type="logic_compare" id="uQqH^0BL8.K$rn$N0nxP">

    <field name="OP">LT</field>

    <value name="A">

    <block type="variables_get" id="D}:-k2![$QRM@yU/54En">

    <field name="VAR" id="k/M.S@PD(Ai*KpM),iFW" variabletype="">Neuwert</field>

    </block>

    </value>

    <value name="B">

    <block type="variables_get" id="VM6L/{9se]4d+AZXKk[.">

    <field name="VAR" id="Eu2@bzi[[11h}TN_TA!2" variabletype="">Altwert</field>

    </block>

    </value>

    </block>

    </value>

    <statement name="DO1">

    <block type="variables_set" id="bh`E$Z8*C@%A+hxwK|-0">

    <field name="VAR" id="Eu2@bzi[[11h}TN_TA!2" variabletype="">Altwert</field>

    <value name="VALUE">

    <block type="math_number" id="mYYl{bdqsJMwQ}z8rH9M">

    <field name="NUM">0</field>

    </block>

    </value>

    </block>

    </statement>

    </block>

    </next>

    </block>

    </statement>

    </block>

    </next>

    </block>

    </next>

    </block>

    </next>

    </block>

    </xml>