RESIDENTS,ROOMMATE,GUEST: fix readingsBeginUpdate
git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@10387 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -144,7 +144,7 @@ sub GUEST_Define($$) {
|
|||||||
|
|
||||||
# trigger for modified objects
|
# trigger for modified objects
|
||||||
unless ( $modified == 0 ) {
|
unless ( $modified == 0 ) {
|
||||||
readingsBulkUpdate( $hash, "state", $hash->{READINGS}{state}{VAL} );
|
readingsBulkUpdate( $hash, "state", ReadingsVal( $name, "state", "" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
readingsEndUpdate( $hash, 1 );
|
readingsEndUpdate( $hash, 1 );
|
||||||
@@ -256,24 +256,12 @@ sub GUEST_Notify($$) {
|
|||||||
###################################
|
###################################
|
||||||
sub GUEST_Set($@) {
|
sub GUEST_Set($@) {
|
||||||
my ( $hash, @a ) = @_;
|
my ( $hash, @a ) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $state =
|
my $state = ReadingsVal( $name, "state", "initialized" );
|
||||||
( defined( $hash->{READINGS}{state}{VAL} ) )
|
my $presence = ReadingsVal( $name, "presence", "undefined" );
|
||||||
? $hash->{READINGS}{state}{VAL}
|
my $mood = ReadingsVal( $name, "mood", "-" );
|
||||||
: "initialized";
|
my $location = ReadingsVal( $name, "location", "undefined" );
|
||||||
my $presence =
|
my $silent = 0;
|
||||||
( defined( $hash->{READINGS}{presence}{VAL} ) )
|
|
||||||
? $hash->{READINGS}{presence}{VAL}
|
|
||||||
: "undefined";
|
|
||||||
my $mood =
|
|
||||||
( defined( $hash->{READINGS}{mood}{VAL} ) )
|
|
||||||
? $hash->{READINGS}{mood}{VAL}
|
|
||||||
: "-";
|
|
||||||
my $location =
|
|
||||||
( defined( $hash->{READINGS}{location}{VAL} ) )
|
|
||||||
? $hash->{READINGS}{location}{VAL}
|
|
||||||
: "undefined";
|
|
||||||
my $silent = 0;
|
|
||||||
|
|
||||||
Log3 $name, 5, "GUEST $name: called function GUEST_Set()";
|
Log3 $name, 5, "GUEST $name: called function GUEST_Set()";
|
||||||
|
|
||||||
@@ -441,21 +429,22 @@ sub GUEST_Set($@) {
|
|||||||
|
|
||||||
# if prior state was asleep, update sleep statistics
|
# if prior state was asleep, update sleep statistics
|
||||||
if ( $state eq "asleep"
|
if ( $state eq "asleep"
|
||||||
&& defined( $hash->{READINGS}{lastSleep}{VAL} ) )
|
&& ReadingsVal( $name, "lastSleep", "" ) ne "" )
|
||||||
{
|
{
|
||||||
readingsBulkUpdate( $hash, "lastAwake", $datetime );
|
readingsBulkUpdate( $hash, "lastAwake", $datetime );
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$hash,
|
$hash,
|
||||||
"lastDurSleep",
|
"lastDurSleep",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime, $hash->{READINGS}{lastSleep}{VAL}
|
$datetime, ReadingsVal( $name, "lastSleep", "" )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$hash,
|
$hash,
|
||||||
"lastDurSleep_cr",
|
"lastDurSleep_cr",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime, $hash->{READINGS}{lastSleep}{VAL}, "min"
|
$datetime, ReadingsVal( $name, "lastSleep", "" ),
|
||||||
|
"min"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -517,7 +506,8 @@ sub GUEST_Set($@) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( !grep( m/^$searchstring$/, @location_underway )
|
if ( !$silent
|
||||||
|
&& !grep( m/^$searchstring$/, @location_underway )
|
||||||
&& $location ne $location_underway[0] )
|
&& $location ne $location_underway[0] )
|
||||||
{
|
{
|
||||||
Log3 $name, 4,
|
Log3 $name, 4,
|
||||||
@@ -529,9 +519,7 @@ sub GUEST_Set($@) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# reset wayhome
|
# reset wayhome
|
||||||
if ( !defined( $hash->{READINGS}{wayhome}{VAL} )
|
if ( ReadingsVal( $name, "wayhome", 1 ) > 0 ) {
|
||||||
|| $hash->{READINGS}{wayhome}{VAL} ne "0" )
|
|
||||||
{
|
|
||||||
readingsBulkUpdate( $hash, "wayhome", "0" );
|
readingsBulkUpdate( $hash, "wayhome", "0" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,14 +528,13 @@ sub GUEST_Set($@) {
|
|||||||
readingsBulkUpdate( $hash, "lastArrival", $datetime );
|
readingsBulkUpdate( $hash, "lastArrival", $datetime );
|
||||||
|
|
||||||
# absence duration
|
# absence duration
|
||||||
if ( defined( $hash->{READINGS}{lastDeparture}{VAL} )
|
if ( ReadingsVal( $name, "lastDeparture", "-" ) ne "-" ) {
|
||||||
&& $hash->{READINGS}{lastDeparture}{VAL} ne "-" )
|
|
||||||
{
|
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$hash,
|
$hash,
|
||||||
"lastDurAbsence",
|
"lastDurAbsence",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime, $hash->{READINGS}{lastDeparture}{VAL}
|
$datetime,
|
||||||
|
ReadingsVal( $name, "lastDeparture", "-" )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
@@ -555,7 +542,8 @@ sub GUEST_Set($@) {
|
|||||||
"lastDurAbsence_cr",
|
"lastDurAbsence_cr",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime,
|
$datetime,
|
||||||
$hash->{READINGS}{lastDeparture}{VAL}, "min"
|
ReadingsVal( $name, "lastDeparture", "-" ),
|
||||||
|
"min"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -564,22 +552,21 @@ sub GUEST_Set($@) {
|
|||||||
readingsBulkUpdate( $hash, "lastDeparture", $datetime );
|
readingsBulkUpdate( $hash, "lastDeparture", $datetime );
|
||||||
|
|
||||||
# presence duration
|
# presence duration
|
||||||
if ( defined( $hash->{READINGS}{lastArrival}{VAL} )
|
if ( ReadingsVal( $name, "lastArrival", "-" ) ne "-" ) {
|
||||||
&& $hash->{READINGS}{lastArrival}{VAL} ne "-" )
|
|
||||||
{
|
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$hash,
|
$hash,
|
||||||
"lastDurPresence",
|
"lastDurPresence",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime, $hash->{READINGS}{lastArrival}{VAL}
|
$datetime,
|
||||||
|
ReadingsVal( $name, "lastArrival", "-" )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$hash,
|
$hash,
|
||||||
"lastDurPresence_cr",
|
"lastDurPresence_cr",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime, $hash->{READINGS}{lastArrival}{VAL},
|
$datetime,
|
||||||
"min"
|
ReadingsVal( $name, "lastArrival", "-" ), "min"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -599,9 +586,8 @@ sub GUEST_Set($@) {
|
|||||||
&& defined( $defs{$object}{TYPE} )
|
&& defined( $defs{$object}{TYPE} )
|
||||||
&& ( $defs{$object}{TYPE} eq "ROOMMATE"
|
&& ( $defs{$object}{TYPE} eq "ROOMMATE"
|
||||||
|| $defs{$object}{TYPE} eq "GUEST" )
|
|| $defs{$object}{TYPE} eq "GUEST" )
|
||||||
&& defined( $defs{$object}{READINGS}{state}{VAL} )
|
&& ReadingsVal( $object, "state", "" ) ne "gone"
|
||||||
&& $defs{$object}{READINGS}{state}{VAL} ne "gone"
|
&& ReadingsVal( $object, "state", "" ) ne "none"
|
||||||
&& $defs{$object}{READINGS}{state}{VAL} ne "none"
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fhem("set $object $newstate");
|
fhem("set $object $newstate");
|
||||||
@@ -613,23 +599,23 @@ sub GUEST_Set($@) {
|
|||||||
# clear readings if guest is gone
|
# clear readings if guest is gone
|
||||||
if ( $newstate eq "none" ) {
|
if ( $newstate eq "none" ) {
|
||||||
readingsBulkUpdate( $hash, "lastArrival", "-" )
|
readingsBulkUpdate( $hash, "lastArrival", "-" )
|
||||||
if ( defined( $hash->{READINGS}{lastArrival}{VAL} ) );
|
if ( ReadingsVal( $name, "lastArrival", "-" ) ne "-" );
|
||||||
readingsBulkUpdate( $hash, "lastAwake", "-" )
|
readingsBulkUpdate( $hash, "lastAwake", "-" )
|
||||||
if ( defined( $hash->{READINGS}{lastAwake}{VAL} ) );
|
if ( ReadingsVal( $name, "lastAwake", "-" ) ne "-" );
|
||||||
readingsBulkUpdate( $hash, "lastDurAbsence", "-" )
|
readingsBulkUpdate( $hash, "lastDurAbsence", "-" )
|
||||||
if ( defined( $hash->{READINGS}{lastDurAbsence}{VAL} ) );
|
if ( ReadingsVal( $name, "lastDurAbsence", "-" ) ne "-" );
|
||||||
readingsBulkUpdate( $hash, "lastDurSleep", "-" )
|
readingsBulkUpdate( $hash, "lastDurSleep", "-" )
|
||||||
if ( defined( $hash->{READINGS}{lastDurSleep}{VAL} ) );
|
if ( ReadingsVal( $name, "lastDurSleep", "-" ) ne "-" );
|
||||||
readingsBulkUpdate( $hash, "lastLocation", "-" )
|
readingsBulkUpdate( $hash, "lastLocation", "-" )
|
||||||
if ( defined( $hash->{READINGS}{lastLocation}{VAL} ) );
|
if ( ReadingsVal( $name, "lastLocation", "-" ) ne "-" );
|
||||||
readingsBulkUpdate( $hash, "lastSleep", "-" )
|
readingsBulkUpdate( $hash, "lastSleep", "-" )
|
||||||
if ( defined( $hash->{READINGS}{lastSleep}{VAL} ) );
|
if ( ReadingsVal( $name, "lastSleep", "-" ) ne "-" );
|
||||||
readingsBulkUpdate( $hash, "lastMood", "-" )
|
readingsBulkUpdate( $hash, "lastMood", "-" )
|
||||||
if ( defined( $hash->{READINGS}{lastMood}{VAL} ) );
|
if ( ReadingsVal( $name, "lastMood", "-" ) ne "-" );
|
||||||
readingsBulkUpdate( $hash, "location", "-" )
|
readingsBulkUpdate( $hash, "location", "-" )
|
||||||
if ( defined( $hash->{READINGS}{location}{VAL} ) );
|
if ( ReadingsVal( $name, "location", "-" ) ne "-" );
|
||||||
readingsBulkUpdate( $hash, "mood", "-" )
|
readingsBulkUpdate( $hash, "mood", "-" )
|
||||||
if ( defined( $hash->{READINGS}{mood}{VAL} ) );
|
if ( ReadingsVal( $name, "mood", "-" ) ne "-" );
|
||||||
}
|
}
|
||||||
|
|
||||||
# calculate duration timers
|
# calculate duration timers
|
||||||
@@ -653,12 +639,12 @@ sub GUEST_Set($@) {
|
|||||||
Log3 $name, 2, "GUEST set $name mood " . $a[2] if ( !$silent );
|
Log3 $name, 2, "GUEST set $name mood " . $a[2] if ( !$silent );
|
||||||
readingsBeginUpdate($hash) if ( !$silent );
|
readingsBeginUpdate($hash) if ( !$silent );
|
||||||
|
|
||||||
if ( $a[2] eq "toggle" ) {
|
if ( $a[2] eq "toggle"
|
||||||
if ( defined( $hash->{READINGS}{lastMood}{VAL} ) ) {
|
&& ReadingsVal( $name, "lastMood", "" ) ne "" )
|
||||||
readingsBulkUpdate( $hash, "mood",
|
{
|
||||||
$hash->{READINGS}{lastMood}{VAL} );
|
readingsBulkUpdate( $hash, "mood",
|
||||||
readingsBulkUpdate( $hash, "lastMood", $mood );
|
ReadingsVal( $name, "lastMood", "" ) );
|
||||||
}
|
readingsBulkUpdate( $hash, "lastMood", $mood );
|
||||||
}
|
}
|
||||||
elsif ( $mood ne $a[2] ) {
|
elsif ( $mood ne $a[2] ) {
|
||||||
readingsBulkUpdate( $hash, "lastMood", $mood )
|
readingsBulkUpdate( $hash, "lastMood", $mood )
|
||||||
@@ -676,13 +662,91 @@ sub GUEST_Set($@) {
|
|||||||
# location
|
# location
|
||||||
elsif ( $a[1] eq "location" ) {
|
elsif ( $a[1] eq "location" ) {
|
||||||
if ( defined( $a[2] ) && $a[2] ne "" ) {
|
if ( defined( $a[2] ) && $a[2] ne "" ) {
|
||||||
shift @a;
|
Log3 $name, 2, "GUEST set $name location " . $a[2] if ( !$silent );
|
||||||
shift @a;
|
|
||||||
my $location = join( " ", @a );
|
|
||||||
Log3 $name, 2, "ROOMMATE set $name location " . $location
|
|
||||||
if ( !$silent );
|
|
||||||
|
|
||||||
GUEST_SetLocation( $name, $location, 1, undef );
|
if ( $location ne $a[2] ) {
|
||||||
|
my $searchstring;
|
||||||
|
|
||||||
|
readingsBeginUpdate($hash) if ( !$silent );
|
||||||
|
|
||||||
|
# read attributes
|
||||||
|
my @location_home =
|
||||||
|
( defined( $attr{$name}{"rg_locationHome"} ) )
|
||||||
|
? split( ' ', $attr{$name}{"rg_locationHome"} )
|
||||||
|
: ("home");
|
||||||
|
|
||||||
|
my @location_underway =
|
||||||
|
( defined( $attr{$name}{"rg_locationUnderway"} ) )
|
||||||
|
? split( ' ', $attr{$name}{"rg_locationUnderway"} )
|
||||||
|
: ("underway");
|
||||||
|
|
||||||
|
my @location_wayhome =
|
||||||
|
( defined( $attr{$name}{"rg_locationWayhome"} ) )
|
||||||
|
? split( ' ', $attr{$name}{"rg_locationWayhome"} )
|
||||||
|
: ("wayhome");
|
||||||
|
|
||||||
|
$searchstring = quotemeta($location);
|
||||||
|
readingsBulkUpdate( $hash, "lastLocation", $location )
|
||||||
|
if ( $location ne "wayhome"
|
||||||
|
&& !grep( m/^$searchstring$/, @location_underway ) );
|
||||||
|
readingsBulkUpdate( $hash, "location", $a[2] )
|
||||||
|
if ( $a[2] ne "wayhome" );
|
||||||
|
|
||||||
|
# wayhome detection
|
||||||
|
$searchstring = quotemeta($location);
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
$a[2] eq "wayhome"
|
||||||
|
|| grep( m/^$searchstring$/, @location_wayhome )
|
||||||
|
)
|
||||||
|
&& ( $presence eq "absent" )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Log3 $name, 3,
|
||||||
|
"GUEST $name: on way back home from $location";
|
||||||
|
readingsBulkUpdate( $hash, "wayhome", "1" )
|
||||||
|
if ( !defined( $hash->{READINGS}{wayhome}{VAL} )
|
||||||
|
|| $hash->{READINGS}{wayhome}{VAL} ne "1" );
|
||||||
|
}
|
||||||
|
|
||||||
|
readingsEndUpdate( $hash, 1 ) if ( !$silent );
|
||||||
|
|
||||||
|
# auto-updates
|
||||||
|
$searchstring = quotemeta( $a[2] );
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
$a[2] eq "home"
|
||||||
|
|| grep( m/^$searchstring$/, @location_home )
|
||||||
|
)
|
||||||
|
&& $state ne "home"
|
||||||
|
&& $state ne "gotosleep"
|
||||||
|
&& $state ne "asleep"
|
||||||
|
&& $state ne "awoken"
|
||||||
|
&& $state ne "initialized"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Log3 $name, 4,
|
||||||
|
"GUEST $name: implicit state change caused by location "
|
||||||
|
. $a[2];
|
||||||
|
GUEST_Set( $hash, $name, "silentSet", "state", "home" );
|
||||||
|
}
|
||||||
|
elsif (
|
||||||
|
(
|
||||||
|
$a[2] eq "underway"
|
||||||
|
|| grep( m/^$searchstring$/, @location_underway )
|
||||||
|
)
|
||||||
|
&& $state ne "gone"
|
||||||
|
&& $state ne "none"
|
||||||
|
&& $state ne "absent"
|
||||||
|
&& $state ne "initialized"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Log3 $name, 4,
|
||||||
|
"GUEST $name: implicit state change caused by location "
|
||||||
|
. $a[2];
|
||||||
|
GUEST_Set( $hash, $name, "silentSet", "state", "absent" );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "Invalid 2nd argument, choose one of location ";
|
return "Invalid 2nd argument, choose one of location ";
|
||||||
@@ -774,9 +838,7 @@ sub GUEST_AutoGone($;$) {
|
|||||||
|
|
||||||
RESIDENTStk_RemoveInternalTimer( "AutoGone", $hash );
|
RESIDENTStk_RemoveInternalTimer( "AutoGone", $hash );
|
||||||
|
|
||||||
if ( defined( $hash->{READINGS}{state}{VAL} )
|
if ( ReadingsVal( $name, "state", "home" ) eq "absent" ) {
|
||||||
&& $hash->{READINGS}{state}{VAL} eq "absent" )
|
|
||||||
{
|
|
||||||
my ( $date, $time, $y, $m, $d, $hour, $min, $sec, $timestamp,
|
my ( $date, $time, $y, $m, $d, $hour, $min, $sec, $timestamp,
|
||||||
$timeDiff );
|
$timeDiff );
|
||||||
my $timestampNow = gettimeofday();
|
my $timestampNow = gettimeofday();
|
||||||
@@ -812,13 +874,10 @@ sub GUEST_AutoGone($;$) {
|
|||||||
###################################
|
###################################
|
||||||
sub GUEST_DurationTimer($;$) {
|
sub GUEST_DurationTimer($;$) {
|
||||||
my ( $mHash, @a ) = @_;
|
my ( $mHash, @a ) = @_;
|
||||||
my $hash = ( $mHash->{HASH} ) ? $mHash->{HASH} : $mHash;
|
my $hash = ( $mHash->{HASH} ) ? $mHash->{HASH} : $mHash;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $state =
|
my $state = ReadingsVal( $name, "state", "initialized" );
|
||||||
( $hash->{READINGS}{state}{VAL} )
|
my $silent = ( defined( $a[0] ) && $a[0] eq "1" ) ? 1 : 0;
|
||||||
? $hash->{READINGS}{state}{VAL}
|
|
||||||
: "initialized";
|
|
||||||
my $silent = ( defined( $a[0] ) && $a[0] eq "1" ) ? 1 : 0;
|
|
||||||
my $timestampNow = gettimeofday();
|
my $timestampNow = gettimeofday();
|
||||||
my $diff;
|
my $diff;
|
||||||
my $durPresence = "0";
|
my $durPresence = "0";
|
||||||
@@ -832,47 +891,33 @@ sub GUEST_DurationTimer($;$) {
|
|||||||
{
|
{
|
||||||
|
|
||||||
# presence timer
|
# presence timer
|
||||||
if ( defined( $hash->{READINGS}{presence}{VAL} )
|
if ( ReadingsVal( $name, "presence", "absent" ) eq "present"
|
||||||
&& $hash->{READINGS}{presence}{VAL} eq "present" )
|
&& ReadingsVal( $name, "lastArrival", "-" ) ne "-" )
|
||||||
{
|
{
|
||||||
if ( defined( $hash->{READINGS}{lastArrival}{VAL} )
|
$durPresence =
|
||||||
&& $hash->{READINGS}{lastArrival}{VAL} ne "-" )
|
$timestampNow -
|
||||||
{
|
RESIDENTStk_Datetime2Timestamp(
|
||||||
$durPresence =
|
ReadingsVal( $name, "lastArrival", "-" ) );
|
||||||
$timestampNow -
|
|
||||||
RESIDENTStk_Datetime2Timestamp(
|
|
||||||
$hash->{READINGS}{lastArrival}{VAL} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# absence timer
|
# absence timer
|
||||||
if ( defined( $hash->{READINGS}{presence}{VAL} )
|
if ( ReadingsVal( $name, "presence", "present" ) eq "absent"
|
||||||
&& $hash->{READINGS}{presence}{VAL} eq "absent"
|
&& ReadingsVal( $name, "lastDeparture", "-" ) ne "-" )
|
||||||
&& defined( $hash->{READINGS}{state}{VAL} )
|
|
||||||
&& $hash->{READINGS}{state}{VAL} eq "absent" )
|
|
||||||
{
|
{
|
||||||
if ( defined( $hash->{READINGS}{lastDeparture}{VAL} )
|
$durAbsence =
|
||||||
&& $hash->{READINGS}{lastDeparture}{VAL} ne "-" )
|
$timestampNow -
|
||||||
{
|
RESIDENTStk_Datetime2Timestamp(
|
||||||
$durAbsence =
|
ReadingsVal( $name, "lastDeparture", "-" ) );
|
||||||
$timestampNow -
|
|
||||||
RESIDENTStk_Datetime2Timestamp(
|
|
||||||
$hash->{READINGS}{lastDeparture}{VAL} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# sleep timer
|
# sleep timer
|
||||||
if ( defined( $hash->{READINGS}{state}{VAL} )
|
if ( ReadingsVal( $name, "state", "home" ) eq "asleep"
|
||||||
&& $hash->{READINGS}{state}{VAL} eq "asleep" )
|
&& ReadingsVal( $name, "lastSleep", "-" ) ne "-" )
|
||||||
{
|
{
|
||||||
if ( defined( $hash->{READINGS}{lastSleep}{VAL} )
|
$durSleep =
|
||||||
&& $hash->{READINGS}{lastSleep}{VAL} ne "-" )
|
$timestampNow -
|
||||||
{
|
RESIDENTStk_Datetime2Timestamp(
|
||||||
$durSleep =
|
ReadingsVal( $name, "lastSleep", "-" ) );
|
||||||
$timestampNow -
|
|
||||||
RESIDENTStk_Datetime2Timestamp(
|
|
||||||
$hash->{READINGS}{lastSleep}{VAL} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $durPresence_hr =
|
my $durPresence_hr =
|
||||||
@@ -891,23 +936,20 @@ sub GUEST_DurationTimer($;$) {
|
|||||||
|
|
||||||
readingsBeginUpdate($hash) if ( !$silent );
|
readingsBeginUpdate($hash) if ( !$silent );
|
||||||
readingsBulkUpdate( $hash, "durTimerPresence_cr", $durPresence_cr )
|
readingsBulkUpdate( $hash, "durTimerPresence_cr", $durPresence_cr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerPresence_cr}{VAL} )
|
if ( ReadingsVal( $name, "durTimerPresence_cr", "" ) ne
|
||||||
|| $hash->{READINGS}{durTimerPresence_cr}{VAL} ne $durPresence_cr );
|
$durPresence_cr );
|
||||||
readingsBulkUpdate( $hash, "durTimerPresence", $durPresence_hr )
|
readingsBulkUpdate( $hash, "durTimerPresence", $durPresence_hr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerPresence}{VAL} )
|
if (
|
||||||
|| $hash->{READINGS}{durTimerPresence}{VAL} ne $durPresence_hr );
|
ReadingsVal( $name, "durTimerPresence", "" ) ne $durPresence_hr );
|
||||||
readingsBulkUpdate( $hash, "durTimerAbsence_cr", $durAbsence_cr )
|
readingsBulkUpdate( $hash, "durTimerAbsence_cr", $durAbsence_cr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerAbsence_cr}{VAL} )
|
if (
|
||||||
|| $hash->{READINGS}{durTimerAbsence_cr}{VAL} ne $durAbsence_cr );
|
ReadingsVal( $name, "durTimerAbsence_cr", "" ) ne $durAbsence_cr );
|
||||||
readingsBulkUpdate( $hash, "durTimerAbsence", $durAbsence_hr )
|
readingsBulkUpdate( $hash, "durTimerAbsence", $durAbsence_hr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerAbsence}{VAL} )
|
if ( ReadingsVal( $name, "durTimerAbsence", "" ) ne $durAbsence_hr );
|
||||||
|| $hash->{READINGS}{durTimerAbsence}{VAL} ne $durAbsence_hr );
|
|
||||||
readingsBulkUpdate( $hash, "durTimerSleep_cr", $durSleep_cr )
|
readingsBulkUpdate( $hash, "durTimerSleep_cr", $durSleep_cr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerSleep_cr}{VAL} )
|
if ( ReadingsVal( $name, "durTimerSleep_cr", "" ) ne $durSleep_cr );
|
||||||
|| $hash->{READINGS}{durTimerSleep_cr}{VAL} ne $durSleep_cr );
|
|
||||||
readingsBulkUpdate( $hash, "durTimerSleep", $durSleep_hr )
|
readingsBulkUpdate( $hash, "durTimerSleep", $durSleep_hr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerSleep}{VAL} )
|
if ( ReadingsVal( $name, "durTimerSleep", "" ) ne $durSleep_hr );
|
||||||
|| $hash->{READINGS}{durTimerSleep}{VAL} ne $durSleep_hr );
|
|
||||||
readingsEndUpdate( $hash, 1 ) if ( !$silent );
|
readingsEndUpdate( $hash, 1 ) if ( !$silent );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -933,7 +975,8 @@ sub GUEST_SetLocation($$$;$$$$$$) {
|
|||||||
$lat = "-" if ( !$lat || $lat eq "" );
|
$lat = "-" if ( !$lat || $lat eq "" );
|
||||||
$long = "-" if ( !$long || $long eq "" );
|
$long = "-" if ( !$long || $long eq "" );
|
||||||
$address = "-" if ( !$address || $address eq "" );
|
$address = "-" if ( !$address || $address eq "" );
|
||||||
$location = "underway" if ( $trigger eq "0" );
|
$time = "" if ( !$time );
|
||||||
|
$device = "" if ( !$device );
|
||||||
|
|
||||||
Log3 $name, 5,
|
Log3 $name, 5,
|
||||||
"GUEST $name: received location information: id=$id name=$location trig=$trigger date=$time lat=$lat long=$long address:$address device=$device";
|
"GUEST $name: received location information: id=$id name=$location trig=$trigger date=$time lat=$lat long=$long address:$address device=$device";
|
||||||
@@ -944,63 +987,41 @@ sub GUEST_SetLocation($$$;$$$$$$) {
|
|||||||
|
|
||||||
# read attributes
|
# read attributes
|
||||||
my @location_home =
|
my @location_home =
|
||||||
split( ' ', AttrVal( $name, "rr_locationHome", "home" ) );
|
split( ' ', AttrVal( $name, "rg_locationHome", "home" ) );
|
||||||
my @location_underway =
|
my @location_underway =
|
||||||
split( ' ', AttrVal( $name, "rr_locationUnderway", "underway" ) );
|
split( ' ', AttrVal( $name, "rg_locationUnderway", "underway" ) );
|
||||||
my @location_wayhome =
|
my @location_wayhome =
|
||||||
split( ' ', AttrVal( $name, "rr_locationWayhome", "wayhome" ) );
|
split( ' ', AttrVal( $name, "rg_locationWayhome", "wayhome" ) );
|
||||||
|
|
||||||
$searchstring = quotemeta($location);
|
$searchstring = quotemeta($location);
|
||||||
if ( $location ne "wayhome" ) {
|
|
||||||
if (
|
|
||||||
!grep( m/^$searchstring$/, @location_underway )
|
|
||||||
&& ( $currLocation ne $location
|
|
||||||
|| $currLat ne $lat
|
|
||||||
|| $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 );
|
# check for implicit state change
|
||||||
readingsBulkUpdate( $hash, "locationLat", $lat );
|
#
|
||||||
readingsBulkUpdate( $hash, "locationLong", $long );
|
my $stateChange = 0;
|
||||||
readingsBulkUpdate( $hash, "locationAddr", $address );
|
|
||||||
}
|
|
||||||
|
|
||||||
# wayhome detection
|
# home/1
|
||||||
$searchstring = quotemeta($location);
|
|
||||||
if (
|
|
||||||
(
|
|
||||||
$location eq "wayhome"
|
|
||||||
|| grep( m/^$searchstring$/, @location_wayhome )
|
|
||||||
)
|
|
||||||
&& ( $presence eq "absent" )
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Log3 $name, 3, "GUEST $name: on way back home from $location";
|
|
||||||
readingsBulkUpdate( $hash, "wayhome", "1" )
|
|
||||||
if ( ReadingsVal( $name, "wayhome", "0" ) ne "1" );
|
|
||||||
}
|
|
||||||
|
|
||||||
readingsEndUpdate( $hash, 1 );
|
|
||||||
|
|
||||||
# auto-updates
|
|
||||||
$searchstring = quotemeta($location);
|
|
||||||
if ( ( $location eq "home" || grep( m/^$searchstring$/, @location_home ) )
|
if ( ( $location eq "home" || grep( m/^$searchstring$/, @location_home ) )
|
||||||
&& $state ne "home"
|
&& $state ne "home"
|
||||||
&& $state ne "gotosleep"
|
&& $state ne "gotosleep"
|
||||||
&& $state ne "asleep"
|
&& $state ne "asleep"
|
||||||
&& $state ne "awoken" )
|
&& $state ne "awoken"
|
||||||
|
&& $trigger eq "1" )
|
||||||
{
|
{
|
||||||
Log3 $name, 4,
|
$stateChange = 1;
|
||||||
"GUEST $name: implicit state change caused by location " . $location;
|
|
||||||
GUEST_Set( $hash, $name, "silentSet", "state", "home" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# home/0
|
||||||
|
elsif (
|
||||||
|
( $location eq "home" || grep( m/^$searchstring$/, @location_home ) )
|
||||||
|
&& $state ne "gone"
|
||||||
|
&& $state ne "none"
|
||||||
|
&& $state ne "absent"
|
||||||
|
&& $trigger eq "0" )
|
||||||
|
{
|
||||||
|
$stateChange = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
# absent
|
||||||
elsif (
|
elsif (
|
||||||
(
|
(
|
||||||
$location eq "underway"
|
$location eq "underway"
|
||||||
@@ -1011,9 +1032,87 @@ sub GUEST_SetLocation($$$;$$$$$$) {
|
|||||||
&& $state ne "absent"
|
&& $state ne "absent"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
$stateChange = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
# wayhome
|
||||||
|
my $wayhome;
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
$location eq "wayhome"
|
||||||
|
|| ( grep( m/^$searchstring$/, @location_wayhome )
|
||||||
|
&& $trigger eq "0" )
|
||||||
|
)
|
||||||
|
&& $presence eq "absent"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Log3 $name, 5, "GUEST $name: wayhome signal received";
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
( $location eq "wayhome" && $trigger eq "1" )
|
||||||
|
|| ( $location ne "wayhome" && $trigger eq "0" )
|
||||||
|
)
|
||||||
|
&& ReadingsVal( $name, "wayhome", "0" ) ne "1"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Log3 $name, 3, "GUEST $name: on way back home from $location";
|
||||||
|
readingsBulkUpdate( $hash, "wayhome", "1" );
|
||||||
|
$wayhome = 1;
|
||||||
|
}
|
||||||
|
elsif ($location eq "wayhome"
|
||||||
|
&& $trigger eq "0"
|
||||||
|
&& ReadingsVal( $name, "wayhome", "0" ) ne "0" )
|
||||||
|
{
|
||||||
|
Log3 $name, 3,
|
||||||
|
"GUEST $name: seems not to be on way back home anymore";
|
||||||
|
readingsBulkUpdate( $hash, "wayhome", "0" );
|
||||||
|
$wayhome = 1;
|
||||||
|
$location = "underway";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !grep( m/^$searchstring$/, @location_underway )
|
||||||
|
&& ( $stateChange > 0 || $currLocation ne $location ) )
|
||||||
|
{
|
||||||
|
Log3 $name, 5, "GUEST $name: archiving last known location";
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationLat", $currLat );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationLong", $currLong );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationAddr", $currAddr );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocation", $currLocation );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $wayhome
|
||||||
|
|| $stateChange > 0
|
||||||
|
|| ( $lat ne "-" && $long ne "-" ) )
|
||||||
|
{
|
||||||
|
Log3 $name, 5, "GUEST $name: Using new lat/long/addr information";
|
||||||
|
readingsBulkUpdate( $hash, "locationLat", $lat );
|
||||||
|
readingsBulkUpdate( $hash, "locationLong", $long );
|
||||||
|
readingsBulkUpdate( $hash, "locationAddr", $address );
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
Log3 $name, 5,
|
||||||
|
"GUEST $name: keeping last known lat/long/addr information";
|
||||||
|
readingsBulkUpdate( $hash, "locationLat", $currLat );
|
||||||
|
readingsBulkUpdate( $hash, "locationLong", $currLong );
|
||||||
|
readingsBulkUpdate( $hash, "locationAddr", $currAddr );
|
||||||
|
}
|
||||||
|
|
||||||
|
readingsBulkUpdate( $hash, "location", $location )
|
||||||
|
if ( $location ne "wayhome" );
|
||||||
|
|
||||||
|
readingsEndUpdate( $hash, 1 );
|
||||||
|
|
||||||
|
# trigger state change
|
||||||
|
if ( $stateChange > 0 ) {
|
||||||
Log3 $name, 4,
|
Log3 $name, 4,
|
||||||
"GUEST $name: implicit state change caused by location " . $location;
|
"GUEST $name: implicit state change caused by location " . $location;
|
||||||
GUEST_Set( $hash, $name, "silentSet", "state", "absent" );
|
|
||||||
|
GUEST_Set( $hash, $name, "silentSet", "state", "home" )
|
||||||
|
if $stateChange == 1;
|
||||||
|
GUEST_Set( $hash, $name, "silentSet", "state", "absent" )
|
||||||
|
if $stateChange == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ sub ROOMMATE_Define($$) {
|
|||||||
|
|
||||||
# trigger for modified objects
|
# trigger for modified objects
|
||||||
unless ( $modified == 0 ) {
|
unless ( $modified == 0 ) {
|
||||||
readingsBulkUpdate( $hash, "state", $hash->{READINGS}{state}{VAL} );
|
readingsBulkUpdate( $hash, "state", ReadingsVal( $name, "state", "" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
readingsEndUpdate( $hash, 1 );
|
readingsEndUpdate( $hash, 1 );
|
||||||
@@ -261,24 +261,12 @@ sub ROOMMATE_Notify($$) {
|
|||||||
###################################
|
###################################
|
||||||
sub ROOMMATE_Set($@) {
|
sub ROOMMATE_Set($@) {
|
||||||
my ( $hash, @a ) = @_;
|
my ( $hash, @a ) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $state =
|
my $state = ReadingsVal( $name, "state", "initialized" );
|
||||||
( defined( $hash->{READINGS}{state}{VAL} ) )
|
my $presence = ReadingsVal( $name, "presence", "undefined" );
|
||||||
? $hash->{READINGS}{state}{VAL}
|
my $mood = ReadingsVal( $name, "mood", "-" );
|
||||||
: "initialized";
|
my $location = ReadingsVal( $name, "location", "undefined" );
|
||||||
my $presence =
|
my $silent = 0;
|
||||||
( defined( $hash->{READINGS}{presence}{VAL} ) )
|
|
||||||
? $hash->{READINGS}{presence}{VAL}
|
|
||||||
: "undefined";
|
|
||||||
my $mood =
|
|
||||||
( defined( $hash->{READINGS}{mood}{VAL} ) )
|
|
||||||
? $hash->{READINGS}{mood}{VAL}
|
|
||||||
: "-";
|
|
||||||
my $location =
|
|
||||||
( defined( $hash->{READINGS}{location}{VAL} ) )
|
|
||||||
? $hash->{READINGS}{location}{VAL}
|
|
||||||
: "undefined";
|
|
||||||
my $silent = 0;
|
|
||||||
|
|
||||||
Log3 $name, 5, "ROOMMATE $name: called function ROOMMATE_Set()";
|
Log3 $name, 5, "ROOMMATE $name: called function ROOMMATE_Set()";
|
||||||
|
|
||||||
@@ -443,21 +431,22 @@ sub ROOMMATE_Set($@) {
|
|||||||
|
|
||||||
# if prior state was asleep, update sleep statistics
|
# if prior state was asleep, update sleep statistics
|
||||||
if ( $state eq "asleep"
|
if ( $state eq "asleep"
|
||||||
&& defined( $hash->{READINGS}{lastSleep}{VAL} ) )
|
&& ReadingsVal( $name, "lastSleep", "" ) ne "" )
|
||||||
{
|
{
|
||||||
readingsBulkUpdate( $hash, "lastAwake", $datetime );
|
readingsBulkUpdate( $hash, "lastAwake", $datetime );
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$hash,
|
$hash,
|
||||||
"lastDurSleep",
|
"lastDurSleep",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime, $hash->{READINGS}{lastSleep}{VAL}
|
$datetime, ReadingsVal( $name, "lastSleep", "" )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$hash,
|
$hash,
|
||||||
"lastDurSleep_cr",
|
"lastDurSleep_cr",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime, $hash->{READINGS}{lastSleep}{VAL}, "min"
|
$datetime, ReadingsVal( $name, "lastSleep", "" ),
|
||||||
|
"min"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -507,7 +496,7 @@ sub ROOMMATE_Set($@) {
|
|||||||
: ("underway");
|
: ("underway");
|
||||||
my $searchstring = quotemeta($location);
|
my $searchstring = quotemeta($location);
|
||||||
|
|
||||||
if ( $newpresence eq "present" ) {
|
if ( !$silent && $newpresence eq "present" ) {
|
||||||
if ( !grep( m/^$searchstring$/, @location_home )
|
if ( !grep( m/^$searchstring$/, @location_home )
|
||||||
&& $location ne $location_home[0] )
|
&& $location ne $location_home[0] )
|
||||||
{
|
{
|
||||||
@@ -519,7 +508,8 @@ sub ROOMMATE_Set($@) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( !grep( m/^$searchstring$/, @location_underway )
|
if ( !$silent
|
||||||
|
&& !grep( m/^$searchstring$/, @location_underway )
|
||||||
&& $location ne $location_underway[0] )
|
&& $location ne $location_underway[0] )
|
||||||
{
|
{
|
||||||
Log3 $name, 4,
|
Log3 $name, 4,
|
||||||
@@ -531,9 +521,7 @@ sub ROOMMATE_Set($@) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# reset wayhome
|
# reset wayhome
|
||||||
if ( !defined( $hash->{READINGS}{wayhome}{VAL} )
|
if ( ReadingsVal( $name, "wayhome", 1 ) > 0 ) {
|
||||||
|| $hash->{READINGS}{wayhome}{VAL} ne "0" )
|
|
||||||
{
|
|
||||||
readingsBulkUpdate( $hash, "wayhome", "0" );
|
readingsBulkUpdate( $hash, "wayhome", "0" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,14 +530,13 @@ sub ROOMMATE_Set($@) {
|
|||||||
readingsBulkUpdate( $hash, "lastArrival", $datetime );
|
readingsBulkUpdate( $hash, "lastArrival", $datetime );
|
||||||
|
|
||||||
# absence duration
|
# absence duration
|
||||||
if ( defined( $hash->{READINGS}{lastDeparture}{VAL} )
|
if ( ReadingsVal( $name, "lastDeparture", "-" ) ne "-" ) {
|
||||||
&& $hash->{READINGS}{lastDeparture}{VAL} ne "-" )
|
|
||||||
{
|
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$hash,
|
$hash,
|
||||||
"lastDurAbsence",
|
"lastDurAbsence",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime, $hash->{READINGS}{lastDeparture}{VAL}
|
$datetime,
|
||||||
|
ReadingsVal( $name, "lastDeparture", "-" )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
@@ -557,7 +544,8 @@ sub ROOMMATE_Set($@) {
|
|||||||
"lastDurAbsence_cr",
|
"lastDurAbsence_cr",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime,
|
$datetime,
|
||||||
$hash->{READINGS}{lastDeparture}{VAL}, "min"
|
ReadingsVal( $name, "lastDeparture", "-" ),
|
||||||
|
"min"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -566,22 +554,21 @@ sub ROOMMATE_Set($@) {
|
|||||||
readingsBulkUpdate( $hash, "lastDeparture", $datetime );
|
readingsBulkUpdate( $hash, "lastDeparture", $datetime );
|
||||||
|
|
||||||
# presence duration
|
# presence duration
|
||||||
if ( defined( $hash->{READINGS}{lastArrival}{VAL} )
|
if ( ReadingsVal( $name, "lastArrival", "-" ) ne "-" ) {
|
||||||
&& $hash->{READINGS}{lastArrival}{VAL} ne "-" )
|
|
||||||
{
|
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$hash,
|
$hash,
|
||||||
"lastDurPresence",
|
"lastDurPresence",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime, $hash->{READINGS}{lastArrival}{VAL}
|
$datetime,
|
||||||
|
ReadingsVal( $name, "lastArrival", "-" )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$hash,
|
$hash,
|
||||||
"lastDurPresence_cr",
|
"lastDurPresence_cr",
|
||||||
RESIDENTStk_TimeDiff(
|
RESIDENTStk_TimeDiff(
|
||||||
$datetime, $hash->{READINGS}{lastArrival}{VAL},
|
$datetime,
|
||||||
"min"
|
ReadingsVal( $name, "lastArrival", "-" ), "min"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -601,9 +588,8 @@ sub ROOMMATE_Set($@) {
|
|||||||
&& defined( $defs{$object}{TYPE} )
|
&& defined( $defs{$object}{TYPE} )
|
||||||
&& ( $defs{$object}{TYPE} eq "ROOMMATE"
|
&& ( $defs{$object}{TYPE} eq "ROOMMATE"
|
||||||
|| $defs{$object}{TYPE} eq "GUEST" )
|
|| $defs{$object}{TYPE} eq "GUEST" )
|
||||||
&& defined( $defs{$object}{READINGS}{state}{VAL} )
|
&& ReadingsVal( $object, "state", "" ) ne "gone"
|
||||||
&& $defs{$object}{READINGS}{state}{VAL} ne "gone"
|
&& ReadingsVal( $object, "state", "" ) ne "none"
|
||||||
&& $defs{$object}{READINGS}{state}{VAL} ne "none"
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fhem("set $object $newstate");
|
fhem("set $object $newstate");
|
||||||
@@ -633,12 +619,12 @@ sub ROOMMATE_Set($@) {
|
|||||||
Log3 $name, 2, "ROOMMATE set $name mood " . $a[2] if ( !$silent );
|
Log3 $name, 2, "ROOMMATE set $name mood " . $a[2] if ( !$silent );
|
||||||
readingsBeginUpdate($hash) if ( !$silent );
|
readingsBeginUpdate($hash) if ( !$silent );
|
||||||
|
|
||||||
if ( $a[2] eq "toggle" ) {
|
if ( $a[2] eq "toggle"
|
||||||
if ( defined( $hash->{READINGS}{lastMood}{VAL} ) ) {
|
&& ReadingsVal( $name, "lastMood", "" ) ne "" )
|
||||||
readingsBulkUpdate( $hash, "mood",
|
{
|
||||||
$hash->{READINGS}{lastMood}{VAL} );
|
readingsBulkUpdate( $hash, "mood",
|
||||||
readingsBulkUpdate( $hash, "lastMood", $mood );
|
ReadingsVal( $name, "lastMood", "" ) );
|
||||||
}
|
readingsBulkUpdate( $hash, "lastMood", $mood );
|
||||||
}
|
}
|
||||||
elsif ( $mood ne $a[2] ) {
|
elsif ( $mood ne $a[2] ) {
|
||||||
readingsBulkUpdate( $hash, "lastMood", $mood )
|
readingsBulkUpdate( $hash, "lastMood", $mood )
|
||||||
@@ -656,13 +642,93 @@ sub ROOMMATE_Set($@) {
|
|||||||
# location
|
# location
|
||||||
elsif ( $a[1] eq "location" ) {
|
elsif ( $a[1] eq "location" ) {
|
||||||
if ( defined( $a[2] ) && $a[2] ne "" ) {
|
if ( defined( $a[2] ) && $a[2] ne "" ) {
|
||||||
shift @a;
|
Log3 $name, 2, "ROOMMATE set $name location " . $a[2]
|
||||||
shift @a;
|
|
||||||
my $location = join( " ", @a );
|
|
||||||
Log3 $name, 2, "ROOMMATE set $name location " . $location
|
|
||||||
if ( !$silent );
|
if ( !$silent );
|
||||||
|
|
||||||
ROOMMATE_SetLocation( $name, $location, 1, undef );
|
if ( $location ne $a[2] ) {
|
||||||
|
my $searchstring;
|
||||||
|
|
||||||
|
readingsBeginUpdate($hash) if ( !$silent );
|
||||||
|
|
||||||
|
# read attributes
|
||||||
|
my @location_home =
|
||||||
|
( defined( $attr{$name}{"rr_locationHome"} ) )
|
||||||
|
? split( ' ', $attr{$name}{"rr_locationHome"} )
|
||||||
|
: ("home");
|
||||||
|
|
||||||
|
my @location_underway =
|
||||||
|
( defined( $attr{$name}{"rr_locationUnderway"} ) )
|
||||||
|
? split( ' ', $attr{$name}{"rr_locationUnderway"} )
|
||||||
|
: ("underway");
|
||||||
|
|
||||||
|
my @location_wayhome =
|
||||||
|
( defined( $attr{$name}{"rr_locationWayhome"} ) )
|
||||||
|
? split( ' ', $attr{$name}{"rr_locationWayhome"} )
|
||||||
|
: ("wayhome");
|
||||||
|
|
||||||
|
$searchstring = quotemeta($location);
|
||||||
|
readingsBulkUpdate( $hash, "lastLocation", $location )
|
||||||
|
if ( $location ne "wayhome"
|
||||||
|
&& !grep( m/^$searchstring$/, @location_underway ) );
|
||||||
|
readingsBulkUpdate( $hash, "location", $a[2] )
|
||||||
|
if ( $a[2] ne "wayhome" );
|
||||||
|
|
||||||
|
# wayhome detection
|
||||||
|
$searchstring = quotemeta($location);
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
$a[2] eq "wayhome"
|
||||||
|
|| grep( m/^$searchstring$/, @location_wayhome )
|
||||||
|
)
|
||||||
|
&& ( $presence eq "absent" )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Log3 $name, 3,
|
||||||
|
"ROOMMATE $name: on way back home from $location";
|
||||||
|
readingsBulkUpdate( $hash, "wayhome", "1" )
|
||||||
|
if ( !defined( $hash->{READINGS}{wayhome}{VAL} )
|
||||||
|
|| $hash->{READINGS}{wayhome}{VAL} ne "1" );
|
||||||
|
}
|
||||||
|
|
||||||
|
readingsEndUpdate( $hash, 1 ) if ( !$silent );
|
||||||
|
|
||||||
|
# auto-updates
|
||||||
|
$searchstring = quotemeta( $a[2] );
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
$a[2] eq "home"
|
||||||
|
|| grep( m/^$searchstring$/, @location_home )
|
||||||
|
)
|
||||||
|
&& $state ne "home"
|
||||||
|
&& $state ne "gotosleep"
|
||||||
|
&& $state ne "asleep"
|
||||||
|
&& $state ne "awoken"
|
||||||
|
&& $state ne "initialized"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Log3 $name, 4,
|
||||||
|
"ROOMMATE $name: implicit state change caused by location "
|
||||||
|
. $a[2];
|
||||||
|
ROOMMATE_Set( $hash, $name, "silentSet", "state", "home" );
|
||||||
|
}
|
||||||
|
elsif (
|
||||||
|
(
|
||||||
|
$a[2] eq "underway"
|
||||||
|
|| grep( m/^$searchstring$/, @location_underway )
|
||||||
|
)
|
||||||
|
&& $state ne "gone"
|
||||||
|
&& $state ne "none"
|
||||||
|
&& $state ne "absent"
|
||||||
|
&& $state ne "initialized"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Log3 $name, 4,
|
||||||
|
"ROOMMATE $name: implicit state change caused by location "
|
||||||
|
. $a[2];
|
||||||
|
ROOMMATE_Set( $hash, $name, "silentSet", "state",
|
||||||
|
"absent" );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "Invalid 2nd argument, choose one of location ";
|
return "Invalid 2nd argument, choose one of location ";
|
||||||
@@ -754,9 +820,7 @@ sub ROOMMATE_AutoGone($;$) {
|
|||||||
|
|
||||||
RESIDENTStk_RemoveInternalTimer( "AutoGone", $hash );
|
RESIDENTStk_RemoveInternalTimer( "AutoGone", $hash );
|
||||||
|
|
||||||
if ( defined( $hash->{READINGS}{state}{VAL} )
|
if ( ReadingsVal( $name, "state", "home" ) eq "absent" ) {
|
||||||
&& $hash->{READINGS}{state}{VAL} eq "absent" )
|
|
||||||
{
|
|
||||||
my ( $date, $time, $y, $m, $d, $hour, $min, $sec, $timestamp,
|
my ( $date, $time, $y, $m, $d, $hour, $min, $sec, $timestamp,
|
||||||
$timeDiff );
|
$timeDiff );
|
||||||
my $timestampNow = gettimeofday();
|
my $timestampNow = gettimeofday();
|
||||||
@@ -808,45 +872,33 @@ sub ROOMMATE_DurationTimer($;$) {
|
|||||||
{
|
{
|
||||||
|
|
||||||
# presence timer
|
# presence timer
|
||||||
if ( defined( $hash->{READINGS}{presence}{VAL} )
|
if ( ReadingsVal( $name, "presence", "absent" ) eq "present"
|
||||||
&& $hash->{READINGS}{presence}{VAL} eq "present" )
|
&& ReadingsVal( $name, "lastArrival", "-" ) ne "-" )
|
||||||
{
|
{
|
||||||
if ( defined( $hash->{READINGS}{lastArrival}{VAL} )
|
$durPresence =
|
||||||
&& $hash->{READINGS}{lastArrival}{VAL} ne "-" )
|
$timestampNow -
|
||||||
{
|
RESIDENTStk_Datetime2Timestamp(
|
||||||
$durPresence =
|
ReadingsVal( $name, "lastArrival", "-" ) );
|
||||||
$timestampNow -
|
|
||||||
RESIDENTStk_Datetime2Timestamp(
|
|
||||||
$hash->{READINGS}{lastArrival}{VAL} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# absence timer
|
# absence timer
|
||||||
if ( defined( $hash->{READINGS}{presence}{VAL} )
|
if ( ReadingsVal( $name, "presence", "present" ) eq "absent"
|
||||||
&& $hash->{READINGS}{presence}{VAL} eq "absent" )
|
&& ReadingsVal( $name, "lastDeparture", "-" ) ne "-" )
|
||||||
{
|
{
|
||||||
if ( defined( $hash->{READINGS}{lastDeparture}{VAL} )
|
$durAbsence =
|
||||||
&& $hash->{READINGS}{lastDeparture}{VAL} ne "-" )
|
$timestampNow -
|
||||||
{
|
RESIDENTStk_Datetime2Timestamp(
|
||||||
$durAbsence =
|
ReadingsVal( $name, "lastDeparture", "-" ) );
|
||||||
$timestampNow -
|
|
||||||
RESIDENTStk_Datetime2Timestamp(
|
|
||||||
$hash->{READINGS}{lastDeparture}{VAL} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# sleep timer
|
# sleep timer
|
||||||
if ( defined( $hash->{READINGS}{state}{VAL} )
|
if ( ReadingsVal( $name, "state", "home" ) eq "asleep"
|
||||||
&& $hash->{READINGS}{state}{VAL} eq "asleep" )
|
&& ReadingsVal( $name, "lastSleep", "-" ) ne "-" )
|
||||||
{
|
{
|
||||||
if ( defined( $hash->{READINGS}{lastSleep}{VAL} )
|
$durSleep =
|
||||||
&& $hash->{READINGS}{lastSleep}{VAL} ne "-" )
|
$timestampNow -
|
||||||
{
|
RESIDENTStk_Datetime2Timestamp(
|
||||||
$durSleep =
|
ReadingsVal( $name, "lastSleep", "-" ) );
|
||||||
$timestampNow -
|
|
||||||
RESIDENTStk_Datetime2Timestamp(
|
|
||||||
$hash->{READINGS}{lastSleep}{VAL} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $durPresence_hr =
|
my $durPresence_hr =
|
||||||
@@ -865,23 +917,20 @@ sub ROOMMATE_DurationTimer($;$) {
|
|||||||
|
|
||||||
readingsBeginUpdate($hash) if ( !$silent );
|
readingsBeginUpdate($hash) if ( !$silent );
|
||||||
readingsBulkUpdate( $hash, "durTimerPresence_cr", $durPresence_cr )
|
readingsBulkUpdate( $hash, "durTimerPresence_cr", $durPresence_cr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerPresence_cr}{VAL} )
|
if ( ReadingsVal( $name, "durTimerPresence_cr", "" ) ne
|
||||||
|| $hash->{READINGS}{durTimerPresence_cr}{VAL} ne $durPresence_cr );
|
$durPresence_cr );
|
||||||
readingsBulkUpdate( $hash, "durTimerPresence", $durPresence_hr )
|
readingsBulkUpdate( $hash, "durTimerPresence", $durPresence_hr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerPresence}{VAL} )
|
if (
|
||||||
|| $hash->{READINGS}{durTimerPresence}{VAL} ne $durPresence_hr );
|
ReadingsVal( $name, "durTimerPresence", "" ) ne $durPresence_hr );
|
||||||
readingsBulkUpdate( $hash, "durTimerAbsence_cr", $durAbsence_cr )
|
readingsBulkUpdate( $hash, "durTimerAbsence_cr", $durAbsence_cr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerAbsence_cr}{VAL} )
|
if (
|
||||||
|| $hash->{READINGS}{durTimerAbsence_cr}{VAL} ne $durAbsence_cr );
|
ReadingsVal( $name, "durTimerAbsence_cr", "" ) ne $durAbsence_cr );
|
||||||
readingsBulkUpdate( $hash, "durTimerAbsence", $durAbsence_hr )
|
readingsBulkUpdate( $hash, "durTimerAbsence", $durAbsence_hr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerAbsence}{VAL} )
|
if ( ReadingsVal( $name, "durTimerAbsence", "" ) ne $durAbsence_hr );
|
||||||
|| $hash->{READINGS}{durTimerAbsence}{VAL} ne $durAbsence_hr );
|
|
||||||
readingsBulkUpdate( $hash, "durTimerSleep_cr", $durSleep_cr )
|
readingsBulkUpdate( $hash, "durTimerSleep_cr", $durSleep_cr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerSleep_cr}{VAL} )
|
if ( ReadingsVal( $name, "durTimerSleep_cr", "" ) ne $durSleep_cr );
|
||||||
|| $hash->{READINGS}{durTimerSleep_cr}{VAL} ne $durSleep_cr );
|
|
||||||
readingsBulkUpdate( $hash, "durTimerSleep", $durSleep_hr )
|
readingsBulkUpdate( $hash, "durTimerSleep", $durSleep_hr )
|
||||||
if ( !defined( $hash->{READINGS}{durTimerSleep}{VAL} )
|
if ( ReadingsVal( $name, "durTimerSleep", "" ) ne $durSleep_hr );
|
||||||
|| $hash->{READINGS}{durTimerSleep}{VAL} ne $durSleep_hr );
|
|
||||||
readingsEndUpdate( $hash, 1 ) if ( !$silent );
|
readingsEndUpdate( $hash, 1 ) if ( !$silent );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -906,7 +955,8 @@ sub ROOMMATE_SetLocation($$$;$$$$$$) {
|
|||||||
$lat = "-" if ( !$lat || $lat eq "" );
|
$lat = "-" if ( !$lat || $lat eq "" );
|
||||||
$long = "-" if ( !$long || $long eq "" );
|
$long = "-" if ( !$long || $long eq "" );
|
||||||
$address = "-" if ( !$address || $address eq "" );
|
$address = "-" if ( !$address || $address eq "" );
|
||||||
$location = "underway" if ( $trigger eq "0" );
|
$time = "" if ( !$time );
|
||||||
|
$device = "" if ( !$device );
|
||||||
|
|
||||||
Log3 $name, 5,
|
Log3 $name, 5,
|
||||||
"ROOMMATE $name: received location information: id=$id name=$location trig=$trigger date=$time lat=$lat long=$long address:$address device=$device";
|
"ROOMMATE $name: received location information: id=$id name=$location trig=$trigger date=$time lat=$lat long=$long address:$address device=$device";
|
||||||
@@ -924,57 +974,34 @@ sub ROOMMATE_SetLocation($$$;$$$$$$) {
|
|||||||
split( ' ', AttrVal( $name, "rr_locationWayhome", "wayhome" ) );
|
split( ' ', AttrVal( $name, "rr_locationWayhome", "wayhome" ) );
|
||||||
|
|
||||||
$searchstring = quotemeta($location);
|
$searchstring = quotemeta($location);
|
||||||
if ( $location ne "wayhome" ) {
|
|
||||||
if (
|
|
||||||
!grep( m/^$searchstring$/, @location_underway )
|
|
||||||
&& ( $currLocation ne $location
|
|
||||||
|| $currLat ne $lat
|
|
||||||
|| $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 );
|
# check for implicit state change
|
||||||
readingsBulkUpdate( $hash, "locationLat", $lat );
|
#
|
||||||
readingsBulkUpdate( $hash, "locationLong", $long );
|
my $stateChange = 0;
|
||||||
readingsBulkUpdate( $hash, "locationAddr", $address );
|
|
||||||
}
|
|
||||||
|
|
||||||
# wayhome detection
|
# home/1
|
||||||
$searchstring = quotemeta($location);
|
|
||||||
if (
|
|
||||||
(
|
|
||||||
$location eq "wayhome"
|
|
||||||
|| grep( m/^$searchstring$/, @location_wayhome )
|
|
||||||
)
|
|
||||||
&& ( $presence eq "absent" )
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Log3 $name, 3, "ROOMMATE $name: on way back home from $location";
|
|
||||||
readingsBulkUpdate( $hash, "wayhome", "1" )
|
|
||||||
if ( ReadingsVal( $name, "wayhome", "0" ) ne "1" );
|
|
||||||
}
|
|
||||||
|
|
||||||
readingsEndUpdate( $hash, 1 );
|
|
||||||
|
|
||||||
# auto-updates
|
|
||||||
$searchstring = quotemeta($location);
|
|
||||||
if ( ( $location eq "home" || grep( m/^$searchstring$/, @location_home ) )
|
if ( ( $location eq "home" || grep( m/^$searchstring$/, @location_home ) )
|
||||||
&& $state ne "home"
|
&& $state ne "home"
|
||||||
&& $state ne "gotosleep"
|
&& $state ne "gotosleep"
|
||||||
&& $state ne "asleep"
|
&& $state ne "asleep"
|
||||||
&& $state ne "awoken" )
|
&& $state ne "awoken"
|
||||||
|
&& $trigger eq "1" )
|
||||||
{
|
{
|
||||||
Log3 $name, 4,
|
$stateChange = 1;
|
||||||
"ROOMMATE $name: implicit state change caused by location "
|
|
||||||
. $location;
|
|
||||||
ROOMMATE_Set( $hash, $name, "silentSet", "state", "home" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# home/0
|
||||||
|
elsif (
|
||||||
|
( $location eq "home" || grep( m/^$searchstring$/, @location_home ) )
|
||||||
|
&& $state ne "gone"
|
||||||
|
&& $state ne "none"
|
||||||
|
&& $state ne "absent"
|
||||||
|
&& $trigger eq "0" )
|
||||||
|
{
|
||||||
|
$stateChange = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
# absent
|
||||||
elsif (
|
elsif (
|
||||||
(
|
(
|
||||||
$location eq "underway"
|
$location eq "underway"
|
||||||
@@ -985,10 +1012,88 @@ sub ROOMMATE_SetLocation($$$;$$$$$$) {
|
|||||||
&& $state ne "absent"
|
&& $state ne "absent"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
$stateChange = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
# wayhome
|
||||||
|
my $wayhome;
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
$location eq "wayhome"
|
||||||
|
|| ( grep( m/^$searchstring$/, @location_wayhome )
|
||||||
|
&& $trigger eq "0" )
|
||||||
|
)
|
||||||
|
&& $presence eq "absent"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Log3 $name, 5, "ROOMMATE $name: wayhome signal received";
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
( $location eq "wayhome" && $trigger eq "1" )
|
||||||
|
|| ( $location ne "wayhome" && $trigger eq "0" )
|
||||||
|
)
|
||||||
|
&& ReadingsVal( $name, "wayhome", "0" ) ne "1"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Log3 $name, 3, "ROOMMATE $name: on way back home from $location";
|
||||||
|
readingsBulkUpdate( $hash, "wayhome", "1" );
|
||||||
|
$wayhome = 1;
|
||||||
|
}
|
||||||
|
elsif ($location eq "wayhome"
|
||||||
|
&& $trigger eq "0"
|
||||||
|
&& ReadingsVal( $name, "wayhome", "0" ) ne "0" )
|
||||||
|
{
|
||||||
|
Log3 $name, 3,
|
||||||
|
"ROOMMATE $name: seems not to be on way back home anymore";
|
||||||
|
readingsBulkUpdate( $hash, "wayhome", "0" );
|
||||||
|
$wayhome = 1;
|
||||||
|
$location = "underway";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !grep( m/^$searchstring$/, @location_underway )
|
||||||
|
&& ( $stateChange > 0 || $currLocation ne $location ) )
|
||||||
|
{
|
||||||
|
Log3 $name, 5, "ROOMMATE $name: archiving last known location";
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationLat", $currLat );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationLong", $currLong );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocationAddr", $currAddr );
|
||||||
|
readingsBulkUpdate( $hash, "lastLocation", $currLocation );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $wayhome
|
||||||
|
|| $stateChange > 0
|
||||||
|
|| ( $lat ne "-" && $long ne "-" ) )
|
||||||
|
{
|
||||||
|
Log3 $name, 5, "ROOMMATE $name: Using new lat/long/addr information";
|
||||||
|
readingsBulkUpdate( $hash, "locationLat", $lat );
|
||||||
|
readingsBulkUpdate( $hash, "locationLong", $long );
|
||||||
|
readingsBulkUpdate( $hash, "locationAddr", $address );
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
Log3 $name, 5,
|
||||||
|
"ROOMMATE $name: keeping last known lat/long/addr information";
|
||||||
|
readingsBulkUpdate( $hash, "locationLat", $currLat );
|
||||||
|
readingsBulkUpdate( $hash, "locationLong", $currLong );
|
||||||
|
readingsBulkUpdate( $hash, "locationAddr", $currAddr );
|
||||||
|
}
|
||||||
|
|
||||||
|
readingsBulkUpdate( $hash, "location", $location )
|
||||||
|
if ( $location ne "wayhome" );
|
||||||
|
|
||||||
|
readingsEndUpdate( $hash, 1 );
|
||||||
|
|
||||||
|
# trigger state change
|
||||||
|
if ( $stateChange > 0 ) {
|
||||||
Log3 $name, 4,
|
Log3 $name, 4,
|
||||||
"ROOMMATE $name: implicit state change caused by location "
|
"ROOMMATE $name: implicit state change caused by location "
|
||||||
. $location;
|
. $location;
|
||||||
ROOMMATE_Set( $hash, $name, "silentSet", "state", "absent" );
|
|
||||||
|
ROOMMATE_Set( $hash, $name, "silentSet", "state", "home" )
|
||||||
|
if $stateChange == 1;
|
||||||
|
ROOMMATE_Set( $hash, $name, "silentSet", "state", "absent" )
|
||||||
|
if $stateChange == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user