diff --git a/fhem/FHEM/20_GUEST.pm b/fhem/FHEM/20_GUEST.pm index fdee6c24e..46e8a174a 100644 --- a/fhem/FHEM/20_GUEST.pm +++ b/fhem/FHEM/20_GUEST.pm @@ -322,8 +322,9 @@ sub GUEST_Set($@) { $usage .= " location$locations"; if ($adminMode) { $usage .= " create:wakeuptimer"; - - # $usage .= " compactMode:noArg largeMode:noArg"; + $usage .= ",locationMap" + if ( ReadingsVal( $name, "locationLat", "-" ) ne "-" + && ReadingsVal( $name, "locationLong", "-" ) ne "-" ); } # silentSet @@ -747,8 +748,12 @@ sub GUEST_Set($@) { } # create - elsif ( $a[1] eq "create" ) { - if ( defined( $a[2] ) && $a[2] eq "wakeuptimer" ) { + elsif ( lc( $a[1] ) eq "create" ) { + if ( !defined( $a[2] ) ) { + return + "Invalid 2nd argument, choose one of wakeuptimer locationMap "; + } + elsif ( lc( $a[2] ) eq "wakeuptimer" ) { my $i = "1"; my $wakeuptimerName = $name . "_wakeuptimer" . $i; my $created = 0; @@ -804,8 +809,38 @@ sub GUEST_Set($@) { return "Dummy $wakeuptimerName and other pending devices created and pre-configured.\nYou may edit Macro_$wakeuptimerName to define your wake-up actions\nand at_$wakeuptimerName for optional at-device adjustments."; } - else { - return "Invalid 2nd argument, choose one of wakeuptimer "; + elsif ( lc( $a[2] ) eq "locationmap" ) { + my $locationmapName = $name . "_map"; + + if ( defined( $defs{$locationmapName} ) ) { + return +"Device $locationmapName existing already, delete it first to have it re-created."; + } + else { + my $sortby = AttrVal( $name, "sortby", -1 ); + $sortby++; + + # create new weblink device + fhem "define $locationmapName weblink htmlCode { +'
+ +
' +}"; + fhem "attr $locationmapName alias Current Location"; + fhem + "attr $locationmapName comment Auto-created by GUEST module"; + fhem "attr $locationmapName group " . $attr{$name}{group} + if ( defined( $attr{$name}{group} ) ); + fhem "attr $locationmapName room " . $attr{$name}{room} + if ( defined( $attr{$name}{room} ) ); + } + + return "Weblink device $locationmapName was created."; } } @@ -889,8 +924,7 @@ sub GUEST_DurationTimer($;$) { { $durPresence = $timestampNow - - time_str2num( - ReadingsVal( $name, "lastArrival", "" ) ); + time_str2num( ReadingsVal( $name, "lastArrival", "" ) ); } # absence timer @@ -899,8 +933,7 @@ sub GUEST_DurationTimer($;$) { { $durAbsence = $timestampNow - - time_str2num( - ReadingsVal( $name, "lastDeparture", "" ) ); + time_str2num( ReadingsVal( $name, "lastDeparture", "" ) ); } # sleep timer @@ -909,8 +942,7 @@ sub GUEST_DurationTimer($;$) { { $durSleep = $timestampNow - - time_str2num( - ReadingsVal( $name, "lastSleep", "" ) ); + time_str2num( ReadingsVal( $name, "lastSleep", "" ) ); } my $durPresence_hr = @@ -1205,7 +1237,9 @@ sub GUEST_StartInternalTimers($$) { state   home,gotosleep,asleep,awoken,absent,none   switch between states; see attribute rg_states to adjust list shown in FHEMWEB
  • - create   wakeuptimer   add several pre-configurations provided by RESIDENTS Toolkit. See separate section in RESIDENTS module commandref for details. + create +
  • locationMap   add a pre-configured weblink device using showing a Google Map if readings locationLat+locationLong are present.
  • +
  • wakeuptimer   add several pre-configurations provided by RESIDENTS Toolkit. See separate section in RESIDENTS module commandref for details.