HM-ES-TX-WM/Strom-Script01: Unterschied zwischen den Versionen

Aus Wikimatic
Wechseln zu: Navigation, Suche
K
K (Script 3  für die Berrechnung der  jährlichen Energiekosten Strom oder Gas universell. )
Zeile 112: Zeile 112:
 
:<code>!!</code><br/>
 
:<code>!!</code><br/>
 
:<code>!! serialCounter = "" - Hier die Seriennummer des HM Zählregrätes eintragen</code><br/>
 
:<code>!! serialCounter = "" - Hier die Seriennummer des HM Zählregrätes eintragen</code><br/>
:<div id="bloop_customfont" style="margin: 0px"><div id="bloop_customfont" style="margin: 0px"><div style="color: rgb(0, 0, 0);  font-family: Helvetica, Arial"><code>!! useAsGasCounter = 0 - E Zähler&nbsp;; = 1 Gas Zähler</code></div><div style="color: rgb(0, 0, 0);  font-family: Helvetica, Arial"><code>!! cuxddevice = Seriennummer des CuxD Exec Devices. Wenn nicht vorhanden leer lassen dann wird system.exec genommen</code></div><div style="color: rgb(0, 0, 0);  font-family: Helvetica, Arial"><br/></div></div></div><div id="bloop_customfont" style="font-family: Helvetica, Arial;  color: rgb(0, 0, 0);  margin: 0px"><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var serialCounter = "";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var useAsGasCounter = 0;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var cuxddevice = "";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>!! ================ ab hier nichts mehr aendern</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var dpname = "ENERGY_COUNTER";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>if (useAsGasCounter==1) {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; dpname = "GAS_ENERGY_COUNTER";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>}</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var svLastInvoice = dom.GetObject("eLastInvoice");</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var svMemory = dom.GetObject("eStart");</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var svUsedEnergyCost = dom.GetObject("eUsedEnergyCost");</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var svUsedEnergyCount = dom.GetObject("eUsedEnergyCount");</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var svTotalEnergyCount = dom.GetObject("eTotalEnergyCount");</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var memory = svMemory.State();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var countLastIncoice = svLastInvoice.State();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>object devEnergyDP = dom.GetObject("BidCos-RF."#serialCounter#":1."#dpname);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real oec = memory.StrValueByIndex("|",0).ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real shc = memory.StrValueByIndex("|",1).ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real chc = devEnergyDP.State();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>string stdout;string stderr;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>string cmd = "/bin/sh -c 'cat /etc/config/energyPrice|sed -r \"s/\\"//g\"'";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>if (cuxddevice!="") {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; dom.GetObject("CUxD."#cuxddevice#":1.CMD_SETS").State(cmd);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; dom.GetObject("CUxD."#cuxddevice#":1.CMD_QUERY_RET").State(1);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; stdout = dom.GetObject("CUxD."#cuxddevice#":1.CMD_RETS").State();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>} else {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; system.Exec(cmd, &stdout, &stderr);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>}</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>string sep = "\n";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>string part;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>string strCur;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real pricekwh=0;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real condvalue=0;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real heatvalue=0;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>foreach(part,stdout.Split(sep)) {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; string key = part.StrValueByIndex(":",0);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; string val = part.StrValueByIndex(":",1);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp;&nbsp;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; if (useAsGasCounter==1) {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; if (key=="gasHeatingValue"){</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; heatvalue = val.ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; if (key=="gasConditionNumber"){</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; condvalue = val.ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; if (key=="gasPrice"){</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; pricekwh = val.ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; } else {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; if (key=="curPrice"){</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; pricekwh = val.ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; if (key=="currency") {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; strCur=val;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>}</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>if (useAsGasCounter==1) {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real cec = (chc - shc)+oec;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real uec = cec-countLastIncoice.ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real consumtion = heatvalue * condvalue * uec;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real costyear = pricekwh * consumtion;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svUsedEnergyCost.State(costyear);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svUsedEnergyCount.State(uec);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svTotalEnergyCount.State(cec);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>} else {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; &nbsp; &nbsp;real cec = ((chc/1000) - shc)+oec;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real uec = cec-countLastIncoice.ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real costyear = pricekwh * (uec);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svUsedEnergyCost.State(costyear);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svUsedEnergyCount.State(uec);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svTotalEnergyCount.State(cec);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>}</code></div><div><br/></div></div>
+
:<div id="bloop_customfont" style="margin: 0px"><div id="bloop_customfont" style="margin: 0px"><div style="color: rgb(0, 0, 0);  font-family: Helvetica, Arial"><code>!! useAsGasCounter = 0 - E Zähler&nbsp;; = 1 Gas Zähler</code></div><div style="color: rgb(0, 0, 0);  font-family: Helvetica, Arial"><code>!! cuxddevice = Seriennummer des CuxD Exec Devices. Wenn nicht vorhanden leer lassen dann wird system.exec genommen</code></div><div style="color: rgb(0, 0, 0);  font-family: Helvetica, Arial"><br/></div></div></div><div id="bloop_customfont" style="font-family: Helvetica, Arial;  color: rgb(0, 0, 0);  margin: 0px"><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var serialCounter = "";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var useAsGasCounter = 0;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var cuxddevice = "";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>!! ================ ab hier nichts mehr aendern</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var dpname = "ENERGY_COUNTER";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>if (useAsGasCounter==1) {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; dpname = "GAS_ENERGY_COUNTER";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>}</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var svLastInvoice = dom.GetObject("eLastInvoice");</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var svMemory = dom.GetObject("eStart");</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var svUsedEnergyCost = dom.GetObject("eUsedEnergyCost");</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var svUsedEnergyCount = dom.GetObject("eUsedEnergyCount");</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var svTotalEnergyCount = dom.GetObject("eTotalEnergyCount");</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var memory = svMemory.State();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>var countLastIncoice = svLastInvoice.State();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>object devEnergyDP = dom.GetObject("BidCos-RF."#serialCounter#":1."#dpname);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real oec = memory.StrValueByIndex("|",0).ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real shc = memory.StrValueByIndex("|",1).ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real chc = devEnergyDP.State();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>string stdout;string stderr;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>string cmd = "/bin/sh -c 'cat /etc/config/energyPrice|sed -r \"s/\\"//g\"'";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>if (cuxddevice!="") {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; dom.GetObject("CUxD."#cuxddevice#":1.CMD_SETS").State(cmd);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; dom.GetObject("CUxD."#cuxddevice#":1.CMD_QUERY_RET").State(1);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; stdout = dom.GetObject("CUxD."#cuxddevice#":1.CMD_RETS").State();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>} else {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; system.Exec(cmd, &stdout, &stderr);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>}</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>string sep = "\n";</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>string part;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>string strCur;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real pricekwh=0;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real condvalue=0;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>real heatvalue=0;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>foreach(part,stdout.Split(sep)) {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; string key = part.StrValueByIndex(":",0);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; string val = part.StrValueByIndex(":",1);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp;&nbsp;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; if (useAsGasCounter==1) {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; if (key=="gasHeatingValue"){</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; heatvalue = val.ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; if (key=="gasConditionNumber"){</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; condvalue = val.ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; if (key=="gasPrice"){</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; pricekwh = val.ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; } else {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; if (key=="curPrice"){</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; pricekwh = val.ToFloat();</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; if (key=="currency") {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; strCur=val;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; }</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>}</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>if (useAsGasCounter==1) {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real cec = (chc - shc)+oec;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real uec = cec-countLastIncoice;</code><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real consumtion = heatvalue * condvalue * uec;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real costyear = pricekwh * consumtion;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svUsedEnergyCost.State(costyear);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svUsedEnergyCount.State(uec);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svTotalEnergyCount.State(cec);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>} else {</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>&nbsp; &nbsp; &nbsp; &nbsp;real cec = ((chc/1000) - shc)+oec;</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real uec = cec-countLastIncoice;</code><br/></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>real costyear = pricekwh * (uec);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svUsedEnergyCost.State(costyear);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svUsedEnergyCount.State(uec);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><span style="color: rgb(0, 0, 0);  font-family: monospace;  line-height: 19.5px;  background-color: rgb(238, 238, 238)">&nbsp; &nbsp; &nbsp; &nbsp;</span><code>svTotalEnergyCount.State(cec);</code></div><div id="bloop_customfont" style="line-height: 19.5px;  margin: 0px"><code>}</code></div><div><br/></div></div>
 
</div>
 
</div>
 
&nbsp;
 
&nbsp;

Version vom 14. Februar 2015, 13:42 Uhr

Thomas hat 3 Scripte geschrieben, die den heutigen und gestrigen Verbrauch in eine SysVar schreiben.
Ausserdem werden die Kosten aus dem entsprechenden Strompreis Eintrag in der Systemsteuerung der CCU berechnet.

http://homematic-forum.de/forum/viewtopic.php?f=27&t=23104#p198925_http://homematic-forum.de/forum/viewtopic.php?f=27&t=23104#p198925




Es werden folgende Systemvariablen für Script 1 und Script 2 benötigt:

eCountToday
Zahl Einheit kWh
eCountYesterday
Zahl Einheit kWh
eCostToday
Zahl Einheit: EUR
eCostYesterday
Zahl Einheit: EUR
eEXMemory
Zeichenkette Einheit : WH (Einheit is egal is nur Show)

 

var serialCounter
"XXXXX"; in jedem der Scripts mit der Seriennummer des eigenen Aktors füllen

 


Script 1 darf nur einmal am Tag (um 0 Uhr zweckmässigerweise) laufen und ermittelt den gestrigen Verbrauch und speichert den Zählerstand.

!! Energy Costs Part 1                                                       
!!
!! Berechnet die verbrauchten kWh seit dem letzten Aufruf + Preis
!! sollte einmal tgl. um 0 Uhr laufen
!! 02/15                                                 
!! (c) by thkl
!!
!! Benötigte SystemVariablen:
!! Name : eCountYesterday Typ: Zahl Einheit kWh
!! Name : eCostYesterday Typ: Zahl Einheit : EUR
!! Name : eEXMemory Typ: Zeichenkette
!!
!! Verbrauchte Energie wird nach Scriptlauf in eCountYesterday in kWh gespeichert Kosten in eCostYesterday

!! serialCounter mit Seriennummer des HM Zählers füllen

var serialCounter = "XXXXX";
var dpname = "ENERGY_COUNTER";
var priceKey = "curPrice";

var eEXMemory = dom.GetObject("eEXMemory");
var svCountYesterday = dom.GetObject("eCountYesterday");
var svCostYesterday = dom.GetObject("eCostYesterday");
object devEnergyDP = dom.GetObject("BidCos-RF."#serialCounter#":1."#dpname);
string tmpSVal = eEXMemory.State();
real devcount = devEnergyDP.State();
real statelast = tmpSVal.ToFloat();
real cnyday = devcount-statelast;

string stdout;string stderr;
string cmd = "/bin/sh -c 'cat /etc/config/energyPrice|sed -r \"s/\\"//g\"'";
system.Exec(cmd, &stdout, &stderr);
string sep = "\n";
string part;
string strCur;
real price;

foreach(part,stdout.Split(sep)) {
  string key = part.StrValueByIndex(":",0);
  string val = part.StrValueByIndex(":",1);
  if (key==priceKey){
    price = val.ToFloat();
  }
  if (key=="currency") {
    strCur=val;
  }
}

eEXMemory.State(devcount.ToString());

integer kwf = 1;

if (priceKey=="curPrice") {
  kwf = 1000;
}

real costyed = price * (cnyday/kwf);
svCountYesterday.State((cnyday/kwf));
svCostYesterday.State(costyed);

 



Script 2 kann beliebig oft laufen und ermittelt den Vebrauch des aktuellen Tages 

!! Energy Costs Part 2                                                       
!!
!! Berechnet die verbrauchten kWh seit dem letzten Aufruf von Script 1 also im Idealfall
!! den Verbrauch seit Mitternacht
!!
!! kann beliebig oft laufen
!! funktioniert nur in Zusammenhang mit Script 1 richtig
!!
!! 02/15                                                 
!! (c) by thkl
!!
!! Benötigte SystemVariablen:
!! Name : eCountToday Typ: Zahl Einheit kWh
!! Name : eCostToday Typ: Zahl Einheit: EUR
!! Name : eEXMemory Typ: Zeichenkette
!!
!! Verbrauchte Energie wird nach Scriptlauf in eCountToday in kWh gespeichert Kosten in eCostToday

!! serialCounter mit Seriennummer des HM Zählers füllen


var serialCounter = "XXXXX";
var dpname = "ENERGY_COUNTER";
var priceKey = "curPrice";

var eEXMemory = dom.GetObject("eEXMemory");
var svCountToday = dom.GetObject("eCountToday");
var svCostToday = dom.GetObject("eCostToday");

object devEnergyDP = dom.GetObject("BidCos-RF."#serialCounter#":1."#dpname);
string tmpSVal = eEXMemory.State();
real devcount = devEnergyDP.State();
real statelast = tmpSVal.ToFloat();
real cntoday = devcount-statelast;

string stdout;string stderr;
string cmd = "/bin/sh -c 'cat /etc/config/energyPrice|sed -r \"s/\\"//g\"'";
system.Exec(cmd, &stdout, &stderr);
string sep = "\n";
string part;
string strCur;
real price;

foreach(part,stdout.Split(sep)) {
  string key = part.StrValueByIndex(":",0);
  string val = part.StrValueByIndex(":",1);
  if (key==priceKey){
    price = val.ToFloat();
  }
  if (key=="currency") {
    strCur=val;
  }
}

integer kwf = 1;

if (priceKey=="curPrice") {
  kwf = 1000;
}
real costtoday = price * (cntoday/kwf);
svCountToday.State((cntoday/kwf));
svCostToday.State(costtoday);

 


Script 3  für die Berrechnung der  jährlichen Energiekosten Strom oder Gas universell. 

Hier wird schon zwischen Elektro und Gas Zähler unterschieden. Auch kann optional ein CuxD Exec Device statt system.exec verwendet werden. Siehe Kommentare im Script

Folgende Variablen:

eLastInvoice
Zahl
hier den Zählerstand der letzten Energieabrechnung in kWh oder m3 eintragen
eStart
Zeichenkette
hier den aktuellen Zählerstand und den Zählerstand des Energiemessgerätes in ganzen kWh oder m3 eintragen und zwar wie folgt:


Zählerstand EZähler|Zählerstand HM Zähler (Beispiel 17456|5 ; wenn der Schwarze Kasten im E-Verteiler 17456 zeigt und gleichzeitig das HM Gerät 5) Achtung das HM Gerät zählt in WattStunden also / 1000


Die Variable eStart dient der Differenzrechnung um bei jedem Scriptaufruf auf den aktuellen Zählerstand des richtigen EZählers berechnen zu können
eUsedEnergyCost
Zahl
Einheit :EUR - Energiekosten
eUsedEnergyCount
Zahl
Einheit :kWh oder m3 - Verbrauchte kWh oder m3
eTotalEnergyCount
Zahl
Einheit :kWh oder m3 - aktueller Stand des Zählers





Folgende Variablen am Anfang des Scriptes anpassen:
useAsGasCounter

useAsGasCounter = 0 - E Zähler ; = 1 Gas Zähler
cuxddevice

cuxddevice = Seriennummer des CuxD Exec Devices. Wenn nicht vorhanden leer lassen dann wird system.exec genommen
var serialCounter

"XXXXX"; -> hier wieder Seriennummer anpassen

 

!! Energy Costs Part 3                                                       
!!
!! Berechnet die verbrauchten kWh/m3 seit der letzten Abrechnung des Energielieferanten
!!
!! kann beliebig oft laufen
!!
!! 02/15                                                 
!! (c) by thkl
!!
!! Benötigte SystemVariablen:
!! Name : eLastInvoice Typ:Zahl -> hier den Zählerstand der letzten Energieabrechnung in kWh oder m3 eintragen.
!! Name : eStart Typ: Zeichenkette -> hier den aktuellen Zählerstand und den Zählerstand des Energiemessgerätes in ganzen kWh eintragen und zwar wie folgt:
!! Zählerstand EZähler|Zählerstand HM Zähler (Beispiel 17456|5 ; wenn der Schwarze Kasten im E-Verteiler 17456 zeigt und gleichzeitig das HM Gerät 5) Achtung das HM Gerät zählt in WattStunden (alternativ natürlich die Gaszählerwerte)
!! also / 1000
!! Name : eUsedEnergyCost Typ: Zahl Einheit :EUR 
!! Name : eUsedEnergyCount Typ: Zahl Einheit :kWh oder m3
!! Name : eTotalEnergyCount Typ: Zahl Einheit :kWh oder m3
!! Energiekosten werden nach Scriptlauf in eUsedEnergyCost gespeichert
!! Verbrauchte KwH werden nach Scriptlauf in eUsedEnergyCount gespeichert
!! aktueller Stand des Stromzählers wird in eTotalEnergyCount gespeichert

!!
!! serialCounter = "" - Hier die Seriennummer des HM Zählregrätes eintragen
!! useAsGasCounter = 0 - E Zähler ; = 1 Gas Zähler
!! cuxddevice = Seriennummer des CuxD Exec Devices. Wenn nicht vorhanden leer lassen dann wird system.exec genommen

var serialCounter = "";
var useAsGasCounter = 0;
var cuxddevice = "";

!! ================ ab hier nichts mehr aendern

var dpname = "ENERGY_COUNTER";
if (useAsGasCounter==1) {
  dpname = "GAS_ENERGY_COUNTER";
}

var svLastInvoice = dom.GetObject("eLastInvoice");
var svMemory = dom.GetObject("eStart");
var svUsedEnergyCost = dom.GetObject("eUsedEnergyCost");
var svUsedEnergyCount = dom.GetObject("eUsedEnergyCount");
var svTotalEnergyCount = dom.GetObject("eTotalEnergyCount");


var memory = svMemory.State();
var countLastIncoice = svLastInvoice.State();

object devEnergyDP = dom.GetObject("BidCos-RF."#serialCounter#":1."#dpname);

real oec = memory.StrValueByIndex("|",0).ToFloat();
real shc = memory.StrValueByIndex("|",1).ToFloat();
real chc = devEnergyDP.State();

string stdout;string stderr;

string cmd = "/bin/sh -c 'cat /etc/config/energyPrice|sed -r \"s/\\"//g\"'";
if (cuxddevice!="") {
  dom.GetObject("CUxD."#cuxddevice#":1.CMD_SETS").State(cmd);
  dom.GetObject("CUxD."#cuxddevice#":1.CMD_QUERY_RET").State(1);
  stdout = dom.GetObject("CUxD."#cuxddevice#":1.CMD_RETS").State();
} else {
  system.Exec(cmd, &stdout, &stderr);
}

string sep = "\n";
string part;
string strCur;

real pricekwh=0;
real condvalue=0;
real heatvalue=0;

foreach(part,stdout.Split(sep)) {
  string key = part.StrValueByIndex(":",0);
  string val = part.StrValueByIndex(":",1);
  
  if (useAsGasCounter==1) {
  if (key=="gasHeatingValue"){
    heatvalue = val.ToFloat();
  }
  if (key=="gasConditionNumber"){
    condvalue = val.ToFloat();
  }
  if (key=="gasPrice"){
    pricekwh = val.ToFloat();
  }
  } else {
    if (key=="curPrice"){
    pricekwh = val.ToFloat();
  }
  }

  if (key=="currency") {
    strCur=val;
  }
}

if (useAsGasCounter==1) {
       real cec = (chc - shc)+oec;
       real uec = cec-countLastIncoice;
       real consumtion = heatvalue * condvalue * uec;
       real costyear = pricekwh * consumtion;
       svUsedEnergyCost.State(costyear);
       svUsedEnergyCount.State(uec);
       svTotalEnergyCount.State(cec);
} else {
       real cec = ((chc/1000) - shc)+oec;
       real uec = cec-countLastIncoice;
       real costyear = pricekwh * (uec);
       svUsedEnergyCost.State(costyear);
       svUsedEnergyCount.State(uec);
       svTotalEnergyCount.State(cec);
}

 


Script 4  setzt die CCU interne Zähl-Variable auf den aktuellen Zählerstand

dom.GetObject("svEnergyCounter_XXXXX_XXXXXXXXXX:1").State(dom.GetObject("BidCos-RF.SERIENNUMMER:1.ENERGY_COUNTER").State()+12345);

Wobei 12345 der Stand des richtigen Zählers bei 0 Stellung des HM Zählers ist. Bei Bedarf kann man natürlich den HM Zähler durch Batterie raus wieder auf 0 setzen.

Wichtig: Der Eintrag svEnergyCounter_XXXXX_XXXXXXXXXX:1 ist auf jeder CCU bei jedem Zählgerät unterschiedlich. Du kannst diesen Namen wie folgt ermitteln:

Rufe im WebUI die Programme auf und blende die Systeminternen Programme mit ein. Du wirst ein Programm finden welches prgEnergyCounter_XXXXXX_XXXXXXXXX:1 heisst.

Wobei die ersten 5 Stellen die interne Objektnummer und die nächsten Stellen die Seriennummer des Zählgerätes sind. Diesen Teil kopiere und ersetze im Script oben.

.