mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-20 07:16:03 +00:00
30_pilight_dimmer: add up|down commands to change the dimlevel
git-svn-id: https://svn.fhem.de/fhem/trunk@8609 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
063089f0d7
commit
09fb060b1f
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 30_pilight_dimmer: up|down commands to change the dimlevel
|
||||||
- bugfix: 76_MSGMail: Add MSGMail_Attr()
|
- bugfix: 76_MSGMail: Add MSGMail_Attr()
|
||||||
- feature: 70_PIONEERAVR: new set <dev> hdmiOut <1/2>to switch hdmi outputs
|
- feature: 70_PIONEERAVR: new set <dev> hdmiOut <1/2>to switch hdmi outputs
|
||||||
- new set <name> networkStandby (on|off) Needed to turn on/off...
|
- new set <name> networkStandby (on|off) Needed to turn on/off...
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
##############################################
|
##############################################
|
||||||
# $Id: 10_pilight_ctrl.pm 1.02 2015-05-16 Risiko $
|
# $Id: 10_pilight_ctrl.pm 1.03 2015-05-20 Risiko $
|
||||||
#
|
#
|
||||||
# Usage
|
# Usage
|
||||||
#
|
#
|
||||||
@ -26,6 +26,7 @@
|
|||||||
# V 1.00 2015-05-09 - NEW: white list for defined submodules activating by ignoreProtocol *
|
# V 1.00 2015-05-09 - NEW: white list for defined submodules activating by ignoreProtocol *
|
||||||
# V 1.01 2015-05-09 - NEW: add quigg_gt* protocol (e.q quigg_gt7000)
|
# V 1.01 2015-05-09 - NEW: add quigg_gt* protocol (e.q quigg_gt7000)
|
||||||
# V 1.02 2015-05-16 - NEW: battery state for temperature sensors
|
# V 1.02 2015-05-16 - NEW: battery state for temperature sensors
|
||||||
|
# V 1.03 2015-05-20 - NEW: handle screen messages (up,down)
|
||||||
##############################################
|
##############################################
|
||||||
package main;
|
package main;
|
||||||
|
|
||||||
@ -44,8 +45,8 @@ sub pilight_ctrl_ClientAccepted(@);
|
|||||||
sub pilight_ctrl_Send($);
|
sub pilight_ctrl_Send($);
|
||||||
|
|
||||||
my %sets = ( "reset:noArg" => "");
|
my %sets = ( "reset:noArg" => "");
|
||||||
my %matchList = ( "1:pilight_switch" => "^SWITCH",
|
my %matchList = ( "1:pilight_switch" => "^PISWITCH",
|
||||||
"2:pilight_dimmer" => "^SWITCH|^DIMMER",
|
"2:pilight_dimmer" => "^PISWITCH|^PIDIMMER|^PISCREEN",
|
||||||
"3:pilight_temp" => "^PITEMP") ;
|
"3:pilight_temp" => "^PITEMP") ;
|
||||||
|
|
||||||
my @idList = ("id","systemcode","gpio");
|
my @idList = ("id","systemcode","gpio");
|
||||||
@ -414,17 +415,25 @@ sub pilight_ctrl_addWhiteList($$)
|
|||||||
my $me = $own->{NAME};
|
my $me = $own->{NAME};
|
||||||
my $devName = $dev->{NAME};
|
my $devName = $dev->{NAME};
|
||||||
|
|
||||||
|
my $id = (defined($dev->{ID})) ? $dev->{ID} : return;
|
||||||
|
my $protocol = (defined($dev->{PROTOCOL})) ? $dev->{PROTOCOL}: return;
|
||||||
|
|
||||||
Log3 $me, 4, "$me(addWhiteList): add $devName to white list";
|
Log3 $me, 4, "$me(addWhiteList): add $devName to white list";
|
||||||
my $entry = {};
|
my $entry = {};
|
||||||
|
|
||||||
my $id = (defined($dev->{ID})) ? $dev->{ID} : "";
|
|
||||||
my $protocol = (defined($dev->{PROTOCOL})) ? $dev->{PROTOCOL}: "";
|
|
||||||
|
|
||||||
my %whiteHash;
|
my %whiteHash;
|
||||||
@whiteHash{@{$own->{helper}->{whiteList}}}=();
|
@whiteHash{@{$own->{helper}->{whiteList}}}=();
|
||||||
if (!exists $whiteHash{"$protocol:$id"}) {
|
if (!exists $whiteHash{"$protocol:$id"}) {
|
||||||
push @{$own->{helper}->{whiteList}}, "$protocol:$id";
|
push @{$own->{helper}->{whiteList}}, "$protocol:$id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#spezial 2nd protocol for dimmer
|
||||||
|
if (defined($dev->{PROTOCOL2})) {
|
||||||
|
$protocol = $dev->{PROTOCOL2};
|
||||||
|
if (!exists $whiteHash{"$protocol:$id"}) {
|
||||||
|
push @{$own->{helper}->{whiteList}}, "$protocol:$id";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -455,8 +464,19 @@ sub pilight_ctrl_Notify($$)
|
|||||||
my $s = $dev->{CHANGED}[$i];
|
my $s = $dev->{CHANGED}[$i];
|
||||||
|
|
||||||
next if(!defined($s));
|
next if(!defined($s));
|
||||||
if ( $s =~/DEFINED/ or $s =~/INITIALIZED/ or $s =~/DELETED/) {
|
my ($what,$who) = split(' ',$s);
|
||||||
Log3 $me, 4, "$me(Notify): create white list";
|
|
||||||
|
if ( $what =~ m/INITIALIZED/ ) {
|
||||||
|
Log3 $me, 4, "$me(Notify): create white list for $s";
|
||||||
|
pilight_ctrl_createWhiteList($own);
|
||||||
|
} elsif ( $what =~ m/DEFINED/ ){
|
||||||
|
my $hash = $defs{$who};
|
||||||
|
next if(!$hash);
|
||||||
|
my $module = $hash->{TYPE};
|
||||||
|
next if ($module !~ /pilight_[d|s|t].*/);
|
||||||
|
pilight_ctrl_addWhiteList($own,$hash);
|
||||||
|
} elsif ( $what =~ m/DELETED/ ){
|
||||||
|
Log3 $me, 4, "$me(Notify): create white list for $s";
|
||||||
pilight_ctrl_createWhiteList($own);
|
pilight_ctrl_createWhiteList($own);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -685,7 +705,7 @@ sub pilight_ctrl_Parse($$)
|
|||||||
case m/lm75/ {$protoID = 4;}
|
case m/lm75/ {$protoID = 4;}
|
||||||
case m/lm76/ {$protoID = 4;}
|
case m/lm76/ {$protoID = 4;}
|
||||||
|
|
||||||
case m/screen/ {return;}
|
case m/screen/ {$protoID = 5;}
|
||||||
case m/firmware/ {return;}
|
case m/firmware/ {return;}
|
||||||
else {Log3 $me, 3, "$me(Parse): unknown protocol -> $proto"; return;}
|
else {Log3 $me, 3, "$me(Parse): unknown protocol -> $proto"; return;}
|
||||||
}
|
}
|
||||||
@ -696,10 +716,10 @@ sub pilight_ctrl_Parse($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch($protoID){
|
switch($protoID){
|
||||||
case 1 { return Dispatch($hash, "SWITCH,$proto,$id,$unit,$state",undef ); }
|
case 1 { return Dispatch($hash, "PISWITCH,$proto,$id,$unit,$state",undef ); }
|
||||||
case 2 {
|
case 2 {
|
||||||
my $dimlevel = (defined($data->{$s}{dimlevel})) ? $data->{$s}{dimlevel} : "";
|
my $dimlevel = (defined($data->{$s}{dimlevel})) ? $data->{$s}{dimlevel} : "";
|
||||||
my $msg = "DIMMER,$proto,$id,$unit,$state";
|
my $msg = "PIDIMMER,$proto,$id,$unit,$state";
|
||||||
$msg.= ",$dimlevel" if ($dimlevel ne "");
|
$msg.= ",$dimlevel" if ($dimlevel ne "");
|
||||||
return Dispatch($hash, $msg ,undef);
|
return Dispatch($hash, $msg ,undef);
|
||||||
}
|
}
|
||||||
@ -710,7 +730,7 @@ sub pilight_ctrl_Parse($$)
|
|||||||
$state =~ s/opened/on/g;
|
$state =~ s/opened/on/g;
|
||||||
$state =~ s/closed/off/g;
|
$state =~ s/closed/off/g;
|
||||||
Log3 $me, 5, "$me(Parse): contact as switch for $id";
|
Log3 $me, 5, "$me(Parse): contact as switch for $id";
|
||||||
return Dispatch($hash, "SWITCH,$proto,$id,$unit,$state",undef);
|
return Dispatch($hash, "PISWITCH,$proto,$id,$unit,$state",undef);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -724,6 +744,7 @@ sub pilight_ctrl_Parse($$)
|
|||||||
my $msg = "PITEMP,$proto,$id,$temp,$humidity,$battery";
|
my $msg = "PITEMP,$proto,$id,$temp,$humidity,$battery";
|
||||||
return Dispatch($hash, $msg,undef);
|
return Dispatch($hash, $msg,undef);
|
||||||
}
|
}
|
||||||
|
case 5 { return Dispatch($hash, "PISCREEN,$proto,$id,$unit,$state",undef); }
|
||||||
else {Log3 $me, 3, "$me(Parse): unknown protocol -> $proto"; return;}
|
else {Log3 $me, 3, "$me(Parse): unknown protocol -> $proto"; return;}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
##############################################
|
##############################################
|
||||||
|
# $Id: 30_pilight_dimmer.pm 0.50 2015-05-20 Risiko $
|
||||||
#
|
#
|
||||||
# Usage
|
# Usage
|
||||||
#
|
#
|
||||||
# define <name> pilight_dimmer <protocol> <id> <unit>
|
# define <name> pilight_dimmer <protocol> <id> <unit> [protocol]
|
||||||
#
|
#
|
||||||
# Changelog
|
# Changelog
|
||||||
#
|
#
|
||||||
# V 0.10 2015-02-26 - initial beta version
|
# V 0.10 2015-02-26 - initial beta version
|
||||||
|
# V 0.50 2015-05-20 - NEW: handle screen messages (up,down)
|
||||||
|
# V 0.50 2015-05-20 - NEW: max dimlevel for gui and device
|
||||||
##############################################
|
##############################################
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
@ -25,10 +28,10 @@ sub pilight_dimmer_Initialize($)
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
$hash->{DefFn} = "pilight_dimmer_Define";
|
$hash->{DefFn} = "pilight_dimmer_Define";
|
||||||
$hash->{Match} = "^SWITCH|^DIMMER";
|
$hash->{Match} = "^PISWITCH|^PIDIMMER|^PISCREEN";
|
||||||
$hash->{ParseFn} = "pilight_dimmer_Parse";
|
$hash->{ParseFn} = "pilight_dimmer_Parse";
|
||||||
$hash->{SetFn} = "pilight_dimmer_Set";
|
$hash->{SetFn} = "pilight_dimmer_Set";
|
||||||
$hash->{AttrList} = "dimlevel_max ".$readingFnAttributes;
|
$hash->{AttrList} = "dimlevel_max dimlevel_step dimlevel_max_device ".$readingFnAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -38,7 +41,7 @@ sub pilight_dimmer_Define($$)
|
|||||||
my @a = split("[ \t][ \t]*", $def);
|
my @a = split("[ \t][ \t]*", $def);
|
||||||
|
|
||||||
if(@a < 5) {
|
if(@a < 5) {
|
||||||
my $msg = "wrong syntax: define <name> pilight_dimmer <protocol> <id> <unit>";
|
my $msg = "wrong syntax: define <name> pilight_dimmer <protocol> <id> <unit> [protocol]";
|
||||||
Log3 undef, 2, $msg;
|
Log3 undef, 2, $msg;
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
@ -52,6 +55,12 @@ sub pilight_dimmer_Define($$)
|
|||||||
$hash->{PROTOCOL} = lc($protocol);
|
$hash->{PROTOCOL} = lc($protocol);
|
||||||
$hash->{ID} = $id;
|
$hash->{ID} = $id;
|
||||||
$hash->{UNIT} = $unit;
|
$hash->{UNIT} = $unit;
|
||||||
|
$hash->{PROTOCOL2} = lc($a[5]) if (@a == 6);
|
||||||
|
|
||||||
|
$hash->{helper}{OWN_DIM} = 1;
|
||||||
|
$hash->{helper}{OWN_DIM} = 0 if ($hash->{PROTOCOL} =~ /screen/);
|
||||||
|
|
||||||
|
$hash->{helper}{ISSCREEN} = 1 if ($hash->{PROTOCOL} =~ /screen/ or $hash->{PROTOCOL2} =~ /screen/);
|
||||||
|
|
||||||
#$attr{$me}{verbose} = 5;
|
#$attr{$me}{verbose} = 5;
|
||||||
|
|
||||||
@ -66,11 +75,12 @@ sub pilight_dimmer_Parse($$)
|
|||||||
|
|
||||||
my ($mhash, $rmsg, $rawdata) = @_;
|
my ($mhash, $rmsg, $rawdata) = @_;
|
||||||
my $backend = $mhash->{NAME};
|
my $backend = $mhash->{NAME};
|
||||||
|
my $dimlevel = undef;
|
||||||
|
|
||||||
Log3 $backend, 4, "pilight_dimmer_Parse: RCV -> $rmsg";
|
Log3 $backend, 4, "pilight_dimmer_Parse: RCV -> $rmsg";
|
||||||
|
|
||||||
my ($dev,$protocol,$id,$unit,$state,$dimlevel) = split(",",$rmsg);
|
my ($dev,$protocol,$id,$unit,$state,$dimlevel) = split(",",$rmsg);
|
||||||
return () if($dev ne "SWITCH" && $dev ne "DIMMER");
|
return () if($dev !~ m/PISWITCH|PIDIMMER|PISCREEN/);
|
||||||
|
|
||||||
my $chash;
|
my $chash;
|
||||||
foreach my $n (keys %{ $modules{pilight_dimmer}{defptr}{lc($id)} }) {
|
foreach my $n (keys %{ $modules{pilight_dimmer}{defptr}{lc($id)} }) {
|
||||||
@ -84,14 +94,74 @@ sub pilight_dimmer_Parse($$)
|
|||||||
|
|
||||||
return () if (!defined($chash->{NAME}));
|
return () if (!defined($chash->{NAME}));
|
||||||
|
|
||||||
|
my $max_default = 15;
|
||||||
|
$max_default = 100 if ($chash->{helper}{OWN_DIM} != 1);
|
||||||
|
|
||||||
|
my $dimlevel_max_dev = AttrVal($chash->{NAME}, "dimlevel_max_device",$max_default);
|
||||||
|
my $dimlevel_max = AttrVal($chash->{NAME}, "dimlevel_max",$dimlevel_max_dev);
|
||||||
|
my $dimlevel_step = AttrVal($chash->{NAME}, "dimlevel_step",1);
|
||||||
|
my $dimlevel_old = ReadingsVal($chash->{NAME},"dimlevel",0);
|
||||||
|
|
||||||
|
Log3 $chash->{NAME}, 4, "pilight_dimmer_Parse: RCV -> $rmsg";
|
||||||
|
|
||||||
readingsBeginUpdate($chash);
|
readingsBeginUpdate($chash);
|
||||||
|
|
||||||
|
if ($state eq "up") {
|
||||||
|
$dimlevel = $dimlevel_old + $dimlevel_step;
|
||||||
|
$dimlevel = $dimlevel_max if ($dimlevel > $dimlevel_max);
|
||||||
|
$state="on";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($state eq "down") {
|
||||||
|
$dimlevel = $dimlevel_old - $dimlevel_step;
|
||||||
|
$state="on";
|
||||||
|
if ($dimlevel < 0) {
|
||||||
|
$state="off";
|
||||||
|
$dimlevel = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
readingsBulkUpdate($chash,"state",$state);
|
readingsBulkUpdate($chash,"state",$state);
|
||||||
readingsBulkUpdate($chash,"dimlevel",$dimlevel) if (defined($dimlevel));
|
if (defined($dimlevel)) {
|
||||||
|
$chash->{helper}{DEV_DIMLEVEL} = $dimlevel;
|
||||||
|
$dimlevel = $dimlevel / $dimlevel_max_dev * $dimlevel_max;
|
||||||
|
$dimlevel = int($dimlevel+0.5);
|
||||||
|
readingsBulkUpdate($chash,"dimlevel",$dimlevel);
|
||||||
|
}
|
||||||
readingsEndUpdate($chash, 1);
|
readingsEndUpdate($chash, 1);
|
||||||
|
|
||||||
return $chash->{NAME};
|
return $chash->{NAME};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
sub pilight_dimmer_Write($$$)
|
||||||
|
{
|
||||||
|
my ($hash, $set, $dimlevel) = @_;
|
||||||
|
my $me = $hash->{NAME};
|
||||||
|
|
||||||
|
my $proto = $hash->{PROTOCOL};
|
||||||
|
|
||||||
|
if ($set =~ /up|down/ and $proto !~ /screen/) {
|
||||||
|
$proto = $hash->{PROTOCOL2} if (defined($hash->{PROTOCOL2}));
|
||||||
|
}
|
||||||
|
if ($set =~ /on|off/ and $proto =~ /screen/) {
|
||||||
|
$proto = $hash->{PROTOCOL2} if (defined($hash->{PROTOCOL2}));
|
||||||
|
}
|
||||||
|
|
||||||
|
my $msg = "$me,$set";
|
||||||
|
$msg = $msg.",".$dimlevel if (defined($dimlevel));
|
||||||
|
|
||||||
|
my $help = $hash->{PROTOCOL};
|
||||||
|
$hash->{PROTOCOL} = $proto;
|
||||||
|
|
||||||
|
Log3 $me, 4, "$me(Set): [$proto] $msg";
|
||||||
|
|
||||||
|
IOWrite($hash, $msg);
|
||||||
|
|
||||||
|
$hash->{PROTOCOL} = $help;
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub pilight_dimmer_Set($$)
|
sub pilight_dimmer_Set($$)
|
||||||
{
|
{
|
||||||
@ -99,21 +169,53 @@ sub pilight_dimmer_Set($$)
|
|||||||
my $me = shift @a;
|
my $me = shift @a;
|
||||||
|
|
||||||
return "no set value specified" if(int(@a) < 1);
|
return "no set value specified" if(int(@a) < 1);
|
||||||
my $maxlevel = $attr{$me}{dimlevel_max};
|
my $dimlevel_max_dev = AttrVal($me, "dimlevel_max_device",15);
|
||||||
$maxlevel = 15 if (!defined($maxlevel));
|
my $dimlevel_step = AttrVal($me, "dimlevel_step",1);
|
||||||
return "Unknown argument ?, choose one of on off dimlevel:slider,0,1,$maxlevel" if($a[0] eq "?");
|
my $dimlevel_max = AttrVal($me, "dimlevel_max",$dimlevel_max_dev);
|
||||||
|
|
||||||
my $msg = "$me,";
|
my $canSet = "on off";
|
||||||
|
$canSet .= " up down" if ($hash->{helper}{ISSCREEN});
|
||||||
|
|
||||||
|
return "Unknown argument ?, choose one of $canSet dimlevel:slider,0,$dimlevel_step,$dimlevel_max" if($a[0] eq "?");
|
||||||
|
|
||||||
|
my $set = $a[0];
|
||||||
|
my $dimlevel = undef;
|
||||||
|
|
||||||
if ($a[0] eq "dimlevel") {
|
if ($a[0] eq "dimlevel") {
|
||||||
$msg .= "on,".$a[1];
|
if ($hash->{helper}{OWN_DIM} == 1) {
|
||||||
} else {
|
$dimlevel = $a[1] / $dimlevel_max * $dimlevel_max_dev;
|
||||||
$msg .= $a[0];
|
$dimlevel = int($dimlevel + 0.5);
|
||||||
|
$set = "on";
|
||||||
|
} elsif ($hash->{helper}{ISSCREEN}){
|
||||||
|
my $newlevel = $a[1];
|
||||||
|
my $currlevel = ReadingsVal($me,"dimlevel",0);
|
||||||
|
my $cnt = int(($newlevel - $currlevel) / $dimlevel_step);
|
||||||
|
return undef if ($cnt==0);
|
||||||
|
$set = "up" if ($cnt>0);
|
||||||
|
$set = "down" if ($cnt<0);
|
||||||
|
for (my $i=0; $i < abs($cnt); $i++) {
|
||||||
|
pilight_dimmer_Write($hash,$set,undef);
|
||||||
|
}
|
||||||
|
return undef;
|
||||||
|
} else {
|
||||||
|
Log3 $me, 1, "$me(Set): error setting dimlevel";
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
} elsif ( ($set eq "up" or $set eq "down") and !$hash->{helper}{ISSCREEN}) {
|
||||||
|
Log3 $me, 1, "$me(Set): up|down not supported";
|
||||||
|
return undef;
|
||||||
|
} elsif ( $set eq "off" ) {
|
||||||
|
delete $hash->{helper}{DEV_DIMLEVEL};
|
||||||
}
|
}
|
||||||
|
|
||||||
Log3 $me, 4, "$me(Set): $msg";
|
if (defined($dimlevel)) {
|
||||||
|
my $dimOld = $hash->{helper}{DEV_DIMLEVEL};
|
||||||
|
if (defined($dimOld)) {
|
||||||
|
return undef if ($dimOld == $dimlevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IOWrite($hash, $msg);
|
pilight_dimmer_Write($hash,$set,$dimlevel);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,17 +233,23 @@ sub pilight_dimmer_Set($$)
|
|||||||
You have to define the base device pilight_ctrl first.<br>
|
You have to define the base device pilight_ctrl first.<br>
|
||||||
Further information to pilight: <a href="http://www.pilight.org/">http://www.pilight.org/</a><br>
|
Further information to pilight: <a href="http://www.pilight.org/">http://www.pilight.org/</a><br>
|
||||||
Supported dimmers: <a href="http://wiki.pilight.org/doku.php/protocols#dimmers">http://wiki.pilight.org/doku.php/protocols#dimmers</a><br>
|
Supported dimmers: <a href="http://wiki.pilight.org/doku.php/protocols#dimmers">http://wiki.pilight.org/doku.php/protocols#dimmers</a><br>
|
||||||
<br><br>
|
<br>
|
||||||
|
It is possible to add the screen feature to a dimmer. So you can change the dimlevel by set 'up' or 'down'.<br>
|
||||||
|
If you push up or down on the remote control the dimlevel will be changed by dimlevel_step.<br>
|
||||||
|
Further it is possible to define a simulated dimmer with a screen and switch protocol. See example three.<br>
|
||||||
|
That means if you change the dimlevel a up or down command will be send n times to dim the device instead of send a dimlevel directly.<br>
|
||||||
|
<br>
|
||||||
<a name="pilight_dimmer_define"></a>
|
<a name="pilight_dimmer_define"></a>
|
||||||
<b>Define</b>
|
<b>Define</b>
|
||||||
<ul>
|
<ul>
|
||||||
<code>define <name> pilight_dimmer protocol id unit</code>
|
<code>define <name> pilight_dimmer protocol id unit [protocol]</code>
|
||||||
<br><br>
|
<br>The second protocol is optional. With it you can add the pilight screen feature (up|down)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
<ul>
|
<ul>
|
||||||
<code>define myctrl pilight_dimmer kaku_dimmer 13483668 0</code><br>
|
<code>define myctrl pilight_dimmer kaku_dimmer 13483668 0</code><br>
|
||||||
|
<code>define myctrl pilight_dimmer kaku_dimmer 13483668 0 kaku_screen</code> - Dimmer with screen feature<br>
|
||||||
|
<code>define myctrl pilight_dimmer quigg_screen 1 0 quigg_gt7000</code> - Simulated dimmer with screen feature<br>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
@ -154,6 +262,12 @@ sub pilight_dimmer_Set($$)
|
|||||||
<li>
|
<li>
|
||||||
<b>off</b>
|
<b>off</b>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>up</b> only if defined with screen protocol
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>down</b> only if defined with screen protocol
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<b>dimlevel</b>
|
<b>dimlevel</b>
|
||||||
</li>
|
</li>
|
||||||
@ -175,10 +289,15 @@ sub pilight_dimmer_Set($$)
|
|||||||
<a name="pilight_dimmer_attr"></a>
|
<a name="pilight_dimmer_attr"></a>
|
||||||
<b>Attributes</b>
|
<b>Attributes</b>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="dimlevel_max">dimlevel_max</a><br>
|
<li><a name="dimlevel_max_device">dimlevel_max_device</a><br>
|
||||||
Maximum of the dimlevel - default 15<br>
|
Maximum of the dimlevel of the device - default 15<br>
|
||||||
|
</li>
|
||||||
|
<li><a name="dimlevel_max">dimlevel_max</a><br>
|
||||||
|
Maximum of the dimlevel in FHEM - default dimlevel_max_device<br>
|
||||||
|
</li>
|
||||||
|
<li><a name="dimlevel_step">dimlevel_step</a><br>
|
||||||
|
Step of the dimlevel - default 1<br>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
##############################################
|
##############################################
|
||||||
|
# $Id: 30_pilight_switch.pm 0.12 2015-05-18 Risiko $
|
||||||
#
|
#
|
||||||
# Usage
|
# Usage
|
||||||
#
|
#
|
||||||
@ -8,6 +9,7 @@
|
|||||||
#
|
#
|
||||||
# V 0.10 2015-02-22 - initial beta version
|
# V 0.10 2015-02-22 - initial beta version
|
||||||
# V 0.11 2015-03-29 - FIX: $readingFnAttributes
|
# V 0.11 2015-03-29 - FIX: $readingFnAttributes
|
||||||
|
# V 0.12 2015-05-18 - FIX: add version information
|
||||||
##############################################
|
##############################################
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
@ -26,7 +28,7 @@ sub pilight_switch_Initialize($)
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
$hash->{DefFn} = "pilight_switch_Define";
|
$hash->{DefFn} = "pilight_switch_Define";
|
||||||
$hash->{Match} = "^SWITCH";
|
$hash->{Match} = "^PISWITCH";
|
||||||
$hash->{ParseFn} = "pilight_switch_Parse";
|
$hash->{ParseFn} = "pilight_switch_Parse";
|
||||||
$hash->{SetFn} = "pilight_switch_Set";
|
$hash->{SetFn} = "pilight_switch_Set";
|
||||||
$hash->{AttrList} = $readingFnAttributes;
|
$hash->{AttrList} = $readingFnAttributes;
|
||||||
@ -71,7 +73,7 @@ sub pilight_switch_Parse($$)
|
|||||||
Log3 $backend, 4, "pilight_switch_Parse: RCV -> $rmsg";
|
Log3 $backend, 4, "pilight_switch_Parse: RCV -> $rmsg";
|
||||||
|
|
||||||
my ($dev,$protocol,$id,$unit,$state,@args) = split(",",$rmsg);
|
my ($dev,$protocol,$id,$unit,$state,@args) = split(",",$rmsg);
|
||||||
return () if($dev ne "SWITCH");
|
return () if($dev ne "PISWITCH");
|
||||||
|
|
||||||
my $chash;
|
my $chash;
|
||||||
foreach my $n (keys %{ $modules{pilight_switch}{defptr}{lc($protocol)} }) {
|
foreach my $n (keys %{ $modules{pilight_switch}{defptr}{lc($protocol)} }) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user