73_GasCalculator.pm 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991
  1. # $Id: 73_GasCalculator.pm 16602 2018-04-13 17:58:19Z Sailor $
  2. ########################################################################################################################
  3. #
  4. # 73_GasCalculator.pm
  5. # Observes a reading of a device which represents the actual counter (e.g. OW_devive)
  6. # acting as gas counter, calculates the corresponding values and writes them back to
  7. # the counter device.
  8. # Written and best viewed with Notepad++ v.6.8.6; Language Markup: Perl
  9. #
  10. # Author : Matthias Deeke
  11. # e-mail : matthias.deeke(AT)deeke(PUNKT)eu
  12. # Fhem Forum : https://forum.fhem.de/index.php/topic,47909.0.html
  13. # Fhem Wiki : Not yet implemented
  14. #
  15. # This file is part of fhem.
  16. #
  17. # Fhem is free software: you can redistribute it and/or modify
  18. # it under the terms of the GNU General Public License as published by
  19. # the Free Software Foundation, either version 2 of the License, or
  20. # (at your option) any later version.
  21. #
  22. # Fhem is distributed in the hope that it will be useful,
  23. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. # GNU General Public License for more details.
  26. #
  27. # You should have received a copy of the GNU General Public License
  28. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
  29. #
  30. # fhem.cfg: define <devicename> GasCalculator <regexp>
  31. #
  32. # Example 1:
  33. # define myGasCalculator GasCalculator myGasCounter:CounterA.*
  34. #
  35. ########################################################################################################################
  36. ########################################################################################################################
  37. # List of open Problems / Issues:
  38. #
  39. # - set command to create Plots automatically
  40. #
  41. ########################################################################################################################
  42. package main;
  43. use strict;
  44. use warnings;
  45. my %GasCalculator_gets;
  46. my %GasCalculator_sets;
  47. ###START###### Initialize module ##############################################################################START####
  48. sub GasCalculator_Initialize($)
  49. {
  50. my ($hash) = @_;
  51. $hash->{STATE} = "Init";
  52. $hash->{DefFn} = "GasCalculator_Define";
  53. $hash->{UndefFn} = "GasCalculator_Undefine";
  54. $hash->{GetFn} = "GasCalculator_Get";
  55. $hash->{SetFn} = "GasCalculator_Set";
  56. $hash->{AttrFn} = "GasCalculator_Attr";
  57. $hash->{NotifyFn} = "GasCalculator_Notify";
  58. $hash->{NotifyOrderPrefix} = "10-"; # Want to be called before the rest
  59. $hash->{AttrList} = "disable:0,1 " .
  60. "header " .
  61. "GasCounterOffset " .
  62. "GasCubicPerCounts " .
  63. "GaszValue " .
  64. "GasNominalHeatingValue " .
  65. "BasicPricePerAnnum " .
  66. "GasPricePerKWh " .
  67. "MonthlyPayment " .
  68. "MonthOfAnnualReading " .
  69. "ReadingDestination:CalculatorDevice,CounterDevice " .
  70. "SiPrefixPower:W,kW,MW,GW " .
  71. "Volume:m&#179;,ft&#179; " .
  72. "Currency:&#8364;,&#163;,&#36; " .
  73. $readingFnAttributes;
  74. }
  75. ####END####### Initialize module ###############################################################################END#####
  76. ###START###### Activate module after module has been used via fhem command "define" ##########################START####
  77. sub GasCalculator_Define($$$)
  78. {
  79. my ($hash, $def) = @_;
  80. my ($name, $type, $RegEx, $RegExst) = split("[ \t]+", $def, 4);
  81. ### Check whether regular expression has correct syntax
  82. if(!$RegEx || $RegExst)
  83. {
  84. my $msg = "Wrong syntax: define <name> GasCalculator device[:event]";
  85. return $msg;
  86. }
  87. ### Check whether regular expression is misleading
  88. eval { "Hallo" =~ m/^$RegEx$/ };
  89. return "Bad regexp: $@" if($@);
  90. $hash->{REGEXP} = $RegEx;
  91. ### Writing values to global hash
  92. notifyRegexpChanged($hash, $RegEx);
  93. $hash->{NAME} = $name;
  94. $hash->{STATE} = "active";
  95. $hash->{REGEXP} = $RegEx;
  96. if(defined($attr{$hash}{SiPrefixPower}))
  97. {
  98. if ($attr{$hash}{SiPrefixPower} eq "W" ) {$hash->{system}{SiPrefixPowerFactor} = 1 ;}
  99. elsif ($attr{$hash}{SiPrefixPower} eq "kW") {$hash->{system}{SiPrefixPowerFactor} = 1000 ;}
  100. elsif ($attr{$hash}{SiPrefixPower} eq "MW") {$hash->{system}{SiPrefixPowerFactor} = 1000000 ;}
  101. elsif ($attr{$hash}{SiPrefixPower} eq "GW") {$hash->{system}{SiPrefixPowerFactor} = 1000000000 ;}
  102. else {$hash->{system}{SiPrefixPowerFactor} = 1 ;}
  103. }
  104. else
  105. {
  106. $hash->{system}{SiPrefixPowerFactor} = 1;
  107. }
  108. ### Writing log entry
  109. Log3 $name, 5, $name. " : GasCalculator - Starting to define module";
  110. return undef;
  111. }
  112. ####END####### Activate module after module has been used via fhem command "define" ############################END#####
  113. ###START###### Deactivate module module after "undefine" command by fhem ######################################START####
  114. sub GasCalculator_Undefine($$)
  115. {
  116. my ($hash, $def) = @_;
  117. my $name = $hash->{NAME};
  118. Log3 $name, 3, $name. " GasCalculator- The gas calculator has been undefined. Values corresponding to Gas Counter will no longer calculated";
  119. return undef;
  120. }
  121. ####END####### Deactivate module module after "undefine" command by fhem #######################################END#####
  122. ###START###### Handle attributes after changes via fhem GUI ###################################################START####
  123. sub GasCalculator_Attr(@)
  124. {
  125. my @a = @_;
  126. my $name = $a[1];
  127. my $hash = $defs{$name};
  128. ### Check whether "disable" attribute has been provided
  129. if ($a[2] eq "disable")
  130. {
  131. if ($a[3] eq 0)
  132. {
  133. $hash->{STATE} = "active";
  134. }
  135. elsif ($a[3] eq 1)
  136. {
  137. $hash->{STATE} = "disabled";
  138. }
  139. }
  140. ### Check whether "SiPrefixPower" attribute has been provided
  141. if ($a[2] eq "SiPrefixPower")
  142. {
  143. if ($a[3] eq "W" ) {$hash->{system}{SiPrefixPowerFactor} = 1 ;}
  144. elsif ($a[3] eq "kW") {$hash->{system}{SiPrefixPowerFactor} = 1000 ;}
  145. elsif ($a[3] eq "MW") {$hash->{system}{SiPrefixPowerFactor} = 1000000 ;}
  146. elsif ($a[3] eq "GW") {$hash->{system}{SiPrefixPowerFactor} = 1000000000 ;}
  147. else {$hash->{system}{SiPrefixPowerFactor} = 1 ;}
  148. }
  149. return undef;
  150. }
  151. ####END####### Handle attributes after changes via fhem GUI ####################################################END#####
  152. ###START###### Manipulate reading after "set" command by fhem #################################################START####
  153. sub GasCalculator_Get($@)
  154. {
  155. my ( $hash, @a ) = @_;
  156. ### If not enough arguments have been provided
  157. if ( @a < 2 )
  158. {
  159. return "\"get GasCalculator\" needs at least one argument";
  160. }
  161. my $GasCalcName = shift @a;
  162. my $reading = shift @a;
  163. my $value;
  164. my $ReturnMessage;
  165. if(!defined($GasCalculator_gets{$reading}))
  166. {
  167. my @cList = keys %GasCalculator_sets;
  168. return "Unknown argument $reading, choose one of " . join(" ", @cList);
  169. ### Create Log entries for debugging
  170. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - get list: " . join(" ", @cList);
  171. }
  172. if ( $reading ne "?")
  173. {
  174. ### Create Log entries for debugging
  175. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - get " . $reading . " with value: " . $value;
  176. ### Write current value
  177. $value = ReadingsVal($GasCalcName, $reading, undef);
  178. ### Create ReturnMessage
  179. $ReturnMessage = $value;
  180. }
  181. return($ReturnMessage);
  182. }
  183. ####END####### Manipulate reading after "set" command by fhem ##################################################END#####
  184. ###START###### Manipulate reading after "set" command by fhem #################################################START####
  185. sub GasCalculator_Set($@)
  186. {
  187. my ( $hash, @a ) = @_;
  188. ### If not enough arguments have been provided
  189. if ( @a < 2 )
  190. {
  191. return "\"set GasCalculator\" needs at least one argument";
  192. }
  193. my $GasCalcName = shift @a;
  194. my $reading = shift @a;
  195. my $value = join(" ", @a);
  196. my $ReturnMessage;
  197. if(!defined($GasCalculator_sets{$reading}))
  198. {
  199. my @cList = keys %GasCalculator_sets;
  200. return "Unknown argument $reading, choose one of " . join(" ", @cList);
  201. ### Create Log entries for debugging
  202. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - set list: " . join(" ", @cList);
  203. }
  204. if ( $reading ne "?")
  205. {
  206. ### Create Log entries for debugging
  207. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - set " . $reading . " with value: " . $value;
  208. ### Write current value
  209. readingsSingleUpdate($hash, $reading, $value, 1);
  210. ### Create ReturnMessage
  211. $ReturnMessage = $GasCalcName . " - Successfully set " . $reading . " with value: " . $value;
  212. }
  213. return($ReturnMessage);
  214. }
  215. ####END####### Manipulate reading after "set" command by fhem ##################################################END#####
  216. ###START###### Calculate gas meter values on changed events ###################################################START####
  217. sub GasCalculator_Notify($$)
  218. {
  219. ### Define variables
  220. my ($GasCalcDev, $GasCountDev) = @_;
  221. my $GasCalcName = $GasCalcDev->{NAME};
  222. my $GasCountName = $GasCountDev->{NAME};
  223. my $GasCountNameEvents = deviceEvents($GasCountDev, 1);
  224. my $NumberOfChangedEvents = int(@{$GasCountNameEvents});
  225. my $RegEx = $GasCalcDev->{REGEXP};
  226. ### Check whether the gas calculator has been disabled
  227. if(IsDisabled($GasCalcName))
  228. {
  229. return "";
  230. }
  231. ### Check whether all required attributes has been provided and if not, create them with standard values
  232. if(!defined($attr{$GasCalcName}{BasicPricePerAnnum}))
  233. {
  234. ### Set attribute with standard value since it is not available
  235. $attr{$GasCalcName}{BasicPricePerAnnum} = 0;
  236. ### Writing log entry
  237. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute BasicPricePerAnnum was missing and has been set to 0";
  238. }
  239. if(!defined($attr{$GasCalcName}{GasCounterOffset}))
  240. {
  241. ### Set attribute with standard value since it is not available
  242. $attr{$GasCalcName}{GasCounterOffset} = 0;
  243. ### Writing log entry
  244. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute GasCounterOffset was missing and has been set to 0";
  245. }
  246. if(!defined($attr{$GasCalcName}{GasCubicPerCounts}))
  247. {
  248. ### Set attribute with standard value since it is not available
  249. $attr{$GasCalcName}{GasCubicPerCounts} = 0.01;
  250. ### Writing log entry
  251. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute GasCubicPerCounts was missing and has been set to 0.01 counts/voulume-unit";
  252. }
  253. if(!defined($attr{$GasCalcName}{GasNominalHeatingValue}))
  254. {
  255. ### Set attribute with standard value since it is not available
  256. $attr{$GasCalcName}{GasNominalHeatingValue} = 10;
  257. ### Writing log entry
  258. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute GasNominalHeatingValue was missing and has been set to 10 kWh/volume-unit";
  259. }
  260. if(!defined($attr{$GasCalcName}{GasPricePerKWh}))
  261. {
  262. ### Set attribute with standard value since it is not available
  263. $attr{$GasCalcName}{GasPricePerKWh} = 0.0654;
  264. ### Writing log entry
  265. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute GasPricePerKWh was missing and has been set to 0.0654 currency-unit/volume-unit";
  266. }
  267. if(!defined($attr{$GasCalcName}{GaszValue}))
  268. {
  269. ### Set attribute with standard value since it is not available
  270. $attr{$GasCalcName}{GaszValue} = 1;
  271. ### Writing log entry
  272. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute GaszValue was missing and has been set to 1";
  273. }
  274. if(!defined($attr{$GasCalcName}{MonthlyPayment}))
  275. {
  276. ### Set attribute with standard value since it is not available
  277. $attr{$GasCalcName}{MonthlyPayment} = 0;
  278. ### Writing log entry
  279. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute MonthlyPayment was missing and has been set to 0 currency-units";
  280. }
  281. if(!defined($attr{$GasCalcName}{MonthOfAnnualReading}))
  282. {
  283. ### Set attribute with standard value since it is not available
  284. $attr{$GasCalcName}{MonthOfAnnualReading} = 5;
  285. ### Writing log entry
  286. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute MonthOfAnnualReading was missing and has been set to 5 which is the month May";
  287. }
  288. if(!defined($attr{$GasCalcName}{Currency}))
  289. {
  290. ### Set attribute with standard value since it is not available
  291. $attr{$GasCalcName}{Currency} = "&#8364;";
  292. ### Writing log entry
  293. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute Currency was missing and has been set to &#8364;";
  294. }
  295. if(!defined($attr{$GasCalcName}{SiPrefixPower}))
  296. {
  297. ### Set attribute with standard value since it is not available
  298. $attr{$GasCalcName}{SiPrefixPower} = "W";
  299. $GasCalcDev->{system}{SiPrefixPowerFactor} = 1;
  300. ### Writing log entry
  301. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute SiPrefixPower was missing and has been set to W";
  302. }
  303. if(!defined($attr{$GasCalcName}{Volume}))
  304. {
  305. ### Set attribute with standard value since it is not available
  306. $attr{$GasCalcName}{Volume} = "m&#179;";
  307. ### Writing log entry
  308. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute Volume was missing and has been set to m&#179;";
  309. }
  310. if(!defined($attr{$GasCalcName}{ReadingDestination}))
  311. {
  312. ### Set attribute with standard value since it is not available
  313. $attr{$GasCalcName}{ReadingDestination} = "CalculatorDevice";
  314. ### Writing log entry
  315. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute ReadingDestination was missing and has been set to CalculatorDevice";
  316. }
  317. if(!defined($attr{$GasCalcName}{room}))
  318. {
  319. if(defined($attr{$GasCountName}{room}))
  320. {
  321. ### Set attribute with standard value since it is not available
  322. $attr{$GasCalcName}{room} = $attr{$GasCountName}{room};
  323. ### Writing log entry
  324. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute room was missing and has been set to the same room of the Gas Counter: " . $attr{$GasCountName}{room};
  325. }
  326. else
  327. {
  328. ### Set attribute with standard value since it is not available
  329. $attr{$GasCalcName}{room} = "Central Heating";
  330. ### Writing log entry
  331. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - The attribute room was missing and has been set to Central Heating";
  332. }
  333. }
  334. ### For each feedback on in the array of defined regexpression which has been changed
  335. for (my $i = 0; $i < $NumberOfChangedEvents; $i++)
  336. {
  337. ### Extract event
  338. my $s = $GasCountNameEvents->[$i];
  339. ### Filtering all events which do not match the defined regex
  340. if(!defined($s))
  341. {
  342. next;
  343. }
  344. my ($GasCountReadingName, $GasCountReadingValueCurrent) = split(": ", $s, 2); # resets $1
  345. if("$GasCountName:$s" !~ m/^$RegEx$/)
  346. {
  347. next;
  348. }
  349. ### Extracting value
  350. if(defined($1))
  351. {
  352. my $RegExArg = $1;
  353. if(defined($2))
  354. {
  355. $GasCountReadingName = $1;
  356. $RegExArg = $2;
  357. }
  358. $GasCountReadingValueCurrent = $RegExArg if(defined($RegExArg) && $RegExArg =~ m/^(-?\d+\.?\d*)/);
  359. }
  360. if(!defined($GasCountReadingValueCurrent) || $GasCountReadingValueCurrent !~ m/^(-?\d+\.?\d*)/)
  361. {
  362. next;
  363. }
  364. ###Get current Counter and transform in Volume (cubic) as read on mechanic gas meter
  365. $GasCountReadingValueCurrent = $1 * $attr{$GasCalcName}{GasCubicPerCounts} + $attr{$GasCalcName}{GasCounterOffset};
  366. my $GasCountReadingTimestampCurrent = ReadingsTimestamp($GasCountName,$GasCountReadingName,0);
  367. ### Create Log entries for debugging
  368. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator Begin_______________________________________________________________________________________________________________________________";
  369. ### Create name and destination device for general reading prefix
  370. my $GasCalcReadingPrefix;
  371. my $GasCalcReadingDestinationDevice;
  372. my $GasCalcReadingDestinationDeviceName;
  373. if ($attr{$GasCalcName}{ReadingDestination} eq "CalculatorDevice")
  374. {
  375. $GasCalcReadingPrefix = ($GasCountName . "_" . $GasCountReadingName);
  376. $GasCalcReadingDestinationDevice = $GasCalcDev;
  377. $GasCalcReadingDestinationDeviceName = $GasCalcName;
  378. ### Create Log entries for debugging
  379. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Attribut ReadingDestination has been set to CalculatorDevice";
  380. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcReadingPrefix : " . $GasCalcReadingPrefix;
  381. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcReadingDestinationDevice : " . $GasCalcReadingDestinationDevice;
  382. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcReadingDestinationDeviceName : " . $GasCalcReadingDestinationDeviceName;
  383. }
  384. elsif ($attr{$GasCalcName}{ReadingDestination} eq "CounterDevice")
  385. {
  386. $GasCalcReadingPrefix = $GasCountReadingName;
  387. $GasCalcReadingDestinationDevice = $GasCountDev;
  388. $GasCalcReadingDestinationDeviceName = $GasCountName;
  389. ### Create Log entries for debugging
  390. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Attribut ReadingDestination has been set to CounterDevice";
  391. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcReadingPrefix : " . $GasCalcReadingPrefix;
  392. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcReadingDestinationDevice : " . $GasCalcReadingDestinationDevice;
  393. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcReadingDestinationDeviceName : " . $GasCalcReadingDestinationDeviceName;
  394. }
  395. else
  396. {
  397. ### Create Log entries for debugging
  398. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Attribut ReadingDestination has not been set up correctly. Skipping event.";
  399. ### Skipping event
  400. next;
  401. }
  402. ### Restore previous Counter and if not available define it with "undef"
  403. my $GasCountReadingTimestampPrevious = ReadingsTimestamp($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_PrevRead", undef);
  404. my $GasCountReadingValuePrevious = ReadingsVal($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_PrevRead", undef);
  405. ### Create Log entries for debugging
  406. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCountReadingValuePrevious : " . $GasCountReadingValuePrevious;
  407. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcReadingPrefix_PrevRead : " . $GasCalcReadingPrefix . "_PrevRead";
  408. ### Find out whether there has been a previous value being stored
  409. if(defined($GasCountReadingValuePrevious))
  410. {
  411. ### Write current Volume as previous Voulume for future use in the GasCalc-Device
  412. readingsSingleUpdate( $GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix. "_PrevRead", sprintf('%.3f', ($GasCountReadingValueCurrent)),1);
  413. ### Create Log entries for debugging
  414. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Previous value found. Continuing with calculations";
  415. }
  416. ### If not: save value and quit loop
  417. else
  418. {
  419. ### Write current Volume as previous Voulume for future use in the GasCalc-Device
  420. readingsSingleUpdate( $GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix. "_PrevRead", sprintf('%.3f', ($GasCountReadingValueCurrent)),1);
  421. ### Create Log entries for debugging
  422. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Previous value NOT found. Skipping Loop";
  423. ### Jump out of loop since there is nothing to do anymore than to wait for the next value
  424. next;
  425. }
  426. ###### Find out whether the device has been freshly defined and certain readings have never been set up yet or certain readings have been deleted
  427. ### Find out whether the reading for the daily start value has not been written yet
  428. if(!defined(ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stDay", undef)))
  429. {
  430. ### Save current Volume as first reading of day = first after midnight and reset min, max value, value counter and value sum
  431. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stDay", $GasCountReadingValueCurrent, 1);
  432. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastDay", $GasCountReadingValuePrevious, 1);
  433. readingsSingleUpdate( $GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix . "_PowerDaySum", 0, 1);
  434. readingsSingleUpdate( $GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix . "_PowerDayCount", 0, 1);
  435. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayMin", 0, 1);
  436. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayMax", 0, 1);
  437. ### Create Log entries for debugging
  438. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Reading for the first daily value was not available and therfore reading and statistics have been written";
  439. }
  440. ### Find out whether the reading for the monthly start value has not been written yet
  441. if(!defined(ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stMonth", undef)))
  442. {
  443. ### Save current Volume as first reading of month
  444. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMonth", $GasCountReadingValueCurrent, 1);
  445. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastMonth", $GasCountReadingValuePrevious, 1);
  446. ### Create Log entries for debugging
  447. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Reading for the first monthly value was not available and therfore reading has been written";
  448. }
  449. ### Find out whether the reading for the meter reading year value has not been written yet
  450. if(!defined(ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stMeter", undef)))
  451. {
  452. ### Save current Volume as first reading of month where gas-meter is read
  453. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMeter", $GasCountReadingValueCurrent, 1);
  454. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastMeter", $GasCountReadingValuePrevious, 1);
  455. ### Create Log entries for debugging
  456. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Reading for the first value of gas meter year was not available and therfore reading has been written";
  457. }
  458. ### Find out whether the reading for the yearly value has not been written yet
  459. if(!defined(ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stYear", undef)))
  460. {
  461. ### Save current Volume as first reading of the calendar year
  462. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stYear", $GasCountReadingValueCurrent, 1);
  463. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastYear", $GasCountReadingValuePrevious, 1);
  464. ### Create Log entries for debugging
  465. Log3 $GasCalcName, 3, $GasCalcName. " : GasCalculator - Reading for the first yearly value was not available and therfore reading has been written";
  466. }
  467. ### Extracting year, month and day as numbers
  468. my $GasCountReadingTimestampPreviousRelative = time_str2num($GasCountReadingTimestampPrevious);
  469. my($GasCountReadingTimestampPreviousSec,$GasCountReadingTimestampPreviousMin,$GasCountReadingTimestampPreviousHour,$GasCountReadingTimestampPreviousMday,$GasCountReadingTimestampPreviousMon,$GasCountReadingTimestampPreviousYear,$GasCountReadingTimestampPreviousWday,$GasCountReadingTimestampPreviousYday,$GasCountReadingTimestampPreviousIsdst) = localtime($GasCountReadingTimestampPreviousRelative);
  470. my $GasCountReadingTimestampCurrentRelative = time_str2num($GasCountReadingTimestampCurrent);
  471. my($GasCountReadingTimestampCurrentSec,$GasCountReadingTimestampCurrentMin,$GasCountReadingTimestampCurrentHour,$GasCountReadingTimestampCurrentMday,$GasCountReadingTimestampCurrentMon,$GasCountReadingTimestampCurrentYear,$GasCountReadingTimestampCurrentWday,$GasCountReadingTimestampCurrentYday,$GasCountReadingTimestampCurrentIsdst) = localtime($GasCountReadingTimestampCurrentRelative);
  472. ### Correct current month by one month since Unix/Linux start January with 0 instead of 1
  473. $GasCountReadingTimestampCurrentMon = $GasCountReadingTimestampCurrentMon + 1;
  474. ### Create Log entries for debugging
  475. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Reading Name : " . $GasCountReadingName;
  476. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Previous Reading Value : " . $GasCountReadingTimestampPrevious;
  477. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Current Reading Value : " . $GasCountReadingTimestampCurrent;
  478. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Previous Reading Value : " . $GasCountReadingValuePrevious;
  479. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Current Reading Value : " . $GasCountReadingValueCurrent;
  480. ####### Check whether Initial readings needs to be written
  481. ### Check whether the current value is the first one after change of day = First one after midnight
  482. if ($GasCountReadingTimestampCurrentHour < $GasCountReadingTimestampPreviousHour)
  483. {
  484. ### Create Log entries for debugging
  485. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of day detected";
  486. ### Calculate gas energy of previous day € = (Vprevious[cubic] - V1stDay[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic]
  487. my $GasCalcEnergyDayLast = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stDay", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue};
  488. ### Calculate pure gas cost of previous day GasCalcEnergyLastDay * Price per kWh
  489. my $GasCalcEnergyCostDayLast = $GasCalcEnergyDayLast * $attr{$GasCalcName}{GasPricePerKWh};
  490. ### Reload last Power Value
  491. my $GasCalcPowerCurrent = ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_PowerCurrent", "0");
  492. ### Save gas pure cost of previous day, current gas Energy as first reading of day = first after midnight and reset min, max value, value counter and value sum
  493. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostDayLast", (sprintf('%.3f', ($GasCalcEnergyCostDayLast ))), 1);
  494. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyDayLast", (sprintf('%.3f', ($GasCalcEnergyDayLast ))), 1);
  495. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stDay", $GasCountReadingValueCurrent , 1);
  496. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastDay", $GasCountReadingValuePrevious , 1);
  497. readingsSingleUpdate( $GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix . "_PowerDaySum", 0 , 1);
  498. readingsSingleUpdate( $GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix . "_PowerDayCount", 0 , 1);
  499. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayMin", (sprintf('%.3f', ($GasCalcPowerCurrent ))), 1);
  500. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayMax", 0 , 1);
  501. ### Check whether the current value is the first one after change of month
  502. if ($GasCountReadingTimestampCurrentMday < $GasCountReadingTimestampPreviousMday)
  503. {
  504. ### Create Log entries for debugging
  505. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of month detected";
  506. ### Calculate gas energy of previous month € = (Vprevious[cubic] - V1stReadMonth[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic]
  507. my $GasCalcEnergyMonthLast = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stMonth", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue};
  508. ### Calculate pure gas cost of previous month GasCalcEnergyLastMonth * Price per kWh
  509. my $GasCalcEnergyCostMonthLast = $GasCalcEnergyMonthLast * $attr{$GasCalcName}{GasPricePerKWh};
  510. ### Save gas energy and pure cost of previous and current month
  511. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostMonthLast", (sprintf('%.3f', ($GasCalcEnergyCostMonthLast ))), 1);
  512. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyMonthLast", (sprintf('%.3f', ($GasCalcEnergyMonthLast ))), 1);
  513. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMonth", (sprintf('%.3f', ($GasCountReadingValueCurrent ))), 1);
  514. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastMonth", (sprintf('%.3f', ($GasCountReadingValuePrevious ))), 1);
  515. ### Check whether the current value is the first one of the meter-reading month
  516. if ($GasCountReadingTimestampCurrentMon eq $attr{$GasCalcName}{MonthOfAnnualReading})
  517. {
  518. ### Create Log entries for debugging
  519. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of month for meter reading detected";
  520. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Current month is : " . $GasCountReadingTimestampCurrentMon;
  521. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Attribute MonthOfAnnualReading is : " . $attr{$GasCalcName}{MonthOfAnnualReading};
  522. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Vol1stMeter is : " . $GasCountReadingValueCurrent;
  523. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - VolLastMeter is : " . $GasCountReadingValuePrevious;
  524. ### Calculate gas energy of previous meter reading year € = (Vprevious[cubic] - V1stMeter[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic]
  525. my $GasCalcEnergyMeterLast = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stMeter", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue};
  526. ### Calculate pure gas cost of previous meter reading year € = GasCalcEnergyLastMeter * Price per kWh
  527. my $GasCalcEnergyCostMeterLast = $GasCalcEnergyMeterLast * $attr{$GasCalcName}{GasPricePerKWh};
  528. ### Save gas energy and pure cost of previous and current meter year
  529. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostMeterLast", (sprintf('%.3f', ($GasCalcEnergyCostMeterLast ))), 1);
  530. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyMeterLast", (sprintf('%.3f', ($GasCalcEnergyMeterLast ))), 1);
  531. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stMeter", (sprintf('%.3f', ($GasCountReadingValueCurrent ))), 1);
  532. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastMeter", (sprintf('%.3f', ($GasCountReadingValuePrevious ))), 1);
  533. }
  534. ### Check whether the current value is the first one of the calendar year
  535. if ($GasCountReadingTimestampCurrentYear > $GasCountReadingTimestampPreviousYear)
  536. {
  537. ### Create Log entries for debugging
  538. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - First reading of calendar year detected";
  539. ### Calculate gas energy of previous calendar year € = (Vcurrent[cubic] - V1stYear[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic]
  540. my $GasCalcEnergyYearLast = ($GasCountReadingValuePrevious - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stYear", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue};
  541. ### Calculate pure gas cost of previous calendar year € = GasCalcEnergyLastYear * Price per kWh
  542. my $GasCalcEnergyCostYearLast = $GasCalcEnergyYearLast * $attr{$GasCalcName}{GasPricePerKWh};
  543. ### Save gas energy and pure cost of previous and current calendar year
  544. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostYearLast", (sprintf('%.3f', ($GasCalcEnergyCostYearLast ))), 1);
  545. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyYearLast", (sprintf('%.3f', ($GasCalcEnergyYearLast ))), 1);
  546. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Vol1stYear", (sprintf('%.3f', ($GasCountReadingValueCurrent ))), 1);
  547. readingsSingleUpdate( $GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_VolLastYear", (sprintf('%.3f', ($GasCountReadingValuePrevious ))), 1);
  548. }
  549. }
  550. }
  551. ###### Do calculations
  552. ### Calculate DtCurrent (time difference) of previous and current timestamp / [s]
  553. my $GasCountReadingTimestampDelta = $GasCountReadingTimestampCurrentRelative - $GasCountReadingTimestampPreviousRelative;
  554. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCountReadingTimestampDelta : " . $GasCountReadingTimestampDelta . " s";
  555. ### Continue with calculations only if time difference is not 0 to avoid "Illegal division by zero"
  556. if ($GasCountReadingTimestampDelta != 0)
  557. {
  558. ### Calculate DV (Volume difference) of previous and current value / [cubic]
  559. my $GasCountReadingValueDelta = sprintf('%.3f', ($GasCountReadingValueCurrent - $GasCountReadingValuePrevious));
  560. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCountReadingValueDelta : " . $GasCountReadingValueDelta . " " . $attr{$GasCalcName}{Volume};
  561. ### Calculate Current Power P = DV/Dt[cubic/s] * GaszValue * GasNominalHeatingValue[kWh/cubic] * 3600[s/h] / SiPrefixPowerFactor
  562. my $GasCalcPowerCurrent = ($GasCountReadingValueDelta / $GasCountReadingTimestampDelta) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue} * 3600 / $GasCalcDev->{system}{SiPrefixPowerFactor};
  563. ### Calculate daily sum of power measurements "SP" and measurement counts "n" and then calculate average Power "Paverage = SP/n"
  564. my $GasCalcPowerDaySum = ReadingsVal($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_PowerDaySum", "0") + $GasCalcPowerCurrent;
  565. my $GasCalcPowerDayCount = ReadingsVal($GasCalcReadingDestinationDeviceName, "." . $GasCalcReadingPrefix . "_PowerDayCount", "0") + 1;
  566. my $GasCalcPowerDayAverage = $GasCalcPowerDaySum / $GasCalcPowerDayCount;
  567. ### Calculate consumed Energy of current day W = (Vcurrent[cubic] - V1stReadDay[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic]
  568. my $GasCalcEnergyDay = ($GasCountReadingValueCurrent - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stDay", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue};
  569. ### Calculate consumed Energy of current month W = (Vcurrent[cubic] - V1stReadMonth[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic]
  570. my $GasCalcEnergyMonth = ($GasCountReadingValueCurrent - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stMonth", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue};
  571. ### Calculate consumed Energy of current year W = (Vcurrent[cubic] - V1stReadYear[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic]
  572. my $GasCalcEnergyYear = ($GasCountReadingValueCurrent - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stYear", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue};
  573. ### Calculate consumed Energy of gas-meter year W = (Vcurrent[cubic] - V1stReadMeter[cubic]) * GaszValue * GasNominalHeatingValue[kWh/cubic]
  574. my $GasCalcEnergyMeter = ($GasCountReadingValueCurrent - ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_Vol1stMeter", "0")) * $attr{$GasCalcName}{GaszValue} * $attr{$GasCalcName}{GasNominalHeatingValue};
  575. ### Calculate pure Electricity cost since midnight
  576. my $GasCalcEnergyCostDay = $GasCalcEnergyDay * $attr{$GasCalcName}{GasPricePerKWh};
  577. ### Calculate pure gas cost since first day of month
  578. my $GasCalcEnergyCostMonth = $GasCalcEnergyMonth * $attr{$GasCalcName}{GasPricePerKWh};
  579. ### Calculate pure gas cost since first day of calendar year
  580. my $GasCalcEnergyCostYear = $GasCalcEnergyYear * $attr{$GasCalcName}{GasPricePerKWh};
  581. ### Calculate pure gas cost since first day of gas meter reading year
  582. my $GasCalcEnergyCostMeter = $GasCalcEnergyMeter * $attr{$GasCalcName}{GasPricePerKWh};
  583. ### Calculate the payment month since the year of gas meter reading started
  584. my $GasCalcMeterYearMonth=0;
  585. if (($GasCountReadingTimestampCurrentMon - $attr{$GasCalcName}{MonthOfAnnualReading} + 1) < 1)
  586. {
  587. $GasCalcMeterYearMonth = 13 + $GasCountReadingTimestampCurrentMon - $attr{$GasCalcName}{MonthOfAnnualReading};
  588. }
  589. else
  590. {
  591. $GasCalcMeterYearMonth = 1 + $GasCountReadingTimestampCurrentMon - $attr{$GasCalcName}{MonthOfAnnualReading};
  592. }
  593. ### Calculate reserves at gas provider based on monthly advance payments within year of gas meter reading
  594. my $GasCalcReserves = ($GasCalcMeterYearMonth * $attr{$GasCalcName}{MonthlyPayment}) - ($attr{$GasCalcName}{BasicPricePerAnnum} / 12 * $GasCalcMeterYearMonth) - $GasCalcEnergyCostMeter;
  595. ### Create Log entries for debugging
  596. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - _______Finance________________________________________";
  597. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Monthly Payment : " . $attr{$GasCalcName}{MonthlyPayment} . " " . $attr{$GasCalcName}{Currency};
  598. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Basic price per annum : " . $attr{$GasCalcName}{BasicPricePerAnnum} . " " . $attr{$GasCalcName}{Currency};
  599. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcEnergyCostMeter : " . sprintf('%.3f', ($GasCalcEnergyCostMeter)) . " " . $attr{$GasCalcName}{Currency};
  600. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcReserves : " . sprintf('%.3f', ($GasCalcReserves)) . " " . $attr{$GasCalcName}{Currency};
  601. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - _______Times__________________________________________";
  602. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcMeterYearMonth : " . $GasCalcMeterYearMonth;
  603. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - Current Month : " . $GasCountReadingTimestampCurrentMon;
  604. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - _______Energy_________________________________________";
  605. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcEnergyDay : " . sprintf('%.3f', ($GasCalcEnergyDay)) . " kWh";
  606. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcEnergyMonth : " . sprintf('%.3f', ($GasCalcEnergyMonth)) . " kWh";
  607. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcEnergyYear : " . sprintf('%.3f', ($GasCalcEnergyYear)) . " kWh";
  608. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcEnergyMeter : " . sprintf('%.3f', ($GasCalcEnergyMeter)) . " kWh";
  609. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - _______Power___________________________________________";
  610. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcPowerCurrent : " . sprintf('%.3f', ($GasCalcPowerCurrent)) . " kW";
  611. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcPowerDayMin : " . ReadingsVal( $GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_PowerDayMin", 0) . " kW";
  612. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcPowerDayAverage : " . sprintf('%.3f', ($GasCalcPowerDayAverage)) . " kW";
  613. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCalcPowerDayMax : " . ReadingsVal( $GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_PowerDayMax", 0) . " kW";
  614. ###### Write readings to GasCalc device
  615. ### Initialize Bulkupdate
  616. readingsBeginUpdate($GasCalcReadingDestinationDevice);
  617. ### Write current mechanic meter reading
  618. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_Meter", sprintf('%.3f', ($GasCountReadingValueCurrent)));
  619. ### Write consumed volume (DV) since last measurement
  620. readingsBulkUpdate($GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix . "_LastDV", sprintf('%.3f', ($GasCountReadingValueDelta)));
  621. ### Write timelap (Dt) since last measurement
  622. readingsBulkUpdate($GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix . "_LastDt", sprintf('%.0f', ($GasCountReadingTimestampDelta)));
  623. ### Write current Power = average Power over last measurement period
  624. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerCurrent", sprintf('%.3f', ($GasCalcPowerCurrent)));
  625. ### Write daily Power = average Power since midnight
  626. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayAver", sprintf('%.3f', ($GasCalcPowerDayAverage)));
  627. ### Write Power measurement sum since midnight for average calculation
  628. readingsBulkUpdate($GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix . "_PowerDaySum", sprintf('%.3f', ($GasCalcPowerDaySum)));
  629. ### Write Power measurement counts since midnight for average calculation
  630. readingsBulkUpdate($GasCalcReadingDestinationDevice, "." . $GasCalcReadingPrefix . "_PowerDayCount", sprintf('%.0f', ($GasCalcPowerDayCount)));
  631. ### Detect new daily minimum power value and write to reading
  632. if (ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_PowerDayMin", 0) > $GasCalcPowerCurrent)
  633. {
  634. ### Write new minimum Power value
  635. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayMin", sprintf('%.0f', ($GasCalcPowerCurrent)));
  636. ### Create Log entries for debugging
  637. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - New daily minimum power value detected : " . sprintf('%.3f', ($GasCalcPowerCurrent));
  638. }
  639. ### Detect new daily maximum power value and write to reading
  640. if (ReadingsVal($GasCalcReadingDestinationDeviceName, $GasCalcReadingPrefix . "_PowerDayMax", 0) < $GasCalcPowerCurrent)
  641. {
  642. ### Write new maximum Power value
  643. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_PowerDayMax", sprintf('%.3f', ($GasCalcPowerCurrent)));
  644. ### Create Log entries for debugging
  645. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - New daily maximum power value detected : " . sprintf('%.3f', ($GasCalcPowerCurrent));
  646. }
  647. ### Write energy consumption since midnight
  648. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyDay", sprintf('%.3f', ($GasCalcEnergyDay)));
  649. ### Write energy consumption since beginning of month
  650. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyMonth", sprintf('%.3f', ($GasCalcEnergyMonth)));
  651. ### Write energy consumption since beginning of year
  652. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyYear", sprintf('%.3f', ($GasCalcEnergyYear)));
  653. ### Write energy consumption since last meter reading
  654. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyMeter", sprintf('%.3f', ($GasCalcEnergyMeter)));
  655. ### Write pure energy costs since midnight
  656. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostDay", sprintf('%.3f', ($GasCalcEnergyCostDay)));
  657. ### Write pure energy costs since beginning of month
  658. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostMonth", sprintf('%.3f', ($GasCalcEnergyCostMonth)));
  659. ### Write pure energy costs since beginning of calendar year
  660. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostYear", sprintf('%.3f', ($GasCalcEnergyCostYear)));
  661. ### Write pure energy costs since beginning of year of gas meter reading
  662. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_EnergyCostMeter", sprintf('%.3f', ($GasCalcEnergyCostMeter)));
  663. ### Write reserves at gas provider based on monthly advance payments within year of gas meter reading
  664. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_FinanceReserve", sprintf('%.3f', ($GasCalcReserves)));
  665. ### Write months since last meter reading
  666. readingsBulkUpdate($GasCalcReadingDestinationDevice, $GasCalcReadingPrefix . "_MonthMeterReading", sprintf('%.0f', ($GasCalcMeterYearMonth)));
  667. ### Finish and execute Bulkupdate
  668. readingsEndUpdate($GasCalcReadingDestinationDevice, 1);
  669. }
  670. else
  671. {
  672. ### Create Log entries for debugging
  673. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - GasCountReadingTimestampDelta = $GasCountReadingTimestampDelta. Calculations skipped!";
  674. }
  675. ### Create Log entries for debugging
  676. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator End_________________________________________________________________________________________________________________________________";
  677. }
  678. ### If readings exist, update list of available readings
  679. if($GasCalcDev->{READINGS})
  680. {
  681. ### Copy readings in list of available "gets" and "sets"
  682. %GasCalculator_gets = %{$GasCalcDev->{READINGS}};
  683. %GasCalculator_sets = %{$GasCalcDev->{READINGS}};
  684. ### Create Log entries for debugging
  685. Log3 $GasCalcName, 5, $GasCalcName. " : GasCalculator - notify x_sets list: " . join(" ", (keys %GasCalculator_sets));
  686. }
  687. return undef;
  688. }
  689. ####END####### Calculate gas meter values on changed events ####################################################END#####
  690. 1;
  691. ###START###### Description for fhem commandref ################################################################START####
  692. =pod
  693. =item helper
  694. =item summary Calculates the gas energy consumption and costs
  695. =item summary_DE Berechnet den Gas-Energieverbrauch und verbundene Kosten
  696. =begin html
  697. <a name="GasCalculator"></a>
  698. <h3>GasCalculator</h3>
  699. <ul>
  700. <table>
  701. <tr>
  702. <td>
  703. The GasCalculator Module calculates the gas consumption and costs of one ore more gas counters.<BR>
  704. It is not a counter module itself but requires a regular expression (regex or regexp) in order to know where retrieve the counting ticks of one or more mechanical gas counter.<BR>
  705. <BR>
  706. As soon the module has been defined within the fhem.cfg, the module reacts on every event of the specified counter like myOWDEVICE:counter.* etc.<BR>
  707. <BR>
  708. The GasCalculator module provides several current, historical, statistical predictable values around with respect to one or more gas-counter and creates respective readings.<BR>
  709. <BR>
  710. To avoid waiting for max. 12 months to have realistic values, the readings <code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stDay</code>, <code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stMonth</code>, <code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stYear</code> and <code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stMeter</code> must be corrected with real values by using the <code>setreading</code> - command.
  711. These real values may be found on the last gas bill. Otherwise it will take 24h for the daily, 30days for the monthly and up to 12 month for the yearly values to become realistic.<BR>
  712. <BR>
  713. </td>
  714. </tr>
  715. </table>
  716. <table><tr><td><a name="GasCalculatorDefine"></a><b>Define</b></td></tr></table>
  717. <table><tr><td><ul><code>define &lt;name&gt; GasCalculator &lt;regex&gt;</code></ul></td></tr></table>
  718. <ul><ul>
  719. <table>
  720. <tr><td><code>&lt;name&gt;</code> : </td><td>The name of the calculation device. Recommendation: "myGasCalculator".</td></tr>
  721. <tr><td><code>&lt;regex&gt;</code> : </td><td>A valid regular expression (also known as regex or regexp) of the event where the counter can be found</td></tr>
  722. </table>
  723. </ul></ul>
  724. <table><tr><td><ul>Example: <code>define myGasCalculator GasCalculator myGasCounter:countersA.*</code></ul></td></tr></table>
  725. <BR>
  726. <table>
  727. <tr><td><a name="GasCalculatorSet"></a><b>Set</b></td></tr>
  728. <tr><td>
  729. <ul>
  730. The set - function sets individual values for example to correct values after power loss etc.<BR>
  731. The set - function works only for readings which have been stored in the CalculatorDevice.<BR>
  732. The Readings being stored in the Counter - Device need to be changed individially with the <code>set</code> - command.<BR>
  733. </ul>
  734. </td></tr>
  735. </table>
  736. <BR>
  737. <table>
  738. <tr><td><a name="GasCalculatorGet"></a><b>Get</b></td></tr>
  739. <tr><td>
  740. <ul>
  741. The get - function just returns the individual value of the reading.<BR>
  742. The get - function works only for readings which have been stored in the CalculatorDevice.<BR>
  743. The Readings being stored in the Counter - Device need to be read individially with <code>get</code> - command.<BR>
  744. </ul>
  745. </td></tr>
  746. </table>
  747. <BR>
  748. <table>
  749. <tr><td><a name="GasCalculatorAttr"></a><b>Attributes</b></td></tr>
  750. <tr><td>
  751. <ul>
  752. If the below mentioned attributes have not been pre-defined completly beforehand, the program will create the GasCalculator specific attributes with default values.<BR>
  753. In addition the global attributes e.g. <a href="#room">room</a> can be used.<BR>
  754. </ul>
  755. </td></tr>
  756. </table>
  757. <ul><ul>
  758. <table>
  759. <tr>
  760. <td>
  761. <tr><td><li><code>BasicPricePerAnnum</code> : </li></td><td> A valid float number for basic annual fee in the chosen currency for the gas supply to the home.<BR>
  762. The value is provided by your local gas provider is shown on your gas bill.<BR>
  763. For UK users it may known under "Standing Charge". Please make sure it is based on one year<BR>
  764. The default value is 0.00<BR>
  765. </td></tr>
  766. </td>
  767. </tr>
  768. </table>
  769. </ul></ul>
  770. <ul><ul>
  771. <table>
  772. <tr>
  773. <td>
  774. <tr><td><li><code>Currency</code> : </li></td><td> One of the pre-defined list of currency symbols [&#8364;,&#163;,&#36;].<BR>
  775. The default value is &#8364;<BR>
  776. </td></tr>
  777. </td>
  778. </tr>
  779. </table>
  780. </ul></ul>
  781. <ul><ul>
  782. <table>
  783. <tr>
  784. <td>
  785. <tr><td><li><code>disable</code> : </li></td><td> Disables the current module. The module will not react on any events described in the regular expression.<BR>
  786. The default value is 0 = enabled.<BR>
  787. </td></tr>
  788. </td>
  789. </tr>
  790. </table>
  791. </ul></ul>
  792. <ul><ul>
  793. <table>
  794. <tr>
  795. <td>
  796. <tr><td><li><code>GasCounterOffset</code> : </li></td><td> A valid float number of the volume difference = offset (not the difference of the counter ticks!) between the value shown on the mechanic meter for the gas volume and the calculated volume of this device.<BR>
  797. The value for this offset will be calculated as follows V<sub>Offset</sub> = V<sub>Mechanical</sub> - V<sub>Module</sub><BR>
  798. The default value is 0.00<BR>
  799. </td></tr>
  800. </td>
  801. </tr>
  802. </table>
  803. </ul></ul>
  804. <ul><ul>
  805. <table>
  806. <tr>
  807. <td>
  808. <tr><td><li><code>GasCubicPerCounts</code> : </li></td><td> A valid float number of the ammount of volume per ticks.<BR>
  809. The value is given by the mechanical trigger of the mechanical gas meter. E.g. GasCubicPerCounts = 0.01 means each count is a hundredth of the volume basis unit.<BR>
  810. The default value is 0.01<BR>
  811. </td></tr>
  812. </td>
  813. </tr>
  814. </table>
  815. </ul></ul>
  816. <ul><ul>
  817. <table>
  818. <tr>
  819. <td>
  820. <tr><td><li><code>GasNominalHeatingValue</code> : </li></td><td> A valid float number for the gas heating value in [kWh/ chosen Volume].<BR>
  821. The value is provided by your local gas provider is shown on your gas bill.<BR>
  822. The default value is 10.00<BR>
  823. </td></tr>
  824. </td>
  825. </tr>
  826. </table>
  827. </ul></ul>
  828. <ul><ul>
  829. <table>
  830. <tr>
  831. <td>
  832. <tr><td><li><code>GaszValue</code> : </li></td><td> A valid float number for the gas condition based on the local installation of the mechanical gas meter in relation of the gas providers main supply station.<BR>
  833. The value is provided by your local gas provider is shown on your gas bill.<BR>
  834. The default value is 1.00<BR>
  835. </td></tr>
  836. </td>
  837. </tr>
  838. </table>
  839. </ul></ul>
  840. <ul><ul>
  841. <table>
  842. <tr>
  843. <td>
  844. <tr><td><li><code>GasPricePerKWh</code> : </li></td><td> A valid float number for gas price in the chosen currency per kWh for the gas.<BR>
  845. The value is provided by your local gas provider is shown on your gas bill.<BR>
  846. The default value is 0.0654<BR>
  847. </td></tr>
  848. </td>
  849. </tr>
  850. </table>
  851. </ul></ul>
  852. <ul><ul>
  853. <table>
  854. <tr>
  855. <td>
  856. <tr><td><li><code>MonthlyPayment</code> : </li></td><td> A valid float number for monthly advance payments in the chosen currency towards the gas supplier.<BR>
  857. The default value is 0.00<BR>
  858. </td></tr>
  859. </td>
  860. </tr>
  861. </table>
  862. </ul></ul>
  863. <ul><ul>
  864. <table>
  865. <tr>
  866. <td>
  867. <tr><td><li><code>MonthOfAnnualReading</code> : </li></td><td> A valid integer number for the month when the mechanical gas meter reading is performed every year.<BR>
  868. The default value is 5 (May)<BR>
  869. </td></tr>
  870. </td>
  871. </tr>
  872. </table>
  873. </ul></ul>
  874. <ul><ul>
  875. <table>
  876. <tr>
  877. <td>
  878. <tr><td><li><code>ReadingDestination</code> : </li></td><td> One of the pre-defined list for the destination of the calculated readings: [CalculatorDevice,CounterDevice].<BR>
  879. The CalculatorDevice is the device which has been created with this module.<BR>
  880. The CounterDevice is the Device which is reading the mechanical gas-meter.<BR>
  881. The default value is CalculatorDevice - Therefore the readings will be written into this device.<BR>
  882. </td></tr>
  883. </td>
  884. </tr>
  885. </table>
  886. </ul></ul>
  887. <ul><ul>
  888. <table>
  889. <tr>
  890. <td>
  891. <tr><td><li><code>Volume</code> : </li></td><td> One of the pre-defined list of volume symbols [m&#179;,ft&#179;].<BR>
  892. The default value is m&#179;<BR>
  893. </td></tr>
  894. </td>
  895. </tr>
  896. </table>
  897. </ul></ul>
  898. <BR>
  899. <table>
  900. <tr><td><a name="GasCalculatorReadings"></a><b>Readings</b></td></tr>
  901. <tr><td>
  902. <ul>
  903. As soon the device has been able to read at least 2 times the counter, it automatically will create a set readings:<BR>
  904. The placeholder <code>&lt;DestinationDevice&gt;</code> is the device which has been chosen in the attribute <code>ReadingDestination</code> above. This will not appear if CalculatorDevice has been chosen.<BR>
  905. The placeholder <code>&lt;SourceCounterReading&gt;</code> is the reading based on the defined regular expression.<BR>
  906. </ul>
  907. </td></tr>
  908. </table>
  909. <ul><ul>
  910. <table>
  911. <tr>
  912. <td>
  913. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostDayLast</code> : </li></td><td>Energy costs of the last day.<BR>
  914. </td></tr>
  915. </td>
  916. </tr>
  917. </table>
  918. </ul></ul>
  919. <ul><ul>
  920. <table>
  921. <tr>
  922. <td>
  923. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostMeter</code> : </li></td><td> Energy costs in the chosen currency since the beginning of the month of where the last gas-meter reading has been performed by the gas supplier.<BR>
  924. </td></tr>
  925. </td>
  926. </tr>
  927. </table>
  928. </ul></ul>
  929. <ul><ul>
  930. <table>
  931. <tr>
  932. <td>
  933. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostMeterLast</code> : </li></td><td> Energy costs in the chosen currency of the last gas-meter period.<BR>
  934. </td></tr>
  935. </td>
  936. </tr>
  937. </table>
  938. </ul></ul>
  939. <ul><ul>
  940. <table>
  941. <tr>
  942. <td>
  943. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostMonth</code> : </li></td><td>Energy costs in the chosen currency since the beginning of the current month.<BR>
  944. </td></tr>
  945. </td>
  946. </tr>
  947. </table>
  948. </ul></ul>
  949. <ul><ul>
  950. <table>
  951. <tr>
  952. <td>
  953. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostMonthLast</code> : </li></td><td>Energy costs in the chosen currency of the last month.<BR>
  954. </td></tr>
  955. </td>
  956. </tr>
  957. </table>
  958. </ul></ul>
  959. <ul><ul>
  960. <table>
  961. <tr>
  962. <td>
  963. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostYear</code> : </li></td><td>Energy costs in the chosen currency since the beginning of the current year.<BR>
  964. </td></tr>
  965. </td>
  966. </tr>
  967. </table>
  968. </ul></ul>
  969. <ul><ul>
  970. <table>
  971. <tr>
  972. <td>
  973. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostYearLast</code> : </li></td><td>Energy costs of the last calendar year.<BR>
  974. </td></tr>
  975. </td>
  976. </tr>
  977. </table>
  978. </ul></ul>
  979. <ul><ul>
  980. <table>
  981. <tr>
  982. <td>
  983. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyDay</code> : </li></td><td>Energy consumption in kWh since the beginning of the current day (midnight).<BR>
  984. </td></tr>
  985. </td>
  986. </tr>
  987. </table>
  988. </ul></ul>
  989. <ul><ul>
  990. <table>
  991. <tr>
  992. <td>
  993. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyDayLast</code> : </li></td><td>Total Energy consumption in kWh of the last day.<BR>
  994. </td></tr>
  995. </td>
  996. </tr>
  997. </table>
  998. </ul></ul>
  999. <ul><ul>
  1000. <table>
  1001. <tr>
  1002. <td>
  1003. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyMeter</code> : </li></td><td>Energy consumption in kWh since the beginning of the month of where the last gas-meter reading has been performed by the gas supplier.<BR>
  1004. </td></tr>
  1005. </td>
  1006. </tr>
  1007. </table>
  1008. </ul></ul>
  1009. <ul><ul>
  1010. <table>
  1011. <tr>
  1012. <td>
  1013. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyMeterLast</code> : </li></td><td>Total Energy consumption in kWh of the last gas-meter reading period.<BR>
  1014. </td></tr>
  1015. </td>
  1016. </tr>
  1017. </table>
  1018. </ul></ul>
  1019. <ul><ul>
  1020. <table>
  1021. <tr>
  1022. <td>
  1023. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyMonth</code> : </li></td><td>Energy consumption in kWh since the beginning of the current month (midnight of the first).<BR>
  1024. </td></tr>
  1025. </td>
  1026. </tr>
  1027. </table>
  1028. </ul></ul>
  1029. <ul><ul>
  1030. <table>
  1031. <tr>
  1032. <td>
  1033. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyMonthLast</code> : </li></td><td>Total Energy consumption in kWh of the last month.<BR>
  1034. </td></tr>
  1035. </td>
  1036. </tr>
  1037. </table>
  1038. </ul></ul>
  1039. <ul><ul>
  1040. <table>
  1041. <tr>
  1042. <td>
  1043. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyYear</code> : </li></td><td>Energy consumption in kWh since the beginning of the current year (midnight of the first).<BR>
  1044. </td></tr>
  1045. </td>
  1046. </tr>
  1047. </table>
  1048. </ul></ul>
  1049. <ul><ul>
  1050. <table>
  1051. <tr>
  1052. <td>
  1053. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyYearLast</code> : </li></td><td>Total Energy consumption in kWh of the last calendar year.<BR>
  1054. </td></tr>
  1055. </td>
  1056. </tr>
  1057. </table>
  1058. </ul></ul>
  1059. <ul><ul>
  1060. <table>
  1061. <tr>
  1062. <td>
  1063. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_FinanceReserve</code> : </li></td><td>Financial Reserver based on the advanced payments done on the first of every month towards the gas supplier. With negative values, an additional payment is to be excpected.<BR>
  1064. </td></tr>
  1065. </td>
  1066. </tr>
  1067. </table>
  1068. </ul></ul>
  1069. <ul><ul>
  1070. <table>
  1071. <tr>
  1072. <td>
  1073. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_MonthMeterReading</code> : </li></td><td>Number of month since last meter reading. The month when the reading occured is the first month = 1.<BR>
  1074. </td></tr>
  1075. </td>
  1076. </tr>
  1077. </table>
  1078. </ul></ul>
  1079. <ul><ul>
  1080. <table>
  1081. <tr>
  1082. <td>
  1083. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Meter</code> : </li></td><td>Current indicated total volume consumption on mechanical gas meter. Correct Offset-attribute if not identical.<BR>
  1084. </td></tr>
  1085. </td>
  1086. </tr>
  1087. </table>
  1088. </ul></ul>
  1089. <ul><ul>
  1090. <table>
  1091. <tr>
  1092. <td>
  1093. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_PowerCurrent</code> : </li></td><td>Current heating Power. (Average between current and previous measurement.)<BR>
  1094. </td></tr>
  1095. </td>
  1096. </tr>
  1097. </table>
  1098. </ul></ul>
  1099. <ul><ul>
  1100. <table>
  1101. <tr>
  1102. <td>
  1103. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_PowerDayAver</code> : </li></td><td>Average heating Power since midnight.<BR>
  1104. </td></tr>
  1105. </td>
  1106. </tr>
  1107. </table>
  1108. </ul></ul>
  1109. <ul><ul>
  1110. <table>
  1111. <tr>
  1112. <td>
  1113. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_PowerDayMax</code> : </li></td><td>Maximum power peak since midnight.<BR>
  1114. </td></tr>
  1115. </td>
  1116. </tr>
  1117. </table>
  1118. </ul></ul>
  1119. <ul><ul>
  1120. <table>
  1121. <tr>
  1122. <td>
  1123. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_PowerDayMin</code> : </li></td><td>Minimum power peak since midnight.<BR>
  1124. </td></tr>
  1125. </td>
  1126. </tr>
  1127. </table>
  1128. </ul></ul>
  1129. <ul><ul>
  1130. <table>
  1131. <tr>
  1132. <td>
  1133. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stDay</code> : </li></td><td>First volume reading of the current day.<BR>
  1134. </td></tr>
  1135. </td>
  1136. </tr>
  1137. </table>
  1138. </ul></ul>
  1139. <ul><ul>
  1140. <table>
  1141. <tr>
  1142. <td>
  1143. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_VolLastDay</code> : </li></td><td>Volume reading of the previous day.<BR>
  1144. </td></tr>
  1145. </td>
  1146. </tr>
  1147. </table>
  1148. </ul></ul>
  1149. <ul><ul>
  1150. <table>
  1151. <tr>
  1152. <td>
  1153. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stMonth</code> : </li></td><td>First volume reading of the current month.<BR>
  1154. </td></tr>
  1155. </td>
  1156. </tr>
  1157. </table>
  1158. </ul></ul>
  1159. <ul><ul>
  1160. <table>
  1161. <tr>
  1162. <td>
  1163. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_VolLastMonth</code> : </li></td><td>Volume reading of the previous month.<BR>
  1164. </td></tr>
  1165. </td>
  1166. </tr>
  1167. </table>
  1168. </ul></ul>
  1169. <ul><ul>
  1170. <table>
  1171. <tr>
  1172. <td>
  1173. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stYear</code> : </li></td><td>First volume reading of the current year.<BR>
  1174. </td></tr>
  1175. </td>
  1176. </tr>
  1177. </table>
  1178. </ul></ul>
  1179. <ul><ul>
  1180. <table>
  1181. <tr>
  1182. <td>
  1183. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_VolLastYear</code> : </li></td><td>Volume reading of the previous year.<BR>
  1184. </td></tr>
  1185. </td>
  1186. </tr>
  1187. </table>
  1188. </ul></ul>
  1189. <ul><ul>
  1190. <table>
  1191. <tr>
  1192. <td>
  1193. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stMeter</code> : </li></td><td>First volume reading of the first day of the month of the current meter reading period.<BR>
  1194. </td></tr>
  1195. </td>
  1196. </tr>
  1197. </table>
  1198. </ul></ul>
  1199. <ul><ul>
  1200. <table>
  1201. <tr>
  1202. <td>
  1203. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_VolLastMeter</code> : </li></td><td>Volume reading of the first day of the month of the last meter reading period.<BR>
  1204. </td></tr>
  1205. </td>
  1206. </tr>
  1207. </table>
  1208. </ul></ul>
  1209. </ul>
  1210. =end html
  1211. =begin html_DE
  1212. <a name="GasCalculator"></a>
  1213. <h3>GasCalculator</h3>
  1214. <ul>
  1215. <table>
  1216. <tr>
  1217. <td>
  1218. Das GasCalculator Modul berechnet den Gas - Verbrauch und den verbundenen Kosten von einem oder mehreren Gas-Z&auml;hlern.<BR>
  1219. Es ist kein eigenes Z&auml;hlermodul sondern ben&ouml;tigt eine Regular Expression (regex or regexp) um das Reading mit den Z&auml;hl-Impulse von einem oder mehreren Gasz&auml;hlern zu finden.<BR>
  1220. <BR>
  1221. Sobald das Modul in der fhem.cfg definiert wurde, reagiert das Modul auf jedes durch das regex definierte event wie beispielsweise ein myOWDEVICE:counter.* etc.<BR>
  1222. <BR>
  1223. Das GasCalculator Modul berechnet augenblickliche, historische statistische und vorhersehbare Werte von einem oder mehreren Gas-Z&auml;hlern und erstellt die entsprechenden Readings.<BR>
  1224. <BR>
  1225. Um zu verhindern, dass man bis zu 12 Monate warten muss, bis alle Werte der Realit&auml;t entsprechen, m&uuml;ssen die Readings <code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stDay</code>, <code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stMonth</code>, <code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stYear</code> und <code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stMeter</code> entsprechend mit dem <code>setreading</code> - Befehl korrigiert werden.
  1226. Diese Werte findet man unter Umst&auml;nden auf der letzten Gas-Rechnung. Andernfalls dauert es bis zu 24h f&uuml;r die t&auml;glichen, 30 Tage f&uuml;r die monatlichen und bis zu 12 Monate f&uuml;r die j&auml;hrlichen Werte bis diese der Realit&auml;t entsprechen.<BR>
  1227. <BR>
  1228. </td>
  1229. </tr>
  1230. </table>
  1231. <table>
  1232. <tr><td><a name="GasCalculatorDefine"></a><b>Define</b></td></tr>
  1233. </table>
  1234. <table><tr><td><ul><code>define &lt;name&gt; GasCalculator &lt;regex&gt;</code></ul></td></tr></table>
  1235. <ul><ul>
  1236. <table>
  1237. <tr><td><code>&lt;name&gt;</code> : </td><td>Der Name dieses Berechnungs-Device. Empfehlung: "myGasCalculator".</td></tr>
  1238. <tr><td><code>&lt;regex&gt;</code> : </td><td>Eine g&uuml;ltige Regular Expression (regex or regexp) von dem Event wo der Z&auml;hlerstand gefunden werden kann</td></tr>
  1239. </table>
  1240. </ul></ul>
  1241. <table><tr><td><ul>Beispiel: <code>define myGasCalculator GasCalculator myGasCounter:countersA.*</code></ul></td></tr></table>
  1242. <BR>
  1243. <table>
  1244. <tr><td><a name="GasCalculatorSet"></a><b>Set</b></td></tr>
  1245. <tr><td>
  1246. <ul>
  1247. Die set - Funktion erlaubt individuelle Readings zu ver&auml;ndern um beispielsweise nach einem Stromausfall Werte zu korrigieren.<BR>
  1248. Die set - Funktion funktioniert nur f&uumlr Readings welche im CalculatorDevice gespeichert wurden.<BR>
  1249. Die Readings welche im Counter - Device gespeichert wurden, m&uumlssen individuell mit <code>set</code> - Befehl gesetzt werden.<BR>
  1250. </ul>
  1251. </td></tr>
  1252. </table>
  1253. <BR>
  1254. <table>
  1255. <tr><td><a name="GasCalculatorGet"></a><b>Get</b></td></tr>
  1256. <tr><td>
  1257. <ul>
  1258. Die get - Funktion liefert nur den Wert des jeweiligen Readings zur&uuml;ck.<BR>
  1259. Die get - Funktion funktioniert nur f&uumlr Readings welche im CalculatorDevice gespeichert wurden.<BR>
  1260. Die Readings welche im Counter - Device gespeichert wurden, m&uumlssen individuell mit <code>get</code> - Befehl ausgelesen werden.<BR>
  1261. </ul>
  1262. </td></tr>
  1263. </table>
  1264. <BR>
  1265. <table>
  1266. <tr><td><a name="GasCalculatorAttr"></a><b>Attributes</b></td></tr>
  1267. <tr><td>
  1268. <ul>
  1269. Sollten die unten ausfeg&auuml;hrten Attribute bei der Definition eines entsprechenden Ger&auml;tes nicht gesetzt sein, so werden sie vom Modul mit Standard Werten automatisch gesetzt<BR>
  1270. Zus&auml;tzlich k&ouml;nnen die globalen Attribute wie <a href="#room">room</a> verwendet werden.<BR>
  1271. </ul>
  1272. </td></tr>
  1273. </table>
  1274. <ul><ul>
  1275. <table>
  1276. <tr>
  1277. <td>
  1278. <tr><td><li><code>BasicPricePerAnnum</code> : </li></td><td> Eine g&uuml;ltige float Zahl f&uuml;r die j&auml;hrliche Grundgeb&uuml;hr in der gew&auml;hlten W&auml;hrung f&uuml;r die Gas-Versorgung zum End-Verbraucher.<BR>
  1279. Dieser Wert stammt vom Gas-Zulieferer und steht auf der Gas-Rechnung.<BR>
  1280. Der Standard Wert ist 0.00<BR>
  1281. </td></tr>
  1282. </td>
  1283. </tr>
  1284. </table>
  1285. </ul></ul>
  1286. <ul><ul>
  1287. <table>
  1288. <tr>
  1289. <td>
  1290. <tr><td><li><code>Currency</code> : </li></td><td> Eines der vordefinerten W&auml;hrungssymbole: [&#8364;,&#163;,&#36;].<BR>
  1291. Der Standard Wert ist &#8364;<BR>
  1292. </td></tr>
  1293. </td>
  1294. </tr>
  1295. </table>
  1296. </ul></ul>
  1297. <ul><ul>
  1298. <table>
  1299. <tr>
  1300. <td>
  1301. <tr><td><li><code>disable</code> : </li></td><td> Deaktiviert das devive. Das Modul wird nicht mehr auf die Events reagieren die durch die Regular Expression definiert wurde.<BR>
  1302. Der Standard Wert ist 0 = ativiert.<BR>
  1303. </td></tr>
  1304. </td>
  1305. </tr>
  1306. </table>
  1307. </ul></ul>
  1308. <ul><ul>
  1309. <table>
  1310. <tr>
  1311. <td>
  1312. <tr><td><li><code>GasCounterOffset</code> : </li></td><td> Eine g&uuml;ltige float-Zahl f&uuml;r den Volumen Unterschied = Offset (Nicht der Unterschied zwischen Z&auml;hlimpulsen) zwischen dem am mechanischen Gasz&auml;hler und dem angezeigten Wert im Reading dieses Device.<BR>
  1313. Der Offset-Wert wird wie folgt ermittelt: V<sub>Offset</sub> = V<sub>Mechanisch</sub> - V<sub>Module</sub><BR>
  1314. Der Standard-Wert ist 0.00<BR>
  1315. </td></tr>
  1316. </td>
  1317. </tr>
  1318. </table>
  1319. </ul></ul>
  1320. <ul><ul>
  1321. <table>
  1322. <tr>
  1323. <td>
  1324. <tr><td><li><code>GasCubicPerCounts</code> : </li></td><td> Eine g&uuml;ltige float-Zahl f&uuml;r die Menge an Z&auml;hlimpulsen pro gew&auml;hlter Volumen-Grundeinheit.<BR>
  1325. Der Wert ist durch das mechanische Z&auml;hlwerk des Gasz&auml;hlers vorgegeben. GasCubicPerCounts = 0.01 bedeutet, dass jeder Z&auml;hlimpuls ein hunderstel der gew&auml;hlten Volumengrundeinheit.<BR>
  1326. Der Standard-Wert ist 0.01<BR>
  1327. </td></tr>
  1328. </td>
  1329. </tr>
  1330. </table>
  1331. </ul></ul>
  1332. <ul><ul>
  1333. <table>
  1334. <tr>
  1335. <td>
  1336. <tr><td><li><code>GasNominalHeatingValue</code> : </li></td><td> Eine g&uuml;ltige float-Zahl f&uuml;r den Heizwert des gelieferten Gases in [kWh/ gew&auml;hlter Volumeneinheit].<BR>
  1337. Dieser Wert stammt vom Gas-Zulieferer und steht auf der Gas-Rechnung.<BR>
  1338. Der Standard-Wert ist 10.00<BR>
  1339. </td></tr>
  1340. </td>
  1341. </tr>
  1342. </table>
  1343. </ul></ul>
  1344. <ul><ul>
  1345. <table>
  1346. <tr>
  1347. <td>
  1348. <tr><td><li><code>GaszValue</code> : </li></td><td> Eine g&uuml;ltige float-Zahl f&uuml;r die Zustandszahl des Gases basierend auf der Relation based on the local installation of the mechganical gas meter in relation of the gas providers main supply station.<BR>
  1349. Dieser Wert stammt vom Gas-Zulieferer und steht auf der Gas-Rechnung.<BR>
  1350. Der Standard-Wert ist 1.00<BR>
  1351. </td></tr>
  1352. </td>
  1353. </tr>
  1354. </table>
  1355. </ul></ul>
  1356. <ul><ul>
  1357. <table>
  1358. <tr>
  1359. <td>
  1360. <tr><td><li><code>GasPricePerKWh</code> : </li></td><td> Eine g&uuml;ltige float-Zahl f&uuml;r den Gas Preis in der gew&auml;hlten W&auml;hrung pro kWh.<BR>
  1361. Dieser Wert stammt vom Gas-Zulieferer und steht auf der Gas-Rechnung.<BR>
  1362. Der Standard-Wert ist 0.0654<BR>
  1363. </td></tr>
  1364. </td>
  1365. </tr>
  1366. </table>
  1367. </ul></ul>
  1368. <ul><ul>
  1369. <table>
  1370. <tr>
  1371. <td>
  1372. <tr><td><li><code>MonthlyPayment</code> : </li></td><td> Eine g&uuml;ltige float-Zahl f&uuml;r die monatlichen Abschlagszahlungen in der gew&auml;hlten W&auml;hrung an den Gas-Lieferanten.<BR>
  1373. Der Standard-Wert ist 0.00<BR>
  1374. </td></tr>
  1375. </td>
  1376. </tr>
  1377. </table>
  1378. </ul></ul>
  1379. <ul><ul>
  1380. <table>
  1381. <tr>
  1382. <td>
  1383. <tr><td><li><code>MonthOfAnnualReading</code> : </li></td><td> Eine g&uuml;ltige Ganz-Zahl f&uuml;r den Monat wenn der mechanische Gas-Z&auml;hler jedes Jahr durch den Gas-Lieferanten abgelesen wird.<BR>
  1384. Der Standard-Wert ist 5 (Mai)<BR>
  1385. </td></tr>
  1386. </td>
  1387. </tr>
  1388. </table>
  1389. </ul></ul>
  1390. <ul><ul>
  1391. <table>
  1392. <tr>
  1393. <td>
  1394. <tr><td><li><code>ReadingDestination</code> : </li></td><td> Eines der vordefinerten Device als Ziel der errechneten Readings: [CalculatorDevice,CounterDevice].<BR>
  1395. Das CalculatorDevice ist das mit diesem Modul erstellte Device.<BR>
  1396. Das CounterDevice ist das Device von welchem der mechanische Z&auml;hler ausgelesen wird.<BR>
  1397. Der Standard-Wert ist CalculatorDevice.<BR>
  1398. </td></tr>
  1399. </td>
  1400. </tr>
  1401. </table>
  1402. </ul></ul>
  1403. <ul><ul>
  1404. <table>
  1405. <tr>
  1406. <td>
  1407. <tr><td><li><code>Volume</code> : </li></td><td> Eine der vordefinierten Volumensymbole f&uuml;r die Volumeneinheit [m&#179;,ft&#179;].<BR>
  1408. Der Standard-Wert ist m&#179;<BR>
  1409. </td></tr>
  1410. </td>
  1411. </tr>
  1412. </table>
  1413. </ul></ul>
  1414. <BR>
  1415. <table>
  1416. <tr><td><a name="GasCalculatorReadings"></a><b>Readings</b></td></tr>
  1417. <tr><td>
  1418. <ul>
  1419. Sobald das Device in der Lage war mindestens 2 Werte des Z&auml;hlers einzulesen, werden automatisch die entsprechenden Readings erzeugt:<BR>
  1420. Der Platzhalter <code>&lt;DestinationDevice&gt;</code> steht f&uuml;r das Device, welches man in dem Attribut <code>ReadingDestination</code> oben festgelegt hat. Dieser Platzhalter bleibt leer, sobald man dort CalculatorDevice ausgew&auml;hlt hat.<BR>
  1421. Der Platzhalter <code>&lt;SourceCounterReading&gt;</code> steht f&uuml;r das Reading welches mit der Regular Expression definiert wurde.<BR>
  1422. </ul>
  1423. </td></tr>
  1424. </table>
  1425. <ul><ul>
  1426. <table>
  1427. <tr>
  1428. <td>
  1429. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostLastDay</code> : </li></td><td>Energiekosten in der gew&auml;hlten W&auml;hrung des letzten Tages.<BR>
  1430. </td></tr>
  1431. </td>
  1432. </tr>
  1433. </table>
  1434. </ul></ul>
  1435. <ul><ul>
  1436. <table>
  1437. <tr>
  1438. <td>
  1439. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostMeter</code> : </li></td><td>Energiekosten in der gew&auml;hlten W&auml;hrung seit Anfang des Monats wo der Gas-Versorger den Z&auml;hler abliest.<BR>
  1440. </td></tr>
  1441. </td>
  1442. </tr>
  1443. </table>
  1444. </ul></ul>
  1445. <ul><ul>
  1446. <table>
  1447. <tr>
  1448. <td>
  1449. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostMeterLast</code> : </li></td><td>Energiekosten in der gew&auml;hlten W&auml;hrung der letzten Z&auml;hlperiode des Gas-Versorgers.<BR>
  1450. </td></tr>
  1451. </td>
  1452. </tr>
  1453. </table>
  1454. </ul></ul>
  1455. <ul><ul>
  1456. <table>
  1457. <tr>
  1458. <td>
  1459. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostMonth</code> : </li></td><td>Energiekosten in der gew&auml;hlten W&auml;hrung seit Anfang des Monats.<BR>
  1460. </td></tr>
  1461. </td>
  1462. </tr>
  1463. </table>
  1464. </ul></ul>
  1465. <ul><ul>
  1466. <table>
  1467. <tr>
  1468. <td>
  1469. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostMonthLast</code> : </li></td><td>Energiekosten in der gew&auml;hlten W&auml;hrung des letzten Monats.<BR>
  1470. </td></tr>
  1471. </td>
  1472. </tr>
  1473. </table>
  1474. </ul></ul>
  1475. <ul><ul>
  1476. <table>
  1477. <tr>
  1478. <td>
  1479. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostYear</code> : </li></td><td>Energiekosten in der gew&auml;hlten W&auml;hrung seit Anfang des Jahres.<BR>
  1480. </td></tr>
  1481. </td>
  1482. </tr>
  1483. </table>
  1484. </ul></ul>
  1485. <ul><ul>
  1486. <table>
  1487. <tr>
  1488. <td>
  1489. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyCostYearLast</code> : </li></td><td>Energiekosten in der gew&auml;hlten W&auml;hrung des letzten Jahres.<BR>
  1490. </td></tr>
  1491. </td>
  1492. </tr>
  1493. </table>
  1494. </ul></ul>
  1495. <ul><ul>
  1496. <table>
  1497. <tr>
  1498. <td>
  1499. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyDay</code> : </li></td><td>Energieverbrauch in kWh seit Mitternacht.<BR>
  1500. </td></tr>
  1501. </td>
  1502. </tr>
  1503. </table>
  1504. </ul></ul>
  1505. <ul><ul>
  1506. <table>
  1507. <tr>
  1508. <td>
  1509. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyDayLast</code> : </li></td><td>Gesamter Energieverbrauch des letzten Tages (Gestern).<BR>
  1510. </td></tr>
  1511. </td>
  1512. </tr>
  1513. </table>
  1514. </ul></ul>
  1515. <ul><ul>
  1516. <table>
  1517. <tr>
  1518. <td>
  1519. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyMeter</code> : </li></td><td>Energieverbrauch in kWh seit Anfang seit Anfang des Monats wo der Gas-Versorger den Z&auml;hler abliest.<BR>
  1520. </td></tr>
  1521. </td>
  1522. </tr>
  1523. </table>
  1524. </ul></ul>
  1525. <ul><ul>
  1526. <table>
  1527. <tr>
  1528. <td>
  1529. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyMeterLast</code> : </li></td><td>Gesamter Energieverbrauch der letzten Z&auml;hlerperiode des Gas-Versorgers.<BR>
  1530. </td></tr>
  1531. </td>
  1532. </tr>
  1533. </table>
  1534. </ul></ul>
  1535. <ul><ul>
  1536. <table>
  1537. <tr>
  1538. <td>
  1539. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyMonth</code> : </li></td><td>Energieverbrauch in kWh seit Anfang seit Anfang des Monats (Mitternacht des 01.).<BR>
  1540. </td></tr>
  1541. </td>
  1542. </tr>
  1543. </table>
  1544. </ul></ul>
  1545. <ul><ul>
  1546. <table>
  1547. <tr>
  1548. <td>
  1549. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyMonthLast</code> : </li></td><td>Gesamter Energieverbrauch im letzten Monat.<BR>
  1550. </td></tr>
  1551. </td>
  1552. </tr>
  1553. </table>
  1554. </ul></ul>
  1555. <ul><ul>
  1556. <table>
  1557. <tr>
  1558. <td>
  1559. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyYear</code> : </li></td><td>Energieverbrauch in kWh seit Anfang seit Anfang des Jahres (Mitternacht des 01. Januar).<BR>
  1560. </td></tr>
  1561. </td>
  1562. </tr>
  1563. </table>
  1564. </ul></ul>
  1565. <ul><ul>
  1566. <table>
  1567. <tr>
  1568. <td>
  1569. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_EnergyYearLast</code> : </li></td><td>Gesamter Energieverbrauch in kWh des letzten Kalender-Jahres.<BR>
  1570. </td></tr>
  1571. </td>
  1572. </tr>
  1573. </table>
  1574. </ul></ul>
  1575. <ul><ul>
  1576. <table>
  1577. <tr>
  1578. <td>
  1579. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_FinanceReserve</code> : </li></td><td>Finanzielle Reserve basierend auf den Abschlagszahlungen die jeden Monat an den Gas-Versorger gezahlt werden. Bei negativen Werten ist von einer Nachzahlung auszugehen.<BR>
  1580. </td></tr>
  1581. </td>
  1582. </tr>
  1583. </table>
  1584. </ul></ul>
  1585. <ul><ul>
  1586. <table>
  1587. <tr>
  1588. <td>
  1589. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_MonthMeterReading</code> : </li></td><td>Anzahl der Monate seit der letzten Zählerablesung. Der Monat der Zählerablesung ist der erste Monat = 1.<BR>
  1590. </td></tr>
  1591. </td>
  1592. </tr>
  1593. </table>
  1594. </ul></ul>
  1595. <ul><ul>
  1596. <table>
  1597. <tr>
  1598. <td>
  1599. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Meter</code> : </li></td><td>Z&auml;hlerstand am Gasz&auml;hler. Bei Differenzen muss das Offset-Attribut korrigiert werden.<BR>
  1600. </td></tr>
  1601. </td>
  1602. </tr>
  1603. </table>
  1604. </ul></ul>
  1605. <ul><ul>
  1606. <table>
  1607. <tr>
  1608. <td>
  1609. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_PowerCurrent</code> : </li></td><td>Aktuelle Heizleistung. (Mittelwert zwischen aktueller und letzter Messung)<BR>
  1610. </td></tr>
  1611. </td>
  1612. </tr>
  1613. </table>
  1614. </ul></ul>
  1615. <ul><ul>
  1616. <table>
  1617. <tr>
  1618. <td>
  1619. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_PowerDayAver</code> : </li></td><td>Mittlere Heitzleistung seit Mitternacht.<BR>
  1620. </td></tr>
  1621. </td>
  1622. </tr>
  1623. </table>
  1624. </ul></ul>
  1625. <ul><ul>
  1626. <table>
  1627. <tr>
  1628. <td>
  1629. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_PowerDayMax</code> : </li></td><td>Maximale Leistungsaufnahme seit Mitternacht.<BR>
  1630. </td></tr>
  1631. </td>
  1632. </tr>
  1633. </table>
  1634. </ul></ul>
  1635. <ul><ul>
  1636. <table>
  1637. <tr>
  1638. <td>
  1639. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_PowerDayMin</code> : </li></td><td>Minimale Leistungsaufnahme seit Mitternacht.<BR>
  1640. </td></tr>
  1641. </td>
  1642. </tr>
  1643. </table>
  1644. </ul></ul>
  1645. <ul><ul>
  1646. <table>
  1647. <tr>
  1648. <td>
  1649. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stDay</code> : </li></td><td>Erster Volumenmesswert des Tages (Mitternacht).<BR>
  1650. </td></tr>
  1651. </td>
  1652. </tr>
  1653. </table>
  1654. </ul></ul>
  1655. <ul><ul>
  1656. <table>
  1657. <tr>
  1658. <td>
  1659. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_VolLastDay</code> : </li></td><td>Verbrauchtes Volumen des vorherigen Tages.<BR>
  1660. </td></tr>
  1661. </td>
  1662. </tr>
  1663. </table>
  1664. </ul></ul>
  1665. <ul><ul>
  1666. <table>
  1667. <tr>
  1668. <td>
  1669. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stMonth</code> : </li></td><td>Erster Volumenmesswert des Monats (Mitternacht des 01.).<BR>
  1670. </td></tr>
  1671. </td>
  1672. </tr>
  1673. </table>
  1674. </ul></ul>
  1675. <ul><ul>
  1676. <table>
  1677. <tr>
  1678. <td>
  1679. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_VolLastMonth</code> : </li></td><td>Verbrauchtes Volumen des vorherigen Monats.<BR>
  1680. </td></tr>
  1681. </td>
  1682. </tr>
  1683. </table>
  1684. </ul></ul>
  1685. <ul><ul>
  1686. <table>
  1687. <tr>
  1688. <td>
  1689. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stYear</code> : </li></td><td>Erster Volumenmesswert des Jahres (Mitternacht des 01. Januar).<BR>
  1690. </td></tr>
  1691. </td>
  1692. </tr>
  1693. </table>
  1694. </ul></ul>
  1695. <ul><ul>
  1696. <table>
  1697. <tr>
  1698. <td>
  1699. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_VolLastYear</code> : </li></td><td>Verbrauchtes Volumen des vorherigen Jahres.<BR>
  1700. </td></tr>
  1701. </td>
  1702. </tr>
  1703. </table>
  1704. </ul></ul>
  1705. <ul><ul>
  1706. <table>
  1707. <tr>
  1708. <td>
  1709. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_Vol1stMeter</code> : </li></td><td>Erster Volumenmesswert des Zeitraums seit Anfang des Monats wo der Gas-Versorger den Z&auml;hler abliest.<BR>
  1710. </td></tr>
  1711. </td>
  1712. </tr>
  1713. </table>
  1714. </ul></ul>
  1715. <ul><ul>
  1716. <table>
  1717. <tr>
  1718. <td>
  1719. <tr><td><li><code>&lt;DestinationDevice&gt;_&lt;SourceCounterReading&gt;_VolLastMeter</code> : </li></td><td>Verbrauchtes Volumen des vorherigen Abrechnungszeitraums.<BR>
  1720. </td></tr>
  1721. </td>
  1722. </tr>
  1723. </table>
  1724. </ul></ul>
  1725. </ul>
  1726. =end html_DE
  1727. =cut