2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-15 16:19:11 +00:00

SOMFY: Added attr "additionalPosReading" that stores the current position.

git-svn-id: https://svn.fhem.de/fhem/trunk@8880 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
thomyd 2015-07-03 17:44:30 +00:00
parent 5c83f2247a
commit e87f558482
2 changed files with 40 additions and 17 deletions

View File

@ -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

View File

@ -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 <name> 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.
</li><br>
<a name="setList"></a>
<li>setList<br>
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
<br>
Example: <code>attr shutter setList open close pos:textField</code>
</li><br>
<a name="additionalPosReading"></a>
<li>additionalPosReading<br>
Position of the shutter will be stored in the reading <code>pos</code> as numeric value.
Additionally this attribute might specify a name for an additional reading to be updated with the same value than the pos.
</li><br>
<a name="eventMap"></a>
<li>eventMap<br>
Replace event names and set arguments. The value of this attribute