diff --git a/FHEM/38_netatmo.pm b/FHEM/38_netatmo.pm index 6aac45c01..4d099951a 100644 --- a/FHEM/38_netatmo.pm +++ b/FHEM/38_netatmo.pm @@ -29,7 +29,7 @@ netatmo_Initialize($) $hash->{NOTIFYDEV} = "global"; $hash->{NotifyFn} = "netatmo_Notify"; $hash->{UndefFn} = "netatmo_Undefine"; - #$hash->{SetFn} = "netatmo_Set"; + $hash->{SetFn} = "netatmo_Set"; $hash->{GetFn} = "netatmo_Get"; $hash->{AttrFn} = "netatmo_Attr"; $hash->{AttrList} = "IODev ". @@ -210,7 +210,13 @@ netatmo_Set($$@) { my ($hash, $name, $cmd) = @_; - my $list = ""; + my $list = "autocreate:noArgs"; + + if( $cmd eq "autocreate" ) { + return netatmo_autocreate($hash, 1 ); + return undef; + } + return "Unknown argument $cmd, choose one of $list"; } @@ -596,19 +602,21 @@ netatmo_dispatch($$$) } sub -netatmo_autocreate($) +netatmo_autocreate($;$) { - my($hash) = @_; + my($hash,$force) = @_; my $name = $hash->{NAME}; if( !$hash->{helper}{devices} ) { netatmo_getDevices($hash); - return undef; + return undef if( !$force ); } - foreach my $d (keys %defs) { - next if($defs{$d}{TYPE} ne "autocreate"); - return undef if(AttrVal($defs{$d}{NAME},"disable",undef)); + if( !$force ) { + foreach my $d (keys %defs) { + next if($defs{$d}{TYPE} ne "autocreate"); + return undef if(AttrVal($defs{$d}{NAME},"disable",undef)); + } } my $autocreated = 0; @@ -646,6 +654,8 @@ netatmo_autocreate($) } CommandSave(undef,undef) if( $autocreated && AttrVal( "autocreate", "autosave", 1 ) ); + + return "created $autocreated devices"; } sub @@ -1068,7 +1078,7 @@ netatmo_Attr($$$)
define <name> netatmo <device>
define <name> netatmo PUBLIC <device> <latitude> <longitude> [<radius>]
define <name> netatmo [ACCOUNT] <username> <password> <client_id> <client_secret>