2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

10_pilight_ctrl: support protocol daycom with three id's

git-svn-id: https://svn.fhem.de/fhem/trunk@11134 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
risiko79 2016-03-28 13:29:02 +00:00
parent 1e58ecdef4
commit fce6448b65
3 changed files with 27 additions and 3 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.
- feature: 10_pilight_ctrl | 30_pilight_switch: support protocol daycom
- feature: 59_Weather: rewritten to use JSON API
- bugfix: 49_SSCAM: "link_open" doesn't work after last update
- added: 70_BRAVIA: new module for Sony Televisions

View File

@ -39,6 +39,7 @@
# V 1.12 2015-09-11 - FIX: handling ContactAsSwitch befor white list check
# V 1.13 2015-11-10 - FIX: POSIX isdigit is deprecated replaced by own isDigit
# V 1.14 2016-03-20 - FIX: send delimiter to signal end of stream if length of data > 1024
# V 1.15 2016-03-28 - NEW: protocol daycom (switch)
##############################################
package main;
@ -399,9 +400,12 @@ sub pilight_ctrl_Write($@)
my $proto = $defs{$cName}->{PROTOCOL};
my $id = $defs{$cName}->{ID};
my $unit = $defs{$cName}->{UNIT};
my $syscode = undef;
$syscode = $defs{$cName}->{SYSCODE} if defined($defs{$cName}->{SYSCODE});
$id = "\"".$id."\"" if (defined($id) && !isDigit($id));
$unit = "\"".$unit."\"" if (defined($unit) && !isDigit($unit));
$id = "\"".$id."\"" if (defined($id) && !isDigit($id));
$unit = "\"".$unit."\"" if (defined($unit) && !isDigit($unit));
$syscode = "\"".$syscode."\"" if (defined($syscode) && !isDigit($syscode));
my $code;
switch($cType){
@ -415,6 +419,12 @@ sub pilight_ctrl_Write($@)
case m/pollin/ {$code .= "\"systemcode\":$id,\"unitcode\":$unit,";}
case m/impuls/ {$code .= "\"systemcode\":$id,\"programcode\":$unit,";}
case m/rsl366/ {$code .= "\"systemcode\":$id,\"programcode\":$unit,";}
case m/daycom/ { if (!defined($syscode)) {
Log3 $me, 1, "$me(Write): Error protocol daycom no systemcode defined";
return;
}
$code .= "\"id\":$id,\"systemcode\":$syscode,\"unit\":$unit,";
}
case m/cleverwatts/ { $code .= "\"id\":$id,";
if ($unit eq "\"all\"") {
$code .= "\"all\":1,";
@ -756,6 +766,9 @@ sub pilight_ctrl_Parse($$)
last if ($id ne "");
}
#systemcode and id for protocol daycom (needs 3 id's, systemcode, id, unit
my $syscode = (defined($data->{$s}{"systemcode"})) ? $data->{$s}{"systemcode"} : "";
my $unit = "";
foreach my $sunit (@unitList) {
$unit = (defined($data->{$s}{$sunit})) ? $data->{$s}{$sunit} : "";
@ -804,6 +817,7 @@ sub pilight_ctrl_Parse($$)
case m/mumbi/ {$protoID = 1;}
case m/brennenstuhl/{$protoID = 1;}
case m/pollin/ {$protoID = 1;}
case m/daycom/ {$protoID = 1;}
case m/impuls/ {$protoID = 1;}
case m/rsl366/ {$protoID = 1;}
case m/cleverwatts/ {$protoID = 1;}
@ -842,6 +856,8 @@ sub pilight_ctrl_Parse($$)
switch($protoID){
case 1 {
my $msg = "PISWITCH,$proto,$id,$unit,$state";
$msg .= ",$syscode" if ($syscode ne "");
Log3 $me, 4, "$me(Dispatch): $msg";
return Dispatch($hash, $msg,undef );
}

View File

@ -13,6 +13,7 @@
# V 0.13 2015-05-30 - FIX: StateFn, noArg
# V 0.14 2015-07-27 - NEW: SetExtensions on-for-timer
# V 0.15 2015-12-17 - NEW: Attribut IODev to switch IO-Device
# V 0.16 2016-03-28 - NEW: protocol daycom with three id's (id, systemcode, unit)
##############################################
package main;
@ -49,7 +50,7 @@ sub pilight_switch_Define($$)
my @a = split("[ \t][ \t]*", $def);
if(@a < 5) {
my $msg = "wrong syntax: define <name> pilight_switch <protocol> <id> <unit>";
my $msg = "wrong syntax: define <name> pilight_switch <protocol> <id> <unit> [systemcode]";
Log3 undef, 2, $msg;
return $msg;
}
@ -63,6 +64,8 @@ sub pilight_switch_Define($$)
$hash->{PROTOCOL} = lc($protocol);
$hash->{ID} = $id;
$hash->{UNIT} = $unit;
$hash->{SYSCODE} = undef;
$hash->{SYSCODE} = $a[5] if (@a == 6);
#$attr{$me}{verbose} = 5;
@ -100,6 +103,10 @@ sub pilight_switch_Parse($$)
my $lh = $modules{pilight_switch}{defptr}{$protocol}{$n};
next if ( !defined($lh->{ID}) || !defined($lh->{UNIT}) );
if ($lh->{ID} eq $id && $lh->{UNIT} eq $unit) {
if (defined($lh->{SYSCODE})) { #protocol daycom needs three id's id, systemcode, unit
next if (@args<=0);
next if ($lh->{SYSCODE} ne $args[0]);
}
$chash = $lh;
last;
}