add shutters in notidyDev, create shutters event processing routine
This commit is contained in:
parent
affabb83e2
commit
b3126e30d6
@ -38,7 +38,7 @@ package main;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my $version = "0.1.80.25";
|
my $version = "0.1.80.31";
|
||||||
|
|
||||||
sub AutoShuttersControl_Initialize($) {
|
sub AutoShuttersControl_Initialize($) {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
@ -315,7 +315,7 @@ sub Notify($$) {
|
|||||||
my $events = deviceEvents( $dev, 1 );
|
my $events = deviceEvents( $dev, 1 );
|
||||||
return if ( !$events );
|
return if ( !$events );
|
||||||
|
|
||||||
Log3( $name, 5,
|
Log3( $name, 4,
|
||||||
"AutoShuttersControl ($name) - Devname: "
|
"AutoShuttersControl ($name) - Devname: "
|
||||||
. $devname
|
. $devname
|
||||||
. " Name: "
|
. " Name: "
|
||||||
@ -356,6 +356,8 @@ sub Notify($$) {
|
|||||||
return
|
return
|
||||||
unless ( ref( $hash->{helper}{shuttersList} ) eq 'ARRAY'
|
unless ( ref( $hash->{helper}{shuttersList} ) eq 'ARRAY'
|
||||||
and scalar( @{ $hash->{helper}{shuttersList} } ) > 0 );
|
and scalar( @{ $hash->{helper}{shuttersList} } ) > 0 );
|
||||||
|
|
||||||
|
my $posReading = $shutters->getPosCmd;
|
||||||
|
|
||||||
if ( $devname eq $name ) {
|
if ( $devname eq $name ) {
|
||||||
if ( grep /^userAttrList:.rolled.out$/, @{$events} ) {
|
if ( grep /^userAttrList:.rolled.out$/, @{$events} ) {
|
||||||
@ -391,6 +393,11 @@ sub Notify($$) {
|
|||||||
unless ( $ascDev->getSunriseTimeWeHoliday eq 'off' );
|
unless ( $ascDev->getSunriseTimeWeHoliday eq 'off' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif ( grep /^($posReading):\s\d+$/,
|
||||||
|
@{$events} )
|
||||||
|
{
|
||||||
|
ShuttersEventProcessing( $hash, $devname, join( ' ', @{$events} ) );
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
GeneralEventProcessing( $hash, $devname, join( ' ', @{$events} ) )
|
GeneralEventProcessing( $hash, $devname, join( ' ', @{$events} ) )
|
||||||
; # bei allen anderen Events wird die entsprechende Funktion zur Verarbeitung aufgerufen
|
; # bei allen anderen Events wird die entsprechende Funktion zur Verarbeitung aufgerufen
|
||||||
@ -505,20 +512,10 @@ sub Get($$@) {
|
|||||||
my $ret = GetMonitoredDevs($hash);
|
my $ret = GetMonitoredDevs($hash);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
elsif ( lc $cmd eq 'test' ) {
|
|
||||||
return "usage: $cmd" if ( @args != 0 );
|
|
||||||
$shutters->setShuttersDev('RolloKinZimSteven_F1');
|
|
||||||
my $ret =
|
|
||||||
'LastPos: ' . $shutters->getLastPos
|
|
||||||
. ' InTimerFuncHash: ' . $shutters->getInTimerFuncHash
|
|
||||||
. ' Sunrise: ' . $shutters->getInTimerFuncHash->{sunrisetime}
|
|
||||||
. ' LastPosTimestamp: ' . $shutters->getLastPosTimestamp;
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
my $list = "";
|
my $list = "";
|
||||||
$list .=
|
$list .=
|
||||||
" showShuttersInformations:noArg showNotifyDevsInformations:noArg test:noArg"
|
" showShuttersInformations:noArg showNotifyDevsInformations:noArg"
|
||||||
if ( ReadingsVal( $name, 'userAttrList', 'none' ) eq 'rolled out' );
|
if ( ReadingsVal( $name, 'userAttrList', 'none' ) eq 'rolled out' );
|
||||||
return "Unknown argument $cmd,choose one of $list";
|
return "Unknown argument $cmd,choose one of $list";
|
||||||
}
|
}
|
||||||
@ -545,10 +542,10 @@ sub ShuttersDeviceScan($) {
|
|||||||
readingsEndUpdate( $hash, 1 );
|
readingsEndUpdate( $hash, 1 );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
my $shuttersList = '';
|
||||||
foreach (@list) {
|
foreach (@list) {
|
||||||
push( @{ $hash->{helper}{shuttersList} }, $_ )
|
push( @{ $hash->{helper}{shuttersList} }, $_ )
|
||||||
; ## einem Hash wird ein Array zugewiesen welches die Liste der erkannten Rollos beinhaltet
|
; ## einem Hash wird ein Array zugewiesen welches die Liste der erkannten Rollos beinhaltet
|
||||||
#AddNotifyDev($hash,$_); # Vorerst keine Shutters in NOTIFYDEV
|
|
||||||
delFromDevAttrList( $_, 'ASC_Up:time,astro' )
|
delFromDevAttrList( $_, 'ASC_Up:time,astro' )
|
||||||
; # temporär muss später gelöscht werden ab Version 0.1.80
|
; # temporär muss später gelöscht werden ab Version 0.1.80
|
||||||
delFromDevAttrList( $_, 'ASC_Down:time,astro' )
|
delFromDevAttrList( $_, 'ASC_Down:time,astro' )
|
||||||
@ -561,13 +558,18 @@ sub ShuttersDeviceScan($) {
|
|||||||
CommandDeleteReading( undef,
|
CommandDeleteReading( undef,
|
||||||
$_ . ' .AutoShuttersControl_LastPosition' )
|
$_ . ' .AutoShuttersControl_LastPosition' )
|
||||||
; # temporär muss später gelöscht werden ab Version 0.1.81
|
; # temporär muss später gelöscht werden ab Version 0.1.81
|
||||||
|
$shuttersList = $shuttersList . ',' . $_;
|
||||||
|
$shutters->setShuttersDev($_);
|
||||||
|
$shutters->setLastPos( $shutters->getStatus );
|
||||||
}
|
}
|
||||||
|
$hash->{NOTIFYDEV} = $hash->{NOTIFYDEV} . $shuttersList;
|
||||||
|
|
||||||
if ( $ascDev->getMonitoredDevs ne 'none' ) {
|
if ( $ascDev->getMonitoredDevs ne 'none' ) {
|
||||||
$hash->{monitoredDevs} =
|
$hash->{monitoredDevs} =
|
||||||
eval { decode_json( $ascDev->getMonitoredDevs ) };
|
eval { decode_json( $ascDev->getMonitoredDevs ) };
|
||||||
my $notifyDevString = $hash->{NOTIFYDEV};
|
my $notifyDevString = $hash->{NOTIFYDEV};
|
||||||
while ( each %{ $hash->{monitoredDevs} } ) {
|
while ( each %{ $hash->{monitoredDevs} } ) {
|
||||||
$notifyDevString .= ',' . $_;
|
$notifyDevString .= ',' . $_ ;
|
||||||
}
|
}
|
||||||
$hash->{NOTIFYDEV} = $notifyDevString;
|
$hash->{NOTIFYDEV} = $notifyDevString;
|
||||||
}
|
}
|
||||||
@ -941,6 +943,16 @@ sub PartyModeEventProcessing($) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub ShuttersEventProcessing($@) {
|
||||||
|
my ( $hash, $shuttersDev, $events ) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
if ( $events =~ m#.*:\s(\d+)# ) {
|
||||||
|
$shutters->setShuttersDev($ShuttersDev);
|
||||||
|
$shutters->setLastPos($1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Sub für das Zusammensetzen der Rolläden Steuerbefehle
|
# Sub für das Zusammensetzen der Rolläden Steuerbefehle
|
||||||
sub ShuttersCommandSet($$$) {
|
sub ShuttersCommandSet($$$) {
|
||||||
my ( $hash, $shuttersDev, $posValue ) = @_;
|
my ( $hash, $shuttersDev, $posValue ) = @_;
|
||||||
@ -1176,6 +1188,7 @@ sub CreateNewNotifyDev($) {
|
|||||||
delete $hash->{monitoredDevs};
|
delete $hash->{monitoredDevs};
|
||||||
|
|
||||||
CommandDeleteReading( undef, $name . ' .monitoredDevs' );
|
CommandDeleteReading( undef, $name . ' .monitoredDevs' );
|
||||||
|
my $shuttersList = '';
|
||||||
foreach ( @{ $hash->{helper}{shuttersList} } ) {
|
foreach ( @{ $hash->{helper}{shuttersList} } ) {
|
||||||
AddNotifyDev( $hash, AttrVal( $_, 'ASC_Roommate_Device', 'none' ),
|
AddNotifyDev( $hash, AttrVal( $_, 'ASC_Roommate_Device', 'none' ),
|
||||||
$_, 'ASC_Roommate_Device' )
|
$_, 'ASC_Roommate_Device' )
|
||||||
@ -1188,10 +1201,12 @@ sub CreateNewNotifyDev($) {
|
|||||||
$_, 'ASC_Shading_Brightness_Sensor' )
|
$_, 'ASC_Shading_Brightness_Sensor' )
|
||||||
if (
|
if (
|
||||||
AttrVal( $_, 'ASC_Shading_Brightness_Sensor', 'none' ) ne 'none' );
|
AttrVal( $_, 'ASC_Shading_Brightness_Sensor', 'none' ) ne 'none' );
|
||||||
|
$shuttersList = $shuttersList . ',' . $_ ;
|
||||||
}
|
}
|
||||||
AddNotifyDev( $hash, AttrVal( $name, 'ASC_residentsDevice', 'none' ),
|
AddNotifyDev( $hash, AttrVal( $name, 'ASC_residentsDevice', 'none' ),
|
||||||
$name, 'ASC_residentsDevice' )
|
$name, 'ASC_residentsDevice' )
|
||||||
if ( AttrVal( $name, 'ASC_residentsDevice', 'none' ) ne 'none' );
|
if ( AttrVal( $name, 'ASC_residentsDevice', 'none' ) ne 'none' );
|
||||||
|
$hash->{NOTIFYDEV} = $hash->{NOTIFYDEV} . $shuttersList;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub GetShuttersInformation($) {
|
sub GetShuttersInformation($) {
|
||||||
@ -1209,11 +1224,21 @@ sub GetShuttersInformation($) {
|
|||||||
$ret .= "<td><b>Partymode</b></td>";
|
$ret .= "<td><b>Partymode</b></td>";
|
||||||
$ret .= "<td> </td>";
|
$ret .= "<td> </td>";
|
||||||
$ret .= "<td><b>Lock-Out</b></td>";
|
$ret .= "<td><b>Lock-Out</b></td>";
|
||||||
|
$ret .= "<td> </td>";
|
||||||
|
$ret .= "<td><b>Sunrise</b></td>";
|
||||||
|
$ret .= "<td> </td>";
|
||||||
|
$ret .= "<td><b>Sunset</b></td>";
|
||||||
|
$ret .= "<td> </td>";
|
||||||
|
$ret .= "<td><b>LastPos</b></td>";
|
||||||
|
$ret .= "<td> </td>";
|
||||||
|
$ret .= "<td><b>LastPosTimestamp</b></td>";
|
||||||
$ret .= '</tr>';
|
$ret .= '</tr>';
|
||||||
|
|
||||||
if ( ref($shuttersInformations) eq "HASH" ) {
|
if ( ref($shuttersInformations) eq "HASH" ) {
|
||||||
my $linecount = 1;
|
my $linecount = 1;
|
||||||
foreach my $shutter ( sort keys( %{$shuttersInformations} ) ) {
|
foreach my $shutter ( sort keys( %{$shuttersInformations} ) ) {
|
||||||
|
$shutters->setShuttersDev($shutter);
|
||||||
|
|
||||||
if ( $linecount % 2 == 0 ) { $ret .= '<tr class="even">'; }
|
if ( $linecount % 2 == 0 ) { $ret .= '<tr class="even">'; }
|
||||||
else { $ret .= '<tr class="odd">'; }
|
else { $ret .= '<tr class="odd">'; }
|
||||||
$ret .= "<td>$shutter</td>";
|
$ret .= "<td>$shutter</td>";
|
||||||
@ -1226,6 +1251,18 @@ sub GetShuttersInformation($) {
|
|||||||
$ret .= "<td>$shuttersInformations->{$shutter}{Partymode}</td>";
|
$ret .= "<td>$shuttersInformations->{$shutter}{Partymode}</td>";
|
||||||
$ret .= "<td> </td>";
|
$ret .= "<td> </td>";
|
||||||
$ret .= "<td>$shuttersInformations->{$shutter}{'Lock-Out'}</td>";
|
$ret .= "<td>$shuttersInformations->{$shutter}{'Lock-Out'}</td>";
|
||||||
|
$ret .= "<td> </td>";
|
||||||
|
$ret .= "<td>".$shutters->getInTimerFuncHash->{sunrisetime}."</td>"
|
||||||
|
if( defined( $shutters->getInTimerFuncHash )
|
||||||
|
and defined( $shutters->getInTimerFuncHash->{sunrisetime} ) ) ;
|
||||||
|
$ret .= "<td> </td>";
|
||||||
|
$ret .= "<td>".$shutters->getInTimerFuncHash->{sunsettime}."</td>"
|
||||||
|
if( defined( $shutters->getInTimerFuncHash )
|
||||||
|
and defined( $shutters->getInTimerFuncHash->{sunsettime} ) ) ;
|
||||||
|
$ret .= "<td> </td>";
|
||||||
|
$ret .= "<td>".$shutters->getLastPos."</td>";
|
||||||
|
$ret .= "<td> </td>";
|
||||||
|
$ret .= "<td>".$shutters->getLastPosTimestamp."</td>";
|
||||||
$ret .= '</tr>';
|
$ret .= '</tr>';
|
||||||
$linecount++;
|
$linecount++;
|
||||||
}
|
}
|
||||||
@ -1729,10 +1766,10 @@ sub setDelayDriveCmd {
|
|||||||
sub setLastPos {
|
sub setLastPos {
|
||||||
my ( $self, $position ) = @_;
|
my ( $self, $position ) = @_;
|
||||||
|
|
||||||
$self->{ $self->{shuttersDev} }{lastPos}{VAL} = $position
|
$self->{ $self->{shuttersDev} }{lastPos}{VAL} = $position
|
||||||
if ( defined($position) );
|
if ( defined($position) );
|
||||||
$self->{ $self->{shuttersDev} }{lastPos}{TIME} = int(gettimeofday())
|
$self->{ $self->{shuttersDev} }{lastPos}{TIME} = int( gettimeofday() )
|
||||||
if ( defined( $self->{ $self->{shuttersDev} }{lastPos} ) );
|
if ( defined( $self->{ $self->{shuttersDev} }{lastPos} ) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2121,7 +2158,6 @@ sub getDelayCmd {
|
|||||||
return ReadingsVal( $shuttersDev, '.ASC_DelayCmd', $default );
|
return ReadingsVal( $shuttersDev, '.ASC_DelayCmd', $default );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
## Klasse Fenster (Window) und die Subklassen Attr und Readings ##
|
## Klasse Fenster (Window) und die Subklassen Attr und Readings ##
|
||||||
package ASC_Window;
|
package ASC_Window;
|
||||||
our @ISA = qw(ASC_Window::Attr ASC_Window::Readings);
|
our @ISA = qw(ASC_Window::Attr ASC_Window::Readings);
|
||||||
|
Loading…
Reference in New Issue
Block a user