Änderungen

Wechseln zu: Navigation, Suche

HM-ES-TX-WM/Strom-Script01

4 Byte hinzugefügt, 13:14, 14. Feb. 2015
<br/><br/><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"
''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">
:<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;</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! Berechnet die verbrauchten kWh seit dem letzten Aufruf von Script 1 also im Idealfall</div><div id="bloop_customfont" style="margin: 0px">!! den Verbrauch seit Mitternacht</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! kann beliebig oft laufen</div><div id="bloop_customfont" style="margin: 0px">!! funktioniert nur in Zusammenhang mit Script 1 richtig</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</div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eCostToday Typ: Zahl Einheit: EUR</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">!! Verbrauchte Energie wird nach Scriptlauf in eCountToday in kWh gespeichert Kosten in eCostToday</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 = Elektro</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">var dpname = "ENERGY_COUNTER";</div><div id="bloop_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");</div><div id="bloop_customfont" style="margin: 0px">var svCountToday = dom.GetObject("eCountToday");</div><div id="bloop_customfont" style="margin: 0px">var svCostToday = dom.GetObject("eCostToday");</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 cntoday = 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 (useAsGasCounter==true) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;real consumtion = heatvalue * condvalue * cntoday;</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;real costtoday = pricekwh * consumtion;</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;svCountToday.State(cnttodaycntoday);<br/></div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;svCostToday.State(costtoday);</div><div id="bloop_customfont" style="margin: 0px">} else {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;real costtoday = pricekwh * (cntoday/1000);</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;svCountToday.State((cntoday/1000));</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;svCostToday.State(costtoday);</div><div id="bloop_customfont" style="margin: 0px">}<br/></div>
</div>
&nbsp;
250
Bearbeitungen