Änderungen

Wechseln zu: Navigation, Suche

HM-ES-TX-WM/Strom-Script01

4.861 Byte hinzugefügt, 12:53, 14. Feb. 2015
<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''&nbsp; ===
 
''Universal für Strom und Gas sowie Einsatz von CuxD Exec.&nbsp; 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&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 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&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;: eCountToday Typ: Zahl Einheit kWh<br/div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eCostToday Typ: Zahl Einheit: 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 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">&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 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">&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">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">&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 (keyuseAsGasCounter==priceKeytrue){<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; price if (key=="gasHeatingValue"){heatvalue = val.ToFloat();}<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; if (key=="gasConditionNumber"){condvalue = val.ToFloat(); }<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; if (key=="currencygasPrice") {pricekwh = val.ToFloat();}<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; } else {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; strCur&nbsp; if (key=="curPrice"){pricekwh =val.ToFloat();}<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/>integer kwf </div><div id= 1"bloop_customfont" style="margin: 0px">if (useAsGasCounter==true) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;real consumtion = heatvalue * condvalue * cntoday;<br/div><brdiv id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;real costtoday = pricekwh * consumtion;</div>if (priceKey<div id="bloop_customfont" style="curPricemargin: 0px">&nbsp; &nbsp;svCountToday.State(consumtion) {;<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; kwf = 1000&nbsp;svCostToday.State(costtoday);<br/div><div id="bloop_customfont" style="margin: 0px">}else {<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;real costtoday = price pricekwh * (cntoday/kwf1000);<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;svCountToday.State((cntoday/kwf1000));<br/div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;svCostToday.State(costtoday);</codediv><div id="bloop_customfont" style="margin: 0px">}<br/></div>
</div>
&nbsp;
250
Bearbeitungen