mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
OWServer, OWDevice
- fixed initialization order for global:INITIALIZED (now independend of device name) OWDevice: - moved reading of initial values after global:INITIALIZED git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@4285 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2a0cebef89
commit
f7285c8bb4
@ -107,6 +107,7 @@ OWServer_Initialize($)
|
|||||||
# Consumer
|
# Consumer
|
||||||
$hash->{DefFn} = "OWServer_Define";
|
$hash->{DefFn} = "OWServer_Define";
|
||||||
$hash->{NotifyFn}= "OWServer_Notify";
|
$hash->{NotifyFn}= "OWServer_Notify";
|
||||||
|
$hash->{NotifyOrderPrefix}= "50a-";
|
||||||
$hash->{UndefFn} = "OWServer_Undef";
|
$hash->{UndefFn} = "OWServer_Undef";
|
||||||
$hash->{GetFn} = "OWServer_Get";
|
$hash->{GetFn} = "OWServer_Get";
|
||||||
$hash->{SetFn} = "OWServer_Set";
|
$hash->{SetFn} = "OWServer_Set";
|
||||||
|
@ -350,6 +350,7 @@ OWDevice_Initialize($)
|
|||||||
$hash->{SetFn} = "OWDevice_Set";
|
$hash->{SetFn} = "OWDevice_Set";
|
||||||
$hash->{DefFn} = "OWDevice_Define";
|
$hash->{DefFn} = "OWDevice_Define";
|
||||||
$hash->{NotifyFn} = "OWDevice_Notify";
|
$hash->{NotifyFn} = "OWDevice_Notify";
|
||||||
|
$hash->{NotifyOrderPrefix}= "50b-";
|
||||||
$hash->{UndefFn} = "OWDevice_Undef";
|
$hash->{UndefFn} = "OWDevice_Undef";
|
||||||
$hash->{AttrFn} = "OWDevice_Attr";
|
$hash->{AttrFn} = "OWDevice_Attr";
|
||||||
|
|
||||||
@ -651,24 +652,9 @@ OWDevice_Define($$)
|
|||||||
$hash->{fhem}{alerting}= $alerting;
|
$hash->{fhem}{alerting}= $alerting;
|
||||||
Log3 $name, 5, "$name: alerting: $alerting";
|
Log3 $name, 5, "$name: alerting: $alerting";
|
||||||
|
|
||||||
$hash->{fhem}{bus}= OWDevice_ReadFromServer($hash,"find",$hash->{fhem}{address});
|
|
||||||
$attr{$name}{model}= OWDevice_ReadValue($hash, "type");
|
|
||||||
if($interface eq "id" && !defined($hash->{fhem}{interval})) {
|
|
||||||
my $dir= OWDevice_ReadFromServer($hash,"dir","/");
|
|
||||||
my $present= ($dir =~ m/$hash->{fhem}{address}/) ? 1 :0;
|
|
||||||
my $bus= OWDevice_ReadFromServer($hash,"find",$hash->{fhem}{address});
|
|
||||||
my $location= (defined($bus)) ? $bus :"absent";
|
|
||||||
my $id= OWDevice_Get($hash, $name, "id");
|
|
||||||
readingsBeginUpdate($hash);
|
|
||||||
readingsBulkUpdate($hash,"id",$id);
|
|
||||||
readingsBulkUpdate($hash,"present",$present);
|
|
||||||
readingsBulkUpdate($hash,"state","present: $present",0);
|
|
||||||
readingsBulkUpdate($hash,"location",$location);
|
|
||||||
readingsEndUpdate($hash,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( $init_done ) {
|
if( $init_done ) {
|
||||||
delete $modules{OWDevice}{NotifyFn};
|
delete $modules{OWDevice}{NotifyFn};
|
||||||
|
OWDevice_InitValues($hash);
|
||||||
OWDevice_UpdateValues($hash) if(defined($hash->{fhem}{interval}));
|
OWDevice_UpdateValues($hash) if(defined($hash->{fhem}{interval}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,11 +677,35 @@ OWDevice_Notify($$)
|
|||||||
|
|
||||||
foreach my $d (keys %defs) {
|
foreach my $d (keys %defs) {
|
||||||
next if($defs{$d}{TYPE} ne "OWDevice");
|
next if($defs{$d}{TYPE} ne "OWDevice");
|
||||||
|
OWDevice_InitValues($defs{$d});
|
||||||
OWDevice_UpdateValues($defs{$d}) if(defined($defs{$d}->{fhem}{interval}));
|
OWDevice_UpdateValues($defs{$d}) if(defined($defs{$d}->{fhem}{interval}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
sub
|
||||||
|
OWDevice_InitValues($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
$hash->{fhem}{bus}= OWDevice_ReadFromServer($hash,"find",$hash->{fhem}{address});
|
||||||
|
$attr{$name}{model}= OWDevice_ReadValue($hash, "type");
|
||||||
|
|
||||||
|
if($hash->{fhem}{interfaces} eq "id" && !defined($hash->{fhem}{interval})) {
|
||||||
|
my $dir= OWDevice_ReadFromServer($hash,"dir","/");
|
||||||
|
my $present= ($dir =~ m/$hash->{fhem}{address}/) ? 1 :0;
|
||||||
|
my $bus= OWDevice_ReadFromServer($hash,"find",$hash->{fhem}{address});
|
||||||
|
my $location= (defined($bus)) ? $bus :"absent";
|
||||||
|
my $id= OWDevice_Get($hash, $name, "id");
|
||||||
|
readingsBeginUpdate($hash);
|
||||||
|
readingsBulkUpdate($hash,"id",$id);
|
||||||
|
readingsBulkUpdate($hash,"present",$present);
|
||||||
|
readingsBulkUpdate($hash,"state","present: $present",0);
|
||||||
|
readingsBulkUpdate($hash,"location",$location);
|
||||||
|
readingsEndUpdate($hash,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
###################################
|
###################################
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user