mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
71_YAMAHA_MC.pm:Define optimiert wie im Wiki beschrieben unter
Beruecksichtigung von $init_done Loglevel herbagestuft fuer einige Meldungen git-svn-id: https://svn.fhem.de/fhem/trunk@21033 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f2e909a985
commit
cfaeb7da10
@ -60,6 +60,7 @@ sub YAMAHA_MC_GetStatus($;$);
|
||||
sub YAMAHA_MC_ResetTimer($;$);
|
||||
sub YAMAHA_MC_Get($@);
|
||||
sub YAMAHA_MC_Define($$);
|
||||
sub YAMAHA_MC_Notify($$);
|
||||
sub YAMAHA_MC_Attr(@);
|
||||
sub YAMAHA_MC_Undefine($$);
|
||||
sub YAMAHA_MC_UpdateLists($;$);
|
||||
@ -287,14 +288,18 @@ sub YAMAHA_MC_Define($$) # only called when defined, not on reload.
|
||||
$hash->{UdpClientPort} = $data{YAMAHA_MC_UDPCLIENTPORTSTART};
|
||||
$data{YAMAHA_MC_UDPCLIENTPORTSTART}++;
|
||||
|
||||
if ( AttrVal( $name, "eventProcessing", 0 ) ) {
|
||||
Log3 $hash->{NAME}, 2, "$hash->{TYPE}: $hash->{NAME} event Processing enabled ";
|
||||
$hash->{NOTIFYDEV} = "global";
|
||||
|
||||
#open UDP Client for incoming events
|
||||
YAMAHA_MC_OpenUDPConn($hash);
|
||||
}
|
||||
else {
|
||||
Log3 $hash->{NAME}, 2, "$hash->{TYPE}: $hash->{NAME} event Processing disabled ";
|
||||
if ($init_done) {
|
||||
if ( AttrVal( $name, "eventProcessing", 0 ) ) {
|
||||
Log3 $hash->{NAME}, 2, "$hash->{TYPE}: $hash->{NAME} event Processing enabled ";
|
||||
|
||||
#open UDP Client for incoming events
|
||||
YAMAHA_MC_OpenUDPConn($hash);
|
||||
}
|
||||
else {
|
||||
Log3 $hash->{NAME}, 2, "$hash->{TYPE}: $hash->{NAME} event Processing disabled ";
|
||||
}
|
||||
}
|
||||
|
||||
# if an update interval was given which is greater than zero, use it.
|
||||
@ -321,11 +326,11 @@ sub YAMAHA_MC_Define($$) # only called when defined, not on reload.
|
||||
if ( defined( $a[6] ) ) {
|
||||
unless ( defined( $hash->{helper}{SELECTED_ZONE} ) ) { $hash->{helper}{SELECTED_ZONE} = $a[6]; }
|
||||
$hash->{ZONE} = $a[6];
|
||||
Log3 $hash->{NAME}, 1, "$hash->{TYPE}: $hash->{NAME} Setting selected zone to " . $a[6];
|
||||
Log3 $hash->{NAME}, 3, "$hash->{TYPE}: $hash->{NAME} Setting selected zone to " . $a[6];
|
||||
}
|
||||
else {
|
||||
$hash->{ZONE} = "main";
|
||||
Log3 $hash->{NAME}, 1, "$hash->{TYPE}: $hash->{NAME} no zone defined in device using main ";
|
||||
Log3 $hash->{NAME}, 3, "$hash->{TYPE}: $hash->{NAME} no zone defined in device using main ";
|
||||
}
|
||||
|
||||
# create empty CMD Queue
|
||||
@ -361,30 +366,32 @@ sub YAMAHA_MC_Define($$) # only called when defined, not on reload.
|
||||
|
||||
readingsSingleUpdate( $hash, 'state', 'opened', 1 );
|
||||
|
||||
my $DLNAsearch = AttrVal( $hash->{NAME}, "DLNAsearch", "on" );
|
||||
if ($init_done) {
|
||||
my $DLNAsearch = AttrVal( $hash->{NAME}, "DLNAsearch", "on" );
|
||||
|
||||
readingsSingleUpdate( $hash, "DLNARenderer", "unknown", 1 );
|
||||
readingsSingleUpdate( $hash, 'MediaServer', 'unknown', 1 );
|
||||
readingsSingleUpdate( $hash, "DLNARenderer", "unknown", 1 );
|
||||
readingsSingleUpdate( $hash, 'MediaServer', 'unknown', 1 );
|
||||
|
||||
if ( $DLNAsearch eq "on" ) {
|
||||
if ( $DLNAsearch eq "on" ) {
|
||||
|
||||
YAMAHA_MC_setupControlpoint($hash);
|
||||
YAMAHA_MC_setupMediaRenderer($hash);
|
||||
YAMAHA_MC_setupControlpoint($hash);
|
||||
YAMAHA_MC_setupMediaRenderer($hash);
|
||||
|
||||
Log3 $hash->{NAME}, 2, "$type: $name DLNAsearch turned $DLNAsearch setting timer for getting devices in 150Secs";
|
||||
InternalTimer( gettimeofday() + 120, 'YAMAHA_MC_getNetworkStatus', $hash, 0 );
|
||||
InternalTimer( gettimeofday() + 150, 'YAMAHA_MC_DiscoverDLNAProcess', $hash, 0 );
|
||||
Log3 $hash->{NAME}, 2, "$type: $name DLNAsearch turned $DLNAsearch setting timer for getting devices in 150Secs";
|
||||
InternalTimer( gettimeofday() + 120, 'YAMAHA_MC_getNetworkStatus', $hash, 0 );
|
||||
InternalTimer( gettimeofday() + 150, 'YAMAHA_MC_DiscoverDLNAProcess', $hash, 0 );
|
||||
}
|
||||
else {
|
||||
|
||||
Log3 $name, 1, "$type: $name - DLNASearch turned $DLNAsearch";
|
||||
Log3 $name, 1, "$type: $name - starting InternalTimer YAMAHA_MC_DiscoverDLNAProcess anyway once in 150Secs";
|
||||
|
||||
YAMAHA_MC_setupControlpoint($hash);
|
||||
YAMAHA_MC_setupMediaRenderer($hash);
|
||||
InternalTimer( gettimeofday() + 150, 'YAMAHA_MC_DiscoverDLNAProcess', $hash, 0 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Log3 $name, 1, "$type: $name - DLNASearch turned $DLNAsearch";
|
||||
Log3 $name, 1, "$type: $name - starting InternalTimer YAMAHA_MC_DiscoverDLNAProcess anyway once in 150Secs";
|
||||
|
||||
YAMAHA_MC_setupControlpoint($hash);
|
||||
YAMAHA_MC_setupMediaRenderer($hash);
|
||||
InternalTimer( gettimeofday() + 150, 'YAMAHA_MC_DiscoverDLNAProcess', $hash, 0 );
|
||||
}
|
||||
|
||||
|
||||
Log3 $hash->{NAME}, 1, "$type: $name opened device $name -> host:$hash->{HOST}:" . "$hash->{PORT}" . " $hash->{OFF_INTERVAL}" . " $hash->{ON_INTERVAL}" . " $hash->{ZONE}";
|
||||
|
||||
# start the status update timer in one second
|
||||
@ -394,6 +401,62 @@ sub YAMAHA_MC_Define($$) # only called when defined, not on reload.
|
||||
return undef;
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# YAMAHA_MC_Notify
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
sub YAMAHA_MC_Notify($$)
|
||||
{
|
||||
my ($hash, $dev_hash) = @_;
|
||||
my $ownName = $hash->{NAME}; # own name / hash
|
||||
|
||||
return "" if(IsDisabled($ownName)); # Return without any further action if the module is disabled
|
||||
|
||||
my $devName = $dev_hash->{NAME}; # Device that created the events
|
||||
my $events = deviceEvents($dev_hash, 1);
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
if($devName eq "global" && grep(m/^INITIALIZED|REREADCFG$/, @{$events}))
|
||||
{
|
||||
|
||||
#Event PRocessing
|
||||
if ( AttrVal( $name, "eventProcessing", 0 ) ) {
|
||||
Log3 $hash->{NAME}, 2, "$hash->{TYPE}: $hash->{NAME} event Processing enabled ";
|
||||
|
||||
#open UDP Client for incoming events
|
||||
YAMAHA_MC_OpenUDPConn($hash);
|
||||
}
|
||||
else {
|
||||
Log3 $hash->{NAME}, 2, "$hash->{TYPE}: $hash->{NAME} event Processing disabled ";
|
||||
}
|
||||
|
||||
# DLNA Search
|
||||
my $DLNAsearch = AttrVal( $hash->{NAME}, "DLNAsearch", "on" );
|
||||
|
||||
readingsSingleUpdate( $hash, "DLNARenderer", "unknown", 1 );
|
||||
readingsSingleUpdate( $hash, 'MediaServer', 'unknown', 1 );
|
||||
|
||||
if ( $DLNAsearch eq "on" ) {
|
||||
|
||||
YAMAHA_MC_setupControlpoint($hash);
|
||||
YAMAHA_MC_setupMediaRenderer($hash);
|
||||
|
||||
Log3 $hash->{NAME}, 2, "$hash->{TYPE}: $name DLNAsearch turned $DLNAsearch setting timer for getting devices in 150Secs";
|
||||
InternalTimer( gettimeofday() + 120, 'YAMAHA_MC_getNetworkStatus', $hash, 0 );
|
||||
InternalTimer( gettimeofday() + 150, 'YAMAHA_MC_DiscoverDLNAProcess', $hash, 0 );
|
||||
}
|
||||
else {
|
||||
|
||||
Log3 $name, 1, "$hash->{TYPE}: $name - DLNASearch turned $DLNAsearch";
|
||||
Log3 $name, 1, "$hash->{TYPE}: $name - starting InternalTimer YAMAHA_MC_DiscoverDLNAProcess anyway once in 150Secs";
|
||||
|
||||
YAMAHA_MC_setupControlpoint($hash);
|
||||
YAMAHA_MC_setupMediaRenderer($hash);
|
||||
InternalTimer( gettimeofday() + 150, 'YAMAHA_MC_DiscoverDLNAProcess', $hash, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# YAMAHA_MC_setupControlpoint
|
||||
# ------------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user