From d035f130a37bca267d1b4375d04219232959dc0c Mon Sep 17 00:00:00 2001 From: jpawlowski Date: Sun, 21 Aug 2016 15:01:37 +0000 Subject: [PATCH] 70_PHTV.pm: implement stateAV reading git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@12042 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/70_PHTV.pm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/FHEM/70_PHTV.pm b/FHEM/70_PHTV.pm index 85fe8a90f..68755b828 100644 --- a/FHEM/70_PHTV.pm +++ b/FHEM/70_PHTV.pm @@ -1733,6 +1733,7 @@ sub PHTV_ReceiveCommand($$$) { . "' not supported by device."; } } + } # data received @@ -3082,6 +3083,11 @@ sub PHTV_ReceiveCommand($$$) { readingsBulkUpdate( $hash, "state", $newstate ); } + # Set reading for stateAV + my $stateAV = PHTV_GetStateAV($hash); + readingsBulkUpdate( $hash, "stateAV", $stateAV ) + if ( ReadingsVal( $name, "stateAV", "-" ) ne $stateAV ); + # Set PHTV online-only readings to "-" in case box is in # offline or in standby mode if ( $newstate eq "off" @@ -3214,6 +3220,29 @@ sub PHTV_Undefine($$) { return; } +################################### +sub PHTV_GetStateAV($) { + my ($hash) = @_; + my $name = $hash->{NAME}; + + if ( ReadingsVal( $name, "presence", "absent" ) eq "absent" ) { + return "absent"; + } + elsif ( ReadingsVal( $name, "power", "off" ) eq "off" ) { + return "off"; + } + elsif ( ReadingsVal( $name, "mute", "off" ) eq "on" ) { + return "muted"; + } + elsif ( ReadingsVal( $name, "playStatus", "stopped" ) ne "stopped" ) + { + return ReadingsVal( $name, "playStatus", "stopped" ); + } + else { + return ReadingsVal( $name, "power", "off" ); + } +} + ################################### sub PHTV_wake ($) { my ($hash) = @_;