2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 19:36:02 +00:00

ENIGMA2: improved logging, default attributes for webCmd and devStateIcon

git-svn-id: https://svn.fhem.de/fhem/trunk@4392 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2013-12-16 13:38:30 +00:00
parent b95f7e0253
commit 9ed66677ff
2 changed files with 131 additions and 34 deletions

View File

@ -1,6 +1,8 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- SVN - SVN
- feature: ENIGMA2: improved logging, default attributes for webCmd and devStateIcon
- bugfix: ENIGMA2: support for option channels
- feature: mailcheck: decode non ascii subjet to utf-8, - feature: mailcheck: decode non ascii subjet to utf-8,
verify gpg signatures verify gpg signatures
- feature: PRESENCE: "statusRequest" command for lan-bluetooth mode - feature: PRESENCE: "statusRequest" command for lan-bluetooth mode

View File

@ -24,9 +24,13 @@
# along with fhem. If not, see <http://www.gnu.org/licenses/>. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
# #
# #
# Version: 1.0.1 # Version: 1.1.0
# #
# Version History: # Version History:
# - 1.1.0 - 2013-12-16
# -- Improved logging & debugging
# -- added default attributes for webCmd and devStateIcon
#
# - 1.0.1 - 2013-12-15 # - 1.0.1 - 2013-12-15
# -- Bugfix release # -- Bugfix release
# #
@ -103,6 +107,9 @@ sub ENIGMA2_GetStatus($;$) {
my $changecount = 0; my $changecount = 0;
$local = 0 unless ( defined($local) ); $local = 0 unless ( defined($local) );
if ( defined( $hash->{attr}{disable} ) && $hash->{attr}{disable} eq "1" ) {
return $hash->{STATE};
}
InternalTimer( gettimeofday() + $interval, "ENIGMA2_GetStatus", $hash, 0 ) InternalTimer( gettimeofday() + $interval, "ENIGMA2_GetStatus", $hash, 0 )
unless ( $local == 1 ); unless ( $local == 1 );
@ -124,18 +131,26 @@ sub ENIGMA2_GetStatus($;$) {
$signalinfo = ENIGMA2_SendCommand( $hash, "signal", "" ); $signalinfo = ENIGMA2_SendCommand( $hash, "signal", "" );
$vol = ENIGMA2_SendCommand( $hash, "vol", "" ); $vol = ENIGMA2_SendCommand( $hash, "vol", "" );
#FIXME workaround for option channels # Read eventinfo
# multiple
if ( ref($serviceinfo) eq "HASH" if ( ref($serviceinfo) eq "HASH"
&& ref( $serviceinfo->{e2service} ) eq "ARRAY" ) && defined( $serviceinfo->{e2service} )
&& ref( $serviceinfo->{e2service} ) eq "ARRAY"
&& defined( $serviceinfo->{e2service}[0]{e2servicereference} )
&& $serviceinfo->{e2service}[0]{e2servicereference} ne "" )
{ {
$serviceinfo = ( $eventinfo = ENIGMA2_SendCommand(
e2service => $serviceinfo->{e2service}, $hash,
e2servicereference => "epgservicenow",
"sRef="
. urlEncode(
$serviceinfo->{e2service}[0]{e2servicereference} $serviceinfo->{e2service}[0]{e2servicereference}
)
); );
} }
if ( ref($serviceinfo) eq "HASH" # single
elsif (ref($serviceinfo) eq "HASH"
&& defined( $serviceinfo->{e2service}{e2servicereference} ) && defined( $serviceinfo->{e2service}{e2servicereference} )
&& $serviceinfo->{e2service}{e2servicereference} ne "" ) && $serviceinfo->{e2service}{e2servicereference} ne "" )
{ {
@ -392,19 +407,42 @@ sub ENIGMA2_GetStatus($;$) {
} }
} }
#FIXME workaround for option channels # servicereference + input + currentMedia
# multiple
if ( ref($serviceinfo) eq "HASH" if ( ref($serviceinfo) eq "HASH"
&& defined( $serviceinfo->{e2service} )
&& ref( $serviceinfo->{e2service} ) eq "ARRAY" ) && ref( $serviceinfo->{e2service} ) eq "ARRAY" )
{ {
$serviceinfo = ( if ( $serviceinfo->{e2service}[0]{e2servicereference} ne "" ) {
e2service => $serviceinfo->{e2service}, if ( !defined( $hash->{READINGS}{servicereference}{VAL} )
e2servicereference => || $hash->{READINGS}{servicereference}{VAL} ne
$serviceinfo->{e2service}[0]{e2servicereference} $serviceinfo->{e2service}[0]{e2servicereference} )
); {
readingsBulkUpdate( $hash, "servicereference",
$serviceinfo->{e2service}[0]{e2servicereference}, 1 );
readingsBulkUpdate( $hash, "currentMedia",
$serviceinfo->{e2service}[0]{e2servicereference}, 1 );
my @servicetype = split( /:/,
$serviceinfo->{e2service}[0]{e2servicereference} );
if ( ref(@servicetype) eq "ARRAY"
&& $servicetype[2] eq "2" )
{
readingsBulkUpdate( $hash, "input", "radio", 1 );
}
else {
readingsBulkUpdate( $hash, "input", "tv", 1 );
}
}
}
elsif ( $hash->{READINGS}{servicereference}{VAL} ne "-" ) {
readingsBulkUpdate( $hash, "servicereference", "-", 1 );
readingsBulkUpdate( $hash, "currentMedia", "-", 1 );
}
} }
# servicereference + input + currentMedia # single
if ( ref($serviceinfo) eq "HASH" elsif ( ref($serviceinfo) eq "HASH"
&& defined( $serviceinfo->{e2service} ) ) && defined( $serviceinfo->{e2service} ) )
{ {
if ( $serviceinfo->{e2service}{e2servicereference} ne "" ) { if ( $serviceinfo->{e2service}{e2servicereference} ne "" ) {
@ -568,8 +606,6 @@ sub ENIGMA2_GetStatus($;$) {
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
Log3 $name, 4, "ENIGMA2 $name: " . $hash->{STATE};
return $hash->{STATE}; return $hash->{STATE};
} }
@ -639,6 +675,7 @@ sub ENIGMA2_Set($@) {
# statusRequest # statusRequest
if ( $a[1] eq "statusRequest" ) { if ( $a[1] eq "statusRequest" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
# Will be executed anyway on the end of the function # Will be executed anyway on the end of the function
@ -646,6 +683,8 @@ sub ENIGMA2_Set($@) {
# toggle # toggle
elsif ( $a[1] eq "toggle" ) { elsif ( $a[1] eq "toggle" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{power}{VAL} eq "off" ) { if ( $hash->{READINGS}{power}{VAL} eq "off" ) {
ENIGMA2_Set( $hash, "on" ); ENIGMA2_Set( $hash, "on" );
return undef; return undef;
@ -659,26 +698,32 @@ sub ENIGMA2_Set($@) {
# shutdown # shutdown
elsif ( $a[1] eq "shutdown" ) { elsif ( $a[1] eq "shutdown" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{state}{VAL} ne "absent" ) { if ( $hash->{READINGS}{state}{VAL} ne "absent" ) {
$cmd = "newstate=1"; $cmd = "newstate=1";
$result = ENIGMA2_SendCommand( $hash, "powerstate", $cmd ); $result = ENIGMA2_SendCommand( $hash, "powerstate", $cmd );
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
if ( !defined( $hash->{READINGS}{state}{VAL} ) if ( !defined( $hash->{READINGS}{state}{VAL} )
|| $hash->{READINGS}{power}{VAL} ne "off" ) || $hash->{READINGS}{power}{VAL} ne "off" )
{ {
readingsBulkUpdate( $hash, "power", "off" ); readingsBulkUpdate( $hash, "power", "off" );
} }
if ( !defined( $hash->{READINGS}{presence}{VAL} ) if ( !defined( $hash->{READINGS}{presence}{VAL} )
|| $hash->{READINGS}{presence}{VAL} ne "absent" ) || $hash->{READINGS}{presence}{VAL} ne "absent" )
{ {
$hash->{helper}{AVAILABLE} = 0; $hash->{helper}{AVAILABLE} = 0;
readingsBulkUpdate( $hash, "presence", "absent" ); readingsBulkUpdate( $hash, "presence", "absent" );
} }
if ( !defined( $hash->{READINGS}{state}{VAL} ) if ( !defined( $hash->{READINGS}{state}{VAL} )
|| $hash->{READINGS}{state}{VAL} ne "absent" ) || $hash->{READINGS}{state}{VAL} ne "absent" )
{ {
readingsBulkUpdate( $hash, "state", "absent" ); readingsBulkUpdate( $hash, "state", "absent" );
} }
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
} }
else { else {
@ -688,6 +733,8 @@ sub ENIGMA2_Set($@) {
# reboot # reboot
elsif ( $a[1] eq "reboot" ) { elsif ( $a[1] eq "reboot" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{state}{VAL} ne "absent" ) { if ( $hash->{READINGS}{state}{VAL} ne "absent" ) {
$cmd = "newstate=2"; $cmd = "newstate=2";
$result = ENIGMA2_SendCommand( $hash, "powerstate", $cmd ); $result = ENIGMA2_SendCommand( $hash, "powerstate", $cmd );
@ -699,6 +746,8 @@ sub ENIGMA2_Set($@) {
# restartGui # restartGui
elsif ( $a[1] eq "restartGui" ) { elsif ( $a[1] eq "restartGui" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{state}{VAL} eq "on" ) { if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
$cmd = "newstate=3"; $cmd = "newstate=3";
$result = ENIGMA2_SendCommand( $hash, "powerstate", $cmd ); $result = ENIGMA2_SendCommand( $hash, "powerstate", $cmd );
@ -710,6 +759,8 @@ sub ENIGMA2_Set($@) {
# on # on
elsif ( $a[1] eq "on" ) { elsif ( $a[1] eq "on" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{state}{VAL} eq "absent" ) { if ( $hash->{READINGS}{state}{VAL} eq "absent" ) {
if ( defined( $hash->{READINGS}{lanmac}{VAL} ) if ( defined( $hash->{READINGS}{lanmac}{VAL} )
&& $hash->{READINGS}{lanmac}{VAL} ne "-" ) && $hash->{READINGS}{lanmac}{VAL} ne "-" )
@ -742,6 +793,8 @@ sub ENIGMA2_Set($@) {
# off # off
elsif ( $a[1] eq "off" ) { elsif ( $a[1] eq "off" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{state}{VAL} ne "absent" ) { if ( $hash->{READINGS}{state}{VAL} ne "absent" ) {
$cmd = "newstate=5"; $cmd = "newstate=5";
$result = ENIGMA2_SendCommand( $hash, "powerstate", $cmd ); $result = ENIGMA2_SendCommand( $hash, "powerstate", $cmd );
@ -765,6 +818,8 @@ sub ENIGMA2_Set($@) {
# volume # volume
elsif ( $a[1] eq "volume" ) { elsif ( $a[1] eq "volume" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1] . " " . $a[2];
return "No argument given" if ( !defined( $a[2] ) ); return "No argument given" if ( !defined( $a[2] ) );
if ( $hash->{READINGS}{state}{VAL} eq "on" ) { if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
@ -790,6 +845,8 @@ sub ENIGMA2_Set($@) {
# volumeUp/volumeDown # volumeUp/volumeDown
elsif ( $a[1] =~ /^(volumeUp|volumeDown)$/ ) { elsif ( $a[1] =~ /^(volumeUp|volumeDown)$/ ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{state}{VAL} eq "on" ) { if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
if ( $a[1] eq "volumeUp" ) { if ( $a[1] eq "volumeUp" ) {
$cmd = "set=up"; $cmd = "set=up";
@ -806,6 +863,8 @@ sub ENIGMA2_Set($@) {
# mute # mute
elsif ( $a[1] eq "mute" ) { elsif ( $a[1] eq "mute" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1] . " " . $a[2];
if ( $hash->{READINGS}{state}{VAL} eq "on" ) { if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
if ( $a[2] eq "off" ) { if ( $a[2] eq "off" ) {
if ( $hash->{READINGS}{mute}{VAL} ne "off" ) { if ( $hash->{READINGS}{mute}{VAL} ne "off" ) {
@ -840,20 +899,27 @@ sub ENIGMA2_Set($@) {
# msg # msg
elsif ( $a[1] eq "msg" ) { elsif ( $a[1] eq "msg" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1] . " " . $a[2];
if ( $hash->{READINGS}{state}{VAL} ne "absent" ) { if ( $hash->{READINGS}{state}{VAL} ne "absent" ) {
return return
"No 1st argument given, choose one of yesno info message attention " "No 1st argument given, choose one of yesno info message attention "
if ( !defined( $a[2] ) ); if ( !defined( $a[2] ) );
return "No 2nd argument given, choose one of timeout " return "No 2nd argument given, choose one of timeout "
if ( !defined( $a[3] ) ); if ( !defined( $a[3] ) );
return "No 3nd argument given, choose one of messagetext " return "No 3nd argument given, choose one of messagetext "
if ( !defined( $a[4] ) ); if ( !defined( $a[4] ) );
$_ = $a[3]; $_ = $a[3];
return return
"Argument " "Argument "
. $_ . $_
. " is not a valid integer between 5 and 49680" . " is not a valid integer between 5 and 49680"
if ( !m/^\d+$/ || $_ < 5 || $_ > 49680 ); if ( !m/^\d+$/ || $_ < 5 || $_ > 49680 );
my $i = 4; my $i = 4;
my $text = $a[$i]; my $text = $a[$i];
$i++; $i++;
@ -892,6 +958,8 @@ sub ENIGMA2_Set($@) {
# remoteControl # remoteControl
elsif ( $a[1] eq "remoteControl" ) { elsif ( $a[1] eq "remoteControl" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1] . " " . $a[2];
if ( $hash->{READINGS}{state}{VAL} ne "absent" ) { if ( $hash->{READINGS}{state}{VAL} ne "absent" ) {
if ( !defined( $a[2] ) ) { if ( !defined( $a[2] ) ) {
my $commandKeys = ""; my $commandKeys = "";
@ -943,9 +1011,12 @@ sub ENIGMA2_Set($@) {
# channel # channel
elsif ( $a[1] eq "channel" ) { elsif ( $a[1] eq "channel" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1] . " " . $a[2];
return return
"No argument given, choose one of channelNumber servicereference " "No argument given, choose one of channelNumber servicereference "
if ( !defined( $a[2] ) ); if ( !defined( $a[2] ) );
if ( $hash->{READINGS}{state}{VAL} eq "on" ) { if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
my $_ = $a[2]; my $_ = $a[2];
if (m/^(\d+):(.*):$/) { if (m/^(\d+):(.*):$/) {
@ -972,6 +1043,8 @@ sub ENIGMA2_Set($@) {
# channelUp/channelDown # channelUp/channelDown
elsif ( $a[1] =~ /^(channelUp|channelDown)$/ ) { elsif ( $a[1] =~ /^(channelUp|channelDown)$/ ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{state}{VAL} eq "on" ) { if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
if ( $a[1] eq "channelUp" ) { if ( $a[1] eq "channelUp" ) {
$cmd = "command=" . ENIGMA2_GetRemotecontrolCommand("RIGHT"); $cmd = "command=" . ENIGMA2_GetRemotecontrolCommand("RIGHT");
@ -988,6 +1061,8 @@ sub ENIGMA2_Set($@) {
# input # input
elsif ( $a[1] eq "input" ) { elsif ( $a[1] eq "input" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1] . " " . $a[2];
if ( $hash->{READINGS}{state}{VAL} eq "on" ) { if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
if ( $a[2] eq "tv" || $a[2] eq "TV" ) { if ( $a[2] eq "tv" || $a[2] eq "TV" ) {
$cmd = "command=" . ENIGMA2_GetRemotecontrolCommand("TV"); $cmd = "command=" . ENIGMA2_GetRemotecontrolCommand("TV");
@ -1012,6 +1087,8 @@ sub ENIGMA2_Set($@) {
# play / pause # play / pause
elsif ( $a[1] =~ /^(play|pause)$/ ) { elsif ( $a[1] =~ /^(play|pause)$/ ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{state}{VAL} eq "on" ) { if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
$cmd = "command=" . ENIGMA2_GetRemotecontrolCommand("PLAYPAUSE"); $cmd = "command=" . ENIGMA2_GetRemotecontrolCommand("PLAYPAUSE");
$result = ENIGMA2_SendCommand( $hash, "remotecontrol", $cmd ); $result = ENIGMA2_SendCommand( $hash, "remotecontrol", $cmd );
@ -1023,6 +1100,8 @@ sub ENIGMA2_Set($@) {
# stop # stop
elsif ( $a[1] eq "stop" ) { elsif ( $a[1] eq "stop" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{state}{VAL} eq "on" ) { if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
$cmd = "command=" . ENIGMA2_GetRemotecontrolCommand("STOP"); $cmd = "command=" . ENIGMA2_GetRemotecontrolCommand("STOP");
$result = ENIGMA2_SendCommand( $hash, "remotecontrol", $cmd ); $result = ENIGMA2_SendCommand( $hash, "remotecontrol", $cmd );
@ -1034,6 +1113,8 @@ sub ENIGMA2_Set($@) {
# showText # showText
elsif ( $a[1] eq "showText" ) { elsif ( $a[1] eq "showText" ) {
Log3 $name, 3, "ENIGMA2 set $name " . $a[1];
if ( $hash->{READINGS}{state}{VAL} ne "absent" ) { if ( $hash->{READINGS}{state}{VAL} ne "absent" ) {
return "No argument given, choose one of messagetext " return "No argument given, choose one of messagetext "
if ( !defined( $a[2] ) ); if ( !defined( $a[2] ) );
@ -1105,6 +1186,15 @@ sub ENIGMA2_Define($$) {
my $http_passwd = $a[6]; my $http_passwd = $a[6];
$hash->{helper}{PASSWORD} = $http_passwd if $http_passwd; $hash->{helper}{PASSWORD} = $http_passwd if $http_passwd;
# set default attributes
unless ( exists( $hash->{attr}{webCmd} ) ) {
$attr{$name}{webCmd} = 'channel:input';
}
unless ( exists( $hash->{attr}{devStateIcon} ) ) {
$attr{$name}{devStateIcon} =
'on:rc_GREEN:off off:rc_YELLOW:on absent:rc_STOP:on';
}
unless ( exists( $hash->{helper}{AVAILABLE} ) unless ( exists( $hash->{helper}{AVAILABLE} )
and ( $hash->{helper}{AVAILABLE} == 0 ) ) and ( $hash->{helper}{AVAILABLE} == 0 ) )
{ {
@ -1119,7 +1209,7 @@ sub ENIGMA2_Define($$) {
return undef; return undef;
} }
############################################################################################################# ############################################################################################################
# #
# Begin of helper functions # Begin of helper functions
# #
@ -1140,15 +1230,13 @@ sub ENIGMA2_SendCommand($$;$) {
my $response; my $response;
my $return; my $return;
if ( !defined($cmd) ) { if ( !defined($cmd) || $cmd eq "" ) {
my $cmd = ""; Log3 $name, 4, "ENIGMA2 $name: REQUEST $service";
} }
else { else {
$cmd = $cmd . "&"; Log3 $name, 4, "ENIGMA2 $name: REQUEST $service -> $cmd";
} }
Log3 $name, 5, "ENIGMA2: execute on $name: $service -> $cmd";
if ( defined($http_user) && defined($http_passwd) ) { if ( defined($http_user) && defined($http_passwd) ) {
$URL = $URL =
"http://" "http://"
@ -1173,11 +1261,9 @@ sub ENIGMA2_SendCommand($$;$) {
"http://" . $address . ":" . $port . "/web/" . $service . "?" . $cmd; "http://" . $address . ":" . $port . "/web/" . $service . "?" . $cmd;
} }
$response = Log3 $name, 5, "ENIGMA2 $name: GET $URL";
Encode::encode_utf8( CustomGetFileFromURL( 0, $URL, 4, $cmd, 0, 5 ) );
Log3 $name, 5, "ENIGMA2: got response for $name: $service" $response = CustomGetFileFromURL( 0, $URL, 4, $cmd, 0, 5 );
if ( defined($response) );
unless ( defined($response) ) { unless ( defined($response) ) {
if ( if (
@ -1186,7 +1272,7 @@ sub ENIGMA2_SendCommand($$;$) {
and $hash->{helper}{AVAILABLE} eq 1 ) and $hash->{helper}{AVAILABLE} eq 1 )
) )
{ {
Log3 $name, 3, "ENIGMA2: device $name is unavailable"; Log3 $name, 3, "ENIGMA2 device $name is unavailable";
readingsSingleUpdate( $hash, "presence", "absent", 1 ); readingsSingleUpdate( $hash, "presence", "absent", 1 );
} }
} }
@ -1194,18 +1280,27 @@ sub ENIGMA2_SendCommand($$;$) {
if ( defined( $hash->{helper}{AVAILABLE} ) if ( defined( $hash->{helper}{AVAILABLE} )
and $hash->{helper}{AVAILABLE} eq 0 ) and $hash->{helper}{AVAILABLE} eq 0 )
{ {
Log3 $name, 3, "ENIGMA2: device $name is available"; Log3 $name, 3, "ENIGMA2 device $name is available";
readingsSingleUpdate( $hash, "presence", "present", 1 ); readingsSingleUpdate( $hash, "presence", "present", 1 );
} }
if ( !defined($cmd) || $cmd eq "" ) {
Log3 $name, 4, "ENIGMA2 $name: RECEIVED $service";
}
else {
Log3 $name, 4, "ENIGMA2 $name: RECEIVED $cmd";
}
if ( $response ne "" ) { if ( $response ne "" ) {
Log3 $name, 5, "ENIGMA2 $name: RESPONSE " . $response;
my $parser = XML::Simple->new( my $parser = XML::Simple->new(
NormaliseSpace => 2, NormaliseSpace => 2,
KeepRoot => 0, KeepRoot => 0,
ForceArray => 0, ForceArray => 0,
SuppressEmpty => 1 SuppressEmpty => 1
); );
$return = $parser->XMLin($response); $return = $parser->XMLin( Encode::encode_utf8($response) );
} }
$hash->{helper}{AVAILABLE} = ( defined($response) ? 1 : 0 ); $hash->{helper}{AVAILABLE} = ( defined($response) ? 1 : 0 );
@ -1214,7 +1309,7 @@ sub ENIGMA2_SendCommand($$;$) {
return $return; return $return;
} }
else { else {
return $response; return Encode::encode_utf8($response);
} }
} }
@ -1257,14 +1352,14 @@ sub ENIGMA2_wake ($) {
or die "setsockopt : $!"; or die "setsockopt : $!";
Log3 $name, 4, Log3 $name, 4,
"ENIGMA2: Waking up $name by sending Wake-On-Lan magic package to " "ENIGMA2 $name: Waking up by sending Wake-On-Lan magic package to "
. $mac_addr; . $mac_addr;
send( $sock, $packet, 0, $sock_addr ) or die "send : $!"; send( $sock, $packet, 0, $sock_addr ) or die "send : $!";
close($sock); close($sock);
} }
else { else {
Log3 $name, 3, Log3 $name, 3,
"ENIGMA2: MAC address for $name unknown. Please turn on manually once."; "ENIGMA2 $name: Unknown MAC address. Please turn on device manually once.";
} }
return 1; return 1;