diff --git a/fhem/CHANGED b/fhem/CHANGED index 7f30f30a5..87e00be3c 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,6 +1,8 @@ # 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. - SVN + - feature: changed 10_OWServer.pm and 11_OWDevice.pm to use + NOTIFYDEV (justme1968) - feature: LightScene: added setcmd command - feature: DASHBOARD: Dashboard get Tabs. Redesign saving of Group positioning. diff --git a/fhem/FHEM/10_OWServer.pm b/fhem/FHEM/10_OWServer.pm index 34397d5f0..647b6e030 100644 --- a/fhem/FHEM/10_OWServer.pm +++ b/fhem/FHEM/10_OWServer.pm @@ -106,6 +106,7 @@ OWServer_Initialize($) # Consumer $hash->{DefFn} = "OWServer_Define"; + $hash->{NOTIFYDEV} = "global"; $hash->{NotifyFn}= "OWServer_Notify"; $hash->{NotifyOrderPrefix}= "50a-"; $hash->{UndefFn} = "OWServer_Undef"; @@ -134,7 +135,6 @@ OWServer_Define($$) $hash->{fhem}{protocol}= $protocol; if( $init_done ) { - delete $modules{OWServer}{NotifyFn}; OWServer_OpenDev($hash); } @@ -209,13 +209,7 @@ OWServer_Notify($$) return if($attr{$name} && $attr{$name}{disable}); - delete $modules{OWServer}{NotifyFn}; - delete $hash->{NTFY_ORDER} if($hash->{NTFY_ORDER}); - - foreach my $d (keys %defs) { - next if($defs{$d}{TYPE} ne "OWServer"); - OWServer_OpenDev($defs{$d}); - } + OWServer_OpenDev($hash); return undef; } @@ -393,6 +387,7 @@ OWServer_Autocreate($) } } + my $created = 0; for my $device (@devices) { my $address= substr($device,1); my $family= substr($address,0,2); @@ -419,12 +414,15 @@ OWServer_Autocreate($) if($cmdret) { Log3 $name, 1, "$name: Autocreate: An error occurred while creating device for address '$address': $cmdret"; } else { + $created++; $cmdret= CommandAttr(undef,"$devname room OWDevice"); } } } } + CommandSave(undef,undef) if( $created && AttrVal( "autocreate", "autosave", 1 ) ); + return undef; } diff --git a/fhem/FHEM/11_OWDevice.pm b/fhem/FHEM/11_OWDevice.pm index f7c50c4a9..b17e79882 100644 --- a/fhem/FHEM/11_OWDevice.pm +++ b/fhem/FHEM/11_OWDevice.pm @@ -349,6 +349,7 @@ OWDevice_Initialize($) $hash->{GetFn} = "OWDevice_Get"; $hash->{SetFn} = "OWDevice_Set"; $hash->{DefFn} = "OWDevice_Define"; + $hash->{NOTIFYDEV} = "global"; $hash->{NotifyFn} = "OWDevice_Notify"; $hash->{NotifyOrderPrefix}= "50b-"; $hash->{UndefFn} = "OWDevice_Undef"; @@ -516,10 +517,8 @@ OWDevice_UpdateValues($) { readingsEndUpdate($hash,1); } RemoveInternalTimer($hash); - # http://forum.fhem.de/index.php/topic,16945.0/topicseen.html#msg110673 - InternalTimer(int(gettimeofday())+$hash->{fhem}{rand}+$hash->{fhem}{interval}, - "OWDevice_UpdateValues", $hash, 0) if(defined($hash->{fhem}{interval})); - $hash->{fhem}{rand} = 0; + InternalTimer(int(gettimeofday()) + $hash->{fhem}{interval}, "OWDevice_UpdateValues", $hash, 0) + if(defined($hash->{fhem}{interval})); } ################################### @@ -662,13 +661,8 @@ OWDevice_Define($$) Log3 $name, 5, "$name: alerting: $alerting"; if( $init_done ) { - $hash->{fhem}{rand} = 0; - delete $modules{OWDevice}{NotifyFn}; OWDevice_InitValues($hash); OWDevice_UpdateValues($hash) if(defined($hash->{fhem}{interval})); - } else { - $hash->{fhem}{rand} = int(rand(20)); - Log3 $name, 5, "$name: initial delay: $hash->{fhem}{rand}"; } return undef; @@ -686,13 +680,12 @@ OWDevice_Notify($$) return if($attr{$name} && $attr{$name}{disable}); - delete $modules{OWDevice}{NotifyFn}; - - foreach my $d (keys %defs) { - next if($defs{$d}{TYPE} ne "OWDevice"); - OWDevice_InitValues($defs{$d}); - OWDevice_UpdateValues($defs{$d}) if(defined($defs{$d}->{fhem}{interval})); - } + OWDevice_InitValues($hash); + RemoveInternalTimer($hash); + # http://forum.fhem.de/index.php/topic,16945.0/topicseen.html#msg110673 + my $delay = int(rand(20)); + Log3 $name, 5, "$name: initial delay: $delay"; + InternalTimer(int(gettimeofday())+$delay, "OWDevice_UpdateValues", $hash, 0) if(defined($hash->{fhem}{interval})); return undef; }