mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 10:46:03 +00:00
58_RPI_1Wire: fix state and STATE setting
git-svn-id: https://svn.fhem.de/fhem/trunk@28387 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
230c244aa9
commit
6e1424ac8b
@ -87,9 +87,10 @@ sub RPI_1Wire_Init { #
|
|||||||
my ( $hash, $args, $check ) = @_;
|
my ( $hash, $args, $check ) = @_;
|
||||||
Log3 $hash->{NAME}, 2, $hash->{NAME}.": Init: $args $check";
|
Log3 $hash->{NAME}, 2, $hash->{NAME}.": Init: $args $check";
|
||||||
if (! -e "$w1_path") {
|
if (! -e "$w1_path") {
|
||||||
$hash->{STATE} ="No 1-Wire Bus found";
|
my $state="No 1-Wire Bus found";
|
||||||
Log3 $hash->{NAME}, 3, $hash->{NAME}.": Init: $hash->{STATE}";
|
readingsSingleUpdate($hash,"state",$state,0);
|
||||||
return $hash->{STATE};
|
Log3 $hash->{NAME}, 3, $hash->{NAME}.": Init: $state";
|
||||||
|
return $state;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @a = split("[ \t]+", $args);
|
my @a = split("[ \t]+", $args);
|
||||||
@ -168,7 +169,8 @@ sub RPI_1Wire_Init { #
|
|||||||
RPI_1Wire_SetConversion($hash,$conv_time);
|
RPI_1Wire_SetConversion($hash,$conv_time);
|
||||||
}
|
}
|
||||||
RPI_1Wire_GetConfig($hash);
|
RPI_1Wire_GetConfig($hash);
|
||||||
$hash->{STATE} = "Initialized";
|
my $state = "Initialized";
|
||||||
|
readingsSingleUpdate($hash,"state",$state,0);
|
||||||
Log3 $hash->{NAME}, 3, $hash->{NAME}.": Init done for $device $family $id $type";
|
Log3 $hash->{NAME}, 3, $hash->{NAME}.": Init done for $device $family $id $type";
|
||||||
RPI_1Wire_DeviceUpdate($hash);
|
RPI_1Wire_DeviceUpdate($hash);
|
||||||
return;
|
return;
|
||||||
@ -178,6 +180,7 @@ sub RPI_1Wire_GetDevices {
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
Log3 $hash->{NAME}, 3 , $hash->{NAME}.": GetDevices";
|
Log3 $hash->{NAME}, 3 , $hash->{NAME}.": GetDevices";
|
||||||
my @devices;
|
my @devices;
|
||||||
|
print $ms_path.$hash->{id}."/w1_master_slaves"."\n";
|
||||||
if (open(my $fh, "<", $ms_path.$hash->{id}."/w1_master_slaves")) {
|
if (open(my $fh, "<", $ms_path.$hash->{id}."/w1_master_slaves")) {
|
||||||
while (my $device = <$fh>) {
|
while (my $device = <$fh>) {
|
||||||
chomp $device; #remove \n
|
chomp $device; #remove \n
|
||||||
@ -307,8 +310,9 @@ sub RPI_1Wire_Switch {
|
|||||||
print $fh pack("C",$switch);
|
print $fh pack("C",$switch);
|
||||||
close($fh);
|
close($fh);
|
||||||
} else {
|
} else {
|
||||||
$hash->{STATE}="Error writing to $w1_path/$hash->{DEF}/output";
|
my $state="Error writing to $w1_path/$hash->{DEF}/output";
|
||||||
return $hash->{STATE};
|
readingsSingleUpdate($hash,"state",$state,0);
|
||||||
|
return $state;
|
||||||
}
|
}
|
||||||
#After setting switch, read back to set readings correctly
|
#After setting switch, read back to set readings correctly
|
||||||
my $ret=RPI_1Wire_Poll($hash);
|
my $ret=RPI_1Wire_Poll($hash);
|
||||||
@ -673,8 +677,8 @@ sub RPI_1Wire_FinishFn {
|
|||||||
$state.="$par:$val ";
|
$state.="$par:$val ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$hash->{STATE}=$state;
|
readingsEndUpdate($hash,1);
|
||||||
readingsEndUpdate($hash,1);
|
readingsSingleUpdate($hash,"state",$state,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub RPI_1Wire_Attr { #
|
sub RPI_1Wire_Attr { #
|
||||||
|
Loading…
x
Reference in New Issue
Block a user