From 6f719315246fd432c889d34fc9bb8391c9d26442 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Thu, 9 Jan 2020 17:20:13 +0100 Subject: [PATCH] bugfix --- 74_NUKIDevice.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/74_NUKIDevice.pm b/74_NUKIDevice.pm index 181c446..358ccab 100755 --- a/74_NUKIDevice.pm +++ b/74_NUKIDevice.pm @@ -187,7 +187,7 @@ sub NUKIDevice_Define($$) { my $d = $modules{NUKIDevice}{defptr}{$nukiId}; return -'NUKIDevice device ' . $name . ' on GardenaSmartBridge ' . $iodev . ' already defined.' +'NUKIDevice device ' . $name . ' on NUKIBridge ' . $iodev . ' already defined.' if ( defined($d) and $d->{IODev} == $hash->{IODev} and $d->{NAME} ne $name ); @@ -242,8 +242,7 @@ sub NUKIDevice_Attr(@) { Log3($name, 3, "NUKIDevice ($name) - enabled"); } } - - if ( $attrName eq 'disabledForIntervals' ) { + elsif ( $attrName eq 'disabledForIntervals' ) { if ( $cmd eq 'set' ) { Log3($name, 3, "NUKIDevice ($name) - enable disabledForIntervals"); readingsSingleUpdate ( $hash, 'state', 'Unknown', 1 ); @@ -254,6 +253,12 @@ sub NUKIDevice_Attr(@) { Log3($name, 3, "NUKIDevice ($name) - delete disabledForIntervals"); } } + elsif ( $attrName eq 'model' ) { + if ( $cmd eq 'set' ) { + Log3($name, 3, "NUKIDevice ($name) - change model"); + $hash->{DEVICETYPE} = $deviceTypeIds{$attrVal}; + } + } return undef; } @@ -367,11 +372,19 @@ sub NUKIDevice_Parse($$) { Log3($name, 4, "NUKIDevice ($name) - find logical device: $hash->{NAME}"); + ################## + ## Zwischenlösung so für die Umstellung, kann später gelöscht werden + if ( AttrVal($name,'model','') eq '' ) { + CommandDefMod(undef,$name . ' NUKIDevice ' . $hash->{NUKIID} . ' ' . $decode_json->{deviceType}); + CommandAttr(undef,$name . ' model ' . $deviceTypes{$decode_json->{deviceType}}); + Log3($name, 2, "NUKIDevice ($name) - redefined Defmod"); + } + return $hash->{NAME}; } else { Log3($name, 3, - 'NUKIDevice ($name) - autocreate new device ' + "NUKIDevice ($name) - autocreate new device " . makeDeviceName( $decode_json->{name} ) . " with nukiId $decode_json->{nukiId}, model $decode_json->{deviceType}"); return