2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-08 01:14:19 +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";
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 {
'<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 =
$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($$) {
<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>
<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>
</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
</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>
</ul>
<ul>

View File

@ -327,8 +327,9 @@ sub ROOMMATE_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
@ -729,8 +730,12 @@ sub ROOMMATE_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;
@ -786,8 +791,38 @@ sub ROOMMATE_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 {
'<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 =
$timestampNow -
time_str2num(
ReadingsVal( $name, "lastArrival", "" ) );
time_str2num( ReadingsVal( $name, "lastArrival", "" ) );
}
# absence timer
@ -880,8 +914,7 @@ sub ROOMMATE_DurationTimer($;$) {
{
$durAbsence =
$timestampNow -
time_str2num(
ReadingsVal( $name, "lastDeparture", "" ) );
time_str2num( ReadingsVal( $name, "lastDeparture", "" ) );
}
# sleep timer
@ -890,8 +923,7 @@ sub ROOMMATE_DurationTimer($;$) {
{
$durSleep =
$timestampNow -
time_str2num(
ReadingsVal( $name, "lastSleep", "" ) );
time_str2num( ReadingsVal( $name, "lastSleep", "" ) );
}
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
</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>
</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
</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>
</ul>
<ul>