From f2e909a985c1570e35d1d4fd1532efd90c083b91 Mon Sep 17 00:00:00 2001 From: HomeAuto_User <> Date: Wed, 22 Jan 2020 10:51:05 +0000 Subject: [PATCH] 88_Timer: fix list "Probably associated with" Forum: #1015549 git-svn-id: https://svn.fhem.de/fhem/trunk@21032 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/88_Timer.pm | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 6a37e36f8..d3a1a7795 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - bugfix: 88_Timer: fix list "Probably associated with" Forum: #1015549 - bugfix: 74_NUKIDevice: fix FHEM Crash Undefined subroutine &FHEM::NUKIDevice::CommandDefMod - change: 73_AutoShuttersControl: change commandref diff --git a/fhem/FHEM/88_Timer.pm b/fhem/FHEM/88_Timer.pm index 9be460144..5a5d8d343 100644 --- a/fhem/FHEM/88_Timer.pm +++ b/fhem/FHEM/88_Timer.pm @@ -9,7 +9,7 @@ # https://forum.fhem.de/index.php/board,20.0.html # https://forum.fhem.de/index.php/topic,103848.html | https://forum.fhem.de/index.php/topic,103986.0.html # -# 2019 - HomeAuto_User & elektron-bbs +# 2019 | 2020 - HomeAuto_User, elektron-bbs ################################################################# # notes: # - module mit package umsetzen @@ -804,6 +804,27 @@ sub FW_pushed_savebutton { readingsBulkUpdate($hash, "state" , $state, 1); readingsEndUpdate($hash, 1); + ## Probably associated with - added to list ## + ### check must work after changed setreadings to new value ### + ## all device must check, for right value in .associatedWith + my $associatedWith = ReadingsVal($name, ".associatedWith", ""); + + foreach my $d (sort keys %{$hash->{READINGS}}) { + if ($d =~ /^Timer_(\d+)$/) { + my @values = split("," , ReadingsVal($name, $d, "")); + if ($values[7] ne "DEF") { + #Log3 $name, 5, "$name: FW_pushed_savebutton | Reading .associatedWith check: ".$values[6]." with ".$values[7]; + if (not grep /$values[6]/, $associatedWith) { + #Log3 $name, 5, "$name: FW_pushed_savebutton | Reading .associatedWith added ".$values[6]; + $associatedWith = $associatedWith eq "" ? $values[6] : $associatedWith.",".$values[6]; + } + } + } + } + Log3 $name, 5, "$name: FW_pushed_savebutton | Reading .associatedWith is: ".$associatedWith; + CommandSetReading(undef, "$name .associatedWith $associatedWith"); + ## current list "Probably associated with" finish ## + ## popup user message (jump to javascript) ## if ($popup != 0) { FW_directNotify("FILTER=(room=)?$name", "#FHEMWEB:WEB", "show_popup(".$selected_buttons[0].")", ""); @@ -907,7 +928,8 @@ sub Timer_Check($) { if ($set == 1) { Log3 $name, 4, "$name: $d - set $values[6] $values[7] ($dayOfWeek, $values[0]-$values[1]-$values[2] $values[3]:$values[4]:$values[5])"; CommandSet($hash, $values[6]." ".$values[7]) if ($values[7] ne "DEF"); - $state = "$d set $values[6] $values[7] accomplished"; + # $state = "$d set $values[6] $values[7] accomplished"; + readingsSingleUpdate($hash, "state" , "$d set $values[6] $values[7] accomplished", 1); if ($values[7] eq "DEF") { if (AttrVal($name, $d."_set", undef)) { Log3 $name, 5, "$name: $d - exec at command: ".AttrVal($name, $d."_set", undef);