mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 04:36:02 +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 ) = @_;
|
||||
Log3 $hash->{NAME}, 2, $hash->{NAME}.": Init: $args $check";
|
||||
if (! -e "$w1_path") {
|
||||
$hash->{STATE} ="No 1-Wire Bus found";
|
||||
Log3 $hash->{NAME}, 3, $hash->{NAME}.": Init: $hash->{STATE}";
|
||||
return $hash->{STATE};
|
||||
my $state="No 1-Wire Bus found";
|
||||
readingsSingleUpdate($hash,"state",$state,0);
|
||||
Log3 $hash->{NAME}, 3, $hash->{NAME}.": Init: $state";
|
||||
return $state;
|
||||
}
|
||||
|
||||
my @a = split("[ \t]+", $args);
|
||||
@ -168,7 +169,8 @@ sub RPI_1Wire_Init { #
|
||||
RPI_1Wire_SetConversion($hash,$conv_time);
|
||||
}
|
||||
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";
|
||||
RPI_1Wire_DeviceUpdate($hash);
|
||||
return;
|
||||
@ -178,6 +180,7 @@ sub RPI_1Wire_GetDevices {
|
||||
my ($hash) = @_;
|
||||
Log3 $hash->{NAME}, 3 , $hash->{NAME}.": GetDevices";
|
||||
my @devices;
|
||||
print $ms_path.$hash->{id}."/w1_master_slaves"."\n";
|
||||
if (open(my $fh, "<", $ms_path.$hash->{id}."/w1_master_slaves")) {
|
||||
while (my $device = <$fh>) {
|
||||
chomp $device; #remove \n
|
||||
@ -307,8 +310,9 @@ sub RPI_1Wire_Switch {
|
||||
print $fh pack("C",$switch);
|
||||
close($fh);
|
||||
} else {
|
||||
$hash->{STATE}="Error writing to $w1_path/$hash->{DEF}/output";
|
||||
return $hash->{STATE};
|
||||
my $state="Error writing to $w1_path/$hash->{DEF}/output";
|
||||
readingsSingleUpdate($hash,"state",$state,0);
|
||||
return $state;
|
||||
}
|
||||
#After setting switch, read back to set readings correctly
|
||||
my $ret=RPI_1Wire_Poll($hash);
|
||||
@ -673,8 +677,8 @@ sub RPI_1Wire_FinishFn {
|
||||
$state.="$par:$val ";
|
||||
}
|
||||
}
|
||||
$hash->{STATE}=$state;
|
||||
readingsEndUpdate($hash,1);
|
||||
readingsEndUpdate($hash,1);
|
||||
readingsSingleUpdate($hash,"state",$state,0);
|
||||
}
|
||||
|
||||
sub RPI_1Wire_Attr { #
|
||||
|
Loading…
x
Reference in New Issue
Block a user