change code to PBP style
This commit is contained in:
parent
79774e3352
commit
ecd35d4526
@ -410,7 +410,8 @@ sub LGTV_WebOS_Set {
|
|||||||
my $uri;
|
my $uri;
|
||||||
my %payload;
|
my %payload;
|
||||||
|
|
||||||
if ( $cmd eq 'connect' ) {
|
given ($cmd) {
|
||||||
|
when ('connect') {
|
||||||
return "usage: connect" if ( @args != 0 );
|
return "usage: connect" if ( @args != 0 );
|
||||||
|
|
||||||
LGTV_WebOS_Open($hash);
|
LGTV_WebOS_Open($hash);
|
||||||
@ -418,7 +419,7 @@ sub LGTV_WebOS_Set {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'clearInputList' ) {
|
when ('clearInputList') {
|
||||||
return "usage: clearInputList" if ( @args != 0 );
|
return "usage: clearInputList" if ( @args != 0 );
|
||||||
|
|
||||||
delete $hash->{helper}{device}{inputs};
|
delete $hash->{helper}{device}{inputs};
|
||||||
@ -427,7 +428,7 @@ sub LGTV_WebOS_Set {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'pairing' ) {
|
when ('pairing') {
|
||||||
return "usage: pairing" if ( @args != 0 );
|
return "usage: pairing" if ( @args != 0 );
|
||||||
|
|
||||||
LGTV_WebOS_Pairing($hash);
|
LGTV_WebOS_Pairing($hash);
|
||||||
@ -435,7 +436,7 @@ sub LGTV_WebOS_Set {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'screenMsg' ) {
|
when ('screenMsg') {
|
||||||
return "usage: screenMsg <message>" if ( @args < 1 );
|
return "usage: screenMsg <message>" if ( @args < 1 );
|
||||||
|
|
||||||
my $msg = join( " ", @args );
|
my $msg = join( " ", @args );
|
||||||
@ -443,13 +444,12 @@ sub LGTV_WebOS_Set {
|
|||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'on' || $cmd eq 'off' ) {
|
when ('off') {
|
||||||
return "usage: on/off" if ( @args != 0 );
|
return "usage: on/off" if ( @args != 0 );
|
||||||
|
|
||||||
if ( $cmd eq 'off' ) {
|
|
||||||
$uri = $lgCommands{powerOff};
|
$uri = $lgCommands{powerOff};
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'on' ) {
|
when ('on') {
|
||||||
if ( AttrVal( $name, 'wakeOnLanMAC', 'none' ) ne 'none' ) {
|
if ( AttrVal( $name, 'wakeOnLanMAC', 'none' ) ne 'none' ) {
|
||||||
LGTV_WebOS_WakeUp_Udp(
|
LGTV_WebOS_WakeUp_Udp(
|
||||||
$hash,
|
$hash,
|
||||||
@ -481,9 +481,7 @@ sub LGTV_WebOS_Set {
|
|||||||
$uri = $lgCommands{powerOn};
|
$uri = $lgCommands{powerOn};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
when ('3D') {
|
||||||
}
|
|
||||||
elsif ( $cmd eq '3D' ) {
|
|
||||||
return "usage: 3D on/off" if ( @args != 1 );
|
return "usage: 3D on/off" if ( @args != 1 );
|
||||||
|
|
||||||
if ( $args[0] eq 'off' ) {
|
if ( $args[0] eq 'off' ) {
|
||||||
@ -494,7 +492,7 @@ sub LGTV_WebOS_Set {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'mute' ) {
|
when ('mute') {
|
||||||
return "usage: mute" if ( @args != 1 );
|
return "usage: mute" if ( @args != 1 );
|
||||||
|
|
||||||
if ( $args[0] eq 'off' ) {
|
if ( $args[0] eq 'off' ) {
|
||||||
@ -509,21 +507,22 @@ sub LGTV_WebOS_Set {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'volume' ) {
|
when ('volume') {
|
||||||
return "usage: volume" if ( @args != 1 );
|
return "usage: volume" if ( @args != 1 );
|
||||||
|
|
||||||
$payload{ $lgCommands{$cmd}->[1] } = int( join( " ", @args ) );
|
$payload{ $lgCommands{$cmd}->[1] } = int( join( " ", @args ) );
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'launchApp' ) {
|
when ('launchApp') {
|
||||||
return "usage: launchApp" if ( @args != 1 );
|
return "usage: launchApp" if ( @args != 1 );
|
||||||
|
|
||||||
$payload{ $lgCommands{$cmd}->[1] } = $openApps{ join( " ", @args ) };
|
$payload{ $lgCommands{$cmd}->[1] } =
|
||||||
|
$openApps{ join( " ", @args ) };
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'input' ) {
|
when ('input') {
|
||||||
return "usage: input" if ( @args != 1 );
|
return "usage: input" if ( @args != 1 );
|
||||||
|
|
||||||
my $inputLabel = join( " ", @args );
|
my $inputLabel = join( " ", @args );
|
||||||
@ -532,98 +531,99 @@ sub LGTV_WebOS_Set {
|
|||||||
$uri = $lgCommands{launchApp}->[0];
|
$uri = $lgCommands{launchApp}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'volumeUp' ) {
|
when ('volumeUp') {
|
||||||
return "usage: volumeUp" if ( @args != 0 );
|
return "usage: volumeUp" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'volumeDown' ) {
|
when ('volumeDown') {
|
||||||
return "usage: volumeDown" if ( @args != 0 );
|
return "usage: volumeDown" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'channelDown' ) {
|
when ('channelDown') {
|
||||||
return "usage: channelDown" if ( @args != 0 );
|
return "usage: channelDown" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'channelUp' ) {
|
when ('channelUp') {
|
||||||
return "usage: channelUp" if ( @args != 0 );
|
return "usage: channelUp" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'channel' ) {
|
when ('channel') {
|
||||||
return "usage: channel" if ( @args != 1 );
|
return "usage: channel" if ( @args != 1 );
|
||||||
|
|
||||||
$payload{ $lgCommands{openChannel}->[1] } = join( " ", @args );
|
$payload{ $lgCommands{openChannel}->[1] } = join( " ", @args );
|
||||||
$uri = $lgCommands{openChannel}->[0];
|
$uri = $lgCommands{openChannel}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'getServiceList' ) {
|
when ('getServiceList') {
|
||||||
return "usage: getServiceList" if ( @args != 0 );
|
return "usage: getServiceList" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'getChannelList' ) {
|
when ('getChannelList') {
|
||||||
return "usage: getChannelList" if ( @args != 0 );
|
return "usage: getChannelList" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'getAppList' ) {
|
when ('getAppList') {
|
||||||
return "usage: getAppList" if ( @args != 0 );
|
return "usage: getAppList" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'getExternalInputList' ) {
|
when ('getExternalInputList') {
|
||||||
return "usage: getExternalInputList" if ( @args != 0 );
|
return "usage: getExternalInputList" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'play' ) {
|
when ('play') {
|
||||||
return "usage: play" if ( @args != 0 );
|
return "usage: play" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'stop' ) {
|
when ('stop') {
|
||||||
return "usage: stop" if ( @args != 0 );
|
return "usage: stop" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'fastForward' ) {
|
when ('fastForward') {
|
||||||
return "usage: fastForward" if ( @args != 0 );
|
return "usage: fastForward" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'rewind' ) {
|
when ('rewind') {
|
||||||
return "usage: rewind" if ( @args != 0 );
|
return "usage: rewind" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $cmd eq 'pause' ) {
|
when ('pause') {
|
||||||
return "usage: pause" if ( @args != 0 );
|
return "usage: pause" if ( @args != 0 );
|
||||||
|
|
||||||
$uri = $lgCommands{$cmd}->[0];
|
$uri = $lgCommands{$cmd}->[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
default {
|
||||||
my $list = "";
|
my $list = "";
|
||||||
$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';
|
'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';
|
||||||
$list .=
|
$list .=
|
||||||
' 3D:on,off stop:noArg play:noArg pause:noArg rewind:noArg fastForward:noArg clearInputList:noArg channel';
|
' 3D:on,off stop:noArg play:noArg pause:noArg rewind:noArg fastForward:noArg clearInputList:noArg channel';
|
||||||
$list .= ' launchApp:' . join( ',', => map qq{$_} => keys %openApps );
|
$list .=
|
||||||
|
' launchApp:' . join( ',', => map qq{$_} => keys %openApps );
|
||||||
$list .= ' input:'
|
$list .= ' input:'
|
||||||
. join( ',',
|
. join( ',',
|
||||||
=> map qq{$_} => keys %{ $hash->{helper}{device}{inputs} } )
|
=> map qq{$_} => keys %{ $hash->{helper}{device}{inputs} } )
|
||||||
@ -632,6 +632,7 @@ sub LGTV_WebOS_Set {
|
|||||||
|
|
||||||
return "Unknown argument $cmd, choose one of $list";
|
return "Unknown argument $cmd, choose one of $list";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$hash->{helper}{device}{runsetcmd} = $hash->{helper}{device}{runsetcmd} + 1;
|
$hash->{helper}{device}{runsetcmd} = $hash->{helper}{device}{runsetcmd} + 1;
|
||||||
return LGTV_WebOS_CreateSendCommand( $hash, $uri, \%payload );
|
return LGTV_WebOS_CreateSendCommand( $hash, $uri, \%payload );
|
||||||
@ -2022,7 +2023,7 @@ sub LGTV_WebOS_WakeUp_Udp {
|
|||||||
],
|
],
|
||||||
"release_status": "stable",
|
"release_status": "stable",
|
||||||
"license": "GPL_2",
|
"license": "GPL_2",
|
||||||
"version": "v3.3.5",
|
"version": "v3.4.0",
|
||||||
"author": [
|
"author": [
|
||||||
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
|
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user