fix ReadingsUpdates

This commit is contained in:
Marko Oldenburg 2017-01-07 21:38:50 +01:00
parent 1de922f39d
commit 4cce22bd05

View File

@ -407,12 +407,10 @@ sub NUKIDevice_WriteReadings($$) {
my $name = $hash->{NAME}; my $name = $hash->{NAME};
############################ ############################
#### Status des Smartlock #### Status des Smartlock
readingsBeginUpdate($hash);
my $battery; my $battery;
if( defined($decode_json->{batteryCritical}) ) { if( defined($decode_json->{batteryCritical}) ) {
if( $decode_json->{batteryCritical} eq "false" or $decode_json->{batteryCritical} == 0 ) { if( $decode_json->{batteryCritical} eq "false" or $decode_json->{batteryCritical} == 0 ) {
@ -424,6 +422,9 @@ sub NUKIDevice_WriteReadings($$) {
} }
} }
readingsBeginUpdate($hash);
if( defined($hash->{helper}{lockAction}) ) { if( defined($hash->{helper}{lockAction}) ) {
my ($state,$lockState); my ($state,$lockState);
@ -440,8 +441,7 @@ sub NUKIDevice_WriteReadings($$) {
$state = "error"; $state = "error";
NUKIDevice_ReadFromNUKIBridge($hash, "lockState", undef, $hash->{NUKIID} ); NUKIDevice_ReadFromNUKIBridge($hash, "lockState", undef, $hash->{NUKIID} );
} }
readingsBulkUpdate( $hash, "state", $state ); readingsBulkUpdate( $hash, "state", $state );
readingsBulkUpdate( $hash, "lockState", $lockState ); readingsBulkUpdate( $hash, "lockState", $lockState );
readingsBulkUpdate( $hash, "success", $decode_json->{success} ); readingsBulkUpdate( $hash, "success", $decode_json->{success} );
@ -463,6 +463,7 @@ sub NUKIDevice_WriteReadings($$) {
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
return undef; return undef;
} }