=== '''Script 1''' darf nur einmal am Tag (um 0 Uhr zweckmässigerweise) laufen und ''ermittelt den gestrigen Verbrauch und speichert den Zählerstand''. ===
''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 1 </div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! Berechnet die verbrauchten kWh seit dem letzten Aufruf + Preis</div><div id="bloop_customfont" style="margin: 0px">!! sollte einmal tgl. um 0 Uhr laufen</div><div id="bloop_customfont" style="margin: 0px">!! 02/15 </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 : eCountYesterday Typ: Zahl Einheit kWh/m3</div><div id="bloop_customfont" style="margin: 0px">!! Name : eCostYesterday Typ: Zahl Einheit : EUR</div><div id="bloop_customfont" style="margin: 0px">!! Name : eEXMemory Typ: Zeichenkette</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! Verbrauchte Energie wird nach Scriptlauf in eCountYesterday in kWh/m3 gespeichert Kosten in eCostYesterday</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 = 0 ; Elektroenergie wird gezählt =1 Gas wird gezählt</div><div id="bloop_customfont" style="margin: 0px">!! cuxddevice wenn mit Seriennummer eines CuxD Exec Gerätes gefüllt wird das sonst system.exec verwendet</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">var serialCounter = "";</div><div id="bloop_customfont" style="margin: 0px">var useAsGasCounter = 0;</div><div id="bloop_customfont" style="margin: 0px">var cuxddevice = "";</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==1) {</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");</div><div id="bloop_customfont" style="margin: 0px">var svCountYesterday = dom.GetObject("eCountYesterday");</div><div id="bloop_customfont" style="margin: 0px">var svCostYesterday = dom.GetObject("eCostYesterday");</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">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"> 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);</div><div id="bloop_customfont" style="margin: 0px"> 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"> 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"><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"><br/></div><div id="bloop_customfont" style="margin: 0px">real pricekwh=0;</div><div id="bloop_customfont" style="margin: 0px">real condvalue=0;</div><div id="bloop_customfont" style="margin: 0px">real heatvalue=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"> string key = part.StrValueByIndex(":",0);</div><div id="bloop_customfont" style="margin: 0px"> string val = part.StrValueByIndex(":",1);</div><div id="bloop_customfont" style="margin: 0px"> </div><div id="bloop_customfont" style="margin: 0px"> if (useAsGasCounter==1) {</div><div id="bloop_customfont" style="margin: 0px"> if (key=="gasHeatingValue"){</div><div id="bloop_customfont" style="margin: 0px"> heatvalue = val.ToFloat();</div><div id="bloop_customfont" style="margin: 0px"> }</div><div id="bloop_customfont" style="margin: 0px"> </div><div id="bloop_customfont" style="margin: 0px"> if (key=="gasConditionNumber"){</div><div id="bloop_customfont" style="margin: 0px"> condvalue = val.ToFloat();</div><div id="bloop_customfont" style="margin: 0px"> }</div><div id="bloop_customfont" style="margin: 0px"> </div><div id="bloop_customfont" style="margin: 0px"> if (key=="gasPrice"){</div><div id="bloop_customfont" style="margin: 0px"> pricekwh = val.ToFloat();</div><div id="bloop_customfont" style="margin: 0px"> }</div><div id="bloop_customfont" style="margin: 0px"> } else {</div><div id="bloop_customfont" style="margin: 0px"> if (key=="curPrice"){</div><div id="bloop_customfont" style="margin: 0px"> pricekwh = val.ToFloat();</div><div id="bloop_customfont" style="margin: 0px"> }</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 (key=="currency") {</div><div id="bloop_customfont" style="margin: 0px"> strCur=val;</div><div id="bloop_customfont" style="margin: 0px"> }</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">eEXMemory.State(devcount.ToString());</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">if (useAsGasCounter==1) {</div><div id="bloop_customfont" style="margin: 0px"> real consumtion = 0;</div><div id="bloop_customfont" style="margin: 0px"> consumtion = heatvalue * condvalue * cnyday;</div><div id="bloop_customfont" style="margin: 0px"> real costyed = pricekwh * consumtion;</div><div id="bloop_customfont" style="margin: 0px"> svCountYesterday.State((cnyday));</div><div id="bloop_customfont" style="margin: 0px"> svCostYesterday.State(costyed);</div><div id="bloop_customfont" style="margin: 0px">} else {</div><div id="bloop_customfont" style="margin: 0px"> real costyed = pricekwh * (cnyday/1000);</div><div id="bloop_customfont" style="margin: 0px"> svCountYesterday.State((cnyday/1000));</div><div id="bloop_customfont" style="margin: 0px"> svCostYesterday.State(costyed);</div><div id="bloop_customfont" style="margin: 0px">}<br/></div>
</div>