fix bug in roommate function
This commit is contained in:
parent
ce7be6caf0
commit
b998e64e3e
@ -46,7 +46,7 @@ use warnings;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
my $version = "0.1.68";
|
my $version = "0.1.70";
|
||||||
|
|
||||||
|
|
||||||
sub AutoShuttersControl_Initialize($) {
|
sub AutoShuttersControl_Initialize($) {
|
||||||
@ -652,7 +652,7 @@ sub RoommateEventProcessing($@) {
|
|||||||
|
|
||||||
ShuttersCommandSet($hash,$shuttersDev,$openPos)
|
ShuttersCommandSet($hash,$shuttersDev,$openPos)
|
||||||
if( ($1 eq 'home' or $1 eq 'awoken') and
|
if( ($1 eq 'home' or $1 eq 'awoken') and
|
||||||
(ReadingsVal(AttrVal($shuttersDev,'ASC_Roommate_Device','none'),'lastState','none') eq 'asleep' or ReadingsVal(AttrVal($shuttersDev,'ASC_Roommate_Device','none'),'lastState','none') eq 'awoken')
|
(LastStateRoommates($shuttersDev) eq 'asleep' or LastStateRoommates($shuttersDev) eq 'awoken')
|
||||||
and AttrVal($name,'ASC_autoShuttersControlMorning','off') eq 'on'
|
and AttrVal($name,'ASC_autoShuttersControlMorning','off') eq 'on'
|
||||||
and IsDay($hash,$shuttersDev)
|
and IsDay($hash,$shuttersDev)
|
||||||
and AttrVal($shuttersDev,'ASC_Mode_Up','off') eq 'always' );
|
and AttrVal($shuttersDev,'ASC_Mode_Up','off') eq 'always' );
|
||||||
@ -821,7 +821,7 @@ sub SunSetShuttersAfterTimerFn($) {
|
|||||||
|
|
||||||
|
|
||||||
ShuttersCommandSet($hash,$shuttersDev,$posValue)
|
ShuttersCommandSet($hash,$shuttersDev,$posValue)
|
||||||
if( AttrVal($shuttersDev,'ASC_Mode_Down','off') eq ReadingsVal(AttrVal($shuttersDev,'ASC_Roommate_Device','none'),AttrVal($shuttersDev,'ASC_Roommate_Reading','none'),'home') or AttrVal($shuttersDev,'ASC_Mode_Down','off') eq 'always' );
|
if( AttrVal($shuttersDev,'ASC_Mode_Down','off') eq StateRoommates($shuttersDev) or AttrVal($shuttersDev,'ASC_Mode_Down','off') eq 'always' );
|
||||||
|
|
||||||
CreateSunRiseSetShuttersTimer($hash,$shuttersDev);
|
CreateSunRiseSetShuttersTimer($hash,$shuttersDev);
|
||||||
}
|
}
|
||||||
@ -836,10 +836,10 @@ sub SunRiseShuttersAfterTimerFn($) {
|
|||||||
|
|
||||||
my ($openPos,$closedPos,$closedPosWinRecTilted) = ShuttersReadAttrForShuttersControl($shuttersDev);
|
my ($openPos,$closedPos,$closedPosWinRecTilted) = ShuttersReadAttrForShuttersControl($shuttersDev);
|
||||||
|
|
||||||
if( AttrVal($shuttersDev,'ASC_Mode_Up','off') eq ReadingsVal(AttrVal($shuttersDev,'ASC_Roommate_Device','none'),AttrVal($shuttersDev,'ASC_Roommate_Reading','none'),'home') or AttrVal($shuttersDev,'ASC_Mode_Up','off') eq 'always' ) {
|
if( AttrVal($shuttersDev,'ASC_Mode_Up','off') eq StateRoommates($shuttersDev) or AttrVal($shuttersDev,'ASC_Mode_Up','off') eq 'always' ) {
|
||||||
|
|
||||||
ShuttersCommandSet($hash,$shuttersDev,$openPos)
|
ShuttersCommandSet($hash,$shuttersDev,$openPos)
|
||||||
if( ReadingsVal(AttrVal($shuttersDev,'ASC_Roommate_Device','none'),AttrVal($shuttersDev,'ASC_Roommate_Reading','none'),'home') eq 'home' or ReadingsVal(AttrVal($shuttersDev,'ASC_Roommate_Device','none'),AttrVal($shuttersDev,'ASC_Roommate_Reading','none'),'awoken') eq 'awoken' or ReadingsVal(AttrVal($shuttersDev,'ASC_Roommate_Device','none'),AttrVal($shuttersDev,'ASC_Roommate_Reading','none'),'absent') eq 'absent' or ReadingsVal(AttrVal($shuttersDev,'ASC_Roommate_Device','none'),AttrVal($shuttersDev,'ASC_Roommate_Reading','none'),'gone') eq 'gone' );
|
if( StateRoommates($shuttersDev) eq 'home' or StateRoommates($shuttersDev) eq 'awoken' or StateRoommates($shuttersDev) eq 'absent' or StateRoommates($shuttersDev) eq 'gone' );
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateSunRiseSetShuttersTimer($hash,$shuttersDev);
|
CreateSunRiseSetShuttersTimer($hash,$shuttersDev);
|
||||||
@ -1165,6 +1165,46 @@ sub IsHoliday($) {
|
|||||||
return ( ReadingsVal(AttrVal($name,'ASC_timeUpHolidayDevice','none'),'state',0) == 1 ? 1 : 0 );
|
return ( ReadingsVal(AttrVal($name,'ASC_timeUpHolidayDevice','none'),'state',0) == 1 ? 1 : 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub StateRoommates($) {
|
||||||
|
|
||||||
|
my ($shuttersDev) = @_;
|
||||||
|
|
||||||
|
|
||||||
|
my $loop = 0;
|
||||||
|
my @roState;
|
||||||
|
my %statePrio = ('asleep' => 1, 'gotosleep' => 2, 'awoken' => 3, 'home' => 4, 'absent' => 5, 'gone' => 6, 'none' => 7);
|
||||||
|
my $minPrio = 10;
|
||||||
|
|
||||||
|
foreach my $ro (split(",", AttrVal($shuttersDev,'ASC_Roommate_Device',''))) {
|
||||||
|
my $currentPrio = $statePrio{ReadingsVal($ro,AttrVal($shuttersDev,'ASC_Roommate_Reading','state'),'home')};
|
||||||
|
$minPrio = $currentPrio if($minPrio > $currentPrio);
|
||||||
|
}
|
||||||
|
|
||||||
|
my %revStatePrio = reverse %statePrio;
|
||||||
|
Log3 $shuttersDev, 1, "AutoShuttersControl ($shuttersDev) - StateRoommates: " . $revStatePrio{$minPrio};
|
||||||
|
return $revStatePrio{$minPrio};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub LastStateRoommates($) {
|
||||||
|
|
||||||
|
my ($shuttersDev) = @_;
|
||||||
|
|
||||||
|
|
||||||
|
my $loop = 0;
|
||||||
|
my @roState;
|
||||||
|
my %statePrio = ('asleep' => 1, 'gotosleep' => 2, 'awoken' => 3, 'home' => 4, 'absent' => 5, 'gone' => 6, 'none' => 7);
|
||||||
|
my $minPrio = 10;
|
||||||
|
|
||||||
|
foreach my $ro (split(",", AttrVal($shuttersDev,'ASC_Roommate_Device',''))) {
|
||||||
|
my $currentPrio = $statePrio{ReadingsVal($ro,'lastState','home')};
|
||||||
|
$minPrio = $currentPrio if($minPrio > $currentPrio);
|
||||||
|
}
|
||||||
|
|
||||||
|
my %revStatePrio = reverse %statePrio;
|
||||||
|
Log3 $shuttersDev, 1, "AutoShuttersControl ($shuttersDev) - LastStateRoommates: " . $revStatePrio{$minPrio};
|
||||||
|
return $revStatePrio{$minPrio};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1419,4 +1459,3 @@ sub IsHoliday($) {
|
|||||||
=end html_DE
|
=end html_DE
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user