Compare commits

...

3 Commits

3 changed files with 195 additions and 200 deletions

View File

@ -2,7 +2,7 @@
#
# Developed with VSCodium and richterger perl plugin.
#
# (c) 2017-2023 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net)
# (c) 2017-2025 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net)
# All rights reserved
#
# Special thanks goes to comitters:
@ -369,7 +369,7 @@ __END__
],
"release_status": "stable",
"license": "GPL_2",
"version": "v3.6.9",
"version": "v3.7.0",
"author": [
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
],

View File

@ -1,2 +1,2 @@
UPD 2023-11-15_19:19:41 19028 FHEM/82_LGTV_WebOS.pm
UPD 2023-11-17_18:00:13 56133 lib/FHEM/Devices/LGTV/LGTVWebOS.pm
UPD 2024-10-12_08:39:35 19028 FHEM/82_LGTV_WebOS.pm
UPD 2024-10-12_08:45:10 55683 lib/FHEM/Devices/LGTV/LGTVWebOS.pm

View File

@ -32,7 +32,8 @@ package FHEM::Devices::LGTV::LGTVWebOS;
use strict;
use warnings;
use experimental qw /switch/;
# use experimental qw /switch/; deprecated
## try / catch
use Try::Tiny;
@ -406,8 +407,7 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
my $uri;
my %payload;
given ($cmd) {
when ('connect') {
if ( $cmd eq 'connect' ) {
return "usage: connect" if ( @args != 0 );
Open($hash);
@ -415,7 +415,7 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
return;
}
when ('clearInputList') {
elsif ( $cmd eq 'clearInputList' ) {
return "usage: clearInputList" if ( @args != 0 );
delete $hash->{helper}{device}{inputs};
@ -424,7 +424,7 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
return;
}
when ('pairing') {
elsif ( $cmd eq 'pairing' ) {
return "usage: pairing" if ( @args != 0 );
Pairing($hash);
@ -432,7 +432,7 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
return;
}
when ('screenMsg') {
elsif ( $cmd eq 'screenMsg' ) {
return "usage: screenMsg <message>" if ( @args < 1 );
my $msg = join( " ", @args );
@ -440,12 +440,12 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
$uri = $lgCommands{$cmd}->[0];
}
when ('off') {
elsif ( $cmd eq 'off' ) {
return "usage: on/off" if ( @args != 0 );
$uri = $lgCommands{powerOff};
}
when ('on') {
elsif ( $cmd eq 'on' ) {
if ( ::AttrVal( $name, 'wakeOnLanMAC', 'none' ) ne 'none' ) {
WakeUp_Udp(
$hash,
@ -458,8 +458,7 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
my $wakeupCmd = ::AttrVal( $name, 'wakeupCmd', 'none' );
if ( $wakeupCmd =~ s/^[ \t]*\{|\}[ \t]*$//xg ) {
::Log3( $name, 4,
"LGTV_WebOS executing wake-up command (Perl): $wakeupCmd"
);
"LGTV_WebOS executing wake-up command (Perl): $wakeupCmd" );
eval { $wakeupCmd } or do {
::Log3( $name, 2,
"LGTV_WebOS executing wake-up command (Perl): $wakeupCmd failed"
@ -470,8 +469,7 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
}
else {
::Log3( $name, 4,
"LGTV_WebOS executing wake-up command (fhem): $wakeupCmd"
);
"LGTV_WebOS executing wake-up command (fhem): $wakeupCmd" );
::fhem $wakeupCmd;
return;
}
@ -480,7 +478,7 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
$uri = $lgCommands{powerOn};
}
}
when ('3D') {
elsif ( $cmd eq '3D' ) {
return "usage: 3D on/off" if ( @args != 1 );
if ( $args[0] eq 'off' ) {
@ -491,7 +489,7 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
}
}
when ('mute') {
elsif ( $cmd eq 'mute' ) {
return "usage: mute" if ( @args != 1 );
if ( $args[0] eq 'off' ) {
@ -506,14 +504,14 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
}
}
when ('volume') {
elsif ( $cmd eq 'volume' ) {
return "usage: volume" if ( @args != 1 );
$payload{ $lgCommands{$cmd}->[1] } = int( join( " ", @args ) );
$uri = $lgCommands{$cmd}->[0];
}
when ('launchApp') {
elsif ( $cmd eq 'launchApp' ) {
return "usage: launchApp" if ( @args != 1 );
$payload{ $lgCommands{$cmd}->[1] } =
@ -521,7 +519,7 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
$uri = $lgCommands{$cmd}->[0];
}
when ('input') {
elsif ( $cmd eq 'input' ) {
return "usage: input" if ( @args != 1 );
my $inputLabel = join( " ", @args );
@ -530,92 +528,92 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
$uri = $lgCommands{launchApp}->[0];
}
when ('volumeUp') {
elsif ( $cmd eq 'volumeUp' ) {
return "usage: volumeUp" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('volumeDown') {
elsif ( $cmd eq 'volumeDown' ) {
return "usage: volumeDown" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('channelDown') {
elsif ( $cmd eq 'channelDown' ) {
return "usage: channelDown" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('channelUp') {
elsif ( $cmd eq 'channelUp' ) {
return "usage: channelUp" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('channel') {
elsif ( $cmd eq 'channel' ) {
return "usage: channel" if ( @args != 1 );
$payload{ $lgCommands{openChannel}->[1] } = join( " ", @args );
$uri = $lgCommands{openChannel}->[0];
}
when ('getServiceList') {
elsif ( $cmd eq 'getServiceList' ) {
return "usage: getServiceList" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('getChannelList') {
elsif ( $cmd eq 'getChannelList' ) {
return "usage: getChannelList" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('getAppList') {
elsif ( $cmd eq 'getAppList' ) {
return "usage: getAppList" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('getExternalInputList') {
elsif ( $cmd eq 'getExternalInputList' ) {
return "usage: getExternalInputList" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('play') {
elsif ( $cmd eq 'play' ) {
return "usage: play" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('stop') {
elsif ( $cmd eq 'stop' ) {
return "usage: stop" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('fastForward') {
elsif ( $cmd eq 'fastForward' ) {
return "usage: fastForward" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('rewind') {
elsif ( $cmd eq 'rewind' ) {
return "usage: rewind" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
when ('pause') {
elsif ( $cmd eq 'pause' ) {
return "usage: pause" if ( @args != 0 );
$uri = $lgCommands{$cmd}->[0];
}
default {
else {
my $list = "";
$list .=
'connect:noArg pairing:noArg screenMsg mute:on,off volume:slider,0,1,100 volumeUp:noArg volumeDown:noArg channelDown:noArg channelUp:noArg getServiceList:noArg on:noArg off:noArg';
@ -634,7 +632,6 @@ sub Set { ## no critic (Subroutine "Set" with high complexity score)
return "Unknown argument $cmd, choose one of $list";
}
}
$hash->{helper}{device}{runsetcmd} = $hash->{helper}{device}{runsetcmd} + 1;
return CreateSendCommand( $hash, $uri, \%payload );
@ -1499,28 +1496,26 @@ sub Hybi10Encode {
my $frame = "";
my $payloadLength = length($payload);
given ($type) {
when ('text') {
if ( $type eq 'text' ) {
# first byte indicates FIN, Text-Frame (10000001):
$frameHead[0] = 129;
}
when ('close') {
elsif ( $type eq 'close' ) {
# first byte indicates FIN, Close Frame(10001000):
$frameHead[0] = 136;
}
when ('ping') {
elsif ( $type eq 'ping' ) {
# first byte indicates FIN, Ping frame (10001001):
$frameHead[0] = 137;
}
when ('pong') {
elsif ( $type eq 'pong' ) {
# first byte indicates FIN, Pong frame (10001010):
$frameHead[0] = 138;
}
}
# set mask and payload length (using 1, 3 or 9 bytes)
if ( $payloadLength > 65535 ) {