mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
ROOMMATE,GUEST: location readings
git-svn-id: https://svn.fhem.de/fhem/trunk@10328 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
33e1fdfabe
commit
0b68b24ea1
@ -925,7 +925,14 @@ sub GUEST_SetLocation($$$;$$$$$$) {
|
|||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
my $state = ReadingsVal( $name, "state", "initialized" );
|
my $state = ReadingsVal( $name, "state", "initialized" );
|
||||||
my $presence = ReadingsVal( $name, "presence", "present" );
|
my $presence = ReadingsVal( $name, "presence", "present" );
|
||||||
my $lastLocation = ReadingsVal( $name, "location", undef );
|
my $currLocation = ReadingsVal( $name, "location", "-" );
|
||||||
|
my $currLat = ReadingsVal( $name, "locationLat", "-" );
|
||||||
|
my $currLong = ReadingsVal( $name, "locationLong", "-" );
|
||||||
|
my $currAddr = ReadingsVal( $name, "locationAddr", "-" );
|
||||||
|
$id = "-" if ( !$id || $id eq "" );
|
||||||
|
$lat = "-" if ( !$lat || $lat eq "" );
|
||||||
|
$long = "-" if ( !$long || $long eq "" );
|
||||||
|
$address = "-" if ( !$address || $address eq "" );
|
||||||
$location = "underway" if ( $trigger eq "0" );
|
$location = "underway" if ( $trigger eq "0" );
|
||||||
|
|
||||||
Log3 $name, 5,
|
Log3 $name, 5,
|
||||||
@ -944,12 +951,26 @@ sub GUEST_SetLocation($$$;$$$$$$) {
|
|||||||
split( ' ', AttrVal( $name, "rr_locationWayhome", "wayhome" ) );
|
split( ' ', AttrVal( $name, "rr_locationWayhome", "wayhome" ) );
|
||||||
|
|
||||||
$searchstring = quotemeta($location);
|
$searchstring = quotemeta($location);
|
||||||
readingsBulkUpdate( $hash, "lastLocation", $lastLocation )
|
if ( $location ne "wayhome" ) {
|
||||||
if ( $lastLocation
|
if (
|
||||||
&& $location ne "wayhome"
|
!grep( m/^$searchstring$/, @location_underway )
|
||||||
&& !grep( m/^$searchstring$/, @location_underway ) );
|
&& ( $currLocation ne $location
|
||||||
readingsBulkUpdate( $hash, "location", $location )
|
|| $currLat ne $lat
|
||||||
if ( $location ne "wayhome" );
|
|| $currLong ne $long
|
||||||
|
|| $currAddr ne $address )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
readingsBulkUpdate( $hash, "lastLocation", $currLocation );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationLat", $currLat );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationLong", $currLong );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationAddr", $currAddr );
|
||||||
|
}
|
||||||
|
|
||||||
|
readingsBulkUpdate( $hash, "location", $location );
|
||||||
|
readingsBulkUpdate( $hash, "locationLat", $lat );
|
||||||
|
readingsBulkUpdate( $hash, "locationLong", $long );
|
||||||
|
readingsBulkUpdate( $hash, "locationAddr", $address );
|
||||||
|
}
|
||||||
|
|
||||||
# wayhome detection
|
# wayhome detection
|
||||||
$searchstring = quotemeta($location);
|
$searchstring = quotemeta($location);
|
||||||
|
@ -898,7 +898,14 @@ sub ROOMMATE_SetLocation($$$;$$$$$$) {
|
|||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
my $state = ReadingsVal( $name, "state", "initialized" );
|
my $state = ReadingsVal( $name, "state", "initialized" );
|
||||||
my $presence = ReadingsVal( $name, "presence", "present" );
|
my $presence = ReadingsVal( $name, "presence", "present" );
|
||||||
my $lastLocation = ReadingsVal( $name, "location", undef );
|
my $currLocation = ReadingsVal( $name, "location", "-" );
|
||||||
|
my $currLat = ReadingsVal( $name, "locationLat", "-" );
|
||||||
|
my $currLong = ReadingsVal( $name, "locationLong", "-" );
|
||||||
|
my $currAddr = ReadingsVal( $name, "locationAddr", "-" );
|
||||||
|
$id = "-" if ( !$id || $id eq "" );
|
||||||
|
$lat = "-" if ( !$lat || $lat eq "" );
|
||||||
|
$long = "-" if ( !$long || $long eq "" );
|
||||||
|
$address = "-" if ( !$address || $address eq "" );
|
||||||
$location = "underway" if ( $trigger eq "0" );
|
$location = "underway" if ( $trigger eq "0" );
|
||||||
|
|
||||||
Log3 $name, 5,
|
Log3 $name, 5,
|
||||||
@ -917,12 +924,26 @@ sub ROOMMATE_SetLocation($$$;$$$$$$) {
|
|||||||
split( ' ', AttrVal( $name, "rr_locationWayhome", "wayhome" ) );
|
split( ' ', AttrVal( $name, "rr_locationWayhome", "wayhome" ) );
|
||||||
|
|
||||||
$searchstring = quotemeta($location);
|
$searchstring = quotemeta($location);
|
||||||
readingsBulkUpdate( $hash, "lastLocation", $lastLocation )
|
if ( $location ne "wayhome" ) {
|
||||||
if ( $lastLocation
|
if (
|
||||||
&& $location ne "wayhome"
|
!grep( m/^$searchstring$/, @location_underway )
|
||||||
&& !grep( m/^$searchstring$/, @location_underway ) );
|
&& ( $currLocation ne $location
|
||||||
readingsBulkUpdate( $hash, "location", $location )
|
|| $currLat ne $lat
|
||||||
if ( $location ne "wayhome" );
|
|| $currLong ne $long
|
||||||
|
|| $currAddr ne $address )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
readingsBulkUpdate( $hash, "lastLocation", $currLocation );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationLat", $currLat );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationLong", $currLong );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationAddr", $currAddr );
|
||||||
|
}
|
||||||
|
|
||||||
|
readingsBulkUpdate( $hash, "location", $location );
|
||||||
|
readingsBulkUpdate( $hash, "locationLat", $lat );
|
||||||
|
readingsBulkUpdate( $hash, "locationLong", $long );
|
||||||
|
readingsBulkUpdate( $hash, "locationAddr", $address );
|
||||||
|
}
|
||||||
|
|
||||||
# wayhome detection
|
# wayhome detection
|
||||||
$searchstring = quotemeta($location);
|
$searchstring = quotemeta($location);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user