73_GasCalculator.pm 80 KB

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