add Meta Support and change version calculation
This commit is contained in:
parent
91e3f864ee
commit
1ca188604f
174
82_LGTV_WebOS.pm
174
82_LGTV_WebOS.pm
@ -55,15 +55,84 @@ my $missingModul = "";
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use FHEM::Meta;
|
||||||
|
|
||||||
eval "use MIME::Base64;1" or $missingModul .= "MIME::Base64 ";
|
eval "use MIME::Base64;1" or $missingModul .= "MIME::Base64 ";
|
||||||
eval "use IO::Socket::INET;1" or $missingModul .= "IO::Socket::INET ";
|
eval "use IO::Socket::INET;1" or $missingModul .= "IO::Socket::INET ";
|
||||||
eval "use Digest::SHA qw(sha1_hex);1" or $missingModul .= "Digest::SHA ";
|
eval "use Digest::SHA qw(sha1_hex);1" or $missingModul .= "Digest::SHA ";
|
||||||
eval "use JSON qw(decode_json encode_json);1" or $missingModul .= "JSON ";
|
|
||||||
eval "use Encode qw(encode_utf8 decode_utf8);1" or $missingModul .= "Encode ";
|
eval "use Encode qw(encode_utf8 decode_utf8);1" or $missingModul .= "Encode ";
|
||||||
eval "use Blocking;1" or $missingModul .= "Blocking ";
|
eval "use Blocking;1" or $missingModul .= "Blocking ";
|
||||||
|
|
||||||
my $version = "2.0.11";
|
# try to use JSON::MaybeXS wrapper
|
||||||
|
# for chance of better performance + open code
|
||||||
|
eval {
|
||||||
|
require JSON::MaybeXS;
|
||||||
|
import JSON::MaybeXS qw( decode_json encode_json );
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# try to use JSON wrapper
|
||||||
|
# for chance of better performance
|
||||||
|
eval {
|
||||||
|
|
||||||
|
# JSON preference order
|
||||||
|
local $ENV{PERL_JSON_BACKEND} =
|
||||||
|
'Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPP'
|
||||||
|
unless ( defined( $ENV{PERL_JSON_BACKEND} ) );
|
||||||
|
|
||||||
|
require JSON;
|
||||||
|
import JSON qw( decode_json encode_json );
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# In rare cases, Cpanel::JSON::XS may
|
||||||
|
# be installed but JSON|JSON::MaybeXS not ...
|
||||||
|
eval {
|
||||||
|
require Cpanel::JSON::XS;
|
||||||
|
import Cpanel::JSON::XS qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# In rare cases, JSON::XS may
|
||||||
|
# be installed but JSON not ...
|
||||||
|
eval {
|
||||||
|
require JSON::XS;
|
||||||
|
import JSON::XS qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# Fallback to built-in JSON which SHOULD
|
||||||
|
# be available since 5.014 ...
|
||||||
|
eval {
|
||||||
|
require JSON::PP;
|
||||||
|
import JSON::PP qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# Fallback to JSON::backportPP in really rare cases
|
||||||
|
require JSON::backportPP;
|
||||||
|
import JSON::backportPP qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Declare functions
|
# Declare functions
|
||||||
sub LGTV_WebOS_Initialize($);
|
sub LGTV_WebOS_Initialize($);
|
||||||
@ -183,13 +252,10 @@ sub LGTV_WebOS_Initialize($) {
|
|||||||
. "pingPresence:1 "
|
. "pingPresence:1 "
|
||||||
. "wakeOnLanMAC "
|
. "wakeOnLanMAC "
|
||||||
. "wakeOnLanBroadcast "
|
. "wakeOnLanBroadcast "
|
||||||
. "wakeupCmd "
|
. "wakeupCmd "
|
||||||
. $readingFnAttributes;
|
. $readingFnAttributes;
|
||||||
|
|
||||||
foreach my $d ( sort keys %{ $modules{LGTV_WebOS}{defptr} } ) {
|
return FHEM::Meta::InitMod( __FILE__, $hash );
|
||||||
my $hash = $modules{LGTV_WebOS}{defptr}{$d};
|
|
||||||
$hash->{VERSION} = $version;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub LGTV_WebOS_Define($$) {
|
sub LGTV_WebOS_Define($$) {
|
||||||
@ -198,6 +264,9 @@ sub LGTV_WebOS_Define($$) {
|
|||||||
|
|
||||||
my @a = split( "[ \t][ \t]*", $def );
|
my @a = split( "[ \t][ \t]*", $def );
|
||||||
|
|
||||||
|
return $@ unless ( FHEM::Meta::SetInternals($hash) );
|
||||||
|
use version 0.60; our $VERSION = FHEM::Meta::Get( $hash, 'version' );
|
||||||
|
|
||||||
return "too few parameters: define <name> LGTV_WebOS <HOST>" if ( @a != 3 );
|
return "too few parameters: define <name> LGTV_WebOS <HOST>" if ( @a != 3 );
|
||||||
return
|
return
|
||||||
"Cannot define LGTV_WebOS device. Perl modul ${missingModul} is missing."
|
"Cannot define LGTV_WebOS device. Perl modul ${missingModul} is missing."
|
||||||
@ -206,9 +275,9 @@ sub LGTV_WebOS_Define($$) {
|
|||||||
my $name = $a[0];
|
my $name = $a[0];
|
||||||
my $host = $a[2];
|
my $host = $a[2];
|
||||||
|
|
||||||
$hash->{HOST} = $host;
|
$hash->{HOST} = $host;
|
||||||
$hash->{VERSION} = $version;
|
$hash->{VERSION} = version->parse($VERSION)->normal;
|
||||||
$hash->{PARTIAL} = '';
|
$hash->{PARTIAL} = '';
|
||||||
$hash->{helper}{device}{channelguide}{counter} = 0;
|
$hash->{helper}{device}{channelguide}{counter} = 0;
|
||||||
$hash->{helper}{device}{registered} = 0;
|
$hash->{helper}{device}{registered} = 0;
|
||||||
$hash->{helper}{device}{runsetcmd} = 0;
|
$hash->{helper}{device}{runsetcmd} = 0;
|
||||||
@ -425,21 +494,23 @@ sub LGTV_WebOS_Set($@) {
|
|||||||
AttrVal( $name, 'wakeOnLanBroadcast', '255.255.255.255' )
|
AttrVal( $name, 'wakeOnLanBroadcast', '255.255.255.255' )
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} elsif( AttrVal($name,'wakeupCmd','none') ne 'none' ) {
|
}
|
||||||
my $wakeupCmd = AttrVal($name,'wakeupCmd','none');
|
elsif ( AttrVal( $name, 'wakeupCmd', 'none' ) ne 'none' ) {
|
||||||
if ( $wakeupCmd =~ s/^[ \t]*\{|\}[ \t]*$//g ) {
|
my $wakeupCmd = AttrVal( $name, 'wakeupCmd', 'none' );
|
||||||
Log3 $name, 4,
|
if ( $wakeupCmd =~ s/^[ \t]*\{|\}[ \t]*$//g ) {
|
||||||
"LGTV_WebOS executing wake-up command (Perl): $wakeupCmd";
|
Log3 $name, 4,
|
||||||
eval $wakeupCmd;
|
"LGTV_WebOS executing wake-up command (Perl): $wakeupCmd";
|
||||||
return;
|
eval $wakeupCmd;
|
||||||
}
|
return;
|
||||||
else {
|
}
|
||||||
Log3 $name, 4,
|
else {
|
||||||
"LGTV_WebOS executing wake-up command (fhem): $wakeupCmd";
|
Log3 $name, 4,
|
||||||
fhem $wakeupCmd;
|
"LGTV_WebOS executing wake-up command (fhem): $wakeupCmd";
|
||||||
return;
|
fhem $wakeupCmd;
|
||||||
}
|
return;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
$uri = $lgCommands{powerOn};
|
$uri = $lgCommands{powerOn};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1662,8 +1733,8 @@ sub LGTV_WebOS_WakeUp_Udp($@) {
|
|||||||
|
|
||||||
=pod
|
=pod
|
||||||
=item device
|
=item device
|
||||||
=item summary Controls LG SmartTVs run with WebOS Operating System (in beta phase)
|
=item summary Controls LG SmartTVs run with WebOS Operating System
|
||||||
=item summary_DE Steuert LG SmartTVs mit WebOS Betriebssystem (derzeit Beta Status)
|
=item summary_DE Steuert LG SmartTVs mit WebOS Betriebssystem
|
||||||
|
|
||||||
=begin html
|
=begin html
|
||||||
|
|
||||||
@ -1911,4 +1982,53 @@ sub LGTV_WebOS_WakeUp_Udp($@) {
|
|||||||
</ul>
|
</ul>
|
||||||
=end html_DE
|
=end html_DE
|
||||||
|
|
||||||
|
=for :application/json;q=META.json 83_LGTV_WebOS.pm
|
||||||
|
{
|
||||||
|
"abstract": "Module for Controls LG SmartTVs run with WebOS Operating System",
|
||||||
|
"x_lang": {
|
||||||
|
"de": {
|
||||||
|
"abstract": "Modul zur Steuerung von LG SmartTVs mit WebOS Betriebssystem"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"fhem-mod-device",
|
||||||
|
"fhem-core",
|
||||||
|
"Multimedia",
|
||||||
|
"TV",
|
||||||
|
"LG"
|
||||||
|
],
|
||||||
|
"release_status": "under develop",
|
||||||
|
"license": "GPL_2",
|
||||||
|
"version": "v2.2.0",
|
||||||
|
"x_developmentversion": "v2.1.99",
|
||||||
|
"author": [
|
||||||
|
"Marko Oldenburg <leongaultier@gmail.com>"
|
||||||
|
],
|
||||||
|
"x_fhem_maintainer": [
|
||||||
|
"CoolTux"
|
||||||
|
],
|
||||||
|
"x_fhem_maintainer_github": [
|
||||||
|
"LeonGaultier"
|
||||||
|
],
|
||||||
|
"prereqs": {
|
||||||
|
"runtime": {
|
||||||
|
"requires": {
|
||||||
|
"FHEM": 5.00918799,
|
||||||
|
"perl": 5.016,
|
||||||
|
"Meta": 1,
|
||||||
|
"JSON": 1,
|
||||||
|
"Date::Parse": 0
|
||||||
|
},
|
||||||
|
"recommends": {
|
||||||
|
"JSON": 0
|
||||||
|
},
|
||||||
|
"suggests": {
|
||||||
|
"Cpanel::JSON::XS": 0,
|
||||||
|
"JSON::XS": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
=end :application/json;q=META.json
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
Loading…
x
Reference in New Issue
Block a user