ABFALL_setUpdate_back.pm 30 KB

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