From 38c4ed0e68c858cfdbc569668d3775caa3a743ea Mon Sep 17 00:00:00 2001 From: rapster <> Date: Thu, 20 Aug 2015 08:15:58 +0000 Subject: [PATCH] 70_VolumeLink: Wrong file in last commit. Changed vol/mute-RegexPattern modifier to /si Changed default timeout to 0.5 Fixed bug while storing RegEx from Attr to hash Added Attr for separate muteRegexPattern Added Attr httpNoShutdown Added possibility to disable ampInput check Added runtime check if still exists git-svn-id: https://svn.fhem.de/fhem/trunk@9099 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/70_VolumeLink.pm | 56 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/fhem/FHEM/70_VolumeLink.pm b/fhem/FHEM/70_VolumeLink.pm index 8b4f875ea..4c711c767 100644 --- a/fhem/FHEM/70_VolumeLink.pm +++ b/fhem/FHEM/70_VolumeLink.pm @@ -1,17 +1,5 @@ ############################################################################### -# $Id: 70_VolumeLink.pm 2015-08-17 23:00 - rapster - rapster at x0e dot de $ - -### TODO'S ### -# Harmony hub support - -### LAST CHANGES ### -# Changed Vol/Mute-RegexPattern modifier to /si -# Fixed failure while storing RegEx from Attr to hash -# Extend logging -# Added seperate muteRegexPattern Attr -# Added httpNoShutdown Attr -# Added possibility to disable ampInput check -# Added runtime check if still exists +# $Id: 70_VolumeLink.pm 2015-08-20 09:00 - rapster - rapster at x0e dot de $ package main; use strict; @@ -61,7 +49,7 @@ sub VolumeLink_Define($$) { interval => $a[2], url => $a[3], ampDevice => $a[4], - timeout => $a[5] || 1, + timeout => $a[5] || 0.5, httpErrorLoglevel => $a[6] || 4, httpLoglevel => $a[7] || 5, httpNoShutdown => ( defined($attr{$name}->{httpNoShutdown}) ) ? $attr{$name}->{httpNoShutdown} : 1, @@ -231,12 +219,6 @@ sub VolumeLink_ReceiveCommand($) { $param->{HTTP_ERROR_COUNT} = 0; - if(!defined($defs{$param->{hash}->{ampDevice}})) { - Log3 $name, 1, "$name: FAILURE, configured '$param->{hash}->{ampDevice}' is not defined. End now..."; - CommandSet(undef, $name.' off'); - return; - } - my ($vol) = $data =~ /$param->{hash}->{volumeRegexPattern}/si; my ($mute) = $data =~ /$param->{hash}->{muteRegexPattern}/si; if (!defined($vol)) {$vol = '';} @@ -254,6 +236,12 @@ sub VolumeLink_ReceiveCommand($) { readingsBulkUpdate($param->{hash}, 'mute', $mute ); readingsEndUpdate($param->{hash}, 0); + if( !defined($defs{$param->{hash}->{ampDevice}}) ) { + Log3 $name, 1, "$name: FAILURE, configured '$param->{hash}->{ampDevice}' is not defined. End now..."; + CommandSet(undef, $name.' off'); + return; + } + my $ampMute = ReadingsVal($param->{hash}->{ampDevice},$param->{hash}->{ampMuteReading},'N/A'); my $ampVol = ReadingsVal($param->{hash}->{ampDevice},$param->{hash}->{ampVolumeReading},'N/A'); my $ampTitle = ( $param->{hash}->{ampInputReading} ) ? ReadingsVal($param->{hash}->{ampDevice},$param->{hash}->{ampInputReading},'N/A') : 0; @@ -312,7 +300,7 @@ sub VolumeLink_ReceiveCommand($) {

VolumeLink

    -VolumeLink links the volume & mute from a physical device (e.g. a Philips-TV) with the volume & mute control of a fhem device (e.g. a SONOS-Playbar, Onkyo, Yamaha or Denon Receiver, etc.). +VolumeLink links the volume-level & mute-state from a physical device (e.g. a Philips-TV) with the volume & mute control of a fhem device (e.g. a SONOS-Playbar, Onkyo, Yamaha or Denon Receiver, etc.).

    Define

    @@ -330,11 +318,11 @@ VolumeLink links the volume & mute from a physical device (e.g. a Philips-TV
<ampDevice>:
    - the amplifier fhem-device.
    + the target fhem-device.
[<timeout>]:
    - optional: timeout of a http-get. default: 1 second
    + optional: timeout of a http-get. default: 0.5 seconds
[<httpErrorLoglevel>]:
    @@ -349,9 +337,12 @@ VolumeLink links the volume & mute from a physical device (e.g. a Philips-TV

    Example

      - Note: This example will work out of the box with many Philips TV's and a SONOS-Playbar as fhem-device.

      define tvVolume_LivingRoom VolumeLink 0.2 http://192.168.1.156:1925/5/audio/volume Sonos_LivingRoom
      set tvVolume_LivingRoom on
      +
      + Note:
      + - This example will work out of the box with many Philips TV's and a SONOS-Playbar as fhem-device.
      + - Pre 2014 Philips TV's use another protocoll, which can be accessed on http://<ip>/1/audio/volume

    @@ -365,19 +356,26 @@ VolumeLink links the volume & mute from a physical device (e.g. a Philips-TV

    Get

      N/A

    +

    Attributes

      Note:
      - All Attributes takes effect immediately.
      - - The default value of volumeRegexPattern applies to many Philips-TV's, otherwise it must be configured.
      + - The default value of volumeRegexPattern & muteRegexPattern applies to many Philips-TV's, otherwise it must be configured.
      - The default values of amp* applies to a SONOS-Playbar, otherwise it must be configured.
      + - If you don't receive a result from url, or the lastHttpErrorMessage shows every time 'timed out', try setting attribute 'httpNoShutdown' to 0.

    • disable <1|0>
      With this attribute you can disable the whole module.
      If set to 1 the module will be stopped and no volume will be fetched from physical-device or transfer to the amplifier-device.
      If set to 0 you can start the module again with: set <name> on.
    • +
    • httpNoShutdown <1|0>
      + If set to 0 the module will tell the http-server to explicit close the connection.
      + Default: 1 +
    • ampInputReading <value>
      Name of the Input-Reading on amplifier-device
      + To disable the InputCheck if your amplifier-device does not support this, set this attribute to 0.
      Default (which applies to SONOS-Player's): currentTitle
    • ampInputReadingVal <RegEx>
      RegEx for the Reading value of the corresponding Input-Channel on amplifier-device
      @@ -401,9 +399,11 @@ VolumeLink links the volume & mute from a physical device (e.g. a Philips-TV Command to mute the amplifier device
      Default: Mute
    • volumeRegexPattern <RegEx>
      - RegEx which is applied to url return data.
      - Must return a number in $1 for volume-level and true, false, 1 or 0 as mute-state in $2.
      - Default (which applies to many Phlips-TV's): current":(\d+).*muted":(\w+|\d+)
    • + RegEx which is applied to url return data. Must return a number for volume-level.
      + Default (which applies to many Phlips-TV's): current":\s*(\d+) +
    • muteRegexPattern <RegEx>
      + RegEx which is applied to url return data. Must return true, false, 1 or 0 as mute-state.
      + Default (which applies to many Phlips-TV's): muted":\s*(\w+|\d+)

    Readings