mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +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.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
- SVN
|
- SVN
|
||||||
|
- feature: changed 10_OWServer.pm and 11_OWDevice.pm to use
|
||||||
|
NOTIFYDEV (justme1968)
|
||||||
- feature: LightScene: added setcmd command
|
- feature: LightScene: added setcmd command
|
||||||
- feature: DASHBOARD: Dashboard get Tabs. Redesign saving of Group
|
- feature: DASHBOARD: Dashboard get Tabs. Redesign saving of Group
|
||||||
positioning.
|
positioning.
|
||||||
|
@ -106,6 +106,7 @@ OWServer_Initialize($)
|
|||||||
|
|
||||||
# Consumer
|
# Consumer
|
||||||
$hash->{DefFn} = "OWServer_Define";
|
$hash->{DefFn} = "OWServer_Define";
|
||||||
|
$hash->{NOTIFYDEV} = "global";
|
||||||
$hash->{NotifyFn}= "OWServer_Notify";
|
$hash->{NotifyFn}= "OWServer_Notify";
|
||||||
$hash->{NotifyOrderPrefix}= "50a-";
|
$hash->{NotifyOrderPrefix}= "50a-";
|
||||||
$hash->{UndefFn} = "OWServer_Undef";
|
$hash->{UndefFn} = "OWServer_Undef";
|
||||||
@ -134,7 +135,6 @@ OWServer_Define($$)
|
|||||||
$hash->{fhem}{protocol}= $protocol;
|
$hash->{fhem}{protocol}= $protocol;
|
||||||
|
|
||||||
if( $init_done ) {
|
if( $init_done ) {
|
||||||
delete $modules{OWServer}{NotifyFn};
|
|
||||||
OWServer_OpenDev($hash);
|
OWServer_OpenDev($hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,13 +209,7 @@ OWServer_Notify($$)
|
|||||||
|
|
||||||
return if($attr{$name} && $attr{$name}{disable});
|
return if($attr{$name} && $attr{$name}{disable});
|
||||||
|
|
||||||
delete $modules{OWServer}{NotifyFn};
|
OWServer_OpenDev($hash);
|
||||||
delete $hash->{NTFY_ORDER} if($hash->{NTFY_ORDER});
|
|
||||||
|
|
||||||
foreach my $d (keys %defs) {
|
|
||||||
next if($defs{$d}{TYPE} ne "OWServer");
|
|
||||||
OWServer_OpenDev($defs{$d});
|
|
||||||
}
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -393,6 +387,7 @@ OWServer_Autocreate($)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $created = 0;
|
||||||
for my $device (@devices) {
|
for my $device (@devices) {
|
||||||
my $address= substr($device,1);
|
my $address= substr($device,1);
|
||||||
my $family= substr($address,0,2);
|
my $family= substr($address,0,2);
|
||||||
@ -419,12 +414,15 @@ OWServer_Autocreate($)
|
|||||||
if($cmdret) {
|
if($cmdret) {
|
||||||
Log3 $name, 1, "$name: Autocreate: An error occurred while creating device for address '$address': $cmdret";
|
Log3 $name, 1, "$name: Autocreate: An error occurred while creating device for address '$address': $cmdret";
|
||||||
} else {
|
} else {
|
||||||
|
$created++;
|
||||||
$cmdret= CommandAttr(undef,"$devname room OWDevice");
|
$cmdret= CommandAttr(undef,"$devname room OWDevice");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommandSave(undef,undef) if( $created && AttrVal( "autocreate", "autosave", 1 ) );
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,6 +349,7 @@ OWDevice_Initialize($)
|
|||||||
$hash->{GetFn} = "OWDevice_Get";
|
$hash->{GetFn} = "OWDevice_Get";
|
||||||
$hash->{SetFn} = "OWDevice_Set";
|
$hash->{SetFn} = "OWDevice_Set";
|
||||||
$hash->{DefFn} = "OWDevice_Define";
|
$hash->{DefFn} = "OWDevice_Define";
|
||||||
|
$hash->{NOTIFYDEV} = "global";
|
||||||
$hash->{NotifyFn} = "OWDevice_Notify";
|
$hash->{NotifyFn} = "OWDevice_Notify";
|
||||||
$hash->{NotifyOrderPrefix}= "50b-";
|
$hash->{NotifyOrderPrefix}= "50b-";
|
||||||
$hash->{UndefFn} = "OWDevice_Undef";
|
$hash->{UndefFn} = "OWDevice_Undef";
|
||||||
@ -516,10 +517,8 @@ OWDevice_UpdateValues($) {
|
|||||||
readingsEndUpdate($hash,1);
|
readingsEndUpdate($hash,1);
|
||||||
}
|
}
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
# http://forum.fhem.de/index.php/topic,16945.0/topicseen.html#msg110673
|
InternalTimer(int(gettimeofday()) + $hash->{fhem}{interval}, "OWDevice_UpdateValues", $hash, 0)
|
||||||
InternalTimer(int(gettimeofday())+$hash->{fhem}{rand}+$hash->{fhem}{interval},
|
if(defined($hash->{fhem}{interval}));
|
||||||
"OWDevice_UpdateValues", $hash, 0) if(defined($hash->{fhem}{interval}));
|
|
||||||
$hash->{fhem}{rand} = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
@ -662,13 +661,8 @@ OWDevice_Define($$)
|
|||||||
Log3 $name, 5, "$name: alerting: $alerting";
|
Log3 $name, 5, "$name: alerting: $alerting";
|
||||||
|
|
||||||
if( $init_done ) {
|
if( $init_done ) {
|
||||||
$hash->{fhem}{rand} = 0;
|
|
||||||
delete $modules{OWDevice}{NotifyFn};
|
|
||||||
OWDevice_InitValues($hash);
|
OWDevice_InitValues($hash);
|
||||||
OWDevice_UpdateValues($hash) if(defined($hash->{fhem}{interval}));
|
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;
|
return undef;
|
||||||
@ -686,13 +680,12 @@ OWDevice_Notify($$)
|
|||||||
|
|
||||||
return if($attr{$name} && $attr{$name}{disable});
|
return if($attr{$name} && $attr{$name}{disable});
|
||||||
|
|
||||||
delete $modules{OWDevice}{NotifyFn};
|
OWDevice_InitValues($hash);
|
||||||
|
RemoveInternalTimer($hash);
|
||||||
foreach my $d (keys %defs) {
|
# http://forum.fhem.de/index.php/topic,16945.0/topicseen.html#msg110673
|
||||||
next if($defs{$d}{TYPE} ne "OWDevice");
|
my $delay = int(rand(20));
|
||||||
OWDevice_InitValues($defs{$d});
|
Log3 $name, 5, "$name: initial delay: $delay";
|
||||||
OWDevice_UpdateValues($defs{$d}) if(defined($defs{$d}->{fhem}{interval}));
|
InternalTimer(int(gettimeofday())+$delay, "OWDevice_UpdateValues", $hash, 0) if(defined($hash->{fhem}{interval}));
|
||||||
}
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user