Änderungen

Wechseln zu: Navigation, Suche

HM-ES-TX-WM/Strom-Script01

40.894 Byte hinzugefügt, 13:46, 20. Feb. 2015
/* Script 4  setzt die CCU interne Zähl-Variable auf den aktuellen Zählerstand */
Thomas hat 2 3 Scripte geschrieben, die den heutigen und gestrigen Verbrauch in eine SysVar schreiben.<br/>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 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 benötigt:
Name&nbsp;: eCountToday Typ: Zahl Einheit kWh<br/>Name&nbsp;: eCountYesterday Typ: Zahl Einheit kWh<br/>Name&nbsp;: eCostToday Typ: Zahl Einheit: EUR<br/>Name&nbsp;: eCostYesterday Typ: Zahl Einheit&nbsp;: EUR<br/>Name&nbsp;: eEXMemory Typ: Zeichenkette Einheit&nbsp;: WH (Einheit is egal is nur Show)
__TOC__<br/>var serialCounter <span style= "XXXXX"; in jedem der Scripts mit der Seriennummer des eigenen Aktors füllenline-height: 1.6">Es werden folgende Systemvariablen für Script 1 und Script 2 benötigt:</span>
{| border="1" cellpadding="1" cellspacing="1"
|-
| eCountToday<br/>
| Zahl Einheit kWh<br/>
|-
| eCountYesterday<br/>
| Zahl Einheit kWh<br/>
|-
| eCostToday<br/>
| Zahl Einheit: EUR<br/>
|-
| eCostYesterday<br/>
| Zahl Einheit: EUR<br/>
|-
| eEXMemory<br/>
| Zeichenkette Einheit&nbsp;: WH (Einheit is egal is nur Show)<br/>
|}
&nbsp;'''Hinweis''': Bei Nutzung vom mehreren Energierzählern müssen die Variablen für jeden Zähler eindeutig sein. In den Scripten lässt sich das sehr einfach mit einem Texteditor ändern, indem die Funktion Suchen / Ersetzen benutzt wird.<br/>Beispiel:&nbsp; eCountToday -> eCountToday01 oder gasCountToday
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">'''var serialCounter'''<br/>"XXXXX"; in jedem der Scripts mit der Seriennummer des eigenen Aktors füllen<br/></div>
&nbsp;
---- === '''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.&nbsp; Bitte Hinweise am Anfang des Scrips beachten!!''
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
:<codediv 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&nbsp;; 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="s/\\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);</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; ---- === <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">
:<codediv 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&nbsp;; 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(cntoday) {;<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;
 
----
 
=== '''Script 2a'''&nbsp; ist eine Kombination aus Script 1 + 2 ===
 
''(Werte für heute, gestern, universell Strom / Gas und CuxD)'' ''Bitte Hinweise am Anfang des Scrips beachten!!''
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px"><div id="bloop_customfont" style="font-family:Helvetica,Arial; font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto"><div id="bloop_customfont" style="margin: 0px">!! Energy Costs Part 2a &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/m3 und den Preis für Gas/Strom für den aktuellen Tag&nbsp;</div><div id="bloop_customfont" style="margin: 0px">!! Der erste Aufruf des Tages speichert den Verbrauch des Vortages&nbsp;</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! kann beliebig oft laufen sollte aber günstigerweise mindestens einmal &nbsp;jeden Tag um 0 Uhr laufen</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 / m3</div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eCostToday Typ: Zahl Einheit: EUR</div><div id="bloop_customfont" style="margin: 0px">!!</div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eCountYesterday Typ: Zahl Einheit kWh / m3</div><div id="bloop_customfont" style="margin: 0px">!! Name&nbsp;: eCostYesterday Typ: Zahl Einheit: EUR</div><div id="bloop_customfont" style="margin: 0px">!!</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">!! serialCounter mit Seriennummer des HM Zählers füllen</div><div id="bloop_customfont" style="margin: 0px">!! useAsGasCounter = true -> Gaszähler&nbsp;; false -> Elektrozähler</div><div id="bloop_customfont" style="margin: 0px">!! cuxddevice = Seriennummer des CuxD Exec Devices (optional - &nbsp;sonst wird system.exe genutzt)</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">!! ================== do not change anything below ==========</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) {dpname = "GAS_ENERGY_COUNTER";}<br/></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">object devEnergyDP = dom.GetObject("BidCos-RF."#serialCounter#":1."#dpname);</div><div id="bloop_customfont" style="margin: 0px">var eEXMemory = dom.GetObject("eEXMemory");</div><div id="bloop_customfont" style="margin: 0px">!!&nbsp; integer lastSetMemory = eEXMemory.Timestamp().ToInteger();<br/>integer day = system.Date("%j").ToInteger();<br/>integer year = system.Date("%Y");<br/>integer lastSetDay = eEXMemory.Timestamp().Yearday();<br/>integer lastSetYear = eEXMemory.Timestamp().Year();<br/>boolean braveNewDay = false;<br/>if ((day>lastSetDay) || (year > lastSetYear)) {<br/>&nbsp;braveNewDay = true;<br/>}<br/></div><div style="margin: 0px"><br/>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">&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 (braveNewDay==true) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; eEXMemory.State(devcount.ToString());</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">real enerycost = 0.0;</div><div id="bloop_customfont" style="margin: 0px">real enerycount = 0.0;</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 = 0;</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;consumtion = heatvalue * condvalue * cnyday;</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;enerycost = pricekwh * consumtion;</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;enerycount = cnyday;</div><div id="bloop_customfont" style="margin: 0px">} else {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;enerycount = (cnyday/1000);</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp;enerycost = pricekwh * enerycount;</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 (braveNewDay==true) {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; &nbsp;dom.GetObject("eCountYesterday").State(enerycount);</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; &nbsp;dom.GetObject("eCostYesterday").State(enerycost);</div><div id="bloop_customfont" style="margin: 0px">} else {</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; &nbsp;dom.GetObject("eCountToday").State(enerycount);</div><div id="bloop_customfont" style="margin: 0px">&nbsp; &nbsp; &nbsp;dom.GetObject("eCostToday").State(enerycost);</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></div>===
----
 
=== '''Script 3&nbsp;''' für die Berrechnung der&nbsp; ''jährlichen Energiekosten'' Strom oder Gas universell.&nbsp; ===
 
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:
 
{| border="1" cellpadding="1" cellspacing="1"
|-
| style="width: 134px" | eLastInvoice<br/>
| style="width: 66px" | Zahl<br/>
| hier den Zählerstand der letzten Energieabrechnung in kWh oder m3 eintragen<br/>
|-
| style="width: 134px" | eStart<br/>
| style="width: 66px" | Zeichenkette<br/>
| hier den aktuellen Zählerstand und den Zählerstand des Energiemessgerätes in ganzen kWh oder m3 eintragen und zwar wie folgt:<br/>
|-
| style="width: 134px" | <br/>
| style="width: 66px" | <br/>
| Zählerstand EZähler&#124;Zählerstand HM Zähler (Beispiel 17456&#124;5&nbsp;; 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<br/>
|-
| style="width: 134px" | <br/>
| style="width: 66px" | <br/>
| Die Variable eStart dient der Differenzrechnung um bei jedem Scriptaufruf auf den aktuellen Zählerstand des richtigen EZählers berechnen zu können<br/>
|-
| style="width: 134px" | eUsedEnergyCost<br/>
| style="width: 66px" | Zahl<br/>
| Einheit&nbsp;:EUR - Energiekosten<br/>
|-
| style="width: 134px" | eUsedEnergyCount<br/>
| style="width: 66px" | Zahl<br/>
| Einheit&nbsp;:kWh oder m3 - Verbrauchte kWh oder m3<br/>
|-
| style="width: 134px" | eTotalEnergyCount<br/>
| style="width: 66px" | Zahl<br/>
| Einheit&nbsp;:kWh oder m3 - aktueller Stand des Zählers<br/>
|-
| style="width: 134px" | <br/>
| style="width: 66px" | <br/>
| <br/>
|-
| style="width: 134px" | <br/>
| style="width: 66px" | <br/>
| <span style="font-size:medium">'''Folgende Variablen am Anfang des Scriptes anpassen:'''</span><br/>
|-
| style="width: 134px" | useAsGasCounter<br/>
| style="width: 66px" | <br/>
| useAsGasCounter = 0 - E Zähler&nbsp;; = 1 Gas Zähler<br/>
|-
| style="width: 134px" | cuxddevice<br/>
| style="width: 66px" | <br/>
| cuxddevice = Seriennummer des CuxD Exec Devices. Wenn nicht vorhanden leer lassen dann wird system.exec genommen<br/>
|-
| style="width: 134px" | var serialCounter<br/>
| style="width: 66px" | <br/>
| "XXXXX"; -> hier wieder Seriennummer anpassen<br/>
|}
 
&nbsp;
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
:<code>!! Energy Costs Part 3&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/>!!<br/>!! Berechnet die verbrauchten kWh/m3 seit der letzten Abrechnung des Energielieferanten<br/>!!<br/>!! kann beliebig oft laufen<br/>!!<br/>!! 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/>!! (c) by thkl<br/>!!<br/>!! Benötigte SystemVariablen:<br/>!! Name&nbsp;: eLastInvoice Typ:Zahl -> hier den Zählerstand der letzten Energieabrechnung in kWh oder m3 eintragen.<br/>!! Name&nbsp;: eStart Typ: Zeichenkette -> hier den aktuellen Zählerstand und den Zählerstand des Energiemessgerätes in ganzen kWh eintragen und zwar wie folgt:<br/>!! Zählerstand EZähler|Zählerstand HM Zähler (Beispiel 17456|5&nbsp;; 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)<br/>!! also / 1000<br/>!! Name&nbsp;: eUsedEnergyCost Typ: Zahl Einheit&nbsp;:EUR&nbsp;<br/>!! Name&nbsp;: eUsedEnergyCount Typ: Zahl Einheit&nbsp;:kWh oder m3<br/>!! Name&nbsp;: eTotalEnergyCount Typ: Zahl Einheit&nbsp;:kWh oder m3<br/>!! Energiekosten werden nach Scriptlauf in eUsedEnergyCost gespeichert<br/>!! Verbrauchte KwH werden nach Scriptlauf in eUsedEnergyCount gespeichert<br/>!! aktueller Stand des Stromzählers wird in eTotalEnergyCount gespeichert</code><br/>
:<code>!!</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;</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>
&nbsp;
 
----
 
=== '''Script 4'''&nbsp; setzt die CCU interne Zähl-Variable auf den aktuellen Zählerstand ===
 
Beispiel für '''Strom Zähler''':
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
dom.GetObject("svEnergyCounter_XXXXX_XXXXXXXXXX:1").State(dom.GetObject("BidCos-RF.SERIENNUMMER:1.ENERGY_COUNTER").State()+12345);
</div>
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:'''&nbsp;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&nbsp;<span style="font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; font-size: 12px; line-height: normal">prgEnergyCounter_XXXXXX_XXXXXXXXX:1 heisst.</span>
 
<span style="font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; font-size: 12px; line-height: normal">Wobei die ersten&nbsp;</span>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.
 
'''2 Beispiele für GAS Zähler''' (anderer Datenpunkt !!)
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
:<code>object oSysVarEnergyCounter = dom.GetObject('svEnergyCounterGas_4678_MEQ0025494:1');<br/>oSysVarEnergyCounter.State(45939.34);</code><br/>
</div><div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
:<code>dom.GetObject("svEnergyCounter_4678_MEQ0025494:1").State(dom.GetObject("BidCos-RF.MEQ0025494:1.GAS_ENERGY_COUNTER").State()+45939,34);</code><br/>
</div>
----
 
=== '''Script 5''' berechnet den Verbrauch für GAS&nbsp; m3/Std&nbsp; fortlaufend ===
 
Es gibt beim Energiezähler einen Datenpunkt "GAS_POWER" , der bei der FW 1.0 unbrauchbar ist. Er soll den momentanen Verbrauch darstellen, geht aber z.B. nicht auf Null, wenn der Gaszähler nicht läuft-. Auch nicht nach mehreren Stunden.
 
In der WebUI der CCU gibt es unter Programme (nach dem die systeminternen Programme eingeblendet wurden) für jeden Energiezähler ein Programm, das getriggert wird, wenn sich der Datenpunkt "GAS_ENERGY_COUNTER" aktualisiert.&nbsp; In diesem Programm fügen wir im DANN Bereich ein zweites Script hinzu, das den Verbrauch / Std berechnet.
 
Gebraucht wird nur eine SystemVariable vom Typ Zahl "gas_m3_Std"<br/>Diese SysVar kann dann mit beliebigen externen Tools aufgezeichnet werden um Diagramme zu erstellen.
 
 
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">&nbsp;&nbsp;&nbsp; ! Durchfluss in m³/h berechnen für Gas Zähler<br/>&nbsp;&nbsp;&nbsp; ! Datenpunkt des auslösenden Zählwertes<br/>&nbsp;&nbsp;&nbsp; object zdp = dom.GetObject("$src$");<br/>&nbsp;&nbsp;&nbsp; if (zdp)<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; integer now = zdp.Timestamp().ToInteger();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; integer last = zdp.LastTimestamp().ToInteger();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; integer diffTime = now - last;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real val = zdp.Value();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real lastval = zdp.LastValue();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real diffVal = val - lastval;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real durchfluss = 3600.0 * diffVal / diffTime;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dom.GetObject("gas_m3_Std").State(durchfluss);<br/>&nbsp;&nbsp;&nbsp; }<br/></div>
250
Bearbeitungen