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

MD15 experiments

git-svn-id: https://svn.fhem.de/fhem/trunk@1130 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2011-12-14 07:57:59 +00:00
parent 33efb8f7f6
commit 1c25832f96
2 changed files with 71 additions and 33 deletions

View File

@ -52,7 +52,7 @@ TCM_Initialize($)
$hash->{DefFn} = "TCM_Define";
$hash->{GetFn} = "TCM_Get";
$hash->{SetFn} = "TCM_Set";
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 loglevel:0,1,2,3,4,5,6 ";
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 loglevel:0,1,2,3,4,5,6";
}
#####################################
@ -480,7 +480,16 @@ TCM_Get($@)
}
########################
sub
TCM_RemovePair($)
{
my $hash = shift;
delete($hash->{pair});
}
my %sets120 = ( # Name, Data to send to the CUL, Regexp for the answer
"pairForSec" => { cmd=>"AB18", arg=>"\\d+" },
"idbase" => { cmd=>"AB18", arg=>"FF[8-9A-F][0-9A-F]{5}" },
"sensitivity" => { cmd=>"AB08", arg=>"0[01]" },
"sleep" => { cmd=>"AB09" },
@ -491,6 +500,7 @@ my %sets120 = ( # Name, Data to send to the CUL, Regexp for the answer
);
my %sets310 = (
"pairForSec" => { cmd=>"AB18", arg=>"\\d+" },
"idbase" => { cmd=>"07", arg=>"FF[8-9A-F][0-9A-F]{5}" },
# The following 3 does not seem to work / dont get an answer
# "sleep" => { cmd=>"01", arg=>"00[0-9A-F]{6}" },
@ -523,6 +533,11 @@ TCM_Set($@)
$cmdHex .= $arg;
}
if($cmd eq "pairForSec") {
$hash->{pair} = 1;
InternalTimer(gettimeofday()+$arg, "TCM_RemovePair", $hash, 1);
return;
}
##############################
if($hash->{MODEL} eq "120") {

View File

@ -9,6 +9,7 @@ sub EnOcean_Define($$);
sub EnOcean_Initialize($);
sub EnOcean_Parse($$);
sub EnOcean_Set($@);
sub EnOcean_MD15Cmd($$$);
my %rorgname = ("F6"=>"switch", # RPS
"D5"=>"contact", # 1BS
@ -82,7 +83,6 @@ EnOcean_Define($$)
my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
my $name = $hash->{NAME};
return "wrong syntax: define <name> EnOcean 8-digit-hex-code"
if(int(@a)!=3 || $a[2] !~ m/^[A-F0-9]{8}$/i);
@ -90,7 +90,7 @@ EnOcean_Define($$)
AssignIoPort($hash);
# Help FHEMWEB split up devices
$attr{$name}{subType} = $1 if($name =~ m/EnO_(.*)_$a[2]/);
return undef;
}
@ -115,9 +115,10 @@ EnOcean_Set($@)
# See also http://www.oscat.de/community/index.php/topic,985.30.html
if($st eq "MD15") {
my %sets = (
"desired-temp" => "\\d+\\.\\d+",
"desired-temp" => "\\d+(\\.\\d)?",
"actuator" => "\\d+",
"unattended" => "",
"initialize" => "",
);
my $re = $sets{$a[0]};
return "Unknown argument $cmd, choose one of ".join(" ", sort keys %sets)
@ -130,10 +131,8 @@ EnOcean_Set($@)
$hash->{READINGS}{CMD}{TIME} = $tn;
$hash->{READINGS}{CMD}{VAL} = $cmd;
my $arg = 1;
my $arg = "true";
if($re) {
$hash->{READINGS}{CMD_ARG}{TIME} = $tn;
$hash->{READINGS}{CMD_ARG}{VAL} = $a[1];
$arg = $a[1];
shift(@a);
}
@ -178,11 +177,6 @@ EnOcean_Parse($$)
{
my ($iohash, $msg) = @_;
my (undef,$rorg,$data,$id,$status,$odata) = split(":", $msg);
#Log 1, "RORG: $rorg";
#Log 1, "DATA: $data";
#Log 1, "ID: $id";
#Log 1, "STATUS: $status";
#Log 1, "ODATA: $odata";
my $rorgname = $rorgname{$rorg};
if(!$rorgname) {
@ -282,6 +276,13 @@ EnOcean_Parse($$)
$st = $subTypes{$st} if($subTypes{$st});
$attr{$name}{subType} = $st;
if("$fn.$tp" eq "20.01" && $iohash->{pair}) { # MD15
select(undef, undef, undef, 0.1); # max 10 Seconds
EnOcean_A5Cmd($hash, "800800F0", "00000000");
select(undef, undef, undef, 0.5);
EnOcean_MD15Cmd($hash, $name, 128); # 128 == 20 degree C
}
} else {
push @event, "3:teach-in:no type/manuf. data transmitted";
@ -314,28 +315,9 @@ EnOcean_Parse($$)
push @event, "3:cover:" . (($db_2 & 0x08) ? "open" : "closed");
push @event, "3:tempSensor:" . (($db_2 & 0x04) ? "failed" : "ok");
push @event, "3:window:" . (($db_2 & 0x02) ? "open" : "closed");
push @event, "3:actuator:" . (($db_2 & 0x01) ? "ok" : "obstructed");
push @event, "3:actuatorStatus:".(($db_2 & 0x01) ? "obstructed" : "ok");
push @event, "3:measured-temp:". sprintf "%.1f", ($db_1*40/255);
my $cmd = ReadingsVal($name, "CMD", undef);
if($cmd) {
my $msg;
my $arg1 = ReadingsVal($name, "CMD_ARG", 20);
if($cmd eq "actuator") {
$msg = sprintf("%02X000000", $arg1);
} elsif($cmd eq "desired-temp") {
$msg = sprintf("%02X%02X0400", $arg1*255/40,
AttrVal($name, "actualTemp", ($db_1*40/255)) * 255/40);
}
select(undef, undef, undef, 0.1);
IOWrite($hash, "000A0701",
sprintf("A5%s%s0001%sFF00",$msg,$hash->{DEF},$hash->{DEF}))
if($msg);
}
EnOcean_MD15Cmd($hash, $name, $db_1);
} else {
push @event, "3:state:$db_3";
@ -380,4 +362,45 @@ EnOcean_Parse($$)
return $name;
}
sub
EnOcean_MD15Cmd($$$)
{
my ($hash, $name, $db_1) = @_;
my $cmd = ReadingsVal($name, "CMD", undef);
if($cmd) {
my $msg; # Unattended
my $arg1 = ReadingsVal($name, $cmd, 0); # Command-Argument
if($cmd eq "actuator") {
$msg = sprintf("%02X000000", $arg1);
} elsif($cmd eq "desired-temp") {
$msg = sprintf("%02X%02X0400", $arg1*255/40,
AttrVal($name, "actualTemp", ($db_1*40/255)) * 255/40);
} elsif($cmd eq "initialize") {
$msg = sprintf("00006400");
}
if($msg) {
select(undef, undef, undef, 0.2);
EnOcean_A5Cmd($hash, $msg, "00000000");
if($cmd eq "initialize") {
delete($defs{$name}{READINGS}{CMD});
delete($defs{$name}{READINGS}{$cmd});
}
}
}
}
sub
EnOcean_A5Cmd($$$)
{
my ($hash, $msg, $org) = @_;
IOWrite($hash, "000A0701", # varLen=0A optLen=07 msgType=01=radio,
sprintf("A5%s%s0001%sFF00",$msg,$org,$hash->{DEF}));
# type=A5 msg:4 senderId:4 status=00 subTelNum=01 destId:4 dBm=FF Security=00
}
1;