From adfb84b2ef4df01cd358c7ce910cb66c1f039d4c Mon Sep 17 00:00:00 2001 From: c-herrmann Date: Sun, 30 Mar 2014 13:44:56 +0000 Subject: [PATCH] 10_UNIRoll.pm added git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@5376 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_UNIRoll.pm | 531 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 531 insertions(+) create mode 100644 fhem/FHEM/10_UNIRoll.pm diff --git a/fhem/FHEM/10_UNIRoll.pm b/fhem/FHEM/10_UNIRoll.pm new file mode 100644 index 000000000..801d4b233 --- /dev/null +++ b/fhem/FHEM/10_UNIRoll.pm @@ -0,0 +1,531 @@ +###################LoTT Uniroll################### +# First release by D. Fuchs and rudolfkoenig +# improved by c-herrmann +# $Id: 10_UNIRoll Ver 1.3 2014-03-30 14:53:00 c-herrmann $ +# +# UNIRoll:no synchronisation, the message protocoll begins directly with datas +# group address 16 Bit like an housecode +# channel address 4 Bit up to 16 devices +# command 4 Bit up: E(1110), stop: D(1101), down: B(1011) +# end off 1 Bit, zero or one it doesnot matter +# whole length 25 Bit +#time intervall: +#Bit-digit 0 high ca. 1,6 ms equal 100(h64) 16us steps +# low ca. 0,576 ms 36(h24) +#Bit-digit 1 high ca. 0,576 ms 36(h24) +# low ca. 1,6 ms 100(h64) +#timespace ca. 100 - 170 ms +#binary : 1010 1011 1100 1101 1110 1 +#hexa: a b c d e (an additional one bit) +#the message is sent with the general cul-command: G +#G0031A364242464abcd6e8 : 00 synchbits 3 databytes, 1 databit, HHLLLLHH, data + +package main; + +use strict; +use warnings; + +# Stings für Anfang und Ende des Raw-Kommandos +# Die Zeiten für die Impulslänge wurden anhand meiner 1-Kanal-FB etwas angepasst. +# Sie können durch Veränderung der letzten 4 Hex-Bytes in $rawpre geändert werden. +# siehe auch: http://culfw.de/commandref.html#cmd_G +# Seit der Entwickler-Version 1.58 vom 29.03.2014 gibt es einen UNIRoll-Send-Befehl "U". +my $rawpre_old = "G0036E368232368"; # geänderte Timings und 1 Bit am Ende + # culfw bis einschl. 1.58 +my $rawpre = "U"; # Nutzt UNIRoll-Send ab FW 1.58 +my $rawpost_old = "80"; # ein 1-Bit senden, culfw bis einschl. 1.58 +my $rawpost = ""; # ein 1-Bit wird mit aktueller culfw automatisch gesendt +my $rPos; +my $tm; + +my %codes = ( + "e" => "up", #1110 e + "d" => "stop", #1101 d + "b" => "down", #1011 b + "a" => "pos", # gezielt eine Position anfahren +); + +use vars qw(%UNIRoll_c2b); # Peter would like to access it from outside + +my $UNIRoll_simple = "up stop down pos"; + +my %models = ( + R_23700 => 'simple', + dummySimple => 'simple', +); + +############################# +sub +UNIRoll_Initialize($) +{ + my ($hash) = @_; + + foreach my $k (keys %codes) { + $UNIRoll_c2b{$codes{$k}} = $k; # c2b liest das allgmeine Array der Gerätegruppe + } +# print "UNIRoll_Initialize \n"; + $hash->{Match} = "^(G|U).*"; + $hash->{SetFn} = "UNIRoll_Set"; + $hash->{StateFn} = "UNIRoll_SetState"; + $hash->{DefFn} = "UNIRoll_Define"; + $hash->{UndefFn} = "UNIRoll_Undef"; + $hash->{ParseFn} = "UNIRoll_Parse"; + $hash->{AttrFn} = "UNIRoll_Attr"; + $hash->{AttrList} = "IODev do_not_notify:1,0 ". + "ignore:1,0 showtime:1,0 ". + "rMin:slider,0,1,120 rMax:slider,0,1,120 rPos:slider,0,1,120 useRolloPos:1,0 " . + "sendStopBeforeCmd:1,0,2,3 " . + "model:".join(",", sort keys %models); +} +## Neues Attribut sendStopBeforeCmd hinzugefügt. Default ist 1 - Stop wird gesendet. +## Bei 0 wird kein Stop-Befehl vor dem auf/ab-Befehl gesendet. +## Bei 2 wird Stop nur vor "auf" und bei 3 nur vor "ab" gesendet. +## Hier ging der auf-Befehl immer zuverlässig. Ab funktionierte +## nur sporadisch, insbesondere wenn es von einem "at" gesendet wurde. + +##################################### +sub +UNIRoll_SetState($$$$) # 4 Skalare Parameter +{ + my ($hash, $tim, $vt, $val) = @_; #@_ Array +# print "UNIRoll_SetState \n"; + + $val = $1 if($val =~ m/^(.*) \d+$/); # m match Funktion + my $name = $hash->{NAME}; + (undef, $val) = ReplaceEventMap($name, [$name, $val], 0) + if($attr{$name}{eventMap}); + return "setstate $name: undefined value $val" if(!defined($UNIRoll_c2b{$val})); + return undef; +} + +################################### +sub +UNIRoll_Set($@) +{ + my ($hash, @a) = @_; # Eingabewerte nach define name typ devicecode channelcode + my $ret = undef; + my $na = int(@a); #na Anzahl Felder in a + # print "UNIRoll_Set \n"; + return "no set value specified" if($na < 2 || $na > 3); + my $c = $UNIRoll_c2b{$a[1]}; # Wert des Kommandos: up stop down pos + my $name = $a[0]; # Gerätename + $tm = 0 if(defined($c)); # optionaler Zeitwert + if($na == 3) { + $tm = $a[2]; + return "Argument for