diff --git a/FHEM/82_LGTV_WebOS.pm b/FHEM/82_LGTV_WebOS.pm index 8aa8039..cfe72c5 100644 --- a/FHEM/82_LGTV_WebOS.pm +++ b/FHEM/82_LGTV_WebOS.pm @@ -37,6 +37,41 @@ require FHEM::Devices::LGTV::LGTVWebOS; use FHEM::Meta; +use GPUtils qw(GP_Import); + +#-- Run before package compilation +BEGIN { + #-- Export to main context with different name + GP_Import(qw( readingFnAttributes)); +} + +sub ::LGTV_WebOS_Initialize { goto &Initialize } + +sub Initialize { + my $hash = shift; + + # Provider + $hash->{ReadFn} = \&FHEM::Devices::LGTV::LGTVWebOS::Read; + $hash->{WriteFn} = \&FHEM::Devices::LGTV::LGTVWebOS::Write; + + # Consumer + $hash->{SetFn} = \&FHEM::Devices::LGTV::LGTVWebOS::Set; + $hash->{DefFn} = \&FHEM::Devices::LGTV::LGTVWebOS::Define; + $hash->{UndefFn} = \&FHEM::Devices::LGTV::LGTVWebOS::Undef; + $hash->{AttrFn} = \&FHEM::Devices::LGTV::LGTVWebOS::Attr; + $hash->{AttrList} = + "disable:1 " + . "channelGuide:1 " + . "pingPresence:1 " + . "wakeOnLanMAC " + . "wakeOnLanBroadcast " + . "wakeupCmd " + . "keepAliveCheckTime " + . $readingFnAttributes; + + return FHEM::Meta::InitMod( __FILE__, $hash ); +} + 1; =pod diff --git a/controls_LGTV_WebOS.txt b/controls_LGTV_WebOS.txt index 0c0a69f..10386f1 100644 --- a/controls_LGTV_WebOS.txt +++ b/controls_LGTV_WebOS.txt @@ -1,2 +1,2 @@ -UPD 2022-02-02_14:30:51 18011 FHEM/82_LGTV_WebOS.pm -UPD 2022-02-02_15:23:47 54856 lib/FHEM/Devices/LGTV/LGTVWebOS.pm +UPD 2022-02-02_15:41:28 18966 FHEM/82_LGTV_WebOS.pm +UPD 2022-02-02_15:41:43 54304 lib/FHEM/Devices/LGTV/LGTVWebOS.pm diff --git a/lib/FHEM/Devices/LGTV/LGTVWebOS.pm b/lib/FHEM/Devices/LGTV/LGTVWebOS.pm index e1e9033..79ac635 100644 --- a/lib/FHEM/Devices/LGTV/LGTVWebOS.pm +++ b/lib/FHEM/Devices/LGTV/LGTVWebOS.pm @@ -50,7 +50,7 @@ use GPUtils qw(GP_Import); BEGIN { #-- Export to main context with different name GP_Import( - qw( readingFnAttributes + qw( modules init_done selectlist @@ -59,33 +59,6 @@ BEGIN { ); } -sub ::LGTV_WebOS_Initialize { goto &Initialize } - -sub Initialize { - my $hash = shift; - - # Provider - $hash->{ReadFn} = \&Read; - $hash->{WriteFn} = \&Write; - - # Consumer - $hash->{SetFn} = \&Set; - $hash->{DefFn} = \&Define; - $hash->{UndefFn} = \&Undef; - $hash->{AttrFn} = \&Attr; - $hash->{AttrList} = - "disable:1 " - . "channelGuide:1 " - . "pingPresence:1 " - . "wakeOnLanMAC " - . "wakeOnLanBroadcast " - . "wakeupCmd " - . "keepAliveCheckTime " - . $readingFnAttributes; - - return FHEM::Meta::InitMod( __FILE__, $hash ); -} - my $missingModul = ""; eval { require MIME::Base64; 1 } or $missingModul .= 'MIME::Base64 '; @@ -390,7 +363,8 @@ sub TimerStatusRequest { } else { - ::readingsSingleUpdate( $hash, 'state', 'off', 1 ); + ::readingsSingleUpdate( $hash, 'state', 'off', 1 ) + if ( ::ReadingsVal( $name, 'state', 'off' ) ne 'off' ); Presence($hash) if ( ::AttrVal( $name, 'pingPresence', 0 ) == 1 );