2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-19 12:46:03 +00:00

20_ROOMMATE,20_GUEST: add create locationMap

git-svn-id: https://svn.fhem.de/fhem/trunk@10560 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-01-17 16:32:03 +00:00
parent 55ddb6a0af
commit c50b70bf07
2 changed files with 100 additions and 28 deletions

View File

@ -322,8 +322,9 @@ sub GUEST_Set($@) {
$usage .= " location$locations"; $usage .= " location$locations";
if ($adminMode) { if ($adminMode) {
$usage .= " create:wakeuptimer"; $usage .= " create:wakeuptimer";
$usage .= ",locationMap"
# $usage .= " compactMode:noArg largeMode:noArg"; if ( ReadingsVal( $name, "locationLat", "-" ) ne "-"
&& ReadingsVal( $name, "locationLong", "-" ) ne "-" );
} }
# silentSet # silentSet
@ -747,8 +748,12 @@ sub GUEST_Set($@) {
} }
# create # create
elsif ( $a[1] eq "create" ) { elsif ( lc( $a[1] ) eq "create" ) {
if ( defined( $a[2] ) && $a[2] eq "wakeuptimer" ) { if ( !defined( $a[2] ) ) {
return
"Invalid 2nd argument, choose one of wakeuptimer locationMap ";
}
elsif ( lc( $a[2] ) eq "wakeuptimer" ) {
my $i = "1"; my $i = "1";
my $wakeuptimerName = $name . "_wakeuptimer" . $i; my $wakeuptimerName = $name . "_wakeuptimer" . $i;
my $created = 0; my $created = 0;
@ -804,8 +809,38 @@ sub GUEST_Set($@) {
return 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."; "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 { elsif ( lc( $a[2] ) eq "locationmap" ) {
return "Invalid 2nd argument, choose one of wakeuptimer "; 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 {
'<div style=\"width: 400px;; overflow: hidden;; height: 300px;;\">
<iframe name=\"$locationmapName\" src=\"https://www.google.com/maps/embed/v1/place?key=AIzaSyB66DvcpbXJ5eWgIkzxpUN2s_9l3_6fegM&q='
.ReadingsVal('$name','locationLat','')
.','
.ReadingsVal('$name','locationLong','')
.'&zoom=13\" width=\"480\" height=\"480\" frameborder=\"0\" style=\"border:0;; margin-top: -165px;; margin-left: -135px;;\">
</iframe>
</div>'
}";
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 = $durPresence =
$timestampNow - $timestampNow -
time_str2num( time_str2num( ReadingsVal( $name, "lastArrival", "" ) );
ReadingsVal( $name, "lastArrival", "" ) );
} }
# absence timer # absence timer
@ -899,8 +933,7 @@ sub GUEST_DurationTimer($;$) {
{ {
$durAbsence = $durAbsence =
$timestampNow - $timestampNow -
time_str2num( time_str2num( ReadingsVal( $name, "lastDeparture", "" ) );
ReadingsVal( $name, "lastDeparture", "" ) );
} }
# sleep timer # sleep timer
@ -909,8 +942,7 @@ sub GUEST_DurationTimer($;$) {
{ {
$durSleep = $durSleep =
$timestampNow - $timestampNow -
time_str2num( time_str2num( ReadingsVal( $name, "lastSleep", "" ) );
ReadingsVal( $name, "lastSleep", "" ) );
} }
my $durPresence_hr = my $durPresence_hr =
@ -1205,7 +1237,9 @@ sub GUEST_StartInternalTimers($$) {
<b>state</b> &nbsp;&nbsp;home,gotosleep,asleep,awoken,absent,none&nbsp;&nbsp; switch between states; see attribute rg_states to adjust list shown in FHEMWEB <b>state</b> &nbsp;&nbsp;home,gotosleep,asleep,awoken,absent,none&nbsp;&nbsp; switch between states; see attribute rg_states to adjust list shown in FHEMWEB
</li> </li>
<li> <li>
<b>create</b> &nbsp;&nbsp;wakeuptimer&nbsp;&nbsp; add several pre-configurations provided by RESIDENTS Toolkit. See separate section in <a href="#RESIDENTS">RESIDENTS module commandref</a> for details. <b>create</b>
<li><i>locationMap</i>&nbsp;&nbsp; add a pre-configured weblink device using showing a Google Map if readings locationLat+locationLong are present.</li>
<li><i>wakeuptimer</i>&nbsp;&nbsp; add several pre-configurations provided by RESIDENTS Toolkit. See separate section in <a href="#RESIDENTS">RESIDENTS module commandref</a> for details.</li>
</li> </li>
</ul> </ul>
<ul> <ul>
@ -1505,7 +1539,9 @@ sub GUEST_StartInternalTimers($$) {
<b>state</b> &nbsp;&nbsp;home,gotosleep,asleep,awoken,absent,gone&nbsp;&nbsp; wechselt den Status; siehe auch Attribut rg_states, um die in FHEMWEB angezeigte Liste anzupassen <b>state</b> &nbsp;&nbsp;home,gotosleep,asleep,awoken,absent,gone&nbsp;&nbsp; wechselt den Status; siehe auch Attribut rg_states, um die in FHEMWEB angezeigte Liste anzupassen
</li> </li>
<li> <li>
<b>create</b> &nbsp;&nbsp;wakeuptimer&nbsp;&nbsp; f&uuml;gt diverse Vorkonfigurationen auf Basis von RESIDENTS Toolkit hinzu. Siehe separate Sektion in der <a href="#RESIDENTS">RESIDENTS Modul Kommandoreferenz</a>. <b>create</b>
<li><i>locationMap</i>&nbsp;&nbsp; f&uuml;gt ein vorkonfiguriertes weblink Device hinzu, welches eine Google Map anzeigt, sofern die Readings locationLat+locationLong vorhanden sind.</li>
<li><i>wakeuptimer</i>&nbsp;&nbsp; f&uuml;gt diverse Vorkonfigurationen auf Basis von RESIDENTS Toolkit hinzu. Siehe separate Sektion in der <a href="#RESIDENTS">RESIDENTS Modul Kommandoreferenz</a>.</li>
</li> </li>
</ul> </ul>
<ul> <ul>

View File

@ -327,8 +327,9 @@ sub ROOMMATE_Set($@) {
$usage .= " location$locations"; $usage .= " location$locations";
if ($adminMode) { if ($adminMode) {
$usage .= " create:wakeuptimer"; $usage .= " create:wakeuptimer";
$usage .= ",locationMap"
# $usage .= " compactMode:noArg largeMode:noArg"; if ( ReadingsVal( $name, "locationLat", "-" ) ne "-"
&& ReadingsVal( $name, "locationLong", "-" ) ne "-" );
} }
# silentSet # silentSet
@ -729,8 +730,12 @@ sub ROOMMATE_Set($@) {
} }
# create # create
elsif ( $a[1] eq "create" ) { elsif ( lc( $a[1] ) eq "create" ) {
if ( defined( $a[2] ) && $a[2] eq "wakeuptimer" ) { if ( !defined( $a[2] ) ) {
return
"Invalid 2nd argument, choose one of wakeuptimer locationMap ";
}
elsif ( lc( $a[2] ) eq "wakeuptimer" ) {
my $i = "1"; my $i = "1";
my $wakeuptimerName = $name . "_wakeuptimer" . $i; my $wakeuptimerName = $name . "_wakeuptimer" . $i;
my $created = 0; my $created = 0;
@ -786,8 +791,38 @@ sub ROOMMATE_Set($@) {
return 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."; "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 { elsif ( lc( $a[2] ) eq "locationmap" ) {
return "Invalid 2nd argument, choose one of wakeuptimer "; 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 {
'<div style=\"width: 400px;; overflow: hidden;; height: 300px;;\">
<iframe name=\"$locationmapName\" src=\"https://www.google.com/maps/embed/v1/place?key=AIzaSyB66DvcpbXJ5eWgIkzxpUN2s_9l3_6fegM&q='
.ReadingsVal('$name','locationLat','')
.','
.ReadingsVal('$name','locationLong','')
.'&zoom=13\" width=\"480\" height=\"480\" frameborder=\"0\" style=\"border:0;; margin-top: -165px;; margin-left: -135px;;\">
</iframe>
</div>'
}";
fhem "attr $locationmapName alias Current Location";
fhem
"attr $locationmapName comment Auto-created by ROOMMATE 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.";
} }
} }
@ -870,8 +905,7 @@ sub ROOMMATE_DurationTimer($;$) {
{ {
$durPresence = $durPresence =
$timestampNow - $timestampNow -
time_str2num( time_str2num( ReadingsVal( $name, "lastArrival", "" ) );
ReadingsVal( $name, "lastArrival", "" ) );
} }
# absence timer # absence timer
@ -880,8 +914,7 @@ sub ROOMMATE_DurationTimer($;$) {
{ {
$durAbsence = $durAbsence =
$timestampNow - $timestampNow -
time_str2num( time_str2num( ReadingsVal( $name, "lastDeparture", "" ) );
ReadingsVal( $name, "lastDeparture", "" ) );
} }
# sleep timer # sleep timer
@ -890,8 +923,7 @@ sub ROOMMATE_DurationTimer($;$) {
{ {
$durSleep = $durSleep =
$timestampNow - $timestampNow -
time_str2num( time_str2num( ReadingsVal( $name, "lastSleep", "" ) );
ReadingsVal( $name, "lastSleep", "" ) );
} }
my $durPresence_hr = my $durPresence_hr =
@ -1193,7 +1225,9 @@ sub ROOMMATE_StartInternalTimers($$) {
<b>state</b> &nbsp;&nbsp;home,gotosleep,asleep,awoken,absent,gone&nbsp;&nbsp; switch between states; see attribute rr_states to adjust list shown in FHEMWEB <b>state</b> &nbsp;&nbsp;home,gotosleep,asleep,awoken,absent,gone&nbsp;&nbsp; switch between states; see attribute rr_states to adjust list shown in FHEMWEB
</li> </li>
<li> <li>
<b>create</b> &nbsp;&nbsp;wakeuptimer&nbsp;&nbsp; add several pre-configurations provided by RESIDENTS Toolkit. See separate section in <a href="#RESIDENTS">RESIDENTS module commandref</a> for details. <b>create</b>
<li><i>locationMap</i>&nbsp;&nbsp; add a pre-configured weblink device using showing a Google Map if readings locationLat+locationLong are present.</li>
<li><i>wakeuptimer</i>&nbsp;&nbsp; add several pre-configurations provided by RESIDENTS Toolkit. See separate section in <a href="#RESIDENTS">RESIDENTS module commandref</a> for details.</li>
</li> </li>
</ul> </ul>
<ul> <ul>
@ -1493,7 +1527,9 @@ sub ROOMMATE_StartInternalTimers($$) {
<b>state</b> &nbsp;&nbsp;home,gotosleep,asleep,awoken,absent,gone&nbsp;&nbsp; wechselt den Status; siehe auch Attribut rr_states, um die in FHEMWEB angezeigte Liste anzupassen <b>state</b> &nbsp;&nbsp;home,gotosleep,asleep,awoken,absent,gone&nbsp;&nbsp; wechselt den Status; siehe auch Attribut rr_states, um die in FHEMWEB angezeigte Liste anzupassen
</li> </li>
<li> <li>
<b>create</b> &nbsp;&nbsp;wakeuptimer&nbsp;&nbsp; f&uuml;gt diverse Vorkonfigurationen auf Basis von RESIDENTS Toolkit hinzu. Siehe separate Sektion in der <a href="#RESIDENTS">RESIDENTS Modul Kommandoreferenz</a>. <b>create</b>
<li><i>locationMap</i>&nbsp;&nbsp; f&uuml;gt ein vorkonfiguriertes weblink Device hinzu, welches eine Google Map anzeigt, sofern die Readings locationLat+locationLong vorhanden sind.</li>
<li><i>wakeuptimer</i>&nbsp;&nbsp; f&uuml;gt diverse Vorkonfigurationen auf Basis von RESIDENTS Toolkit hinzu. Siehe separate Sektion in der <a href="#RESIDENTS">RESIDENTS Modul Kommandoreferenz</a>.</li>
</li> </li>
</ul> </ul>
<ul> <ul>