Änderungen
<br/><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"
=== <br/>'''Script 2''' kann beliebig oft laufen und ermittelt den ''Vebrauch des aktuellen Tages'' ===
''Universal für Strom und Gas sowie Einsatz von CuxD Exec. Bitte Hinweise am Anfang des Scrips beachten!!''
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
:<code></code><div id="bloop_customfont" style="margin: 0px">!! Energy Costs Part 2 <br/div><div id="bloop_customfont" style="margin: 0px">!!<br/div><div id="bloop_customfont" style="margin: 0px">!! Berechnet die verbrauchten kWh seit dem letzten Aufruf von Script 1 also im Idealfall<br/div><div id="bloop_customfont" style="margin: 0px">!! den Verbrauch seit Mitternacht<br/div><div id="bloop_customfont" style="margin: 0px">!!<br/div><div id="bloop_customfont" style="margin: 0px">!! kann beliebig oft laufen<br/div><div id="bloop_customfont" style="margin: 0px">!! funktioniert nur in Zusammenhang mit Script 1 richtig<br/div><div id="bloop_customfont" style="margin: 0px">!!<br/div><div id="bloop_customfont" style="margin: 0px">!! 02/15 <br/div><div id="bloop_customfont" style="margin: 0px">!! (c) by thkl<br/div><div id="bloop_customfont" style="margin: 0px">!!<br/div><div id="bloop_customfont" style="margin: 0px">!! Benötigte SystemVariablen:<br/div><div id="bloop_customfont" style="margin: 0px">!! Name : eCountToday Typ: Zahl Einheit kWh<br/div><div id="bloop_customfont" style="margin: 0px">!! Name : eCostToday Typ: Zahl Einheit: EUR<br/div><div id="bloop_customfont" style="margin: 0px">!! Name : eEXMemory Typ: Zeichenkette<br/div><div id="bloop_customfont" style="margin: 0px">!!<br/div><div id="bloop_customfont" style="margin: 0px">!! Verbrauchte Energie wird nach Scriptlauf in eCountToday in kWh gespeichert Kosten in eCostToday<br/div><br/div id="bloop_customfont" style="margin: 0px">!! serialCounter mit Seriennummer des HM Zählers füllen<br/div><brdiv id="bloop_customfont" style="margin: 0px">!! useAsGasCounter true = Gaszähler ; false = Elektro</div><div id="bloop_customfont" style="margin: 0px"><br/>var </div><div id="bloop_customfont" style="margin: 0px">string serialCounter = "XXXXX";</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">var dpname = "ENERGY_COUNTER";<br/div>var priceKey <div id= "curPricebloop_customfont" style="margin: 0px">if (useAsGasCounter==true) {</div><div id="bloop_customfont" style="margin: 0px"> dpname = "GAS_ENERGY_COUNTER";</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 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"><br/></div><div id="bloop_customfont" style="margin: 0px">var eEXMemory = dom.GetObject("eEXMemory");<br/div><div id="bloop_customfont" style="margin: 0px">var svCountToday = dom.GetObject("eCountToday");<br/div><div id="bloop_customfont" style="margin: 0px">var svCostToday = dom.GetObject("eCostToday");<br/div><br/div id="bloop_customfont" style="margin: 0px">object devEnergyDP = dom.GetObject("BidCos-RF."#serialCounter#":1."#dpname);<br/div><div id="bloop_customfont" style="margin: 0px">string tmpSVal = eEXMemory.State();<br/div><div id="bloop_customfont" style="margin: 0px">real devcount = devEnergyDP.State();<br/div><div id="bloop_customfont" style="margin: 0px">real statelast = tmpSVal.ToFloat();<br/div><div id="bloop_customfont" style="margin: 0px">real cntoday = devcount-statelast;<br/div><div id="bloop_customfont" style="margin: 0px"><br/>string stdout;string stderr;<br/div>string cmd <div id= "bloop_customfont" style="margin: 0px">if (cuxddevice!="") {</bin/sh -c 'cat /etc/config/energyPrice|sed -r \div><div id="sbloop_customfont" style="margin: 0px"> dom.GetObject("CUxD."#cuxddevice#":1.CMD_SETS").State(cmd);</\\div><div id="bloop_customfont" style="margin: 0px"> dom.GetObject("CUxD."#cuxddevice#":1.CMD_QUERY_RET").State(1);<//g\div><div id="'bloop_customfont"style="margin: 0px"> stdout = dom.GetObject("CUxD."#cuxddevice#":1.CMD_RETS").State();<br/div><div id="bloop_customfont" style="margin: 0px">} else {</div><div id="bloop_customfont" style="margin: 0px"> 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";<br/div><div id="bloop_customfont" style="margin: 0px">string part;<br/div><div id="bloop_customfont" style="margin: 0px">string strCur;<br/div><div id="bloop_customfont" style="margin: 0px">real pricepricekwh=0.0;<br/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)) {<br/div><div id="bloop_customfont" style="margin: 0px"> string key = part.StrValueByIndex(":",0);<br/div><div id="bloop_customfont" style="margin: 0px"> string val = part.StrValueByIndex(":",1);<br/div><div id="bloop_customfont" style="margin: 0px"> </div><div id="bloop_customfont" style="margin: 0px"> if (keyuseAsGasCounter==priceKeytrue){<br/div><div id="bloop_customfont" style="margin: 0px"> price if (key=="gasHeatingValue"){heatvalue = val.ToFloat();}<br/div><div id="bloop_customfont" style="margin: 0px"> if (key=="gasConditionNumber"){condvalue = val.ToFloat(); }<br/div><div id="bloop_customfont" style="margin: 0px"> if (key=="currencygasPrice") {pricekwh = val.ToFloat();}<br/div><div id="bloop_customfont" style="margin: 0px"> } else {</div><div id="bloop_customfont" style="margin: 0px"> strCur if (key=="curPrice"){pricekwh =val.ToFloat();}<br/div><div id="bloop_customfont" style="margin: 0px"> }<br/div><div id="bloop_customfont" style="margin: 0px">}<br/div><div id="bloop_customfont" style="margin: 0px"><br/>integer kwf </div><div id= 1"bloop_customfont" style="margin: 0px">if (useAsGasCounter==true) {</div><div id="bloop_customfont" style="margin: 0px"> real consumtion = heatvalue * condvalue * cntoday;<br/div><brdiv id="bloop_customfont" style="margin: 0px"> real costtoday = pricekwh * consumtion;</div>if (priceKey<div id="bloop_customfont" style="curPricemargin: 0px"> svCountToday.State(consumtion) {;<br/div><div id="bloop_customfont" style="margin: 0px"> kwf = 1000 svCostToday.State(costtoday);<br/div><div id="bloop_customfont" style="margin: 0px">}else {<br/div><div id="bloop_customfont" style="margin: 0px"> real costtoday = price pricekwh * (cntoday/kwf1000);<br/div><div id="bloop_customfont" style="margin: 0px"> svCountToday.State((cntoday/kwf1000));<br/div><div id="bloop_customfont" style="margin: 0px"> svCostToday.State(costtoday);</codediv><div id="bloop_customfont" style="margin: 0px">}<br/></div>
</div>