ABFALL_setUpdate.pm 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. # $Id: ABFALL_setUpdate.pm 11021 2017-09-13 00:32:22Z uniqueck $
  2. # *** WARNING: DO NOT MODIFY *** This is a generated Perl source code!
  3. #
  4. # Generated by LF-ET 2.1.5 (170905a), http://www.lohrfink.de/lfet
  5. # From decision table
  6. # "/data/github/fhem/fhem-abfall/lfet/ABFALL_setUpdate.lfet"
  7. # 12.09.2017 22:09
  8. #
  9. # Changes to this code resulting from refactorings can be synchronised
  10. # with LF-ET using the function "Scrapbook Import".
  11. #
  12. # Prolog Decision Table ---->
  13. package main;
  14. use strict;
  15. use warnings;
  16. use POSIX;
  17. use Time::Local;
  18. use Time::Piece;
  19. use ABFALL_getEvents;
  20. sub ABFALL_setUpdate_Initialize($$)
  21. {
  22. my ($hash) = @_;
  23. }
  24. sub ABFALL_setUpdate($) {
  25. my ($hash) = @_;
  26. my $name = $hash->{NAME};
  27. Log3 $name, 4, "ABFALL_setUpdate($name) - Start";
  28. # step counter
  29. my $step = 1;
  30. # array counter
  31. my $eventIndex = 0;
  32. my $nowTextMoreThen1 = 0;
  33. my $nextTextMoreThen1 = 0;
  34. my $lastNow = ReadingsVal($name, "now", "");
  35. Log3 $name, 5, "ABFALL_setUpdate($name) - reading lastNow $lastNow";
  36. # array for events
  37. my @events = ();
  38. my $actualEvent = ();
  39. # readings
  40. my $nowAbfall_tage = -1;
  41. my $nowAbfall_text = "";
  42. my $nowAbfall_location = "";
  43. my $nowAbfall_description = "";
  44. my $nowAbfall_datum;
  45. my $nowAbfall_weekday;
  46. my $now_readingTermin = "";
  47. my $nextAbfall_tage = -1;
  48. my $nextAbfall_text = "";
  49. my $nextAbfall_location = "";
  50. my $nextAbfall_description = "";
  51. my $nextAbfall_datum;
  52. my $nextAbfall_weekday;
  53. my $next_readingTermin = "";
  54. # attribute values
  55. my $delimiter_text_reading = " " . AttrVal($name,"delimiter_text_reading","und") . " ";
  56. my $delimiter_reading = AttrVal($name,"delimiter_reading","|");
  57. while ($step != -1) {
  58. # Prolog Decision Table <----
  59. # Condition B01/01: step / 1 / cleanup step
  60. if (
  61. $step eq 1
  62. )
  63. {
  64. # Condition B02: counting pickups
  65. if (
  66. AttrVal($name, "enable_counting_pickups", "0")
  67. )
  68. {
  69. # Rule R01 ---->
  70. # Trace ---->
  71. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 1, 21";
  72. # Trace <----
  73. # Action A01: clean readings
  74. Log3 $name, 5, "ABFALL_GetUpdate ($name) - delete readings";
  75. fhem("deletereading $name next", 1);
  76. fhem("deletereading $name now", 1);
  77. fhem("deletereading $name .*_tage", 1);
  78. fhem("deletereading $name .*_days", 1);
  79. fhem("deletereading $name .*_wochentag", 1);
  80. fhem("deletereading $name .*_weekday", 1);
  81. fhem("deletereading $name .*_text", 1);
  82. fhem("deletereading $name .*_datum", 1);
  83. fhem("deletereading $name .*_date", 1);
  84. fhem("deletereading $name .*_location", 1);
  85. fhem("deletereading $name .*_description", 1);
  86. fhem("deletereading $name .*_uid", 1);
  87. fhem("deletereading $name state", 1);
  88. # Action A03: getEvents
  89. @events = ABFALL_getEvents($hash);
  90. # Action A17: readingsBeginUpdate
  91. readingsBeginUpdate($hash);
  92. # Action A19/02: step / 2 / event step
  93. $step = 2;
  94. # Rule R01 <----
  95. }
  96. else
  97. {
  98. # Rule R02 ---->
  99. # Trace ---->
  100. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 2, 21";
  101. # Trace <----
  102. # Action A01: clean readings
  103. Log3 $name, 5, "ABFALL_GetUpdate ($name) - delete readings";
  104. fhem("deletereading $name next", 1);
  105. fhem("deletereading $name now", 1);
  106. fhem("deletereading $name .*_tage", 1);
  107. fhem("deletereading $name .*_days", 1);
  108. fhem("deletereading $name .*_wochentag", 1);
  109. fhem("deletereading $name .*_weekday", 1);
  110. fhem("deletereading $name .*_text", 1);
  111. fhem("deletereading $name .*_datum", 1);
  112. fhem("deletereading $name .*_date", 1);
  113. fhem("deletereading $name .*_location", 1);
  114. fhem("deletereading $name .*_description", 1);
  115. fhem("deletereading $name .*_uid", 1);
  116. fhem("deletereading $name state", 1);
  117. # Action A02: clean pickup readings
  118. fhem("deletereading $name .*_pickups", 1);
  119. fhem("deletereading $name .*_pickups_used", 1);
  120. fhem("deletereading $name .*_abholungen", 1);
  121. fhem("deletereading $name .*_abholungen_genutzt", 1);
  122. # Action A03: getEvents
  123. @events = ABFALL_getEvents($hash);
  124. # Action A17: readingsBeginUpdate
  125. readingsBeginUpdate($hash);
  126. # Action A19/02: step / 2 / event step
  127. $step = 2;
  128. # Rule R02 <----
  129. }
  130. # Condition B01/02: step / 2 / next event step
  131. }
  132. elsif (
  133. $step eq 2
  134. )
  135. {
  136. # Condition B05: has events
  137. if (
  138. scalar(@events) > 0
  139. )
  140. {
  141. # Condition B06: has more events
  142. if (
  143. $eventIndex < scalar(@events)
  144. )
  145. {
  146. # Rule R03 ---->
  147. # Trace ---->
  148. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 3, 21";
  149. # Trace <----
  150. # Action A04: next event
  151. $actualEvent = $events[$eventIndex];
  152. $eventIndex++;
  153. # Action A19/03: step / 3 / event step
  154. $step = 3
  155. # Rule R03 <----
  156. }
  157. else
  158. {
  159. # Rule R04 ---->
  160. # Trace ---->
  161. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 4, 21";
  162. # Trace <----
  163. # Action A18: readingsEndUpdate
  164. readingsEndUpdate($hash,1); #end update
  165. # Action A19/01: step / E / end step
  166. $step = -1;
  167. # Rule R04 <----
  168. }
  169. }
  170. else
  171. {
  172. # Rule R05 ---->
  173. # Trace ---->
  174. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 5, 21";
  175. # Trace <----
  176. # Action A13: set state no pickups
  177. readingsBulkUpdate($hash, "state", "Keine Abholungen");
  178. # Action A18: readingsEndUpdate
  179. readingsEndUpdate($hash,1); #end update
  180. # Action A19/01: step / E / end step
  181. $step = -1;
  182. # Rule R05 <----
  183. }
  184. # Condition B01/03: step / 3 / event step
  185. }
  186. elsif (
  187. $step eq 3
  188. )
  189. {
  190. # Condition B07: event readingName is empty
  191. if (
  192. $actualEvent->{readingName} eq ""
  193. )
  194. {
  195. # Rule R06 ---->
  196. # Trace ---->
  197. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 6, 21";
  198. # Trace <----
  199. # Action A16: warn empty readingname
  200. Log3 $name, 2, "ABFALL_setUpdate($name) - readingName is empty for uid($actualEvent->{uid})";
  201. # Action A19/02: step / 2 / event step
  202. $step = 2;
  203. # Rule R06 <----
  204. }
  205. else
  206. {
  207. # Condition B08: event days equals 0
  208. if (
  209. $actualEvent->{days} eq 0
  210. )
  211. {
  212. # Rule R07 ---->
  213. # Trace ---->
  214. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 7, 21";
  215. # Trace <----
  216. # Action A05: append as now
  217. if($nowAbfall_text eq "") {
  218. $nowAbfall_text = $actualEvent->{summary};
  219. $nowTextMoreThen1 = 0;
  220. } else {
  221. if($nowTextMoreThen1 == 0){
  222. $nowAbfall_text .= $delimiter_text_reading . $actualEvent->{summary};
  223. $nowTextMoreThen1 = 1;
  224. } else{
  225. $nowAbfall_text = $actualEvent->{summary} . ", " . $nowAbfall_text;
  226. }
  227. }
  228. if($nowAbfall_location eq "") {
  229. $nowAbfall_location = $actualEvent->{location};
  230. } elsif ($nowAbfall_location ne $actualEvent->{location}) {
  231. # TODO change check to regex expression contains
  232. $nowAbfall_location .= $delimiter_text_reading . $actualEvent->{location};
  233. }
  234. # check if description reading is the same
  235. if($nowAbfall_description eq "") {
  236. $nowAbfall_description = $actualEvent->{description};
  237. } elsif ($nowAbfall_description ne $actualEvent->{description}) {
  238. # TODO change check to regex expression contains
  239. $nowAbfall_description .= $delimiter_text_reading . $actualEvent->{description};
  240. }
  241. $nowAbfall_tage = $actualEvent->{days};
  242. $nowAbfall_datum = $actualEvent->{dateFormatted};
  243. $nowAbfall_weekday = $actualEvent->{weekday};
  244. if ($now_readingTermin eq "") {
  245. $now_readingTermin = $actualEvent->{readingName};
  246. } else {
  247. $now_readingTermin .= $delimiter_reading . $actualEvent->{readingName};
  248. }
  249. # Action A08: set as reading
  250. my $enable_old_readingnames = AttrVal($name, "enable_old_readingnames", "0");
  251. my $readingTermin = $actualEvent->{readingName};
  252. readingsBulkUpdate($hash, $readingTermin ."_days", $actualEvent->{days});
  253. readingsBulkUpdate($hash, $readingTermin ."_text", $actualEvent->{summary});
  254. readingsBulkUpdate($hash, $readingTermin ."_date", $actualEvent->{dateFormatted});
  255. readingsBulkUpdate($hash, $readingTermin ."_weekday", $actualEvent->{weekday});
  256. readingsBulkUpdate($hash, $readingTermin ."_location", $actualEvent->{location});
  257. readingsBulkUpdate($hash, $readingTermin ."_description", $actualEvent->{description});
  258. readingsBulkUpdate($hash, $readingTermin ."_uid", $actualEvent->{uid});
  259. readingsBulkUpdate($hash, $readingTermin ."_tage", $actualEvent->{days}) if ($enable_old_readingnames);
  260. readingsBulkUpdate($hash, $readingTermin ."_wochentag", $actualEvent->{weekday}) if ($enable_old_readingnames);
  261. readingsBulkUpdate($hash, $readingTermin ."_datum", $actualEvent->{dateFormatted}) if ($enable_old_readingnames);
  262. # Action A19/04: step / 4 / counting pickup step
  263. $step = 4
  264. # Rule R07 <----
  265. }
  266. else
  267. {
  268. # Condition B09: next days initialized
  269. if (
  270. $nextAbfall_tage > -1
  271. )
  272. {
  273. # Condition B10: event days < next days
  274. if (
  275. $actualEvent->{days} < $nextAbfall_tage
  276. )
  277. {
  278. # Rule R08 ---->
  279. # Trace ---->
  280. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 8, 21";
  281. # Trace <----
  282. # Action A07: set next
  283. $nextAbfall_text = $actualEvent->{summary};
  284. $nextAbfall_location = $actualEvent->{location};
  285. $nextAbfall_description = $actualEvent->{description};
  286. $nextAbfall_tage = $actualEvent->{days};
  287. $nextAbfall_datum = $actualEvent->{dateFormatted};
  288. $nextAbfall_weekday = $actualEvent->{weekday};
  289. $next_readingTermin = $actualEvent->{readingName};
  290. # Action A08: set as reading
  291. my $enable_old_readingnames = AttrVal($name, "enable_old_readingnames", "0");
  292. my $readingTermin = $actualEvent->{readingName};
  293. readingsBulkUpdate($hash, $readingTermin ."_days", $actualEvent->{days});
  294. readingsBulkUpdate($hash, $readingTermin ."_text", $actualEvent->{summary});
  295. readingsBulkUpdate($hash, $readingTermin ."_date", $actualEvent->{dateFormatted});
  296. readingsBulkUpdate($hash, $readingTermin ."_weekday", $actualEvent->{weekday});
  297. readingsBulkUpdate($hash, $readingTermin ."_location", $actualEvent->{location});
  298. readingsBulkUpdate($hash, $readingTermin ."_description", $actualEvent->{description});
  299. readingsBulkUpdate($hash, $readingTermin ."_uid", $actualEvent->{uid});
  300. readingsBulkUpdate($hash, $readingTermin ."_tage", $actualEvent->{days}) if ($enable_old_readingnames);
  301. readingsBulkUpdate($hash, $readingTermin ."_wochentag", $actualEvent->{weekday}) if ($enable_old_readingnames);
  302. readingsBulkUpdate($hash, $readingTermin ."_datum", $actualEvent->{dateFormatted}) if ($enable_old_readingnames);
  303. # Action A19/04: step / 4 / counting pickup step
  304. $step = 4
  305. # Rule R08 <----
  306. }
  307. else
  308. {
  309. # Condition B11: event days = next days
  310. if (
  311. $actualEvent->{days} == $nextAbfall_tage
  312. )
  313. {
  314. # Rule R09 ---->
  315. # Trace ---->
  316. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 9, 21";
  317. # Trace <----
  318. # Action A06: append next
  319. if ($nextAbfall_text eq "") {
  320. $nextAbfall_text = $actualEvent->{summary};
  321. $nextTextMoreThen1 = 0;
  322. } else {
  323. if($nextTextMoreThen1 == 0){
  324. $nextAbfall_text .= $delimiter_text_reading . $actualEvent->{summary};
  325. $nextTextMoreThen1 = 1;
  326. } else {
  327. $nextAbfall_text = $actualEvent->{summary} . ", " . $nextAbfall_text;
  328. }
  329. }
  330. # check if location reading is the same
  331. if ($nextAbfall_location eq "") {
  332. $nextAbfall_location = $actualEvent->{location};
  333. } else {
  334. # TODO check if nextAbfall_location contains $actualEvent->{location}
  335. $nextAbfall_location .= $delimiter_text_reading . $actualEvent->{location};
  336. }
  337. # check if description reading is the same
  338. if ($nextAbfall_description eq "") {
  339. $nextAbfall_description = $actualEvent->{description};
  340. } else {
  341. # TODO check if nextAbfall_location contains $actualEvent->{location}
  342. $nextAbfall_description .= $delimiter_text_reading . $actualEvent->{description};
  343. }
  344. $nextAbfall_tage = $actualEvent->{days};
  345. $nextAbfall_datum = $actualEvent->{dateFormatted};
  346. $nextAbfall_weekday = $actualEvent->{weekday};
  347. if ($next_readingTermin eq "") {
  348. $next_readingTermin = $actualEvent->{readingName};
  349. } else {
  350. $next_readingTermin .= $delimiter_reading . $actualEvent->{readingName};
  351. }
  352. # Action A08: set as reading
  353. my $enable_old_readingnames = AttrVal($name, "enable_old_readingnames", "0");
  354. my $readingTermin = $actualEvent->{readingName};
  355. readingsBulkUpdate($hash, $readingTermin ."_days", $actualEvent->{days});
  356. readingsBulkUpdate($hash, $readingTermin ."_text", $actualEvent->{summary});
  357. readingsBulkUpdate($hash, $readingTermin ."_date", $actualEvent->{dateFormatted});
  358. readingsBulkUpdate($hash, $readingTermin ."_weekday", $actualEvent->{weekday});
  359. readingsBulkUpdate($hash, $readingTermin ."_location", $actualEvent->{location});
  360. readingsBulkUpdate($hash, $readingTermin ."_description", $actualEvent->{description});
  361. readingsBulkUpdate($hash, $readingTermin ."_uid", $actualEvent->{uid});
  362. readingsBulkUpdate($hash, $readingTermin ."_tage", $actualEvent->{days}) if ($enable_old_readingnames);
  363. readingsBulkUpdate($hash, $readingTermin ."_wochentag", $actualEvent->{weekday}) if ($enable_old_readingnames);
  364. readingsBulkUpdate($hash, $readingTermin ."_datum", $actualEvent->{dateFormatted}) if ($enable_old_readingnames);
  365. # Action A19/04: step / 4 / counting pickup step
  366. $step = 4
  367. # Rule R09 <----
  368. }
  369. else
  370. {
  371. # Rule R10 ---->
  372. # Trace ---->
  373. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 10, 21";
  374. # Trace <----
  375. # Action A08: set as reading
  376. my $enable_old_readingnames = AttrVal($name, "enable_old_readingnames", "0");
  377. my $readingTermin = $actualEvent->{readingName};
  378. readingsBulkUpdate($hash, $readingTermin ."_days", $actualEvent->{days});
  379. readingsBulkUpdate($hash, $readingTermin ."_text", $actualEvent->{summary});
  380. readingsBulkUpdate($hash, $readingTermin ."_date", $actualEvent->{dateFormatted});
  381. readingsBulkUpdate($hash, $readingTermin ."_weekday", $actualEvent->{weekday});
  382. readingsBulkUpdate($hash, $readingTermin ."_location", $actualEvent->{location});
  383. readingsBulkUpdate($hash, $readingTermin ."_description", $actualEvent->{description});
  384. readingsBulkUpdate($hash, $readingTermin ."_uid", $actualEvent->{uid});
  385. readingsBulkUpdate($hash, $readingTermin ."_tage", $actualEvent->{days}) if ($enable_old_readingnames);
  386. readingsBulkUpdate($hash, $readingTermin ."_wochentag", $actualEvent->{weekday}) if ($enable_old_readingnames);
  387. readingsBulkUpdate($hash, $readingTermin ."_datum", $actualEvent->{dateFormatted}) if ($enable_old_readingnames);
  388. # Action A19/04: step / 4 / counting pickup step
  389. $step = 4
  390. # Rule R10 <----
  391. }
  392. }
  393. }
  394. else
  395. {
  396. # Rule R11 ---->
  397. # Trace ---->
  398. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 11, 21";
  399. # Trace <----
  400. # Action A07: set next
  401. $nextAbfall_text = $actualEvent->{summary};
  402. $nextAbfall_location = $actualEvent->{location};
  403. $nextAbfall_description = $actualEvent->{description};
  404. $nextAbfall_tage = $actualEvent->{days};
  405. $nextAbfall_datum = $actualEvent->{dateFormatted};
  406. $nextAbfall_weekday = $actualEvent->{weekday};
  407. $next_readingTermin = $actualEvent->{readingName};
  408. # Action A08: set as reading
  409. my $enable_old_readingnames = AttrVal($name, "enable_old_readingnames", "0");
  410. my $readingTermin = $actualEvent->{readingName};
  411. readingsBulkUpdate($hash, $readingTermin ."_days", $actualEvent->{days});
  412. readingsBulkUpdate($hash, $readingTermin ."_text", $actualEvent->{summary});
  413. readingsBulkUpdate($hash, $readingTermin ."_date", $actualEvent->{dateFormatted});
  414. readingsBulkUpdate($hash, $readingTermin ."_weekday", $actualEvent->{weekday});
  415. readingsBulkUpdate($hash, $readingTermin ."_location", $actualEvent->{location});
  416. readingsBulkUpdate($hash, $readingTermin ."_description", $actualEvent->{description});
  417. readingsBulkUpdate($hash, $readingTermin ."_uid", $actualEvent->{uid});
  418. readingsBulkUpdate($hash, $readingTermin ."_tage", $actualEvent->{days}) if ($enable_old_readingnames);
  419. readingsBulkUpdate($hash, $readingTermin ."_wochentag", $actualEvent->{weekday}) if ($enable_old_readingnames);
  420. readingsBulkUpdate($hash, $readingTermin ."_datum", $actualEvent->{dateFormatted}) if ($enable_old_readingnames);
  421. # Action A19/04: step / 4 / counting pickup step
  422. $step = 4
  423. # Rule R11 <----
  424. }
  425. }
  426. }
  427. # Condition B01/04: step / 4 / counting pickup step
  428. }
  429. elsif (
  430. $step eq 4
  431. )
  432. {
  433. # Condition B02: counting pickups
  434. if (
  435. AttrVal($name, "enable_counting_pickups", "0")
  436. )
  437. {
  438. # Condition B03: reading pickups initialized
  439. if (
  440. ReadingsVal($name, $actualEvent->{readingName} . "_pickups", "-1") > -1
  441. )
  442. {
  443. # Condition B04: reading pickups used initialized
  444. if (
  445. ReadingsVal($name, $actualEvent->{readingName} . "_pickups_used", "-1") > -1
  446. )
  447. {
  448. # Rule R12 ---->
  449. # Trace ---->
  450. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 12, 21";
  451. # Trace <----
  452. # Action A19/05: step / 5 / now step
  453. $step = 5
  454. # Rule R12 <----
  455. }
  456. else
  457. {
  458. # Rule R13 ---->
  459. # Trace ---->
  460. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 13, 21";
  461. # Trace <----
  462. # Action A15: initialize pickups used
  463. readingsBulkUpdate($hash, $actualEvent->{readingName} ."_pickups_used", "0");
  464. # Action A19/05: step / 5 / now step
  465. $step = 5
  466. # Rule R13 <----
  467. }
  468. }
  469. else
  470. {
  471. # Condition B04: reading pickups used initialized
  472. if (
  473. ReadingsVal($name, $actualEvent->{readingName} . "_pickups_used", "-1") > -1
  474. )
  475. {
  476. # Rule R14 ---->
  477. # Trace ---->
  478. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 14, 21";
  479. # Trace <----
  480. # Action A14: initialize pickups
  481. readingsBulkUpdate($hash, $actualEvent->{readingName} ."_pickups", "0");
  482. # Action A19/05: step / 5 / now step
  483. $step = 5
  484. # Rule R14 <----
  485. }
  486. else
  487. {
  488. # Rule R15 ---->
  489. # Trace ---->
  490. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 15, 21";
  491. # Trace <----
  492. # Action A14: initialize pickups
  493. readingsBulkUpdate($hash, $actualEvent->{readingName} ."_pickups", "0");
  494. # Action A15: initialize pickups used
  495. readingsBulkUpdate($hash, $actualEvent->{readingName} ."_pickups_used", "0");
  496. # Action A19/05: step / 5 / now step
  497. $step = 5
  498. # Rule R15 <----
  499. }
  500. }
  501. }
  502. else
  503. {
  504. # Rule R16 ---->
  505. # Trace ---->
  506. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 16, 21";
  507. # Trace <----
  508. # Action A19/05: step / 5 / now step
  509. $step = 5
  510. # Rule R16 <----
  511. }
  512. # Condition B01/05: step / 5 / now step
  513. }
  514. elsif (
  515. $step eq 5
  516. )
  517. {
  518. # Condition B12: now days = 0
  519. if (
  520. $nowAbfall_tage == 0
  521. )
  522. {
  523. # Condition B13: last pickup <> actual pickup
  524. if (
  525. $lastNow ne $now_readingTermin
  526. )
  527. {
  528. # Rule R17 ---->
  529. # Trace ---->
  530. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 17, 21";
  531. # Trace <----
  532. # Action A09: set now reading
  533. readingsBulkUpdate($hash, "now", $now_readingTermin);
  534. readingsBulkUpdate($hash, "now_text", $nowAbfall_text);
  535. readingsBulkUpdate($hash, "now_date", $nowAbfall_datum);
  536. readingsBulkUpdate($hash, "now_weekday", $nowAbfall_weekday);
  537. readingsBulkUpdate($hash, "now_location", $nowAbfall_location);
  538. readingsBulkUpdate($hash, "now_description", $nowAbfall_description);
  539. my $enable_old_readingnames = AttrVal($name, "enable_old_readingnames", "0");
  540. readingsBulkUpdate($hash, "now_datum", $nowAbfall_datum) if ($enable_old_readingnames);
  541. readingsBulkUpdate($hash, "now_wochentag", $nowAbfall_weekday) if ($enable_old_readingnames);
  542. # Action A10: increment last pickup
  543. Log3 $name, 4, "ABFALL_setUpdate($name) - inc count for pickups for $now_readingTermin";
  544. my $now_readingTermin_count = ReadingsVal($hash, $now_readingTermin . "_pickups", "0");
  545. $now_readingTermin_count++;
  546. readingsBulkUpdate($hash, $now_readingTermin . "_pickups", $now_readingTermin_count);
  547. # Action A19/06: step / 6 / next step
  548. $step = 6;
  549. # Rule R17 <----
  550. }
  551. else
  552. {
  553. # Rule R18 ---->
  554. # Trace ---->
  555. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 18, 21";
  556. # Trace <----
  557. # Action A09: set now reading
  558. readingsBulkUpdate($hash, "now", $now_readingTermin);
  559. readingsBulkUpdate($hash, "now_text", $nowAbfall_text);
  560. readingsBulkUpdate($hash, "now_date", $nowAbfall_datum);
  561. readingsBulkUpdate($hash, "now_weekday", $nowAbfall_weekday);
  562. readingsBulkUpdate($hash, "now_location", $nowAbfall_location);
  563. readingsBulkUpdate($hash, "now_description", $nowAbfall_description);
  564. my $enable_old_readingnames = AttrVal($name, "enable_old_readingnames", "0");
  565. readingsBulkUpdate($hash, "now_datum", $nowAbfall_datum) if ($enable_old_readingnames);
  566. readingsBulkUpdate($hash, "now_wochentag", $nowAbfall_weekday) if ($enable_old_readingnames);
  567. # Action A19/06: step / 6 / next step
  568. $step = 6;
  569. # Rule R18 <----
  570. }
  571. }
  572. else
  573. {
  574. # Rule R19 ---->
  575. # Trace ---->
  576. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 19, 21";
  577. # Trace <----
  578. # Action A19/06: step / 6 / next step
  579. $step = 6;
  580. # Rule R19 <----
  581. }
  582. }
  583. else
  584. {
  585. # Condition B14: next days > 0
  586. if (
  587. $nextAbfall_tage > 0
  588. )
  589. {
  590. # Rule R20 ---->
  591. # Trace ---->
  592. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 20, 21";
  593. # Trace <----
  594. # Action A11: set next reading
  595. readingsBulkUpdate($hash, "next", $next_readingTermin . "_" . $nextAbfall_tage);
  596. readingsBulkUpdate($hash, "next_days", $nextAbfall_tage);
  597. readingsBulkUpdate($hash, "next_text", $nextAbfall_text);
  598. readingsBulkUpdate($hash, "next_date", $nextAbfall_datum);
  599. readingsBulkUpdate($hash, "next_weekday", $nextAbfall_weekday);
  600. readingsBulkUpdate($hash, "next_location", $nextAbfall_location);
  601. readingsBulkUpdate($hash, "next_description", $nextAbfall_description);
  602. my $enable_old_readingnames = AttrVal($name, "enable_old_readingnames", "0");
  603. readingsBulkUpdate($hash, "next_tage", $nextAbfall_tage) if ($enable_old_readingnames);
  604. readingsBulkUpdate($hash, "next_datum", $nextAbfall_datum) if ($enable_old_readingnames);
  605. readingsBulkUpdate($hash, "next_wochentag", $nextAbfall_weekday) if ($enable_old_readingnames);
  606. # Action A12: set state next days
  607. readingsBulkUpdate($hash, "state", $nextAbfall_tage);
  608. # Action A19/02: step / 2 / event step
  609. $step = 2;
  610. # Rule R20 <----
  611. }
  612. else
  613. {
  614. # Rule R21 ---->
  615. # Trace ---->
  616. Log3 $name, 5, "ABFALL_setUpdate($name) - ABFALL_setUpdate, 20170912.220919, 21, 21";
  617. # Trace <----
  618. # Action A13: set state no pickups
  619. readingsBulkUpdate($hash, "state", "Keine Abholungen");
  620. # Action A19/02: step / 2 / event step
  621. $step = 2;
  622. # Rule R21 <----
  623. }
  624. }
  625. # Epilog Decision Table ---->
  626. } # end while
  627. }
  628. 1;
  629. # Epilog Decision Table <----
  630. # End of generated Perl source code
  631. # Generated by LF-ET 2.1.5 (170905a), http://www.lohrfink.de/lfet