2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 07:16:03 +00:00

ENIGMA2: add attribute macaddr

git-svn-id: https://svn.fhem.de/fhem/trunk@7705 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2015-01-25 11:28:00 +00:00
parent e76df61ab3
commit 1725473539

View File

@ -24,7 +24,7 @@
# along with fhem. If not, see <http://www.gnu.org/licenses/>. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
# #
# #
# Version: 1.4.1 # Version: 1.4.4
# #
# Major Version History: # Major Version History:
# - 1.4.0 - 2014-11-27 # - 1.4.0 - 2014-11-27
@ -83,7 +83,7 @@ sub ENIGMA2_Initialize($) {
$hash->{UndefFn} = "ENIGMA2_Undefine"; $hash->{UndefFn} = "ENIGMA2_Undefine";
$hash->{AttrList} = $hash->{AttrList} =
"https:0,1 http-method:GET,POST http-noshutdown:1,0 disable:0,1 bouquet-tv bouquet-radio timeout remotecontrol:standard,advanced,keyboard lightMode:0,1 " "https:0,1 http-method:GET,POST http-noshutdown:1,0 disable:0,1 bouquet-tv bouquet-radio timeout remotecontrol:standard,advanced,keyboard lightMode:0,1 macaddr:textField"
. $readingFnAttributes; . $readingFnAttributes;
$data{RC_layout}{ENIGMA2_DreamMultimedia_DM500_DM800_SVG} = $data{RC_layout}{ENIGMA2_DreamMultimedia_DM500_DM800_SVG} =
@ -334,14 +334,20 @@ sub ENIGMA2_Set($@) {
if ( $hash->{READINGS}{state}{VAL} eq "absent" ) { if ( $hash->{READINGS}{state}{VAL} eq "absent" ) {
Log3 $name, 2, "ENIGMA2 set $name " . $a[1] . " (wakeup)"; Log3 $name, 2, "ENIGMA2 set $name " . $a[1] . " (wakeup)";
if ( defined( $hash->{READINGS}{lanmac}{VAL} ) if (
&& $hash->{READINGS}{lanmac}{VAL} ne "-" ) (
defined( $hash->{READINGS}{lanmac}{VAL} )
&& $hash->{READINGS}{lanmac}{VAL} ne "-"
)
|| ( defined( $attr{$name}{macaddr} )
&& $attr{$name}{macaddr} ne "" )
)
{ {
$result = ENIGMA2_wake($hash); $result = ENIGMA2_wake($hash);
} }
else { else {
return return
"Device MAC address unknown. Please turn on the device manually once."; "Device MAC address unknown. Please turn on the device manually once or set attribute macaddr.";
} }
} }
else { else {
@ -821,7 +827,8 @@ sub ENIGMA2_SendCommand($$;$$) {
my $address = $hash->{helper}{ADDRESS}; my $address = $hash->{helper}{ADDRESS};
my $port = $hash->{helper}{PORT}; my $port = $hash->{helper}{PORT};
my $http_method = $attr{$name}{"http-method"}; my $http_method = $attr{$name}{"http-method"};
my $http_noshutdown = ( defined($attr{$name}{"http-noshutdown"}) && $attr{$name}{"http-noshutdown"} eq "0" ) ? 0 : 1; my $http_noshutdown = ( defined( $attr{$name}{"http-noshutdown"} )
&& $attr{$name}{"http-noshutdown"} eq "0" ) ? 0 : 1;
my $timeout; my $timeout;
$cmd = ( defined($cmd) ) ? $cmd : ""; $cmd = ( defined($cmd) ) ? $cmd : "";
@ -891,7 +898,11 @@ sub ENIGMA2_SendCommand($$;$$) {
# send request via HTTP-GET method # send request via HTTP-GET method
if ( $http_method eq "GET" || $http_method eq "" || $cmd eq "" ) { if ( $http_method eq "GET" || $http_method eq "" || $cmd eq "" ) {
Log3 $name, 5, "ENIGMA2 $name: GET " . urlDecode($URL) . " (noshutdown=" . $http_noshutdown . ")"; Log3 $name, 5,
"ENIGMA2 $name: GET "
. urlDecode($URL)
. " (noshutdown="
. $http_noshutdown . ")";
HttpUtils_NonblockingGet( HttpUtils_NonblockingGet(
{ {
@ -915,7 +926,9 @@ sub ENIGMA2_SendCommand($$;$$) {
"ENIGMA2 $name: GET " "ENIGMA2 $name: GET "
. $URL . $URL
. " (POST DATA: " . " (POST DATA: "
. urlDecode($cmd) . ", noshutdown=" . $http_noshutdown . ")"; . urlDecode($cmd)
. ", noshutdown="
. $http_noshutdown . ")";
HttpUtils_NonblockingGet( HttpUtils_NonblockingGet(
{ {
@ -2275,7 +2288,10 @@ sub ENIGMA2_Undefine($$) {
sub ENIGMA2_wake ($) { sub ENIGMA2_wake ($) {
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $mac_addr = $hash->{READINGS}{lanmac}{VAL}; my $mac_addr =
( defined( $attr{$name}{macaddr} ) )
? $attr{$name}{macaddr}
: $hash->{READINGS}{lanmac}{VAL};
my $address; my $address;
my $port; my $port;