Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement slats angle for Venetian blinds #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions KLF200/2.0/FHEM/83_KLF200Node.pm
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ sub KLF200Node_Set($$$) {
my $interval = shift @a;
return KLF200Node_SetLimitationUpdateInterval($hash, $interval);
}

if ($cmd eq "slatsAngle") {
my $slatsAngle = shift @a;
return KLF200Node_SetSlatsAngle($hash, $slatsAngle);
}

my $usage= " on:noArg off:noArg toggle:noArg up:noArg down:noArg stop:noArg" ;
$usage .= " my:noArg" if (ReadingsVal($name, "ioManufacturer", "") eq "Somfy");
Expand All @@ -384,6 +389,7 @@ sub KLF200Node_Set($$$) {
$usage .= " limitationMin:slider,0,1,100" ;
$usage .= " limitationMax:slider,0,1,100" ;
$usage .= " limitationUpdateInterval" ;
$usage .= " slatsAngle:slider,0,1,90 if (ReadingsVal($name, 'nodeTypeSubType', '') eq 'Exterior Venetian blind')";
# $usage .= " target:noArg" ;

return SetExtensions($hash, $usage, $name, $cmd, @a);
Expand Down Expand Up @@ -468,6 +474,17 @@ sub KLF200Node_SetRaw($$) {
return KLF200Node_GW_COMMAND_SEND_REQ($hash, $ParameterActive, \@a);
}

sub KLF200Node_SetSlatsAngle($$) {
use List::Util qw(min max);
my ($hash, $slatsAngle) = @_;
my $name = $hash->{NAME};
$slatsAngle = max(0, min(90, $slatsAngle));
my $slatsAngleRaw = int($slatsAngle * 51200 / 90);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you scale to 90 and not to 100%.

my @a = (undef, undef, undef, $slatsAngleRaw);

return KLF200Node_GW_COMMAND_SEND_REQ($hash, 3, \@a);
}

sub KLF200Node_SetLimitation($$$) {
my ($hash, $minPct, $maxPct) = @_;
my $name = $hash->{NAME};
Expand Down Expand Up @@ -1431,6 +1448,12 @@ sub KLF200Node_GW_SET_LIMITATION_REQ($$$$) {
If you are not using the Functional Parameters (FP1 - FP7) prefer set updateStatus.
<br>
</li>
<a name="slatsAngle"></a>
<li>
<code>set &lt;name&gt; slatsAngle &lt;0 - 90&gt;</code><br>
<br>
Set the angle of the slats of a blind for "Exterior Venetian blind" (17)<br>
</li>
</ul><br>
<a name="KLF200Nodeattr"></a>
<b>Attributes</b><br><br>
Expand Down