mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 10:46:53 +00:00
changed 10_OWServer.pm and 11_OWDevice.pm to use NOTIFYDEV
git-svn-id: https://svn.fhem.de/fhem/trunk@4729 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
d175f8b82a
commit
64927fb3e2
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user