2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

70_BRAVIA.pm: new attribute wolBroadcast

git-svn-id: https://svn.fhem.de/fhem/trunk@20868 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
vuffiraa 2020-01-02 15:34:22 +00:00
parent 264c306b8e
commit d43f6a7bfe
2 changed files with 35 additions and 28 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- feature: 70_BRAVIA: new attribute wolBroadcast used as address for WOL packet
- change: 74_XiaomiBTLESens: add special patch from charlie71
- bugfix: 93_DbLog: fix behavior if value is empty and attribute
addStateEvent is set (default), Forum: #106769

View File

@ -30,6 +30,8 @@ package main;
use strict;
use warnings;
use vars qw( $readingFnAttributes );
###################################
sub BRAVIA_Initialize($) {
my ($hash) = @_;
@ -41,7 +43,7 @@ sub BRAVIA_Initialize($) {
$hash->{DefFn} = "BRAVIA::Define";
$hash->{UndefFn} = "BRAVIA::Undefine";
$hash->{AttrList} = "disable:0,1 macaddr:textField channelsMax:textField " . $::readingFnAttributes;
$hash->{AttrList} = "disable:0,1 macaddr:textField channelsMax:textField wolBroadcast:textField " . $readingFnAttributes;
$::data{RC_layout}{BRAVIA_SVG} = "BRAVIA::RClayout_SVG";
$::data{RC_layout}{BRAVIA} = "BRAVIA::RClayout";
@ -453,7 +455,6 @@ sub Set($@) {
elsif ( lc( $a[1] ) eq "remotecontrol" ) {
Log3($name, 2, "BRAVIA set $name " . $a[1] . " " . $a[2]);
if ( $presence eq "present" ) {
if ( !defined( $a[2] ) ) {
my $commandKeys = "";
for (sort keys %{GetRemotecontrolCommand("GetRemotecontrolCommands")}) {
@ -461,9 +462,15 @@ sub Set($@) {
}
return "No argument given, choose one of" . $commandKeys;
}
$cmd = uc( $a[2] );
if ( $cmd eq "WOL" ) {
my $macAddr = AttrVal( $name, "macaddr", "" );
$macAddr = ReadingsVal( $name, "macAddr", "") if ($macAddr eq "");
wake( $name, $macAddr ) if ( $macAddr ne "" && $macAddr ne "-" );
}
elsif ( $presence eq "present" ) {
if ( $cmd eq "MUTE" ) {
Set( $hash, $name, "mute" );
}
@ -473,11 +480,6 @@ sub Set($@) {
elsif ( $cmd eq "CHANDOWN" ) {
Set( $hash, $name, "channelDown" );
}
elsif ( $cmd eq "WOL" ) {
my $macAddr = AttrVal( $name, "macaddr", "" );
$macAddr = ReadingsVal( $name, "macAddr", "") if ($macAddr eq "");
wake( $name, $macAddr ) if ( $macAddr ne "" && $macAddr ne "-" );
}
elsif ( $cmd ne "" ) {
SendCommand( $hash, "ircc", $cmd );
}
@ -1197,7 +1199,7 @@ sub ReceiveCommand($$$) {
###################################
sub wake ($$) {
my ( $name, $mac_addr ) = @_;
my $address = '255.255.255.255';
my $address = AttrVal($name, 'wolBroadcast', '255.255.255.255');
my $port = 9;
my $sock = new IO::Socket::INET( Proto => 'udp' )
@ -1213,7 +1215,7 @@ sub wake ($$) {
setsockopt( $sock, SOL_SOCKET, SO_BROADCAST, 1 )
or die "setsockopt : $!";
Log3($name, 4, "BRAVIA $name: Waking up by sending Wake-On-Lan magic package to $mac_addr");
Log3($name, 4, "BRAVIA $name: Waking up by sending Wake-On-Lan magic packet to $mac_addr");
send( $sock, $packet, 0, $sock_addr ) or die "send : $!";
close($sock);
@ -2288,7 +2290,9 @@ sub GetNormalizedName($) {
<li><a name="channelsMax"></a><i>channelsMax</i><br>
Maximum amount of channels to be displayed, default is 50.</li>
<li><a name="macaddr"></a><i>macaddr</i><br>
Enables power on of TV using WOL.</li>
Enables power on of TV using Wake-On-Lan.</li>
<li><a name="wolBroadcast"></a><i>wolBroadcast</i><br>
Broadcast address for Wake-On-Lan magic packets, default is 255.255.255.255.</li>
</ul>
</ul>
</ul>
@ -2405,7 +2409,9 @@ sub GetNormalizedName($) {
<li><a name="channelsMax"></a><i>channelsMax</i><br>
Maximale Anzahl der im FHEMWEB angezeigten Kanäle. Der Standartwert ist 50.</li>
<li><a name="macaddr"></a><i>macaddr</i><br>
Ermöglicht das Einschalten des TV per WOL.</li>
Ermöglicht das Einschalten des TV per Wake-On-Lan.</li>
<li><a name="wolBroadcast"></a><i>wolBroadcast</i><br>
Broadcast-Adresse für die Wake-On-Lan <i>Magic Packets</i>. Der Standartwert ist 255.255.255.255.</li>
</ul>
</ul>
</ul>