Änderungen

Wechseln zu: Navigation, Suche

HM-ES-TX-WM/Strom-Script01

5.914 Byte hinzugefügt, 11:45, 14. Feb. 2015
=== '''Script 1''' darf nur einmal am Tag (um 0 Uhr zweckmässigerweise) laufen und ''ermittelt den gestrigen Verbrauch und speichert den Zählerstand''. ===
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
:<code></code><div id="bloop_customfont" style="margin: 0px">!! Energy Costs Part 1&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;<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 + Preis<br/div><div id="bloop_customfont" style="margin: 0px">!! sollte einmal tgl. um 0 Uhr laufen<br/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;<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&nbsp;: eCountYesterday Typ: Zahl Einheit kWh/m3<br/div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eCostYesterday Typ: Zahl Einheit&nbsp;: EUR<br/div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: 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 eCountYesterday in kWh /m3 gespeichert Kosten in eCostYesterday<br/div><br/div id="bloop_customfont" style="margin: 0px">!! serialCounter mit Seriennummer des HM Zählers füllen<br/div><div id="bloop_customfont" style="margin: 0px">!! useAsGasCounter = 0 ; Elektroenergie wird gezählt &nbsp;=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 = "XXXXX";</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";<br/div>var priceKey <div id= "curPricebloop_customfont"style="margin: 0px">if (useAsGasCounter==1) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp;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 svCountYesterday = dom.GetObject("eCountYesterday");<br/div><div id="bloop_customfont" style="margin: 0px">var svCostYesterday = dom.GetObject("eCostYesterday");<br/div><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 cnyday = 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">&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);<//g\div><div id="'bloop_customfont"style="margin: 0px">&nbsp; 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">&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"><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;</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">real pricepricekwh=0;<br/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)) {<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; string key = part.StrValueByIndex(":",0);<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; string val = part.StrValueByIndex(":",1);<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp;&nbsp;</div><div id="bloop_customfont" style="margin: 0px">&nbsp;if (useAsGasCounter==1) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; if (key==priceKey"gasHeatingValue"){<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; price heatvalue = val.ToFloat();<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; }</div><div id="bloop_customfont" style="margin: 0px">&nbsp;</div><div id="bloop_customfont" style="margin: 0px">&nbsp; if (key=="gasConditionNumber"){</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; condvalue = val.ToFloat();</div><div id="bloop_customfont" style="margin: 0px">&nbsp; }</div><div id="bloop_customfont" style="margin: 0px">&nbsp;</div><div id="bloop_customfont" style="margin: 0px">&nbsp; if (key=="gasPrice"){</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; pricekwh = val.ToFloat();</div><div id="bloop_customfont" style="margin: 0px">&nbsp; }</div><div id="bloop_customfont" style="margin: 0px">&nbsp;} else {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; if (key=="curPrice"){</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; pricekwh = val.ToFloat();</div><div id="bloop_customfont" style="margin: 0px">&nbsp; }</div><div id="bloop_customfont" style="margin: 0px">&nbsp;}</div><div id="bloop_customfont" style="margin: 0px"><br/></div><div id="bloop_customfont" style="margin: 0px">&nbsp; if (key=="currency") {<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; strCur=val;<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; }<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">eEXMemory.State(devcount.ToString());<br/div><div id="bloop_customfont" style="margin: 0px"><br/>integer kwf </div><div id="bloop_customfont" style="margin: 0px">if (useAsGasCounter== 1) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;real consumtion = 0;<br/div><brdiv id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;consumtion = heatvalue * condvalue * cnyday;</div>if (priceKey<div id="bloop_customfont" style="curPricemargin: 0px") {>&nbsp; &nbsp;real costyed = pricekwh * consumtion;<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; kwf &nbsp;svCountYesterday.State((cnyday));</div><div id= 1000"bloop_customfont" style="margin: 0px">&nbsp; &nbsp;svCostYesterday.State(costyed);<br/div><div id="bloop_customfont" style="margin: 0px">}else {<br/div><br/div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;real costyed = price pricekwh * (cnyday/kwf1000);<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;svCountYesterday.State((cnyday/kwf1000));<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;svCostYesterday.State(costyed);</codediv><div id="bloop_customfont" style="margin: 0px">}<br/></div>
</div>
&nbsp;
250
Bearbeitungen