Änderungen

Wechseln zu: Navigation, Suche

HM-ES-TX-WM/Strom-Script01

2.114 Byte hinzugefügt, 18:25, 15. Feb. 2015
__TOC__
  <br/><span style="line-height: 1.6">Es werden folgende Systemvariablen für Script 1 und Script 2 benötigt:</span>
{| border="1" cellpadding="1" cellspacing="1"
|}
&nbsp;'''Hinweis''': Bei Nutzung vom mehreren Energierzählern müssen die Variablen für jeden Zähler eindeutig sein. In den Scripten lässt sich das sehr einfach mit einem Texteditor ändern, indem die Funktion Suchen / Ersetzen benutzt wird.<br/>Beispiel:&nbsp; eCountToday -> eCountToday01 oder gasCountToday
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">'''var serialCounter'''<br/>"XXXXX"; in jedem der Scripts mit der Seriennummer des eigenen Aktors füllen<br/></div>
&nbsp;
----
=== '''Script 2a'''&nbsp; ist eine Kombination aus Script 1 + 2 ===
''(Werte für heute, gestern, universell Strom / Gas und CuxD)'' ''Bitte Hinweise am Anfang des Scrips beachten!!''
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px"><div id="bloop_customfont" style="font-family:Helvetica,Arial; font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto"><div id="bloop_customfont" style="margin: 0px">!! Energy Costs Part 2a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! Berechnet die verbrauchten kWh/m3 und den Preis für Gas/Strom für den aktuellen Tag&nbsp;</div><div id="bloop_customfont" style="margin: 0px">!! Der erste Aufruf des Tages speichert den Verbrauch des Vortages&nbsp;</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! kann beliebig oft laufen sollte aber günstigerweise mindestens einmal &nbsp;jeden Tag um 0 Uhr laufen</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! 02/15 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div id="bloop_customfont" style="margin: 0px">!! (c) by thkl</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! Benötigte SystemVariablen:</div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eCountToday Typ: Zahl Einheit kWh / m3</div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eCostToday Typ: Zahl Einheit: EUR</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eCountYesterday Typ: Zahl Einheit kWh / m3</div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eCostYesterday Typ: Zahl Einheit: EUR</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eEXMemory Typ: Zeichenkette</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! serialCounter mit Seriennummer des HM Zählers füllen</div><div id="bloop_customfont" style="margin: 0px">!! useAsGasCounter = true -> Gaszähler&nbsp;; false -> Elektrozähler</div><div id="bloop_customfont" style="margin: 0px">!! cuxddevice = Seriennummer des CuxD Exec Devices (optional - &nbsp;sonst wird system.exe genutzt)</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">string serialCounter = "";</div><div id="bloop_customfont" style="margin: 0px">boolean useAsGasCounter = false;</div><div id="bloop_customfont" style="margin: 0px">string cuxddevice = "";</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">!! ================== do not change anything below ==========</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">var dpname = "ENERGY_COUNTER";</div><div id="bloop_customfont" style="margin: 0px">if (useAsGasCounter==true) {dpname = "GAS_ENERGY_COUNTER";}<br/></div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">string stdout;string stderr;</div><div id="bloop_customfont" style="margin: 0px">string cmd = "/bin/sh -c 'cat /etc/config/energyPrice|sed -r \"s/\\"//g\"'";</div><div id="bloop_customfont" style="margin: 0px">object devEnergyDP = dom.GetObject("BidCos-RF."#serialCounter#":1."#dpname);</div><div id="bloop_customfont" style="margin: 0px">var eEXMemory = dom.GetObject("eEXMemory");</div><div id="bloop_customfont" style="margin: 0px">!!&nbsp; integer lastSetMemory = eEXMemory.Timestamp().ToInteger();<br/>integer day = system.Date("%j").ToInteger();<br/>integer year = system.Date("%Y");<br/>integer lastSetDay = eEXMemory.Timestamp().Yearday();<br/>integer lastSetYear = eEXMemory.Timestamp().Year();<br/>boolean braveNewDay = false;<br/>if ((day>lastSetDay) || (year > lastSetYear)) {<br/>&nbsp;braveNewDay = true;<br/>}<br/></div><div style="margin: 0px"><br/>string tmpSVal = eEXMemory.State();</div><div id="bloop_customfont" style="margin: 0px">real devcount = devEnergyDP.State();</div><div id="bloop_customfont" style="margin: 0px">real statelast = tmpSVal.ToFloat();</div><div id="bloop_customfont" style="margin: 0px">real cnyday = devcount-statelast;</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">if (cuxddevice!="") {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; dom.GetObject("CUxD."#cuxddevice#":1.CMD_SETS").State(cmd);</div><div id="bloop_customfont" style="margin: 0px">&nbsp; dom.GetObject("CUxD."#cuxddevice#":1.CMD_QUERY_RET").State(1);</div><div id="bloop_customfont" style="margin: 0px">&nbsp; stdout = dom.GetObject("CUxD."#cuxddevice#":1.CMD_RETS").State();</div><div id="bloop_customfont" style="margin: 0px">} else {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; system.Exec(cmd, &stdout, &stderr);</div><div id="bloop_customfont" style="margin: 0px">}</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">string sep = "\n";</div><div id="bloop_customfont" style="margin: 0px">string part;</div><div id="bloop_customfont" style="margin: 0px">string strCur;</div><div id="bloop_customfont" style="margin: 0px">real pricekwh=0.0;</div><div id="bloop_customfont" style="margin: 0px">real condvalue=0.0;</div><div id="bloop_customfont" style="margin: 0px">real heatvalue=0.0;</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">foreach(part,stdout.Split(sep)) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; string key = part.StrValueByIndex(":",0);</div><div id="bloop_customfont" style="margin: 0px">&nbsp; string val = part.StrValueByIndex(":",1);</div><div id="bloop_customfont" style="margin: 0px">&nbsp;&nbsp;</div><div id="bloop_customfont" style="margin: 0px">&nbsp;if (useAsGasCounter==true) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; if (key=="gasHeatingValue"){heatvalue = val.ToFloat();}</div><div id="bloop_customfont" style="margin: 0px">&nbsp; if (key=="gasConditionNumber"){condvalue = val.ToFloat();}</div><div id="bloop_customfont" style="margin: 0px">&nbsp; if (key=="gasPrice"){pricekwh = val.ToFloat();}</div><div id="bloop_customfont" style="margin: 0px">&nbsp;} else {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; if (key=="curPrice"){pricekwh = val.ToFloat();}</div><div id="bloop_customfont" style="margin: 0px">&nbsp;}</div><div id="bloop_customfont" style="margin: 0px">}</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">if (braveNewDay==true) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; eEXMemory.State(devcount.ToString());</div><div id="bloop_customfont" style="margin: 0px">}</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">real enerycost = 0.0;</div><div id="bloop_customfont" style="margin: 0px">real enerycount = 0.0;</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">if (useAsGasCounter==true) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;real consumtion = 0;</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;consumtion = heatvalue * condvalue * cnyday;</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;enerycost = pricekwh * consumtion;</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;enerycount = cnyday;</div><div id="bloop_customfont" style="margin: 0px">} else {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;enerycount = (cnyday/1000);</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;enerycost = pricekwh * enerycount;</div><div id="bloop_customfont" style="margin: 0px">}</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">if (braveNewDay==true) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; &nbsp;dom.GetObject("eCountYesterday").State(enerycount);</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; &nbsp;dom.GetObject("eCostYesterday").State(enerycost);</div><div id="bloop_customfont" style="margin: 0px">} else {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; &nbsp;dom.GetObject("eCountToday").State(enerycount);</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; &nbsp;dom.GetObject("eCostToday").State(enerycost);</div><div id="bloop_customfont" style="margin: 0px">}</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px"><br/></div></div></div>===
----
<span style="font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; font-size: 12px; line-height: normal">Wobei die ersten&nbsp;</span>5 Stellen die interne Objektnummer und die nächsten Stellen die Seriennummer des Zählgerätes sind. Diesen Teil kopiere und ersetze im Script oben.
---- === '''Script 5''' berechnet den Verbrauch für GAS&nbsp; m3/Std&nbsp; fortlaufend === Es gibt beim Energiezähler einen Datenpunkt "GAS_POWER" , der bei der FW 1.0 unbrauchbar ist. Er soll den momentanen Verbrauch darstellen, geht aber z.B. nicht auf Null, wenn der Gaszähler nicht läuft-. Auch nicht nach mehreren Stunden. In der WebUI der CCU gibt es unter Programme (nach dem die systeminternen Programme eingeblendet wurden) für jeden Energiezähler ein Programm, das getriggert wird, wenn sich der Datenpunkt "GAS_ENERGY_COUNTER" aktualisiert.&nbsp; In diesem Programm fügen wir im DANN Bereich ein zweites Script hinzu, das den Verbrauch / Std berechnet. Gebraucht wird nur eine SystemVariable vom Typ Zahl "gas_m3_Std"<br/>Diese SysVar kann dann mit beliebigen externen Tools aufgezeichnet werden um Diagramme zu erstellen.  <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">&nbsp;&nbsp;&nbsp; ! Durchfluss in m³/h berechnen für Gas Zähler<br/>&nbsp;&nbsp;&nbsp; ! Datenpunkt des auslösenden Zählwertes<br/>&nbsp;&nbsp;&nbsp; object zdp = dom.GetObject("$src$");<br/>&nbsp;&nbsp;&nbsp; if (zdp)<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; integer now = zdp.Timestamp().ToInteger();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; integer last = zdp.LastTimestamp().ToInteger();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; integer diffTime = now - last;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real val = zdp.Value();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real lastval = zdp.LastValue();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real diffVal = val - lastval;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real durchfluss = 3600.0 * diffVal / diffTime;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dom.GetObject("gas_m3_Std").State(durchfluss);<br/>&nbsp;&nbsp;&nbsp; }<br/></div>
250
Bearbeitungen