From e87f5584824bda45ff93961d4f1d7e9cdbf70af7 Mon Sep 17 00:00:00 2001 From: thomyd <> Date: Fri, 3 Jul 2015 17:44:30 +0000 Subject: [PATCH] SOMFY: Added attr "additionalPosReading" that stores the current position. git-svn-id: https://svn.fhem.de/fhem/trunk@8880 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/10_SOMFY.pm | 56 ++++++++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 753e6f6de..45e506f98 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - bugfix: SOMFY: Added attr "additionalPosReading" to store current position - bugfix: 10_IT: Fix readings State for IT V3 switch (Forum #38406) - change: SOMFY: New state and action handling (added virtual receiver capability) - change: FRITZBOX: for most features no telnet access needed anymore diff --git a/fhem/FHEM/10_SOMFY.pm b/fhem/FHEM/10_SOMFY.pm index 478cfa400..33bea5b33 100644 --- a/fhem/FHEM/10_SOMFY.pm +++ b/fhem/FHEM/10_SOMFY.pm @@ -35,7 +35,8 @@ # 2015-04-30 - state/position are now regularly updated during longer moves (as specified in somfy_updateFreq in seconds) # 2015-04-30 - For blinds normalize on pos 0 to 100 (max) (meaning if drive-down-time-to-close == drive-down-time-to-100 and drive-up-time-to-100 == 0) # 2015-04-30 - new reading exact position called 'exact' also used for further pos calculations - +# 2015-07-03 additionalPosReading for allowing to specify an additional reading to contain position for shutter +# 2015-07-03 Cleanup of reading update routine # ###################################################### # @@ -174,7 +175,9 @@ sub SOMFY_Initialize($) { . " drive-down-time-to-close" . " drive-up-time-to-100" . " drive-up-time-to-open " + . " additionalPosReading " . " IODev" + . " setList" . " symbol-length" . " enc-key" . " rolling-code" @@ -624,11 +627,17 @@ sub SOMFY_InternalSet($@) { if(!exists($sets{$cmd})) { my @cList; + + # overwrite %sets with setList + my $atts = AttrVal($name,'setList',undef); + my %setlist = split("[: ][ ]*", $atts); + foreach my $k (sort keys %sets) { my $opts = undef; $opts = $sets{$k}; + $opts = $setlist{$k} if(exists($setlist{$k})); - if (defined($opts)) { + if (defined($opts)) { push(@cList,$k . ':' . $opts); } else { push (@cList,$k); @@ -1005,40 +1014,36 @@ sub SOMFY_TimedUpdate($) { sub SOMFY_UpdateState($$$$$) { my ($hash, $newState, $move, $updateState, $doTrigger) = @_; -# my $timestamp = TimeNow(); + my $addtlPosReading = AttrVal($hash->{NAME},'additionalPosReading',undef); + $addtlPosReading = undef if ( ( $addtlPosReading eq "" ) ); + $addtlPosReading = undef if ( ( $addtlPosReading eq "state" ) or ( $addtlPosReading eq "position" ) or ( $addtlPosReading eq "exact" ) ); readingsBeginUpdate($hash); -# $hash->{READINGS}{state}{TIME} = $timestamp; -# $hash->{READINGS}{position}{TIME} = $timestamp; if(exists($positions{$newState})) { readingsBulkUpdate($hash,"state",$newState); $hash->{STATE} = $newState; -# $hash->{READINGS}{state}{VAL} = $newState; -# $hash->{CHANGED}[0] = $newState; - readingsBulkUpdate($hash,"position",$positions{$newState}); -# $hash->{READINGS}{position}{VAL} = $positions{$newState}; $hash->{position} = $positions{$newState}; + + readingsBulkUpdate($hash,$addtlPosReading,$positions{$newState}) if ( defined($addtlPosReading) ); - } else { + } else { my $rounded = SOMFY_Runden( $newState ); my $stateTrans = SOMFY_Translate( $rounded ); readingsBulkUpdate($hash,"state",$stateTrans); $hash->{STATE} = $stateTrans; -# $hash->{READINGS}{state}{VAL} = $stateTrans; -# $hash->{CHANGED}[0] = $stateTrans; - readingsBulkUpdate($hash,"position",$rounded); -# $hash->{READINGS}{position}{VAL} = $rounded; $hash->{position} = $rounded; - } + + readingsBulkUpdate($hash,$addtlPosReading,$rounded) if ( defined($addtlPosReading) ); + + + } readingsBulkUpdate($hash,"exact",$newState); -# $hash->{READINGS}{exact}{TIME} = $timestamp; -# $hash->{READINGS}{exact}{VAL} = $newState; $hash->{exact} = $newState; if ( defined( $updateState ) ) { @@ -1267,6 +1272,23 @@ sub SOMFY_CalcCurrentPos($$$$) { If you have both a CUL868 and CUL433, use the CUL433 as IODev for increased range.
+ +
  • setList
    + Space separated list of commands, which will be returned upon "set name ?", + so the FHEMWEB frontend can construct the correct control and command dropdown. Specific controls can be added after a colon for each command +
    + Example: attr shutter setList open close pos:textField +

  • + + +
  • additionalPosReading
    + Position of the shutter will be stored in the reading pos as numeric value. + Additionally this attribute might specify a name for an additional reading to be updated with the same value than the pos. +

  • + + + +
  • eventMap
    Replace event names and set arguments. The value of this attribute