Änderungen

Wechseln zu: Navigation, Suche

HM-ES-TX-WM/Strom-Script01

2.513 Byte hinzugefügt, 16:23, 12. Feb. 2015
Script 1 darf nur einmal am Tag (um 0 Uhr zweckmässigerweise) laufen und ermittelt den gestrigen Verbrauch und speichert den Zählerstand.
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
:<code>!! 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/>!!<br/>!! Berechnet die verbrauchten kWh seit dem letzten Aufruf + Preis<br/>!! sollte einmal tgl. um 0 Uhr laufen<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;: eCountYesterday Typ: Zahl Einheit kWh<br/>!! Name&nbsp;: eCostYesterday Typ: Zahl Einheit&nbsp;: EUR<br/>!! Name&nbsp;: eEXMemory Typ: Zeichenkette<br/>!!<br/>!! Verbrauchte Energie wird nach Scriptlauf in eCountYesterday in kWh gespeichert Kosten in eCostYesterday<br/><br/>!! serialCounter mit Seriennummer des HM Zählers füllen<br/><br/>var serialCounter = "XXXXX";<br/>var dpname = "ENERGY_COUNTER";<br/>var priceKey = "curPrice";<br/><br/>var eEXMemory = dom.GetObject("eEXMemory");<br/>var svCountYesterday = dom.GetObject("eCountYesterday");<br/>var svCostYesterday = dom.GetObject("eCostYesterday");<br/>object devEnergyDP = dom.GetObject("BidCos-RF."#serialCounter#":1."#dpname);<br/>string tmpSVal = eEXMemory.State();<br/>real devcount = devEnergyDP.State();<br/>real statelast = tmpSVal.ToFloat();<br/>real cnyday = devcount-statelast;<br/><br/>string stdout;string stderr;<br/>string cmd = "/bin/sh -c 'cat /etc/config/energyPrice|sed -r \"s/\\"//g\"'";<br/>system.Exec(cmd, &stdout, &stderr);<br/>string sep = "\n";<br/>string part;<br/>string strCur;<br/>real price;<br/><br/>foreach(part,stdout.Split(sep)) {<br/>&nbsp; string key = part.StrValueByIndex(":",0);<br/>&nbsp; string val = part.StrValueByIndex(":",1);<br/>&nbsp; if (key==priceKey){<br/>&nbsp; &nbsp; price = val.ToFloat();<br/>&nbsp; }<br/>&nbsp; if (key=="currency") {<br/>&nbsp; &nbsp; strCur=val;<br/>&nbsp; }<br/>}<br/><br/>eEXMemory.State(devcount.ToString());<br/><br/>integer kwf = 1;<br/><br/>if (priceKey=="curPrice") {<br/>&nbsp; kwf = 1000;<br/>}<br/><br/>real costyed = price * (cnyday/kwf);<br/>svCountYesterday.State((cnyday/kwf));<br/>svCostYesterday.State(costyed);</code><br/>
</div>
 
 
Script 2 kann beliebig oft laufen und ermittelt den Vebrauch des aktuellen Tages&nbsp;
<div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
:<code>!! Energy Costs Part 12&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 seit dem letzten Aufruf + Preisvon Script 1 also im Idealfall<br/>!! sollte einmal tgl. um 0 Uhr den Verbrauch seit Mitternacht<br/>!!<br/>!! kann beliebig oft laufen<br/>!! funktioniert nur in Zusammenhang mit Script 1 richtig<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 : eCountYesterday eCountToday Typ: Zahl Einheit kWh<br/>!! Name : eCostYesterday eCostToday Typ: Zahl Einheit : EUR<br/>!! Name : eEXMemory Typ: Zeichenkette<br/>!!<br/>!! Verbrauchte Energie wird nach Scriptlauf in eCountYesterday eCountToday in kWh gespeichert Kosten in eCostYesterdayeCostToday<br/><br/>!! serialCounter mit Seriennummer des HM Zählers füllen<br/><br/><br/>var serialCounter = "XXXXX";<br/>var dpname = "ENERGY_COUNTER";<br/>var priceKey = "curPrice";<br/><br/>var eEXMemory = dom.GetObject("eEXMemory");<br/>var svCountYesterday svCountToday = dom.GetObject("eCountYesterdayeCountToday");<br/>var svCostYesterday svCostToday = dom.GetObject("eCostYesterdayeCostToday");<br/><br/>object devEnergyDP = dom.GetObject("BidCos-RF."#serialCounter#":1."#dpname);<br/>string tmpSVal = eEXMemory.State();<br/>real devcount = devEnergyDP.State();<br/>real statelast = tmpSVal.ToFloat();<br/>real cnyday cntoday = devcount-statelast;<br/><br/>string stdout;string stderr;<br/>string cmd = "/bin/sh -c 'cat /etc/config/energyPrice|sed -r \"s/\\"//g\"'";<br/>system.Exec(cmd, &stdout, &stderr);<br/>string sep = "\n";<br/>string part;<br/>string strCur;<br/>real price;<br/><br/>foreach(part,stdout.Split(sep)) {<br/>&nbsp; string key = part.StrValueByIndex(":",0);<br/>&nbsp; string val = part.StrValueByIndex(":",1);<br/>&nbsp; if (key==priceKey){<br/>&nbsp; &nbsp; price = val.ToFloat();<br/>&nbsp; }<br/>&nbsp; if (key=="currency") {<br/>&nbsp; &nbsp; strCur=val;<br/>&nbsp; }<br/>}<br/><br/>eEXMemory.State(devcount.ToString());<br/><br/>integer kwf = 1;<br/><br/>if (priceKey=="curPrice") {<br/>&nbsp; kwf = 1000;<br/>}<br/><br/>real costyed costtoday = price * (cnydaycntoday/kwf);<br/>svCountYesterdaysvCountToday.State((cnydaycntoday/kwf));<br/>svCostYesterdaysvCostToday.State(costyedcosttoday);</code><br/>
</div>
&nbsp;
250
Bearbeitungen