This commit is contained in:
Marko Oldenburg 2020-01-09 17:20:13 +01:00
parent f24fcbf5b5
commit 6f71931524

View File

@ -187,7 +187,7 @@ sub NUKIDevice_Define($$) {
my $d = $modules{NUKIDevice}{defptr}{$nukiId}; my $d = $modules{NUKIDevice}{defptr}{$nukiId};
return return
'NUKIDevice device ' . $name . ' on GardenaSmartBridge ' . $iodev . ' already defined.' 'NUKIDevice device ' . $name . ' on NUKIBridge ' . $iodev . ' already defined.'
if ( defined($d) if ( defined($d)
and $d->{IODev} == $hash->{IODev} and $d->{IODev} == $hash->{IODev}
and $d->{NAME} ne $name ); and $d->{NAME} ne $name );
@ -242,8 +242,7 @@ sub NUKIDevice_Attr(@) {
Log3($name, 3, "NUKIDevice ($name) - enabled"); Log3($name, 3, "NUKIDevice ($name) - enabled");
} }
} }
elsif ( $attrName eq 'disabledForIntervals' ) {
if ( $attrName eq 'disabledForIntervals' ) {
if ( $cmd eq 'set' ) { if ( $cmd eq 'set' ) {
Log3($name, 3, "NUKIDevice ($name) - enable disabledForIntervals"); Log3($name, 3, "NUKIDevice ($name) - enable disabledForIntervals");
readingsSingleUpdate ( $hash, 'state', 'Unknown', 1 ); readingsSingleUpdate ( $hash, 'state', 'Unknown', 1 );
@ -254,6 +253,12 @@ sub NUKIDevice_Attr(@) {
Log3($name, 3, "NUKIDevice ($name) - delete disabledForIntervals"); 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; return undef;
} }
@ -367,11 +372,19 @@ sub NUKIDevice_Parse($$) {
Log3($name, 4, Log3($name, 4,
"NUKIDevice ($name) - find logical device: $hash->{NAME}"); "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}; return $hash->{NAME};
} }
else { else {
Log3($name, 3, Log3($name, 3,
'NUKIDevice ($name) - autocreate new device ' "NUKIDevice ($name) - autocreate new device "
. makeDeviceName( $decode_json->{name} ) . makeDeviceName( $decode_json->{name} )
. " with nukiId $decode_json->{nukiId}, model $decode_json->{deviceType}"); . " with nukiId $decode_json->{nukiId}, model $decode_json->{deviceType}");
return return