98_Dooya.pm 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  1. ######################################################
  2. # $Id: 98_Dooya.pm 15400 2017-11-05 18:11:51Z Sidey $
  3. #
  4. # Dooya module for FHEM
  5. # Thanks for templates/coding from Somfy and SIGNALduino team
  6. #
  7. # Needs SIGNALduino.
  8. # Published under GNU GPL License, v2
  9. # History:
  10. # 0.10 2016-02-16 Jarnsen initial template
  11. # 0.20 2016-03-06 darkmission first functions, renamed from 10_ to 99_
  12. # 0.21 2016-03-06 darkmission Bug default channel corrected, changed attribute repetition to SignalRepeats
  13. # 0.22 2016-03-10 darkmission code cleaned, renamed from 99_ to 98_
  14. # 0.23 2016-03-11 Jarnsen AttrList cleaned and change priority
  15. # 1.00 2016-03-12 darkmission autocreate, parse communication from SIGNALduino for correct position when using remote from doooya
  16. # 1.10 2016-03-13 Ralf9 changed SendCommand with sendMsg
  17. # 1.11 2016-03-17 Ralf9 ID + Channel = DeviceCode
  18. # 1.12 2016-04-26 Jarnsen im Dooya parse cmd geändert
  19. # 1.13 2017-08-26 darkmission Update state when called by remote, little code cleaning (setlist and go-my deleted), some more debug messages
  20. #TODOS:
  21. # - Groups, diff by channels
  22. #
  23. ######################################################
  24. package main;
  25. use strict;
  26. use warnings;
  27. #use List::Util qw(first max maxstr min minstr reduce shuffle sum);
  28. my %codes = (
  29. "01010101" => "stop", # stop the current movement
  30. "00010001" => "off", # go "up"
  31. "00110011" => "on", # go "down"
  32. "11001100" => "prog", # finish pairing
  33. );
  34. my %sets = (
  35. "off" => "noArg",
  36. "on" => "noArg",
  37. "down"=> "noArg",
  38. "stop" => "noArg",
  39. "prog" => "noArg",
  40. # "on-for-timer" => "textField",
  41. # "off-for-timer" => "textField",
  42. # "pos" => "0,10,20,30,40,50,60,70,80,90,100" # Todo: Warum nicht als Slider?
  43. "pos" => "slider,0,10,100"
  44. );
  45. my %sendCommands = (
  46. "off" => "off",
  47. "open" => "off",
  48. "on" => "on",
  49. "close" => "on",
  50. "prog" => "prog",
  51. "stop" => "stop"
  52. );
  53. my %dooya_c2b; # Todo: Als internal speichern
  54. my $dooya_updateFreq = 3; # Interval for State update # Todo: Als internal speichern
  55. # supported models (blinds and shutters)
  56. my %models = (
  57. dooyablinds => 'blinds',
  58. dooyashutter => 'shutter'
  59. );
  60. ##################################################
  61. # new globals for new set
  62. #
  63. my $dooya_posAccuracy = 2; # Todo: Als internal speichern
  64. my $dooya_maxRuntime = 50; # Todo: Als internal speichern
  65. my %positions = (
  66. "moving" => "50",
  67. "open" => "0",
  68. "off" => "0",
  69. "down" => "150",
  70. "closed" => "200",
  71. "on" => "200"
  72. );
  73. my %translations = (
  74. "0" => "open",
  75. "10" => "10",
  76. "20" => "20",
  77. "30" => "30",
  78. "40" => "40",
  79. "50" => "50",
  80. "60" => "60",
  81. "70" => "70",
  82. "80" => "80",
  83. "90" => "90",
  84. "100" => "100",
  85. "150" => "down",
  86. "200" => "closed"
  87. );
  88. ######################################################
  89. # Forward declarations
  90. #
  91. sub Dooya_CalcCurrentPos($$$$);
  92. ######################################################
  93. sub myUtilsDooya_Initialize($) {
  94. $modules{Dooya}{LOADED} = 1;
  95. my $hash = $modules{Dooya};
  96. Dooya_Initialize($hash);
  97. } # end sub myUtilsDooya_initialize
  98. ######################################################
  99. sub Dooya_Initialize($) {
  100. my ($hash) = @_;
  101. # map commands from web interface to codes used in Dooya
  102. foreach my $k ( keys %codes ) {
  103. $dooya_c2b{ $codes{$k} } = $k;
  104. }
  105. $hash->{SetFn} = "Dooya_Set";
  106. #$hash->{StateFn} = "Dooya_SetState";
  107. $hash->{DefFn} = "Dooya_Define";
  108. $hash->{UndefFn} = "Dooya_Undef";
  109. $hash->{ParseFn} = "Dooya_Parse";
  110. $hash->{AttrFn} = "Dooya_Attr";
  111. $hash->{Match} = "^P16#[A-Fa-f0-9]+";
  112. $hash->{AttrList} = " IODev"
  113. . " SignalRepeats:5,10,15,20"
  114. . " channel:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15"
  115. . " drive-down-time-to-100"
  116. . " drive-down-time-to-close"
  117. . " drive-up-time-to-100"
  118. . " drive-up-time-to-open"
  119. . " additionalPosReading"
  120. . " $readingFnAttributes"
  121. # . " setList"
  122. . " ignore:0,1"
  123. . " dummy:1,0"
  124. # . " model:dooyablinds,dooyashutter"
  125. . " loglevel:0,1,2,3,4,5,6";
  126. $hash->{AutoCreate} =
  127. { "Dooya.*" => { ATTR => "event-min-interval:.*:300 event-on-change-reading:.*",
  128. FILTER => "%NAME",
  129. autocreateThreshold => "2:10" } };
  130. }
  131. ######################################################
  132. sub Dooya_StartTime($) {
  133. my ($d) = @_;
  134. my ($s, $ms) = gettimeofday();
  135. my $t = $s + ($ms / 1000000); # 10 msec
  136. my $t1 = 0;
  137. $t1 = $d->{'starttime'} if(exists($d->{'starttime'} ));
  138. $d->{'starttime'} = $t;
  139. my $dt = sprintf("%.2f", $t - $t1);
  140. return $dt;
  141. } # end sub Dooya_StartTime
  142. ######################################################
  143. sub Dooya_Define($$) {
  144. my ( $hash, $def ) = @_;
  145. my @a = split( "[ \t][ \t]*", $def );
  146. my $u = "wrong syntax: define <name> Dooya id ";
  147. # fail early and display syntax help
  148. if ( int(@a) < 3 ) {
  149. return $u;
  150. }
  151. my ($id, $channel) = split('_', $a[2]);
  152. Log3 $hash,4 ,"Dooya_Define: id = $id channel = $channel";
  153. # check id format (28 binaer digits)
  154. if ( ( $id !~ m/^[0-1]{28}$/i ) ) {
  155. return "Define $a[0]: wrong address format: specify a 28 binaer id value "
  156. }
  157. # group devices by their id
  158. my $name = $a[0];
  159. $hash->{ID} = uc($id);
  160. $hash->{CHANNEL} = $channel;
  161. my $tn = TimeNow();
  162. my $code = uc($a[2]);
  163. my $ncode = 1;
  164. $hash->{CODE}{ $ncode++ } = $code;
  165. $modules{Dooya}{defptr}{$code}{$name} = $hash;
  166. $hash->{move} = 'stop';
  167. AssignIoPort($hash);
  168. }
  169. ######################################################
  170. sub Dooya_Undef($$) {
  171. my ( $hash, $name ) = @_;
  172. foreach my $c ( keys %{ $hash->{CODE} } ) {
  173. $c = $hash->{CODE}{$c};
  174. # As after a rename the $name my be different from the $defptr{$c}{$n}
  175. # we look for the hash.
  176. foreach my $dname ( keys %{ $modules{Dooya}{defptr}{$c} } ) {
  177. if ( $modules{Dooya}{defptr}{$c}{$dname} == $hash ) {
  178. delete( $modules{Dooya}{defptr}{$c}{$dname} );
  179. }
  180. }
  181. }
  182. return undef;
  183. }
  184. ######################################################
  185. sub Dooya_SendCommand($@){
  186. my ($hash, @args) = @_;
  187. my $ret = undef;
  188. my $cmd = $args[0];
  189. my $message;
  190. my $chan;
  191. my $channel;
  192. my $SignalRepeats;
  193. my $name = $hash->{NAME};
  194. my $bin;
  195. my $numberOfArgs = int(@args);
  196. Log3($name,4,"Dooya_sendCommand: $name -> cmd :$cmd: ");
  197. my $command = $dooya_c2b{ $cmd };
  198. # eigentlich ueberfluessig, da oben schon auf Existenz geprueft wird -> %sets
  199. if ( !defined($command) ) {
  200. return "Unknown argument $cmd, choose one of "
  201. . join( " ", sort keys %dooya_c2b );
  202. }
  203. my $io = $hash->{IODev};
  204. $SignalRepeats = AttrVal($name,'SignalRepeats', '10');
  205. Log3 $io,4, "Dooya set SignalRepeats: $SignalRepeats for $io->{NAME}";
  206. $chan = AttrVal($name,'channel', undef);
  207. if (!defined($chan)) {
  208. $chan = $hash->{CHANNEL};
  209. }
  210. $channel = sprintf("%04b",$chan);
  211. Log3 $io,4, "Dooya set channel: $chan ($channel) for $io->{NAME}";
  212. my $value = $name ." ". join(" ", @args);
  213. $bin = uc($hash->{ID}) . $channel . $command;
  214. #print ("data = $bin \n");
  215. Log3 $io, 4, "Dooya set value = $value";
  216. ## Send Message to IODev using IOWrite
  217. $message = 'P16#' . $bin . '#R' . $SignalRepeats;
  218. Log3 $io, 4, "Dooya_sendCommand: $name -> message :$message: ";
  219. IOWrite($hash, 'sendMsg', $message);
  220. return $ret;
  221. } # end sub Dooya_SendCommand
  222. ######################################################
  223. sub Dooya_Runden($) {
  224. my ($v) = @_;
  225. if ( ( $v > 105 ) && ( $v < 195 ) ) {
  226. $v = 150;
  227. } else {
  228. $v = int(($v + 5) /10) * 10;
  229. }
  230. return sprintf("%d", $v );
  231. } # end sub Dooya_Runden
  232. ######################################################
  233. sub Dooya_Translate($) {
  234. my ($v) = @_;
  235. if(exists($translations{$v})) {
  236. $v = $translations{$v}
  237. }
  238. return $v
  239. } # end sub Dooya_Runden
  240. ######################################################
  241. sub Dooya_Parse($$) {
  242. my ($hash, $msg) = @_;
  243. my (undef ,$rawData) = split("#",$msg);
  244. my $hlen = length($rawData);
  245. my $blen = $hlen * 4;
  246. my $bitData = unpack("B$blen", pack("H$hlen", $rawData));
  247. Log3 $hash, 4, "Dooya_Parse: rawData = $rawData length: $hlen";
  248. Log3 $hash, 4, "Dooya_Parse: converted to bits: $bitData";
  249. # get id, channel, cmd
  250. my $id = substr($bitData, 0, 28);
  251. my $BitChannel = substr($bitData, 28, 4); #noch nicht benoetigt
  252. my $channel = oct("0b" . $BitChannel);
  253. my $cmd = substr($bitData, 32, 4);
  254. my $newstate = $codes{ $cmd . $cmd}; # set new state
  255. my $deviceCode = $id . '_' . $channel;
  256. Log3 $hash, 4, "Dooya_Parse: device ID: $id";
  257. Log3 $hash, 4, "Dooya_Parse: Channel: $channel";
  258. Log3 $hash, 4, "Dooya_Parse: Cmd: $cmd Newstate: $newstate";
  259. Log3 $hash, 4, "Dooya_Parse: deviceCode: $deviceCode";
  260. my $def = $modules{Dooya}{defptr}{$deviceCode};
  261. if($def) {
  262. my @list;
  263. foreach my $name (keys %{ $def }) {
  264. my $lh = $def->{$name};
  265. $name = $lh->{NAME}; # It may be renamed
  266. return "" if(IsIgnored($name)); # Little strange.
  267. # update the state and log it
  268. ### NEEDS to be deactivated due to the state being maintained by the timer
  269. # readingsSingleUpdate($lh, "state", $newstate, 1);
  270. readingsSingleUpdate($lh, "parsestate", $newstate, 1);
  271. Log3 $name, 4, "Dooya_Parse n:$name ns:$newstate lhn:$lh->{NAME} lht:$lh->{TYPE}";
  272. Dooya_Set( $lh, $name, 'virtual', $newstate );
  273. push(@list, $name);
  274. }
  275. # return list of affected devices
  276. return @list;
  277. } else {
  278. Log3 $hash, 3, "Dooya Unknown device $deviceCode, please define it";
  279. return "UNDEFINED Dooya_$deviceCode Dooya $deviceCode";
  280. }
  281. }
  282. ######################################################
  283. sub Dooya_Attr(@) {
  284. my ($cmd,$name,$aName,$aVal) = @_;
  285. my $hash = $defs{$name};
  286. return "\"Dooya Attr: \" $name does not exist" if (!defined($hash));
  287. # $cmd can be "del" or "set"
  288. # $name is device name
  289. # aName and aVal are Attribute name and value
  290. if ($cmd eq "set") {
  291. if($aName eq 'drive-up-time-to-100') {
  292. return "Dooya_attr: value must be >=0 and <= 100" if($aVal < 0 || $aVal > 100);
  293. } elsif ($aName =~/drive-(down|up)-time-to.*/) {
  294. # check name and value
  295. return "Dooya_attr: value must be >0 and <= 100" if($aVal <= 0 || $aVal > 100);
  296. }
  297. if ($aName eq 'drive-down-time-to-100') {
  298. $attr{$name}{'drive-down-time-to-100'} = $aVal;
  299. $attr{$name}{'drive-down-time-to-close'} = $aVal if(!defined($attr{$name}{'drive-down-time-to-close'}) || ($attr{$name}{'drive-down-time-to-close'} < $aVal));
  300. } elsif($aName eq 'drive-down-time-to-close') {
  301. $attr{$name}{'drive-down-time-to-close'} = $aVal;
  302. $attr{$name}{'drive-down-time-to-100'} = $aVal if(!defined($attr{$name}{'drive-down-time-to-100'}) || ($attr{$name}{'drive-down-time-to-100'} > $aVal));
  303. } elsif($aName eq 'drive-up-time-to-100') {
  304. $attr{$name}{'drive-up-time-to-100'} = $aVal;
  305. } elsif($aName eq 'drive-up-time-to-open') {
  306. $attr{$name}{'drive-up-time-to-open'} = $aVal;
  307. $attr{$name}{'drive-up-time-to-100'} = 0 if(!defined($attr{$name}{'drive-up-time-to-100'}) || ($attr{$name}{'drive-up-time-to-100'} > $aVal));
  308. }
  309. }
  310. return undef;
  311. }
  312. ##################################################
  313. ### New set (state) method (using internalset)
  314. ###
  315. ### Reimplemented calculations for position readings and state
  316. ### Allowed sets to be done without sending actually commands to the blinds
  317. ### syntax set <name> [ <virtual|send> ] <normal set parameter>
  318. ### position and state are also updated on stop or other commands based on remaining time
  319. ### position is handled between 0 and 100 blinds down but not completely closed and 200 completely closed
  320. ### if timings for 100 and close are equal no position above 100 is used (then 100 == closed)
  321. ### position is rounded to a value of 5 and state is rounded to a value of 10
  322. #
  323. ### General assumption times are rather on the upper limit to reach desired state
  324. # Readings
  325. ## state contains rounded (to 10) position and/or textField
  326. ## position contains rounded position (limited detail)
  327. # STATE
  328. ## might contain position or textual form of the state (same as STATE reading)
  329. ######################################################
  330. # call with hash, name, [virtual/send], set-args (send is default if ommitted)
  331. sub Dooya_Set($@) {
  332. my ( $hash, $name, @args ) = @_;
  333. Log3 $name, 4, "Dooya_Set: Called";
  334. if ( lc($args[0]) =~m/(virtual|send)/ ) {
  335. Log3 $name, 4, "Dooya_InternalSet call $args[0] ";
  336. Dooya_InternalSet( $hash, $name, @args );
  337. } else {
  338. Log3 $name, 4, "Dooya_InternalSet call send $hash->{NAME} $hash->{TYPE} $name";
  339. Dooya_InternalSet( $hash, $name, 'send', @args );
  340. }
  341. }
  342. ######################################################
  343. # call with hash, name, virtual/send, set-args
  344. sub Dooya_InternalSet($@) {
  345. my ( $hash, $name, $mode, @args ) = @_;
  346. ### Check Args
  347. return "Dooya_InternalSet: mode must be virtual or send: $mode " if ( $mode !~m/(virtual|send)/ );
  348. my $numberOfArgs = int(@args);
  349. return "Dooya_set: No set value specified" if ( $numberOfArgs < 1 );
  350. my $cmd = lc($args[0]);
  351. # just a number provided, assume "pos" command
  352. if ($cmd =~ m/\d{1,3}/) {
  353. pop @args;
  354. push @args, "pos";
  355. push @args, $cmd;
  356. $cmd = "pos";
  357. $numberOfArgs = int(@args);
  358. }
  359. if(!exists($sets{$cmd})) {
  360. my @cList;
  361. foreach my $k (sort keys %sets) {
  362. my $opts = undef;
  363. $opts = $sets{$k};
  364. if (defined($opts)) {
  365. push(@cList,$k . ':' . $opts);
  366. } else {
  367. push (@cList,$k);
  368. }
  369. } # end foreach
  370. return "Dooya_set: Unknown argument $cmd, choose one of " . join(" ", @cList);
  371. } # error unknown cmd handling
  372. my $arg1 = "";
  373. if ( $numberOfArgs >= 2 ) {
  374. $arg1 = $args[1];
  375. }
  376. return "Dooya_set: Bad time spec" if($cmd =~m/(on|off)-for-timer/ && $numberOfArgs == 2 && $arg1 !~ m/^\d*\.?\d+$/);
  377. # read timing variables
  378. my ($t1down100, $t1downclose, $t1upopen, $t1up100) = Dooya_getTimingValues($hash);
  379. Log3($name,5,"Dooya_set: $name -> timings -> td1:$t1down100: tdc :$t1downclose: tuo :$t1upopen: tu1 :$t1up100: ");
  380. my $model = AttrVal($name,'model',$models{dooyablinds});
  381. if($cmd eq 'pos') {
  382. return "Dooya_set: No pos specification" if(!defined($arg1));
  383. return "Dooya_set: $arg1 must be > 0 and < 100 for pos" if($arg1 < 0 || $arg1 > 100);
  384. return "Dooya_set: Please set attr drive-down-time-to-100, drive-down-time-to-close, etc"
  385. if(!defined($t1downclose) || !defined($t1down100) || !defined($t1upopen) || !defined($t1up100));
  386. }
  387. ### initialize locals
  388. my $drivetime = 0; # timings until halt command to be sent for on/off-for-timer and pos <value> -> move by time
  389. my $updatetime = 0; # timing until update of pos to be done for any unlimited move move to endpos stop
  390. my $move = $cmd;
  391. my $newState;
  392. my $updateState;
  393. # get current infos
  394. my $state = $hash->{STATE};
  395. my $pos = ReadingsVal($name,'exact',undef);
  396. if ( !defined($pos) ) {
  397. $pos = ReadingsVal($name,'position',undef);
  398. }
  399. # translate state info to numbers - closed = 200 , open = 0 (correct missing values)
  400. if ( !defined($pos) ) {
  401. if(exists($positions{$state})) {
  402. $pos = $positions{$state};
  403. } else {
  404. $pos = $state;
  405. }
  406. $pos = sprintf( "%d", $pos );
  407. }
  408. Log3($name,4,"Dooya_set: $name -> entering with mode :$mode: cmd :$cmd: arg1 :$arg1: pos :$pos: ");
  409. # check timer running - stop timer if running and update detail pos
  410. # recognize timer running if internal updateState is still set
  411. if ( defined( $hash->{updateState} )) {
  412. # timer is running so timer needs to be stopped and pos needs update
  413. RemoveInternalTimer($hash);
  414. $pos = Dooya_CalcCurrentPos( $hash, $hash->{move}, $pos, Dooya_UpdateStartTime($hash) );
  415. delete $hash->{starttime};
  416. delete $hash->{updateState};
  417. delete $hash->{runningtime};
  418. delete $hash->{runningcmd};
  419. }
  420. ################ No error returns after this point to avoid stopped timer causing confusion...
  421. # calc posRounded
  422. my $posRounded = Dooya_RoundInternal( $pos );
  423. ### handle commands
  424. if(!defined($t1downclose) || !defined($t1down100) || !defined($t1upopen) || !defined($t1up100)) {
  425. #if timings not set
  426. if($cmd eq 'on') {
  427. $newState = 'closed';
  428. # $newState = 'moving';
  429. # $updatetime = $dooya_maxRuntime;
  430. # $updateState = 'closed';
  431. } elsif($cmd eq 'off') {
  432. $newState = 'open';
  433. # $newState = 'moving';
  434. # $updatetime = $dooya_maxRuntime;
  435. # $updateState = 'open';
  436. } elsif($cmd eq 'on-for-timer') {
  437. # elsif cmd == on-for-timer - time x
  438. $move = 'on';
  439. $newState = 'moving';
  440. $drivetime = $arg1;
  441. if ( $drivetime == 0 ) {
  442. $move = 'stop';
  443. } else {
  444. $updateState = 'moving';
  445. }
  446. } elsif($cmd eq 'off-for-timer') {
  447. # elsif cmd == off-for-timer - time x
  448. $move = 'off';
  449. $newState = 'moving';
  450. $drivetime = $arg1;
  451. if ( $drivetime == 0 ) {
  452. $move = 'stop';
  453. } else {
  454. $updateState = 'moving';
  455. }
  456. } elsif($cmd =~m/stop/) {
  457. $move = 'stop';
  458. $newState = $state
  459. } else {
  460. $newState = $state;
  461. }
  462. ###else (here timing is set)
  463. } else {
  464. # default is roundedPos as new StatePos
  465. $newState = $posRounded;
  466. if($cmd eq 'on') {
  467. if ( $posRounded == 200 ) {
  468. # if pos == 200 - no state pos change / no timer
  469. } elsif ( $posRounded >= 100 ) {
  470. # elsif pos >= 100 - set timer for 100-to-closed --> update timer(newState 200)
  471. my $remTime = ( $t1downclose - $t1down100 ) * ( (200-$pos) / 100 );
  472. $updatetime = $remTime;
  473. $updateState = 200;
  474. } elsif ( $posRounded < 100 ) {
  475. # elseif pos < 100 - set timer for remaining time to 100+time-to-close --> update timer( newState 200)
  476. my $remTime = $t1down100 * ( (100 - $pos) / 100 );
  477. $updatetime = ( $t1downclose - $t1down100 ) + $remTime;
  478. $updateState = 200;
  479. } else {
  480. # else - unknown pos - assume pos 0 set timer for full time --> update timer( newState 200)
  481. $newState = 0;
  482. $updatetime = $t1downclose;
  483. $updateState = 200;
  484. }
  485. } elsif($cmd eq 'off') {
  486. if ( $posRounded == 0 ) {
  487. # if pos == 0 - no state pos change / no timer
  488. } elsif ( $posRounded <= 100 ) {
  489. # elsif pos <= 100 - set timer for remaining time to 0 --> update timer( newState 0 )
  490. my $remTime = ( $t1upopen - $t1up100 ) * ( $pos / 100 );
  491. $updatetime = $remTime;
  492. $updateState = 0;
  493. } elsif ( $posRounded > 100 ) {
  494. # elseif ( pos > 100 ) - set timer for remaining time to 100+time-to-open --> update timer( newState 0 )
  495. my $remTime = $t1up100 * ( ($pos - 100 ) / 100 );
  496. $updatetime = ( $t1upopen - $t1up100 ) + $remTime;
  497. $updateState = 0;
  498. } else {
  499. # else - unknown pos assume pos 200 set time for full time --> update timer( newState 0 )
  500. $newState = 200;
  501. $updatetime = $t1upopen;
  502. $updateState = 0;
  503. }
  504. } elsif($cmd eq 'pos') {
  505. if ( $pos < $arg1 ) {
  506. # if pos < x - set halt timer for remaining time to x / cmd close --> halt timer`( newState x )
  507. $move = 'on';
  508. my $remTime = $t1down100 * ( ( $arg1 - $pos ) / 100 );
  509. $drivetime = $remTime;
  510. $updateState = $arg1;
  511. } elsif ( ( $pos >= $arg1 ) && ( $posRounded <= 100 ) ) {
  512. # elsif pos <= 100 & pos > x - set halt timer for remaining time to x / cmd open --> halt timer ( newState x )
  513. $move = 'off';
  514. my $remTime = ( $t1upopen - $t1up100 ) * ( ( $pos - $arg1) / 100 );
  515. $drivetime = $remTime;
  516. if ( $drivetime == 0 ) {
  517. # $move = 'stop'; # avoid sending stop to move to my-pos
  518. $move = 'none';
  519. } else {
  520. $updateState = $arg1;
  521. }
  522. } elsif ( $pos > 100 ) {
  523. # else if pos > 100 - set timer for remaining time to 100+time for 100-x / cmd open --> halt timer ( newState x )
  524. $move = 'off';
  525. my $remTime = ( $t1upopen - $t1up100 ) * ( ( 100 - $arg1) / 100 );
  526. my $posTime = $t1up100 * ( ( $pos - 100) / 100 );
  527. $drivetime = $remTime + $posTime;
  528. $updateState = $arg1;
  529. } else {
  530. # else - send error (might be changed to first open completely then drive to pos x) / assume open
  531. $newState = 0;
  532. $move = 'on';
  533. my $remTime = $t1down100 * ( ( $arg1 - 0 ) / 100 );
  534. $drivetime = $remTime;
  535. $updateState = $arg1;
  536. ### return "Dooya_set: Pos not currently known please open or close first";
  537. }
  538. } elsif($cmd =~m/stop/) {
  539. # update pos according to current detail pos
  540. $move = 'stop';
  541. } elsif($cmd eq 'off-for-timer') {
  542. # calcPos at new time y / cmd close --> halt timer ( newState y )
  543. $move = 'off';
  544. $drivetime = $arg1;
  545. if ( $drivetime == 0 ) {
  546. $move = 'stop';
  547. } else {
  548. $updateState = Dooya_CalcCurrentPos( $hash, $move, $pos, $arg1 );
  549. }
  550. } elsif($cmd eq 'on-for-timer') {
  551. # calcPos at new time y / cmd open --> halt timer ( newState y )
  552. $move = 'on';
  553. $drivetime = $arg1;
  554. if ( $drivetime == 0 ) {
  555. $move = 'stop';
  556. } else {
  557. $updateState = Dooya_CalcCurrentPos( $hash, $move, $pos, $arg1 );
  558. }
  559. }
  560. ## special case close is at 100 ("markisen")
  561. if( ( $t1downclose == $t1down100) && ( $t1up100 == 0 ) ) {
  562. if ( defined( $updateState )) {
  563. $updateState = min( 100, $updateState );
  564. }
  565. $newState = min( 100, $posRounded );
  566. }
  567. }
  568. ### update hash / readings
  569. Log3($name,3,"Dooya_set: handled command $cmd --> move :$move: newState :$newState: ");
  570. if ( defined($updateState)) {
  571. Log3($name,5,"Dooya_set: handled for drive/udpate: updateState :$updateState: drivet :$drivetime: updatet :$updatetime: ");
  572. } else {
  573. Log3($name,5,"Dooya_set: handled for drive/udpate: updateState :: drivet :$drivetime: updatet :$updatetime: ");
  574. }
  575. # bulk update should do trigger if virtual mode
  576. Dooya_UpdateState( $hash, $newState, $move, $updateState, ( $mode eq 'virtual' ) );
  577. ### send command
  578. if ( $mode ne 'virtual' ) {
  579. if(exists($sendCommands{$move})) {
  580. $args[0] = $sendCommands{$move};
  581. Dooya_SendCommand($hash,@args);
  582. } elsif ( $move eq 'none' ) {
  583. # do nothing if commmand / move is set to none
  584. } else {
  585. Log3($name,1,"Dooya_set: Error - unknown move for sendCommands: $move");
  586. }
  587. }
  588. ### start timer
  589. if ( $mode eq 'virtual' ) {
  590. # in virtual mode define drivetime as updatetime only, so no commands will be send
  591. if ( $updatetime == 0 ) {
  592. $updatetime = $drivetime;
  593. }
  594. $drivetime = 0;
  595. }
  596. ### update time stamp
  597. Dooya_UpdateStartTime($hash);
  598. $hash->{runningtime} = 0;
  599. if($drivetime > 0) {
  600. $hash->{runningcmd} = 'stop';
  601. $hash->{runningtime} = $drivetime;
  602. } elsif($updatetime > 0) {
  603. $hash->{runningtime} = $updatetime;
  604. }
  605. if($hash->{runningtime} > 0) {
  606. # timer fuer stop starten
  607. if ( defined( $hash->{runningcmd} )) {
  608. Log3($name,4,"Dooya_set: $name -> stopping in $hash->{runningtime} sec");
  609. } else {
  610. Log3($name,4,"Dooya_set: $name -> update state in $hash->{runningtime} sec");
  611. }
  612. my $utime = $hash->{runningtime} ;
  613. if($utime > $dooya_updateFreq) {
  614. $utime = $dooya_updateFreq;
  615. }
  616. InternalTimer(gettimeofday()+$utime,"Dooya_TimedUpdate",$hash,0);
  617. } else {
  618. delete $hash->{runningtime};
  619. delete $hash->{starttime};
  620. }
  621. return undef;
  622. } # end sub Dooya_setFN
  623. ######################################################
  624. ######################################################
  625. ###
  626. ### Helper for set routine
  627. ###
  628. ######################################################
  629. ######################################################
  630. sub Dooya_RoundInternal($) { # Todo: kann das nicht die Round Funktion von FHEM?
  631. my ($v) = @_;
  632. return sprintf("%d", ($v + ($dooya_posAccuracy/2)) / $dooya_posAccuracy) * $dooya_posAccuracy;
  633. } # end sub Dooya_RoundInternal
  634. ######################################################
  635. sub Dooya_UpdateStartTime($) {
  636. my ($d) = @_;
  637. my ($s, $ms) = gettimeofday();
  638. my $t = $s + ($ms / 1000000); # 10 msec
  639. my $t1 = 0;
  640. $t1 = $d->{starttime} if(exists($d->{starttime} ));
  641. $d->{starttime} = $t;
  642. my $dt = sprintf("%.2f", $t - $t1);
  643. return $dt;
  644. } # end sub Dooya_UpdateStartTime
  645. ######################################################
  646. sub Dooya_TimedUpdate($) {
  647. my ($hash) = @_;
  648. Log3($hash->{NAME},4,"Dooya_TimedUpdate");
  649. # get current infos
  650. my $pos = ReadingsVal($hash->{NAME},'exact',undef);
  651. Log3($hash->{NAME},5,"Dooya_TimedUpdate : pos so far : $pos");
  652. my $dt = Dooya_UpdateStartTime($hash);
  653. my $nowt = gettimeofday();
  654. $pos = Dooya_CalcCurrentPos( $hash, $hash->{move}, $pos, $dt );
  655. # my $posRounded = Dooya_RoundInternal( $pos );
  656. Log3($hash->{NAME},5,"Dooya_TimedUpdate : delta time : $dt new rounde pos (rounded): $pos ");
  657. $hash->{runningtime} = $hash->{runningtime} - $dt;
  658. if ( $hash->{runningtime} <= 0.1) {
  659. if ( defined( $hash->{runningcmd} ) ) {
  660. Dooya_SendCommand($hash, $hash->{runningcmd});
  661. }
  662. # trigger update from timer
  663. Dooya_UpdateState( $hash, $hash->{updateState}, 'stop', undef, 1 );
  664. delete $hash->{starttime};
  665. delete $hash->{runningtime};
  666. delete $hash->{runningcmd};
  667. } else {
  668. my $utime = $hash->{runningtime} ;
  669. if($utime > $dooya_updateFreq) {
  670. $utime = $dooya_updateFreq;
  671. }
  672. Dooya_UpdateState( $hash, $pos, $hash->{move}, $hash->{updateState}, 1 );
  673. if ( defined( $hash->{runningcmd} )) {
  674. Log3($hash->{NAME},4,"Dooya_TimedUpdate: $hash->{NAME} -> stopping in $hash->{runningtime} sec");
  675. } else {
  676. Log3($hash->{NAME},4,"Dooya_TimedUpdate: $hash->{NAME} -> update state in $hash->{runningtime} sec");
  677. }
  678. my $nstt = max($nowt+$utime-0.01, gettimeofday()+.1 );
  679. Log3($hash->{NAME},5,"Dooya_TimedUpdate: $hash->{NAME} -> next time to stop: $nstt");
  680. InternalTimer($nstt,"Dooya_TimedUpdate",$hash,0);
  681. }
  682. Log3($hash->{NAME},5,"Dooya_TimedUpdate DONE");
  683. } # end sub Dooya_TimedUpdate
  684. ######################################################
  685. # Dooya_UpdateState( $hash, $newState, $move, $updateState );
  686. sub Dooya_UpdateState($$$$$) {
  687. my ($hash, $newState, $move, $updateState, $doTrigger) = @_;
  688. my $addtlPosReading = AttrVal($hash->{NAME},'additionalPosReading',undef);
  689. if ( defined($addtlPosReading )) {
  690. $addtlPosReading = undef if ( ( $addtlPosReading eq "" ) or ( $addtlPosReading eq "state" ) or ( $addtlPosReading eq "position" ) or ( $addtlPosReading eq "exact" ) );
  691. }
  692. readingsBeginUpdate($hash);
  693. if(exists($positions{$newState})) {
  694. readingsBulkUpdate($hash,"state",$newState);
  695. $hash->{STATE} = $newState;
  696. readingsBulkUpdate($hash,"position",$positions{$newState});
  697. $hash->{position} = $positions{$newState};
  698. readingsBulkUpdate($hash,$addtlPosReading,$positions{$newState}) if ( defined($addtlPosReading) );
  699. } else {
  700. my $rounded = Dooya_Runden( $newState );
  701. my $stateTrans = Dooya_Translate( $rounded );
  702. readingsBulkUpdate($hash,"state",$stateTrans);
  703. $hash->{STATE} = $stateTrans;
  704. readingsBulkUpdate($hash,"position",$rounded);
  705. $hash->{position} = $rounded;
  706. readingsBulkUpdate($hash,$addtlPosReading,$rounded) if ( defined($addtlPosReading) );
  707. }
  708. readingsBulkUpdate($hash,"exact",$newState);
  709. $hash->{exact} = $newState;
  710. if ( defined( $updateState ) ) {
  711. $hash->{updateState} = $updateState;
  712. } else {
  713. delete $hash->{updateState};
  714. }
  715. $hash->{move} = $move;
  716. readingsEndUpdate($hash,$doTrigger);
  717. } # end sub Dooya_UpdateState
  718. ######################################################
  719. # Return timingvalues from attr and after correction
  720. sub Dooya_getTimingValues($) {
  721. my ($hash) = @_;
  722. my $name = $hash->{NAME};
  723. my $t1down100 = AttrVal($name,'drive-down-time-to-100',undef);
  724. my $t1downclose = AttrVal($name,'drive-down-time-to-close',undef);
  725. my $t1upopen = AttrVal($name,'drive-up-time-to-open',undef);
  726. my $t1up100 = AttrVal($name,'drive-up-time-to-100',undef);
  727. return (undef, undef, undef, undef) if(!defined($t1downclose) || !defined($t1down100) || !defined($t1upopen) || !defined($t1up100));
  728. if ( ( $t1downclose < 0 ) || ( $t1down100 < 0 ) || ( $t1upopen < 0 ) || ( $t1up100 < 0 ) ) {
  729. Log3($name,1,"Dooya_getTimingValues: $name time values need to be positive values");
  730. return (undef, undef, undef, undef);
  731. }
  732. if ( $t1downclose < $t1down100 ) {
  733. Log3($name,1,"Dooya_getTimingValues: $name close time needs to be higher or equal than time to pos100");
  734. return (undef, undef, undef, undef);
  735. } elsif ( $t1downclose == $t1down100 ) {
  736. $t1up100 = 0;
  737. }
  738. if ( $t1upopen <= $t1up100 ) {
  739. Log3($name,1,"Dooya_getTimingValues: $name open time needs to be higher or equal than time to pos100");
  740. return (undef, undef, undef, undef);
  741. }
  742. if ( $t1upopen < 1 ) {
  743. Log3($name,1,"Dooya_getTimingValues: $name time to open needs to be at least 1 second");
  744. return (undef, undef, undef, undef);
  745. }
  746. if ( $t1downclose < 1 ) {
  747. Log3($name,1,"Dooya_getTimingValues: $name time to close needs to be at least 1 second");
  748. return (undef, undef, undef, undef);
  749. }
  750. return ($t1down100, $t1downclose, $t1upopen, $t1up100);
  751. }
  752. ######################################################
  753. # call with hash, translated state
  754. sub Dooya_CalcCurrentPos($$$$) {
  755. my ($hash, $move, $pos, $dt) = @_;
  756. my $name = $hash->{NAME};
  757. my $newPos = $pos;
  758. # Attributes for calculation
  759. my ($t1down100, $t1downclose, $t1upopen, $t1up100) = Dooya_getTimingValues($hash);
  760. if(defined($t1down100) && defined($t1downclose) && defined($t1up100) && defined($t1upopen)) {
  761. if( ( $t1downclose == $t1down100) && ( $t1up100 == 0 ) ) {
  762. $pos = min( 100, $pos );
  763. if($move eq 'on') {
  764. $newPos = min( 100, $pos );
  765. if ( $pos < 100 ) {
  766. # calc remaining time to 100%
  767. my $remTime = ( 100 - $pos ) * $t1down100 / 100;
  768. if ( $remTime > $dt ) {
  769. $newPos = $pos + ( $dt * 100 / $t1down100 );
  770. }
  771. }
  772. } elsif($move eq 'off') {
  773. $newPos = max( 0, $pos );
  774. if ( $pos > 0 ) {
  775. $newPos = $dt * 100 / ( $t1upopen );
  776. $newPos = max( 0, ($pos - $newPos) );
  777. }
  778. } else {
  779. Log3($name,1,"Dooya_CalcCurrentPos: $name move wrong $move");
  780. }
  781. } else {
  782. if($move eq 'on') {
  783. if ( $pos >= 100 ) {
  784. $newPos = $dt * 100 / ( $t1downclose - $t1down100 );
  785. $newPos = min( 200, $pos + $newPos );
  786. } else {
  787. # calc remaining time to 100%
  788. my $remTime = ( 100 - $pos ) * $t1down100 / 100;
  789. if ( $remTime > $dt ) {
  790. $newPos = $pos + ( $dt * 100 / $t1down100 );
  791. } else {
  792. $dt = $dt - $remTime;
  793. $newPos = 100 + ( $dt * 100 / ( $t1downclose - $t1down100 ) );
  794. }
  795. }
  796. } elsif($move eq 'off') {
  797. if ( $pos <= 100 ) {
  798. $newPos = $dt * 100 / ( $t1upopen - $t1up100 );
  799. $newPos = max( 0, $pos - $newPos );
  800. } else {
  801. # calc remaining time to 100%
  802. my $remTime = ( $pos - 100 ) * $t1up100 / 100;
  803. if ( $remTime > $dt ) {
  804. $newPos = $pos - ( $dt * 100 / $t1up100 );
  805. } else {
  806. $dt = $dt - $remTime;
  807. $newPos = 100 - ( $dt * 100 / ( $t1upopen - $t1up100 ) );
  808. }
  809. }
  810. } else {
  811. Log3($name,1,"Dooya_CalcCurrentPos: $name move wrong $move");
  812. }
  813. }
  814. } else {
  815. ### no timings set so just assume it is always moving
  816. $newPos = $positions{'moving'};
  817. }
  818. return $newPos;
  819. }
  820. ######################################################
  821. ######################################################
  822. ######################################################
  823. 1;
  824. =pod
  825. =item summary Supports rf shutters from dooya
  826. =item summary_DE Unterst&uumltzt dooya Funkrolladen
  827. =begin html
  828. <a name="Dooya"></a>
  829. <h3>Dooya protocol</h3>
  830. <ul>
  831. The Dooya protocol is used by a wide range of devices,
  832. which are either senders or receivers/actuators.
  833. The RECIVING and SENDING of Dooya commands is implemented in the SIGNALduino, so this module currently supports
  834. devices like blinds and shutters. The Dooya protocol is used from a lot of different shutter companies in Germanyr. Examples are Rohrmotor24 or Nobily.
  835. <br><br>
  836. <pre>
  837. <code>4: sduino/msg READ: MU;P0=4717;P1=-1577;P2=284;P3=-786;P4=649;P5=-423;D=01232345[......]445232;CP=2;</code>
  838. <code>4: sduino: Fingerprint for MU Protocol id 16 -> Dooya shutter matches, trying to demodulate</code>
  839. <code>4: sduino: decoded matched MU Protocol id 16 dmsg u16#370658E133 length 40</code>
  840. <code>4: SIGNALduino_unknown Protocol: 16</code>
  841. <code>4: SIGNALduino_unknown converted to bits: 0011011100000110010110001110000100110011</code>
  842. <code>4: SIGNALduino_unknown / shutter Dooya 0011011100000110010110001110000100110011 received</code>
  843. <code>4: 00110111000001100101100 1110 0001 0011 0011</code>
  844. <code>4: SIGNALduino_unknown found shutter from Dooya. id=3606104, remotetype=14, channel=1, direction=down, all_shutters=false</code>
  845. </pre>
  846. <br> a <a href="#SIGNALduino">SIGNALduino</a> device (must be defined first) <br>
  847. <br>
  848. <br>
  849. <a name="Dooyadefine"></a>
  850. <br>
  851. <b>Define</b>
  852. <br>
  853. <ul>
  854. <code>define &lt;name&gt; Dooya &lt;id&gt;_&lt;channel&gt; </code>
  855. <br>
  856. <br>
  857. The id is a 28-digit binar code, that uniquely identifies a single remote control.
  858. <br>
  859. Pairing is done by setting the shutter in programming mode, either by disconnecting/reconnecting the power,
  860. and by pressing the program button on an already associated remote.
  861. <br>
  862. Once the shutter is in programming mode, send the "prog" command from within FHEM to complete the pairing.
  863. The shutter will peep shortly to indicate completion.
  864. <br>
  865. You are now able to control this blind from FHEM, the receiver thinks it is just another remote control or the real exist remote.
  866. For the shutter it´s the same.
  867. <ul>
  868. <li><code>&lt;id&gt;</code> is a 28 digit binar number that uniquely identifies FHEM as a new remote control.
  869. <br>You can use a different one for each device definition, and group them using a structure. You can use the same ID for a couple of shutters
  870. and you can give every one an other channel. (0 to 15, 0 ist the MASTER and conrols all other channels.)
  871. If you set one of them, you need to pick the same address as an existing remote. You can create the Device with autocreate with a real remote or manuel without remote control.</li>
  872. </ul>
  873. <br>
  874. Examples:
  875. <ul>
  876. <code>define Rollo_Master Dooya 0011011100000110010110001110_0</code><br> Rollo_Master channel 0 controls all shutters (channel 1 - 15) with the same ID, in this case Rollo_1 and Rollo_2 <br>
  877. <br>
  878. <code>define Rollo_1 Dooya 0011011100000110010110001110_1</code><br> Rollo_1 channel 1<br>
  879. <code>define Rollo_2 Dooya 0011011100000110010110101110_2</code><br> Rollo_2 channel 2<br>
  880. </ul>
  881. </ul>
  882. <br>
  883. <a name="Dooyaset"></a>
  884. <b>Set </b>
  885. <ul>
  886. <code>set &lt;name&gt; &lt;value&gt; [&lt;time&gt]</code>
  887. <br><br>
  888. where <code>value</code> is one of:<br>
  889. <pre>
  890. on
  891. off
  892. stop
  893. pos value (0..100) # see note
  894. prog # Special, see note
  895. </pre>
  896. Examples:
  897. <ul>
  898. <code>set rollo_1 on</code><br>
  899. <code>set rollo_1 on,sleep 1,rollo_2 on,sleep 1,rollo_3 on</code><br>
  900. <code>set rollo_1 off</code><br>
  901. <code>set rollo_1 pos 50</code><br>
  902. </ul>
  903. <br>
  904. Notes:
  905. <ul>
  906. <li>prog is a special command used to pair the receiver to FHEM:
  907. Set the receiver in programming mode and send the "prog" command from FHEM to finish pairing.<br>
  908. The shutter will peep shortly to indicate success.
  909. </li>
  910. <li>pos value<br>
  911. The position is variying between 0 completely open and 100 for covering the full window.
  912. The position must be between 0 and 100 and the appropriate
  913. attributes drive-down-time-to-100, drive-down-time-to-close,
  914. drive-up-time-to-100 and drive-up-time-to-open must be set.<br>
  915. </li>
  916. </ul>
  917. The position reading distinuishes between multiple cases
  918. <ul>
  919. <li>Without timing values set only generic values are used for status and position: <pre>open, closed, moving</pre> are used
  920. </li>
  921. <li>With timing values set but drive-down-time-to-close equal to drive-down-time-to-100 and drive-up-time-to-100 equal 0
  922. the device is considered to only vary between 0 and 100 (100 being completely closed)
  923. </li>
  924. <li>With full timing values set the device is considerd a window shutter (Rolladen) with a difference between
  925. covering the full window (position 100) and being completely closed (position 200)
  926. </li>
  927. </ul>
  928. </ul>
  929. <br>
  930. <b>Get</b>
  931. <ul>N/A</ul><br>
  932. <a name="Dooyaattr"></a>
  933. <b>Attributes</b>
  934. <ul>
  935. <a name="IODev"></a>
  936. <li>IODev<br>
  937. Set the IO or physical device which should be used for sending signals
  938. for this "logical" device. It must be the SIGNALduino.<br>
  939. Note: The IODev has to be set, otherwise no commands will be sent!<br>
  940. </li><br>
  941. <a name="channel"></a>
  942. <li>channel<br>
  943. Set the channel of the remote. You can use 0 (MASTER) to 15.<br>
  944. Note: The MASTER conrols all remotes with the same ID!!!<br>
  945. </li><br>
  946. <a name="SignalRepeats"></a>
  947. <li>SignalRepeats<br>
  948. Set the repeats for sending signal. You can use 5, 10, 15 and 20.
  949. </li><br>
  950. <a name="additionalPosReading"></a>
  951. <li>additionalPosReading<br>
  952. Position of the shutter will be stored in the reading <code>pos</code> as numeric value.
  953. Additionally this attribute might specify a name for an additional reading to be updated with the same value than the pos.
  954. </li><br>
  955. <a name="eventMap"></a>
  956. <li>eventMap<br>
  957. Replace event names and set arguments. The value of this attribute
  958. consists of a list of space separated values, each value is a colon
  959. separated pair. The first part specifies the "old" value, the second
  960. the new/desired value. If the first character is slash(/) or comma(,)
  961. then split not by space but by this character, enabling to embed spaces.
  962. Examples:
  963. <ul><code>
  964. attr store eventMap on:open off:closed<br>
  965. attr store eventMap /on-for-timer 10:open/off:closed/<br>
  966. set store open
  967. </code>
  968. </ul>
  969. </li>
  970. <br>
  971. <li><a href="#do_not_notify">do_not_notify</a></li><br>
  972. <a name="attrdummy"></a>
  973. <li>dummy<br>
  974. Set the device attribute dummy to define devices which should not
  975. output any radio signals. Associated notifys will be executed if
  976. the signal is received. Used e.g. to react to a code from a sender, but
  977. it will not emit radio signal if triggered in the web frontend.
  978. </li><br>
  979. <li><a href="#loglevel">loglevel</a></li><br>
  980. <li><a href="#showtime">showtime</a></li><br>
  981. <a name="model"></a>
  982. <a name="ignore"></a>
  983. <li>ignore<br>
  984. Ignore this device, e.g. if it belongs to your neighbour. The device
  985. won't trigger any FileLogs/notifys, issued commands will silently
  986. ignored (no RF signal will be sent out, just like for the <a
  987. href="#attrdummy">dummy</a> attribute). The device won't appear in the
  988. list command (only if it is explicitely asked for it), nor will it
  989. appear in commands which use some wildcard/attribute as name specifiers
  990. (see <a href="#devspec">devspec</a>). You still get them with the
  991. "ignored=1" special devspec.
  992. </li><br>
  993. <a name="drive-down-time-to-100"></a>
  994. <li>drive-down-time-to-100<br>
  995. The time the blind needs to drive down from "open" (pos 0) to pos 100.<br>
  996. In this position, the lower edge touches the window frame, but it is not completely shut.<br>
  997. For a mid-size window this time is about 12 to 15 seconds.
  998. </li><br>
  999. <a name="drive-down-time-to-close"></a>
  1000. <li>drive-down-time-to-close<br>
  1001. The time the blind needs to drive down from "open" (pos 0) to "close", the end position of the blind.<br>
  1002. This is about 3 to 5 seonds more than the "drive-down-time-to-100" value.
  1003. </li><br>
  1004. <a name="drive-up-time-to-100"></a>
  1005. <li>drive-up-time-to-100<br>
  1006. The time the blind needs to drive up from "close" (endposition) to "pos 100".<br>
  1007. This usually takes about 3 to 5 seconds.
  1008. </li><br>
  1009. <a name="drive-up-time-to-open"></a>
  1010. <li>drive-up-time-to-open<br>
  1011. The time the blind needs drive up from "close" (endposition) to "open" (upper endposition).<br>
  1012. This value is usually a bit higher than "drive-down-time-to-close", due to the blind's weight.
  1013. </li><br>
  1014. </ul>
  1015. <br>
  1016. <a name="Dooyaevents"></a>
  1017. <b>Generated events:</b>
  1018. <ul>
  1019. From a Dooya device you can receive one of the following events.
  1020. <li>on</li>
  1021. <li>off</li>
  1022. <li>stop</li>
  1023. Which event is sent is device dependent and can sometimes be configured on
  1024. the device.
  1025. </ul>
  1026. </ul>
  1027. =end html
  1028. =cut