diff --git a/controls_LGTV_WebOS.txt b/controls_LGTV_WebOS.txt index 566adea..ee238ed 100644 --- a/controls_LGTV_WebOS.txt +++ b/controls_LGTV_WebOS.txt @@ -1,2 +1,2 @@ UPD 2022-03-13_11:17:13 18968 FHEM/82_LGTV_WebOS.pm -UPD 2022-03-17_08:25:38 54313 lib/FHEM/Devices/LGTV/LGTVWebOS.pm +UPD 2022-03-17_08:40:15 54825 lib/FHEM/Devices/LGTV/LGTVWebOS.pm diff --git a/lib/FHEM/Devices/LGTV/LGTVWebOS.pm b/lib/FHEM/Devices/LGTV/LGTVWebOS.pm index a79b8f2..0e6ac03 100644 --- a/lib/FHEM/Devices/LGTV/LGTVWebOS.pm +++ b/lib/FHEM/Devices/LGTV/LGTVWebOS.pm @@ -994,6 +994,8 @@ sub WriteServiceReadings { my $hash = shift; my $decode_json = shift; + ::readingsBeginUpdate($hash); + for my $services ( @{ $decode_json->{payload}{services} } ) { ::readingsBulkUpdateIfChanged( $hash, @@ -1002,6 +1004,8 @@ sub WriteServiceReadings { ); } + ::readingsEndUpdate( $hash, 1 ); + return; } @@ -1009,6 +1013,8 @@ sub WriteDeviceReadings { my $hash = shift; my $decode_json = shift; + ::readingsBeginUpdate($hash); + for my $devices ( @{ $decode_json->{payload}{devices} } ) { if ( !exists( $hash->{helper}{device}{inputs}{ $devices->{label} } ) @@ -1029,6 +1035,8 @@ sub WriteDeviceReadings { ); } + ::readingsEndUpdate( $hash, 1 ); + return; } @@ -1038,6 +1046,9 @@ sub WriteProgramlistReadings { require Date::Parse; my $count = 0; + + ::readingsBeginUpdate($hash); + for my $programList ( @{ $decode_json->{payload}{programList} } ) { if ( @@ -1069,6 +1080,8 @@ sub WriteProgramlistReadings { } } + ::readingsEndUpdate( $hash, 1 ); + return; } @@ -1076,6 +1089,8 @@ sub WriteMuteReadings { my $hash = shift; my $decode_json = shift; + ::readingsBeginUpdate($hash); + if ( exists( $decode_json->{payload}{'mute'} ) && ( $decode_json->{payload}{'mute'} eq 'true' @@ -1115,6 +1130,8 @@ sub WriteMuteReadings { ::readingsBulkUpdateIfChanged( $hash, 'mute', 'off' ); } + ::readingsEndUpdate( $hash, 1 ); + return; } @@ -1122,6 +1139,8 @@ sub Write3dReadings { my $hash = shift; my $decode_json = shift; + ::readingsBeginUpdate($hash); + if ( $decode_json->{payload}{status3D}{status} eq 'false' || $decode_json->{payload}{status3D}{status} == 0 ) { @@ -1139,6 +1158,8 @@ sub Write3dReadings { ::readingsBulkUpdateIfChanged( $hash, '3DMode', $decode_json->{payload}{status3D}{pattern} ); + ::readingsEndUpdate( $hash, 1 ); + return; } @@ -1146,6 +1167,8 @@ sub WriteAppIdReadings { my $hash = shift; my $decode_json = shift; + ::readingsBeginUpdate($hash); + if ( ( $decode_json->{payload}{appId} =~ /com.webos.app.externalinput/x @@ -1173,6 +1196,8 @@ sub WriteAppIdReadings { ::readingsBulkUpdateIfChanged( $hash, 'input', '-' ); } + ::readingsEndUpdate( $hash, 1 ); + return; } @@ -1182,6 +1207,8 @@ sub WriteTypeReadings { my $response; + ::readingsBeginUpdate($hash); + if ( $decode_json->{type} eq 'registered' && exists( $decode_json->{payload}{'client-key'} ) ) { @@ -1225,6 +1252,8 @@ sub WriteTypeReadings { if ( $hash->{helper}{device}{runsetcmd} > 0 ); } + ::readingsEndUpdate( $hash, 1 ); + return $response; } @@ -1236,8 +1265,6 @@ sub WriteReadings { ::Log3( $name, 4, "LGTV_WebOS ($name) - Beginn Readings writing" ); - ::readingsBeginUpdate($hash); - if ( ref( $decode_json->{payload}{services} ) eq "ARRAY" && scalar( @{ $decode_json->{payload}{services} } ) > 0 ) { @@ -1266,6 +1293,8 @@ sub WriteReadings { WriteAppIdReadings( $hash, $decode_json ); } + ::readingsBeginUpdate($hash); + if ( exists( $decode_json->{type} ) ) { $response = WriteTypeReadings( $hash, $decode_json ); }