diff --git a/fhem/FHEM/11_FHT8V.pm b/fhem/FHEM/11_FHT8V.pm new file mode 100755 index 000000000..aeab7d5e4 --- /dev/null +++ b/fhem/FHEM/11_FHT8V.pm @@ -0,0 +1,107 @@ +############################################# +package main; + +use strict; +use warnings; + +sub +FHT8V_Initialize($) +{ + my ($hash) = @_; + + $hash->{DefFn} = "FHT8V_Define"; + $hash->{SetFn} = "FHT8V_Set"; + $hash->{GetFn} = "FHT8V_Get"; + $hash->{AttrList} = "IODev dummy:1,0 ignore:1,0 loglevel:0,1,2,3,4,5,6"; +} + +############################# +sub +FHT8V_Define($$) +{ + my ($hash, $def) = @_; + my @a = split("[ \t][ \t]*", $def); + my $n = $a[0]; + + return "wrong syntax: define FHT8V housecode [IODev]" if(@a < 3); + return "wrong housecode format: specify a 4 digit hex value " + if(($a[2] !~ m/^[a-f0-9]{4}$/i)); + if(@a > 3) { + $hash->{IODev} = $defs{$a[3]}; + } else { + AssignIoPort($hash); + } + return "$n: No IODev found" if(!$hash->{IODev}); + return "$n: Wrong IODev, has no FHTID" if(!$hash->{IODev}->{FHTID}); + + ##################### + # Check if the address corresponds to the CUL + my $ioaddr = hex($hash->{IODev}->{FHTID}); + my $myaddr = hex($a[2]); + my ($io1, $io0) = (int($ioaddr/255), $ioaddr % 256); + my ($my1, $my0) = (int($myaddr/255), $myaddr % 256); + if($my1 < $io1 || $my1 > $io1+7 || $io0 != $my0) { + my $vals = ""; + for(my $m = 0; $m <= 7; $m++) { + $vals .= sprintf(" %2x%2x", $io1+$m, $io0); + } + return sprintf("Wrong housecode: must be one of$vals"); + } + + $hash->{ADDR} = uc($a[2]); + $hash->{IDX} = sprintf("%02X", $my1-$io1); + $hash->{STATE} = "defined"; + return ""; +} + + +sub +FHT8V_Set($@) +{ + my ($hash, @a) = @_; + my $n = $hash->{NAME}; + + return "Need a parameter for set" if(@a < 2); + my $arg = $a[1]; + + if($arg eq "valve" ) { + return "Set valve needs a numeric parameter between 0 and 100" + if(@a != 3 || $a[2] !~ m/^\d+$/ || $a[2] < 0 || $a[2] > 100); + Log GetLogLevel($n,3), "FHT8V set $n $arg $a[2]"; + $hash->{STATE} = sprintf("%d %%", $a[2]); + IOWrite($hash, "", sprintf("T%s0026%02X", $hash->{ADDR}, $a[2]*2.55)); + + } elsif ($arg eq "pair" ) { + Log GetLogLevel($n,3), "FHT8V set $n $arg"; + IOWrite($hash, "", sprintf("T%s002f00", $hash->{ADDR})); + + } else { + return "Unknown argument $a[1], choose one of valve pair" + + } + return ""; + +} + +sub +FHT8V_Get($@) +{ + my ($hash, @a) = @_; + my $n = $hash->{NAME}; + + return "Need a parameter for get" if(@a < 2); + my $arg = $a[1]; + + if($arg eq "valve" ) { + my $io = $hash->{IODev}; + my $msg = CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", "T10")); + my $idx = $hash->{IDX}; + return int(hex($1)/2.55) if($msg =~ m/$idx:26(..)/); + return "N/A"; + + } + return "Unknown argument $a[1], choose one of valve" +} + + +1; diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index af415e363..15a8a2a54 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -88,6 +88,7 @@ FHEMRENDERER   FHEMWEB   FHT   + FHT8V   FHZ   FS20   HMS   @@ -1135,13 +1136,13 @@ A line ending with \ will be concatenated with the next one, so long lines corresponding to a button of the transmitter.
  • The optional <fgaddr> specifies the function group. It is a 2 digit hex or 4 digit ELV address. The first digit of the hex - adress must be F or the first 2 digits of the ELV4 address must be + address must be F or the first 2 digits of the ELV4 address must be 44.
  • The optional <lmaddr> specifies the local master. It is a 2 digit hex or 4 digit ELV address. The last digit of the hex address must be F or the last 2 digits of the ELV4 address must be 44.
  • -
  • The optional gm specifies the global master, the adress must be FF if +
  • The optional gm specifies the global master, the address must be FF if defined as hex value or 4444 if defined as ELV4 value.

  • @@ -1310,7 +1311,7 @@ A line ending with \ will be concatenated with the next one, so long lines

    <housecode> is a four digit hex number, - corresponding to the adress of the FHT80b device. + corresponding to the address of the FHT80b device.
    Examples: @@ -1546,6 +1547,77 @@ A line ending with \ will be concatenated with the next one, so long lines + +

    FHT8V

    + + +

    CUL_FHTTK

    @@ -1611,7 +1683,7 @@ A line ending with \ will be concatenated with the next one, so long lines

    <housecode> is a four digit hex number, - corresponding to the adress of the HMS device. + corresponding to the address of the HMS device.
    Examples: @@ -2442,7 +2514,7 @@ A line ending with \ will be concatenated with the next one, so long lines

    <housecode> is a four digit hex number, - corresponding to the adress of the KS300 device, right now it is ignored. + corresponding to the address of the KS300 device, right now it is ignored. The ml/raincounter defaults to 255 ml, but it must be specified if you wish to set the wind factor, which defaults to 1.0.
    diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 2d6efc97f..55b1c9464 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -160,7 +160,7 @@ my $nextat; # Time when next timer will be triggered. my $intAtCnt=0; my %duplicate; # Pool of received msg for multi-fhz/cul setups my $duplidx=0; # helper for the above pool -my $cvsid = '$Id: fhem.pl,v 1.112 2010-10-08 07:07:40 rudolfkoenig Exp $'; +my $cvsid = '$Id: fhem.pl,v 1.113 2010-10-10 08:23:29 rudolfkoenig Exp $'; my $namedef = "where is either:\n" . "- a single device name\n" . @@ -1095,12 +1095,14 @@ CommandDefine($$) if($ret) { delete $defs{$a[0]}; # Veto delete $attr{$a[0]}; + } else { foreach my $da (sort keys (%defaultattr)) { # Default attributes CommandAttr($cl, "$a[0] $da $defaultattr{$da}"); } + DoTrigger("global", "DEFINED $a[0]"); + } - DoTrigger("global", "DEFINED $a[0]"); return $ret; }