88_HMCCUDEV.pm 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  1. ######################################################################
  2. #
  3. # 88_HMCCUDEV.pm
  4. #
  5. # $Id: 88_HMCCUDEV.pm 17372 2018-09-19 11:39:04Z zap $
  6. #
  7. # Version 4.3.003
  8. #
  9. # (c) 2018 zap (zap01 <at> t-online <dot> de)
  10. #
  11. ######################################################################
  12. #
  13. # define <name> HMCCUDEV {<ccudev>|virtual} [<statechannel>] [readonly] [defaults]
  14. # [{group={<device>|<channel>}[,...]|groupexp=<regexp>}] [iodev=<iodevname>]
  15. #
  16. # set <name> clear [<regexp>]
  17. # set <name> config [<channel-number>] <parameter>=<value> [...]
  18. # set <name> control <value>
  19. # set <name> datapoint [<channel-number>.]<datapoint> <value> [...]
  20. # set <name> defaults
  21. # set <name> devstate <value>
  22. # set <name> on-till <timestamp>
  23. # set <name> on-for-timer <ontime>
  24. # set <name> pct <level> [{<ontime>|0} [<ramptime>]]
  25. # set <name> <stateval_cmds>
  26. # set <name> toggle
  27. #
  28. # get <name> config [<channel-number>] [<filter-expr>]
  29. # get <name> configdesc [<channel-number>]
  30. # get <name> configlist [<channel-number>]
  31. # get <name> datapoint [<channel-number>.]<datapoint>
  32. # get <name> defaults
  33. # get <name> devstate
  34. # get <name> update
  35. #
  36. # attr <name> ccucalculate <value>:<reading>[:<dp-list>][...]
  37. # attr <name> ccuflags { ackState, nochn0, trace }
  38. # attr <name> ccuget { State | Value }
  39. # attr <name> ccureadings { 0 | 1 }
  40. # attr <name> ccureadingformat { address[lc] | name[lc] | datapoint[lc] }
  41. # attr <name> ccureadingfilter <filter-rule>[,...]
  42. # attr <name> ccureadingname <oldname>:<newname>[,...]
  43. # attr <name> ccuscaleval <datapoint>:<factor>[:<min>:<max>][,...]
  44. # attr <name> ccuverify { 0 | 1 | 2}
  45. # attr <name> controldatapoint <channel-number>.<datapoint>
  46. # attr <name> disable { 0 | 1 }
  47. # attr <name> peer datapoints:condition:{hmccu:object=value|ccu:object=value|fhem:command}
  48. # attr <name> hmstatevals <subst-rule>[;...]
  49. # attr <name> statechannel <channel>
  50. # attr <name> statedatapoint [<channel-number>.]<datapoint>
  51. # attr <name> statevals <text1>:<subtext1>[,...]
  52. # attr <name> substexcl <reading-expr>
  53. # attr <name> substitute <subst-rule>[;...]
  54. #
  55. ######################################################################
  56. # Requires modules 88_HMCCU.pm, HMCCUConf.pm
  57. ######################################################################
  58. package main;
  59. use strict;
  60. use warnings;
  61. use SetExtensions;
  62. # use Data::Dumper;
  63. # use Time::HiRes qw( gettimeofday usleep );
  64. sub HMCCUDEV_Initialize ($);
  65. sub HMCCUDEV_Define ($@);
  66. sub HMCCUDEV_InitDevice ($$);
  67. sub HMCCUDEV_Set ($@);
  68. sub HMCCUDEV_Get ($@);
  69. sub HMCCUDEV_Attr ($@);
  70. #####################################
  71. # Initialize module
  72. #####################################
  73. sub HMCCUDEV_Initialize ($)
  74. {
  75. my ($hash) = @_;
  76. $hash->{DefFn} = "HMCCUDEV_Define";
  77. $hash->{SetFn} = "HMCCUDEV_Set";
  78. $hash->{GetFn} = "HMCCUDEV_Get";
  79. $hash->{AttrFn} = "HMCCUDEV_Attr";
  80. $hash->{parseParams} = 1;
  81. $hash->{AttrList} = "IODev ccucalculate:textField-long ".
  82. "ccuflags:multiple-strict,ackState,nochn0,trace ccureadingfilter:textField-long ".
  83. "ccureadingformat:name,namelc,address,addresslc,datapoint,datapointlc ".
  84. "ccureadingname:textField-long ".
  85. "ccureadings:0,1 ccuget:State,Value ccuscaleval ccuverify:0,1,2 disable:0,1 ".
  86. "hmstatevals:textField-long statevals substexcl substitute:textField-long statechannel ".
  87. "statedatapoint controldatapoint stripnumber peer:textField-long ".$readingFnAttributes;
  88. }
  89. #####################################
  90. # Define device
  91. #####################################
  92. sub HMCCUDEV_Define ($@)
  93. {
  94. my ($hash, $a, $h) = @_;
  95. my $name = $hash->{NAME};
  96. my $usage = "Usage: define $name HMCCUDEV {device|'virtual'} [state-channel] ".
  97. "['readonly'] ['defaults'] [iodev={iodev-name}] ".
  98. "[{groupexp=regexp|group={device|channel}[,...]]";
  99. return $usage if (scalar (@$a) < 3);
  100. my @errmsg = (
  101. "OK",
  102. "Invalid or unknown CCU device name or address",
  103. "Can't assign I/O device",
  104. "No devices in group",
  105. "No matching CCU devices found",
  106. "Type of virtual device not defined",
  107. "Device type not found"
  108. );
  109. my $devname = shift @$a;
  110. my $devtype = shift @$a;
  111. my $devspec = shift @$a;
  112. my $hmccu_hash = undef;
  113. # Store some definitions for delayed initialization
  114. $hash->{hmccu}{devspec} = $devspec;
  115. $hash->{hmccu}{groupexp} = $h->{groupexp} if (exists ($h->{groupexp}));
  116. $hash->{hmccu}{group} = $h->{group} if (exists ($h->{group}));
  117. # Defaults
  118. $hash->{statevals} = 'devstate';
  119. # Parse optional command line parameters
  120. foreach my $arg (@$a) {
  121. if ($arg eq 'readonly') { $hash->{statevals} = $arg; }
  122. elsif ($arg eq 'defaults') {
  123. HMCCU_SetDefaults ($hash) if ($init_done);
  124. }
  125. elsif ($arg =~ /^[0-9]+$/) { $attr{$name}{statechannel} = $arg; }
  126. else { return $usage; }
  127. }
  128. # IO device can be set by command line parameter iodev, otherwise try to detect IO device
  129. if (exists ($h->{iodev})) {
  130. return "Specified IO Device ".$h->{iodev}." does not exist" if (!exists ($defs{$h->{iodev}}));
  131. return "Specified IO Device ".$h->{iodev}." is not a HMCCU device"
  132. if ($defs{$h->{iodev}}->{TYPE} ne 'HMCCU');
  133. $hmccu_hash = $defs{$h->{iodev}};
  134. }
  135. else {
  136. # The following call will fail during FHEM start if CCU is not ready
  137. $hmccu_hash = $devspec eq 'virtual' ? HMCCU_GetHash (0) : HMCCU_FindIODevice ($devspec);
  138. }
  139. if ($init_done) {
  140. # Interactive define command while CCU not ready
  141. if (!defined ($hmccu_hash)) {
  142. my ($ccuactive, $ccuinactive) = HMCCU_IODeviceStates ();
  143. if ($ccuinactive > 0) {
  144. return "CCU and/or IO device not ready. Please try again later";
  145. }
  146. else {
  147. return "Cannot detect IO device";
  148. }
  149. }
  150. }
  151. else {
  152. # CCU not ready during FHEM start
  153. if (!defined ($hmccu_hash) || $hmccu_hash->{ccustate} ne 'active') {
  154. Log3 $name, 2, "HMCCUDEV: [$devname] Cannot detect IO device, maybe CCU not ready. Trying later ...";
  155. readingsSingleUpdate ($hash, "state", "Pending", 1);
  156. $hash->{ccudevstate} = 'pending';
  157. return undef;
  158. }
  159. }
  160. # Initialize FHEM device, set IO device
  161. my $rc = HMCCUDEV_InitDevice ($hmccu_hash, $hash);
  162. return $errmsg[$rc] if ($rc > 0);
  163. return undef;
  164. }
  165. ######################################################################
  166. # Initialization of FHEM device.
  167. # Called during Define() or by HMCCU after CCU ready.
  168. # Return 0 on successful initialization or >0 on error:
  169. # 1 = Invalid channel name or address
  170. # 2 = Cannot assign IO device
  171. # 3 = No devices in group
  172. # 4 = No matching CCU devices found
  173. # 5 = Type of virtual device not defined
  174. # 6 = Device type not found
  175. ######################################################################
  176. sub HMCCUDEV_InitDevice ($$)
  177. {
  178. my ($hmccu_hash, $dev_hash) = @_;
  179. my $name = $dev_hash->{NAME};
  180. my $devspec = $dev_hash->{hmccu}{devspec};
  181. my $gdcount = 0;
  182. my $gdname = $devspec;
  183. if ($devspec eq 'virtual') {
  184. # Virtual device FHEM only, search for free address
  185. my $no = 0;
  186. foreach my $d (sort keys %defs) {
  187. my $ch = $defs{$d};
  188. next if (!exists ($ch->{TYPE}));
  189. next if ($ch->{TYPE} ne 'HMCCUDEV' || $d eq $name);
  190. next if ($ch->{ccuif} ne 'fhem' || $ch->{ccuname} ne 'virtual');
  191. $no++;
  192. }
  193. $dev_hash->{ccuif} = 'fhem';
  194. $dev_hash->{ccuaddr} = sprintf ("VIR%07d", $no+1);
  195. $dev_hash->{ccuname} = 'virtual';
  196. }
  197. else {
  198. return 1 if (!HMCCU_IsValidDevice ($hmccu_hash, $devspec, 7));
  199. my ($di, $da, $dn, $dt, $dc) = HMCCU_GetCCUDeviceParam ($hmccu_hash, $devspec);
  200. return 1 if (!defined ($da));
  201. $gdname = $dn;
  202. $dev_hash->{ccuif} = $di;
  203. $dev_hash->{ccuaddr} = $da;
  204. $dev_hash->{ccuname} = $dn;
  205. $dev_hash->{ccutype} = $dt;
  206. $dev_hash->{channels} = $dc;
  207. }
  208. # Parse group options
  209. if ($dev_hash->{ccuif} eq 'VirtualDevices' || $dev_hash->{ccuif} eq 'fhem') {
  210. my @devlist = ();
  211. if (exists ($dev_hash->{hmccu}{groupexp})) {
  212. # Group devices specified by name expression
  213. $gdcount = HMCCU_GetMatchingDevices ($hmccu_hash, $dev_hash->{hmccu}{groupexp}, 'dev', \@devlist);
  214. return 4 if ($gdcount == 0);
  215. }
  216. elsif (exists ($dev_hash->{hmccu}{group})) {
  217. # Group devices specified by comma separated name list
  218. my @gdevlist = split (",", $dev_hash->{hmccu}{group});
  219. $dev_hash->{ccugroup} = '' if (@gdevlist > 0);
  220. foreach my $gd (@gdevlist) {
  221. my ($gda, $gdc, $gdo) = ('', '', '', '');
  222. return 1 if (!HMCCU_IsValidDevice ($hmccu_hash, $gd, 7));
  223. ($gda, $gdc) = HMCCU_GetAddress ($hmccu_hash, $gd, '', '');
  224. $gdo = $gda;
  225. $gdo .= ':'.$gdc if ($gdc ne '');
  226. push @devlist, $gdo;
  227. $gdcount++;
  228. }
  229. }
  230. else {
  231. # Group specified by CCU virtual group name
  232. @devlist = HMCCU_GetGroupMembers ($hmccu_hash, $gdname);
  233. $gdcount = scalar (@devlist);
  234. return 5 if ($gdcount == 0);
  235. }
  236. return 3 if ($gdcount == 0);
  237. $dev_hash->{ccugroup} = join (',', @devlist);
  238. if ($devspec eq 'virtual') {
  239. my $dev = shift @devlist;
  240. my $devtype = HMCCU_GetDeviceType ($hmccu_hash, $dev, 'n/a');
  241. my $devna = $devtype eq 'n/a' ? 1 : 0;
  242. for my $d (@devlist) {
  243. if (HMCCU_GetDeviceType ($hmccu_hash, $d, 'n/a') ne $devtype) {
  244. $devna = 1;
  245. last;
  246. }
  247. }
  248. my $rc = 0;
  249. if ($devna) {
  250. $dev_hash->{ccutype} = 'n/a';
  251. $dev_hash->{statevals} = 'readonly';
  252. $rc = HMCCU_CreateDevice ($hmccu_hash, $dev_hash->{ccuaddr}, $name, undef, $dev);
  253. }
  254. else {
  255. $dev_hash->{ccutype} = $devtype;
  256. $rc = HMCCU_CreateDevice ($hmccu_hash, $dev_hash->{ccuaddr}, $name, $devtype, $dev);
  257. }
  258. return $rc+4 if ($rc > 0);
  259. # Set default attributes
  260. $attr{$name}{ccureadingformat} = 'name';
  261. }
  262. }
  263. # Inform HMCCU device about client device
  264. return 2 if (!HMCCU_AssignIODevice ($dev_hash, $hmccu_hash->{NAME}, undef));
  265. readingsSingleUpdate ($dev_hash, "state", "Initialized", 1);
  266. $dev_hash->{ccudevstate} = 'active';
  267. return 0;
  268. }
  269. #####################################
  270. # Set attribute
  271. #####################################
  272. sub HMCCUDEV_Attr ($@)
  273. {
  274. my ($cmd, $name, $attrname, $attrval) = @_;
  275. my $hash = $defs{$name};
  276. if ($cmd eq "set") {
  277. return "Missing attribute value" if (!defined ($attrval));
  278. if ($attrname eq 'IODev') {
  279. $hash->{IODev} = $defs{$attrval};
  280. }
  281. elsif ($attrname eq "statevals") {
  282. return "Device is read only" if ($hash->{statevals} eq 'readonly');
  283. $hash->{statevals} = 'devstate';
  284. my @states = split /,/,$attrval;
  285. foreach my $st (@states) {
  286. my @statesubs = split /:/,$st;
  287. return "value := text:substext[,...]" if (@statesubs != 2);
  288. $hash->{statevals} .= '|'.$statesubs[0];
  289. }
  290. }
  291. }
  292. elsif ($cmd eq "del") {
  293. if ($attrname eq "statevals") {
  294. $hash->{statevals} = "devstate";
  295. }
  296. }
  297. return;
  298. }
  299. #####################################
  300. # Set commands
  301. #####################################
  302. sub HMCCUDEV_Set ($@)
  303. {
  304. my ($hash, $a, $h) = @_;
  305. my $name = shift @$a;
  306. my $opt = shift @$a;
  307. # Valid commands for read only devices
  308. my $rocmds = "clear config defaults:noArg";
  309. # Get I/O device, check device state
  310. return HMCCU_SetError ($hash, -19) if (!defined ($hash->{ccudevstate}) || $hash->{ccudevstate} eq 'pending');
  311. return HMCCU_SetError ($hash, -3) if (!defined ($hash->{IODev}));
  312. my $hmccu_hash = $hash->{IODev};
  313. my $hmccu_name = $hmccu_hash->{NAME};
  314. # Handle read only and disabled devices
  315. return undef if ($hash->{statevals} eq 'readonly' && $opt ne '?'
  316. && $opt !~ /^(clear|config|defaults)$/);
  317. my $disable = AttrVal ($name, "disable", 0);
  318. return undef if ($disable == 1);
  319. # Check if CCU is busy
  320. if (HMCCU_IsRPCStateBlocking ($hmccu_hash)) {
  321. return undef if ($opt eq '?');
  322. return "HMCCUDEV: CCU busy";
  323. }
  324. # Get parameters of current device
  325. my $ccutype = $hash->{ccutype};
  326. my $ccuaddr = $hash->{ccuaddr};
  327. my $ccuif = $hash->{ccuif};
  328. my $ccuflags = AttrVal ($name, 'ccuflags', 'null');
  329. my $statevals = AttrVal ($name, 'statevals', '');
  330. my ($sc, $sd, $cc, $cd) = HMCCU_GetSpecialDatapoints ($hash, '', 'STATE', '', '');
  331. my $result = '';
  332. my $rc;
  333. if ($opt eq 'datapoint') {
  334. my $usage = "Usage: set $name datapoint [{channel-number}.]{datapoint} {value} [...]";
  335. my %dpval;
  336. while (my $objname = shift @$a) {
  337. my $objvalue = shift @$a;
  338. if ($ccutype eq 'HM-Dis-EP-WM55' && !defined ($objvalue)) {
  339. $objvalue = '';
  340. foreach my $t (keys %{$h}) {
  341. if ($objvalue eq '') {
  342. $objvalue = $t.'='.$h->{$t};
  343. }
  344. else {
  345. $objvalue .= ','.$t.'='.$h->{$t};
  346. }
  347. }
  348. }
  349. return HMCCU_SetError ($hash, $usage) if (!defined ($objvalue) || $objvalue eq '');
  350. if ($objname =~ /^([0-9]+)\..+$/) {
  351. my $chn = $1;
  352. return HMCCU_SetError ($hash, -7) if ($chn >= $hash->{channels});
  353. }
  354. else {
  355. return HMCCU_SetError ($hash, -11) if ($sc eq '');
  356. $objname = $sc.'.'.$objname;
  357. }
  358. return HMCCU_SetError ($hash, -8)
  359. if (!HMCCU_IsValidDatapoint ($hash, $ccutype, undef, $objname, 2));
  360. $objvalue =~ s/\\_/%20/g;
  361. $objvalue = HMCCU_Substitute ($objvalue, $statevals, 1, undef, '');
  362. $objname = $ccuif.'.'.$ccuaddr.':'.$objname;
  363. $dpval{$objname} = $objvalue;
  364. }
  365. return HMCCU_SetError ($hash, $usage) if (scalar (keys %dpval) < 1);
  366. foreach my $dpt (keys %dpval) {
  367. $rc = HMCCU_SetDatapoint ($hash, $dpt, $dpval{$dpt});
  368. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  369. }
  370. return HMCCU_SetState ($hash, "OK");
  371. }
  372. elsif ($opt eq 'control') {
  373. return HMCCU_SetError ($hash, -12) if ($cc eq '');
  374. return HMCCU_SetError ($hash, -14) if ($cd eq '');
  375. return HMCCU_SetError ($hash, -7) if ($cc >= $hash->{channels});
  376. my $objvalue = shift @$a;
  377. return HMCCU_SetError ($hash, "Usage: set $name control {value}") if (!defined ($objvalue));
  378. return HMCCU_SetError ($hash, -8) if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $cc, $cd, 2));
  379. $objvalue =~ s/\\_/%20/g;
  380. $objvalue = HMCCU_Substitute ($objvalue, $statevals, 1, undef, '');
  381. my $objname = $ccuif.'.'.$ccuaddr.':'.$cc.'.'.$cd;
  382. $rc = HMCCU_SetDatapoint ($hash, $objname, $objvalue);
  383. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  384. return HMCCU_SetState ($hash, "OK");
  385. }
  386. elsif ($opt =~ /^($hash->{statevals})$/) {
  387. my $cmd = $1;
  388. my $objvalue = ($cmd ne 'devstate') ? $cmd : shift @$a;
  389. return HMCCU_SetError ($hash, -11) if ($sc eq '');
  390. return HMCCU_SetError ($hash, -13) if ($sd eq '');
  391. return HMCCU_SetError ($hash, -8) if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, $sd, 2));
  392. return HMCCU_SetError ($hash, "Usage: set $name devstate {value}") if (!defined ($objvalue));
  393. $objvalue =~ s/\\_/%20/g;
  394. $objvalue = HMCCU_Substitute ($objvalue, $statevals, 1, undef, '');
  395. my $objname = $ccuif.'.'.$ccuaddr.':'.$sc.'.'.$sd;
  396. $rc = HMCCU_SetDatapoint ($hash, $objname, $objvalue);
  397. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  398. return HMCCU_SetState ($hash, "OK");
  399. }
  400. elsif ($opt eq 'toggle') {
  401. return HMCCU_SetError ($hash, -15) if ($statevals eq '' || !exists($hash->{statevals}));
  402. return HMCCU_SetError ($hash, -11) if ($sc eq '');
  403. return HMCCU_SetError ($hash, -13) if ($sd eq '');
  404. return HMCCU_SetError ($hash, -8) if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, $sd, 2));
  405. my $tstates = $hash->{statevals};
  406. $tstates =~ s/devstate\|//;
  407. my @states = split /\|/, $tstates;
  408. my $stc = scalar (@states);
  409. my $objname = $ccuif.'.'.$ccuaddr.':'.$sc.'.'.$sd;
  410. # Read current value of datapoint
  411. ($rc, $result) = HMCCU_GetDatapoint ($hash, $objname);
  412. Log3 $name, 2, "HMCCU: set toggle: GetDatapoint returned $rc, $result"
  413. if ($ccuflags =~ /trace/);
  414. return HMCCU_SetError ($hash, $rc, $result) if ($rc < 0);
  415. my $objvalue = '';
  416. my $st = 0;
  417. while ($st < $stc) {
  418. if ($states[$st] eq $result) {
  419. $objvalue = ($st == $stc-1) ? $states[0] : $states[$st+1];
  420. last;
  421. }
  422. else {
  423. $st++;
  424. }
  425. }
  426. return HMCCU_SetError ($hash, "Current device state doesn't match statevals")
  427. if ($objvalue eq '');
  428. $objvalue = HMCCU_Substitute ($objvalue, $statevals, 1, undef, '');
  429. $rc = HMCCU_SetDatapoint ($hash, $objname, $objvalue);
  430. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  431. return HMCCU_SetState ($hash, "OK");
  432. }
  433. elsif ($opt eq 'pct') {
  434. return HMCCU_SetError ($hash, -11) if ($sc eq '' && $cc eq '');
  435. my $dp;
  436. if (HMCCU_IsValidDatapoint ($hash, $ccutype, $cc, "LEVEL", 2)) {
  437. $dp = "$cc.LEVEL";
  438. }
  439. elsif (HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, "LEVEL", 2)) {
  440. $dp = "$sc.LEVEL";
  441. }
  442. else {
  443. return HMCCU_SetError ($hash, "Can't find LEVEL datapoint for device type $ccutype")
  444. }
  445. my $objname = '';
  446. my $objvalue = shift @$a;
  447. return HMCCU_SetError ($hash, "Usage: set $name pct {value} [{ontime} [{ramptime}]]")
  448. if (!defined ($objvalue));
  449. my $timespec = shift @$a;
  450. my $ramptime = shift @$a;
  451. # Set on time
  452. if (defined ($timespec)) {
  453. return HMCCU_SetError ($hash, "Can't find ON_TIME datapoint for device type $ccutype")
  454. if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, "ON_TIME", 2));
  455. if ($timespec =~ /^[0-9]{2}:[0-9]{2}/) {
  456. $timespec = HMCCU_GetTimeSpec ($timespec);
  457. return HMCCU_SetError ($hash, "Wrong time format. Use HH:MM[:SS]") if ($timespec < 0);
  458. }
  459. if ($timespec > 0) {
  460. $objname = $ccuif.'.'.$ccuaddr.':'.$sc.'.ON_TIME';
  461. $rc = HMCCU_SetDatapoint ($hash, $objname, $timespec);
  462. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  463. }
  464. }
  465. # Set ramp time
  466. if (defined ($ramptime)) {
  467. return HMCCU_SetError ($hash, "Can't find RAMP_TIME datapoint for device type $ccutype")
  468. if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, "RAMP_TIME", 2));
  469. $objname = $ccuif.'.'.$ccuaddr.':'.$sc.'.RAMP_TIME';
  470. $rc = HMCCU_SetDatapoint ($hash, $objname, $ramptime);
  471. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  472. }
  473. # Set level
  474. $objname = $ccuif.'.'.$ccuaddr.':'.$dp;
  475. $rc = HMCCU_SetDatapoint ($hash, $objname, $objvalue);
  476. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  477. return HMCCU_SetState ($hash, "OK");
  478. }
  479. elsif ($opt eq 'on-for-timer' || $opt eq 'on-till') {
  480. return HMCCU_SetError ($hash, -15) if ($statevals eq '' || !exists($hash->{statevals}));
  481. return HMCCU_SetError ($hash, "No state value for 'on' defined")
  482. if ("on" !~ /($hash->{statevals})/);
  483. return HMCCU_SetError ($hash, -11) if ($sc eq '');
  484. return HMCCU_SetError ($hash, -13) if ($sd eq '');
  485. return HMCCU_SetError ($hash, -8) if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, $sd, 2));
  486. return HMCCU_SetError ($hash, "Can't find ON_TIME datapoint for device type")
  487. if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, "ON_TIME", 2));
  488. my $timespec = shift @$a;
  489. return HMCCU_SetError ($hash, "Usage: set $name $opt {ontime-spec}")
  490. if (!defined ($timespec));
  491. if ($opt eq 'on-till') {
  492. $timespec = HMCCU_GetTimeSpec ($timespec);
  493. return HMCCU_SetError ($hash, "Wrong time format. Use HH:MM[:SS]") if ($timespec < 0);
  494. }
  495. # Set time
  496. my $objname = $ccuif.'.'.$ccuaddr.':'.$sc.'.ON_TIME';
  497. $rc = HMCCU_SetDatapoint ($hash, $objname, $timespec);
  498. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  499. # Set state
  500. $objname = $ccuif.'.'.$ccuaddr.':'.$sc.'.'.$sd;
  501. my $objvalue = HMCCU_Substitute ("on", $statevals, 1, undef, '');
  502. $rc = HMCCU_SetDatapoint ($hash, $objname, $objvalue);
  503. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  504. return HMCCU_SetState ($hash, "OK");
  505. }
  506. elsif ($opt eq 'clear') {
  507. my $rnexp = shift @$a;
  508. $rnexp = '.*' if (!defined ($rnexp));
  509. my @readlist = keys %{$hash->{READINGS}};
  510. foreach my $rd (@readlist) {
  511. delete ($hash->{READINGS}{$rd}) if ($rd ne 'state' && $rd ne 'control' && $rd =~ /$rnexp/);
  512. }
  513. }
  514. elsif ($opt eq 'config') {
  515. return HMCCU_SetError ($hash, "Usage: set $name config [{channel-number}] {parameter}={value} [...]")
  516. if ((scalar keys %{$h}) < 1);
  517. my $objname = $ccuaddr;
  518. # Channel number is optional because parameter can be related to device or channel
  519. if ((scalar @$a) > 0 && $$a[0] =~ /^([0-9]{1,2})$/) {
  520. return HMCCU_SetError ($hash, -7) if ($1 >= $hash->{channels});
  521. $objname .= ':'.$1;
  522. }
  523. my $rc = HMCCU_RPCSetConfig ($hash, $objname, $h);
  524. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  525. return HMCCU_SetState ($hash, "OK");
  526. }
  527. elsif ($opt eq 'defaults') {
  528. my $rc = HMCCU_SetDefaults ($hash);
  529. return HMCCU_SetError ($hash, "HMCCU: No default attributes found") if ($rc == 0);
  530. return HMCCU_SetState ($hash, "OK");
  531. }
  532. else {
  533. return "HMCCUCHN: Unknown argument $opt, choose one of ".$rocmds
  534. if ($hash->{statevals} eq 'readonly');
  535. my $retmsg = "HMCCUDEV: Unknown argument $opt, choose one of clear config control datapoint defaults:noArg";
  536. if ($sc ne '') {
  537. $retmsg .= " devstate";
  538. if ($hash->{statevals} ne '') {
  539. my @cmdlist = split /\|/,$hash->{statevals};
  540. shift @cmdlist;
  541. $retmsg .= ':'.join(',',@cmdlist) if (@cmdlist > 0);
  542. foreach my $sv (@cmdlist) {
  543. $retmsg .= ' '.$sv.':noArg';
  544. }
  545. $retmsg .= " toggle:noArg";
  546. $retmsg .= " on-for-timer on-till"
  547. if (HMCCU_IsValidDatapoint ($hash, $hash->{ccutype}, $sc, "ON_TIME", 2));
  548. $retmsg .= " pct"
  549. if (HMCCU_IsValidDatapoint ($hash, $hash->{ccutype}, $sc, "LEVEL", 2) ||
  550. HMCCU_IsValidDatapoint ($hash, $hash->{ccutype}, $cc, "LEVEL", 2));
  551. }
  552. }
  553. return $retmsg;
  554. }
  555. }
  556. #####################################
  557. # Get commands
  558. #####################################
  559. sub HMCCUDEV_Get ($@)
  560. {
  561. my ($hash, $a, $h) = @_;
  562. my $name = shift @$a;
  563. my $opt = shift @$a;
  564. # Get I/O device
  565. return HMCCU_SetError ($hash, -3) if (!defined ($hash->{IODev}));
  566. my $hmccu_hash = $hash->{IODev};
  567. my $hmccu_name = $hmccu_hash->{NAME};
  568. # Handle disabled devices
  569. my $disable = AttrVal ($name, "disable", 0);
  570. return undef if ($disable == 1);
  571. # Check if CCU is busy
  572. if (HMCCU_IsRPCStateBlocking ($hmccu_hash)) {
  573. return undef if ($opt eq '?');
  574. return "HMCCUDEV: CCU busy";
  575. }
  576. # Get parameters of current device
  577. my $ccutype = $hash->{ccutype};
  578. my $ccuaddr = $hash->{ccuaddr};
  579. my $ccuif = $hash->{ccuif};
  580. my $ccureadings = AttrVal ($name, 'ccureadings', 1);
  581. my ($sc, $sd, $cc, $cd) = HMCCU_GetSpecialDatapoints ($hash, '', 'STATE', '', '');
  582. my $result = '';
  583. my $rc;
  584. if ($ccuif eq "VirtualDevices" && $hash->{ccuname} eq "virtual" && $opt ne 'update') {
  585. return "HMCCUDEV: Unknown argument $opt, choose one of update:noArg";
  586. }
  587. if ($opt eq 'devstate') {
  588. return HMCCU_SetError ($hash, -11) if ($sc eq '');
  589. return HMCCU_SetError ($hash, -13) if ($sd eq '');
  590. return HMCCU_SetError ($hash, -8) if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, $sd, 1));
  591. my $objname = $ccuif.'.'.$ccuaddr.':'.$sc.'.'.$sd;
  592. ($rc, $result) = HMCCU_GetDatapoint ($hash, $objname);
  593. return HMCCU_SetError ($hash, $rc, $result) if ($rc < 0);
  594. return $ccureadings ? undef : $result;
  595. }
  596. elsif ($opt eq 'datapoint') {
  597. my $objname = shift @$a;
  598. return HMCCU_SetError ($hash, "Usage: get $name datapoint [{channel-number}.]{datapoint}")
  599. if (!defined ($objname));
  600. if ($objname =~ /^([0-9]+)\..+$/) {
  601. my $chn = $1;
  602. return HMCCU_SetError ($hash, -7) if ($chn >= $hash->{channels});
  603. }
  604. else {
  605. return HMCCU_SetError ($hash, -11) if ($sc eq '');
  606. $objname = $sc.'.'.$objname;
  607. }
  608. return HMCCU_SetError ($hash, -8)
  609. if (!HMCCU_IsValidDatapoint ($hash, $ccutype, undef, $objname, 1));
  610. $objname = $ccuif.'.'.$ccuaddr.':'.$objname;
  611. ($rc, $result) = HMCCU_GetDatapoint ($hash, $objname);
  612. return HMCCU_SetError ($hash, $rc, $result) if ($rc < 0);
  613. HMCCU_SetState ($hash, "OK") if (exists ($hash->{STATE}) && $hash->{STATE} eq "Error");
  614. return $ccureadings ? undef : $result;
  615. }
  616. elsif ($opt eq 'update') {
  617. my $ccuget = shift @$a;
  618. $ccuget = 'Attr' if (!defined ($ccuget));
  619. if ($ccuget !~ /^(Attr|State|Value)$/) {
  620. return HMCCU_SetError ($hash, "Usage: get $name update [{'State'|'Value'}]");
  621. }
  622. if ($hash->{ccuname} ne 'virtual') {
  623. $rc = HMCCU_GetUpdate ($hash, $ccuaddr, $ccuget);
  624. return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  625. }
  626. # Update other devices belonging to group
  627. # if ($hash->{ccuif} eq "VirtualDevices" && exists ($hash->{ccugroup})) {
  628. # my @vdevs = split (",", $hash->{ccugroup});
  629. # foreach my $vd (@vdevs) {
  630. # $rc = HMCCU_GetUpdate ($hash, $vd, $ccuget);
  631. # return HMCCU_SetError ($hash, $rc) if ($rc < 0);
  632. # }
  633. # }
  634. return undef;
  635. }
  636. elsif ($opt eq 'deviceinfo') {
  637. my $ccuget = shift @$a;
  638. $ccuget = 'Attr' if (!defined ($ccuget));
  639. if ($ccuget !~ /^(Attr|State|Value)$/) {
  640. return HMCCU_SetError ($hash, "Usage: get $name deviceinfo [{'State'|'Value'}]");
  641. }
  642. $result = HMCCU_GetDeviceInfo ($hash, $ccuaddr, $ccuget);
  643. return HMCCU_SetError ($hash, -2) if ($result eq '');
  644. return HMCCU_FormatDeviceInfo ($result);
  645. }
  646. elsif ($opt eq 'config') {
  647. my $channel = undef;
  648. my $ccuobj = $ccuaddr;
  649. my $par = shift @$a;
  650. if (defined ($par)) {
  651. if ($par =~ /^([0-9]{1,2})$/) {
  652. return HMCCU_SetError ($hash, -7) if ($1 >= $hash->{channels});
  653. $ccuobj .= ':'.$1;
  654. $par = shift @$a;
  655. }
  656. }
  657. $par = '.*' if (!defined ($par));
  658. my ($rc, $res) = HMCCU_RPCGetConfig ($hash, $ccuobj, "getParamset", $par);
  659. return HMCCU_SetError ($hash, $rc, $res) if ($rc < 0);
  660. HMCCU_SetState ($hash, "OK") if (exists ($hash->{STATE}) && $hash->{STATE} eq "Error");
  661. return $ccureadings ? undef : $res;
  662. }
  663. elsif ($opt eq 'configlist') {
  664. my $channel = undef;
  665. my $ccuobj = $ccuaddr;
  666. my $par = shift @$a;
  667. if (defined ($par)) {
  668. if ($par =~ /^([0-9]{1,2})$/) {
  669. return HMCCU_SetError ($hash, -7) if ($1 >= $hash->{channels});
  670. $ccuobj .= ':'.$1;
  671. $par = shift @$a;
  672. }
  673. }
  674. $par = '.*' if (!defined ($par));
  675. my ($rc, $res) = HMCCU_RPCGetConfig ($hash, $ccuobj, "listParamset", $par);
  676. return HMCCU_SetError ($hash, $rc, $res) if ($rc < 0);
  677. HMCCU_SetState ($hash, "OK") if (exists ($hash->{STATE}) && $hash->{STATE} eq "Error");
  678. return $res;
  679. }
  680. elsif ($opt eq 'configdesc') {
  681. my $channel = undef;
  682. my $ccuobj = $ccuaddr;
  683. my $par = shift @$a;
  684. if (defined ($par)) {
  685. if ($par =~ /^([0-9]{1,2})$/) {
  686. return HMCCU_SetError ($hash, -7) if ($1 >= $hash->{channels});
  687. $ccuobj .= ':'.$1;
  688. }
  689. else {
  690. return HMCCU_SetError ($hash, -7) if ($1 >= $hash->{channels});
  691. }
  692. }
  693. my ($rc, $res) = HMCCU_RPCGetConfig ($hash, $ccuobj, "getParamsetDescription", undef);
  694. return HMCCU_SetError ($hash, $rc, $res) if ($rc < 0);
  695. HMCCU_SetState ($hash, "OK") if (exists ($hash->{STATE}) && $hash->{STATE} eq "Error");
  696. return $res;
  697. }
  698. elsif ($opt eq 'defaults') {
  699. $result = HMCCU_GetDefaults ($hash, 0);
  700. return $result;
  701. }
  702. else {
  703. my $retmsg = "HMCCUDEV: Unknown argument $opt, choose one of datapoint";
  704. my @valuelist;
  705. my $valuecount = HMCCU_GetValidDatapoints ($hash, $ccutype, -1, 1, \@valuelist);
  706. $retmsg .= ":".join(",", @valuelist) if ($valuecount > 0);
  707. $retmsg .= " defaults:noArg update:noArg config configlist configdesc deviceinfo:noArg";
  708. $retmsg .= ' devstate:noArg' if ($sc ne '');
  709. return $retmsg;
  710. }
  711. }
  712. 1;
  713. =pod
  714. =item device
  715. =item summary controls HMCCU client devices for Homematic CCU2 - FHEM integration
  716. =begin html
  717. <a name="HMCCUDEV"></a>
  718. <h3>HMCCUDEV</h3>
  719. <ul>
  720. The module implements Homematic CCU devices as client devices for HMCCU. A HMCCU I/O device must
  721. exist before a client device can be defined. If a CCU channel is not found execute command
  722. 'get devicelist' in I/O device.<br/>
  723. This reference contains only commands and attributes which differ from module
  724. <a href="#HMCCUCHN">HMCCUCHN</a>.
  725. </br></br>
  726. <a name="HMCCUDEVdefine"></a>
  727. <b>Define</b><br/><br/>
  728. <ul>
  729. <code>define &lt;name&gt; HMCCUDEV {&lt;device&gt; | 'virtual'} [&lt;statechannel&gt;]
  730. [readonly] [defaults] [{group={device|channel}[,...]|groupexp=regexp]
  731. [iodev=&lt;iodev-name&gt;]</code>
  732. <br/><br/>
  733. If option 'readonly' is specified no set command will be available. With option 'defaults'
  734. some default attributes depending on CCU device type will be set. Default attributes are only
  735. available for some device types. The option is ignored during FHEM start.
  736. Parameter <i>statechannel</i> corresponds to attribute 'statechannel'.<br/>
  737. A HMCCUDEV device supports CCU group devices. The CCU devices or channels related to a group
  738. device are specified by using options 'group' or 'groupexp' followed by the names or
  739. addresses of the CCU devices or channels. By using 'groupexp' one can specify a regular
  740. expression for CCU device or channel names. Since version 4.2.009 of HMCCU HMCCUDEV
  741. is able to detect members of group devices automatically. So options 'group' or
  742. 'groupexp' are no longer necessary to define a group device.<br/>
  743. It's also possible to group any kind of CCU devices or channels without defining a real
  744. group in CCU by using option 'virtual' instead of a CCU device specification.
  745. <br/><br/>
  746. Examples:<br/>
  747. <code>
  748. # Simple device by using CCU device name<br/>
  749. define window_living HMCCUDEV WIN-LIV-1<br/>
  750. # Simple device by using CCU device address and with state channel<br/>
  751. define temp_control HMCCUDEV BidCos-RF.LEQ1234567 1<br/>
  752. # Simple read only device by using CCU device address and with default attributes<br/>
  753. define temp_sensor HMCCUDEV BidCos-RF.LEQ2345678 1 readonly defaults
  754. # Group device by using CCU group device and 3 group members<br/>
  755. define heating_living HMCCUDEV GRP-LIV group=WIN-LIV,HEAT-LIV,THERM-LIV
  756. </code>
  757. <br/>
  758. </ul>
  759. <br/>
  760. <a name="HMCCUDEVset"></a>
  761. <b>Set</b><br/><br/>
  762. <ul>
  763. <li><b>set &lt;name&gt; clear [&lt;reading-exp&gt;]</b><br/>
  764. <a href="#HMCCUCHNset">see HMCCUCHN</a>
  765. </li><br/>
  766. <li><b>set &lt;name&gt; config [&lt;channel-number&gt;] &lt;parameter&gt;=&lt;value&gt;
  767. [...]</b><br/>
  768. Set configuration parameter of CCU device or channel. Valid parameters can be listed by
  769. using command 'get configdesc'.
  770. </li><br/>
  771. <li><b>set &lt;name&gt; datapoint [&lt;channel-number&gt;.]&lt;datapoint&gt;
  772. &lt;value&gt; [...]</b><br/>
  773. Set datapoint values of a CCU device channel. If channel number is not specified
  774. state channel is used. String \_ is substituted by blank.
  775. <br/><br/>
  776. Example:<br/>
  777. <code>set temp_control datapoint 2.SET_TEMPERATURE 21</code><br/>
  778. <code>set temp_control datapoint 2.AUTO_MODE 1 2.SET_TEMPERATURE 21</code>
  779. </li><br/>
  780. <li><b>set &lt;name&gt; defaults</b><br/>
  781. Set default attributes for CCU device type. Default attributes are only available for
  782. some device types.
  783. </li><br/>
  784. <li><b>set &lt;name&gt; devstate &lt;value&gt;</b><br/>
  785. Set state of a CCU device channel. Channel and state datapoint must be defined as
  786. attribute 'statedatapoint'. If <i>value</i> contains string \_ it is substituted by blank.
  787. </li><br/>
  788. <li><b>set &lt;name&gt; on-for-timer &lt;ontime&gt;</b><br/>
  789. <a href="#HMCCUCHNset">see HMCCUCHN</a>
  790. </li><br/>
  791. <li><b>set &lt;name&gt; on-till &lt;timestamp&gt;</b><br/>
  792. <a href="#HMCCUCHNset">see HMCCUCHN</a>
  793. </li><br/>
  794. <li><b>set &lt;name&gt; pct &lt;value;&gt; [&lt;ontime&gt; [&lt;ramptime&gt;]]</b><br/>
  795. <a href="#HMCCUCHNset">see HMCCUCHN</a>
  796. </li><br/>
  797. <li><b>set &lt;name&gt; &lt;statevalue&gt;</b><br/>
  798. State datapoint of a CCU device channel is set to 'statevalue'. State channel and state
  799. datapoint must be defined as attribute 'statedatapoint'. Values for <i>statevalue</i>
  800. are defined by setting attribute 'statevals'.
  801. <br/><br/>
  802. Example:<br/>
  803. <code>
  804. attr myswitch statedatapoint 1.STATE<br/>
  805. attr myswitch statevals on:true,off:false<br/>
  806. set myswitch on
  807. </code>
  808. </li><br/>
  809. <li><b>set &lt;name&gt; toggle</b><br/>
  810. <a href="#HMCCUCHNset">see HMCCUCHN</a>
  811. </li><br/>
  812. <li><b>ePaper Display</b><br/><br/>
  813. This display has 5 text lines. The lines 1,2 and 4,5 are accessible via config parameters
  814. TEXTLINE_1 and TEXTLINE_2 in channels 1 and 2. Example:<br/><br/>
  815. <code>
  816. define HM_EPDISP HMCCUDEV CCU_EPDISP<br/>
  817. set HM_EPDISP config 2 TEXTLINE_1=Line1<br/>
  818. set HM_EPDISP config 2 TEXTLINE_2=Line2<br/>
  819. set HM_EPDISP config 1 TEXTLINE_1=Line4<br/>
  820. set HM_EPDISP config 1 TEXTLINE_2=Line5<br/>
  821. </code>
  822. <br/>
  823. The lines 2,3 and 4 of the display can be accessed by setting the datapoint SUBMIT of the
  824. display to a string containing command tokens in format 'parameter=value'. The following
  825. commands are allowed:
  826. <br/><br/>
  827. <ul>
  828. <li>text1-3=Text - Content of display line 2-4</li>
  829. <li>icon1-3=IconCode - Icons of display line 2-4</li>
  830. <li>sound=SoundCode - Sound</li>
  831. <li>signal=SignalCode - Optical signal</li>
  832. <li>pause=Seconds - Pause between signals (1-160)</li>
  833. <li>repeat=Count - Repeat count for sound (0-15)</li>
  834. </ul>
  835. <br/>
  836. IconCode := ico_off, ico_on, ico_open, ico_closed, ico_error, ico_ok, ico_info,
  837. ico_newmsg, ico_svcmsg<br/>
  838. SignalCode := sig_off, sig_red, sig_green, sig_orange<br/>
  839. SoundCode := snd_off, snd_longlong, snd_longshort, snd_long2short, snd_short, snd_shortshort,
  840. snd_long<br/><br/>
  841. Example:<br/>
  842. <code>
  843. set HM_EPDISP datapoint 3.SUBMIT text1=Line2,text2=Line3,text3=Line4,sound=snd_short,
  844. signal=sig_red
  845. </code>
  846. </li>
  847. </ul>
  848. <br/>
  849. <a name="HMCCUDEVget"></a>
  850. <b>Get</b><br/><br/>
  851. <ul>
  852. <li><b>get &lt;name&gt; config [&lt;channel-number&gt;] [&lt;filter-expr&gt;]</b><br/>
  853. Get configuration parameters of CCU device. If attribute 'ccureadings' is set to 0
  854. parameters are displayed in browser window (no readings set). Parameters can be filtered
  855. by <i>filter-expr</i>.
  856. </li><br/>
  857. <li><b>get &lt;name&gt; configdesc [&lt;channel-number&gt;] [&lt;rpcport&gt;]</b><br/>
  858. Get description of configuration parameters for CCU device. Default value for Parameter
  859. <i>rpcport</i> is 2001 (BidCos-RF). Other valid values are 2000 (wired) and 2010 (HMIP).
  860. </li><br/>
  861. <li><b>get &lt;name&gt; configlist [&lt;channel-number&gt;] [&lt;filter-expr&gt;]</b><br/>
  862. Display configuration parameters of CCU device. Parameters can be filtered by
  863. <i>filter-expr</i>.
  864. </li><br/>
  865. <li><b>get &lt;name&gt; datapoint [&lt;channel-number&gt;.]&lt;datapoint&gt;</b><br/>
  866. Get value of a CCU device datapoint. If <i>channel-number</i> is not specified state
  867. channel is used.
  868. </li><br/>
  869. <li><b>get &lt;name&gt; defaults</b><br/>
  870. <a href="#HMCCUCHNget">see HMCCUCHN</a>
  871. </li><br/>
  872. <li><b>get &lt;name&gt; deviceinfo [{State | <u>Value</u>}]</b><br/>
  873. Display all channels and datapoints of device with datapoint values and types.
  874. </li><br/>
  875. <li><b>get &lt;name&gt; devstate</b><br/>
  876. Get state of CCU device. Attribute 'statechannel' must be set. Default state datapoint
  877. STATE can be modified by attribute 'statedatapoint'.
  878. </li><br/>
  879. <li><b>get &lt;name&gt; update [{State | <u>Value</u>}]</b><br/>
  880. <a href="#HMCCUCHNget">see HMCCUCHN</a>
  881. </li><br/>
  882. </ul>
  883. <br/>
  884. <a name="HMCCUDEVattr"></a>
  885. <b>Attributes</b><br/><br/>
  886. <ul>
  887. To reduce the amount of events it's recommended to set attribute 'event-on-change-reading'
  888. to '.*'.<br/><br/>
  889. <li><b>ccucalculate &lt;value-type&gt;:&lt;reading&gt;[:&lt;dp-list&gt;[;...]</b><br/>
  890. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  891. </li><br/>
  892. <li><b>ccuflags {nochn0, trace}</b><br/>
  893. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  894. </li><br/>
  895. <li><b>ccuget {State | <u>Value</u>}</b><br/>
  896. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  897. </li><br/>
  898. <li><b>ccureadings {0 | <u>1</u>}</b><br/>
  899. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  900. </li><br/>
  901. <li><b>ccureadingfilter &lt;filter-rule[,...]&gt;</b><br/>
  902. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  903. </li><br/>
  904. <li><b>ccureadingformat {address[lc] | name[lc] | datapoint[lc]}</b><br/>
  905. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  906. </li><br/>
  907. <li><b>ccureadingname &lt;old-readingname-expr&gt;:&lt;new-readingname&gt;[,...]</b><br/>
  908. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  909. </li><br/>
  910. <li><b>ccuscaleval &lt;datapoint&gt;:&lt;factor&gt;[,...]</b><br/>
  911. ccuscaleval &lt;[!]datapoint&gt;:&lt;min&gt;:&lt;max&gt;:&lt;minn&gt;:&lt;maxn&gt;[,...]<br/>
  912. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  913. </li><br/>
  914. <li><b>ccuverify {0 | 1 | 2}</b><br/>
  915. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  916. </li><br/>
  917. <li><b>controldatapoint &lt;channel-number.datapoint&gt;</b><br/>
  918. Set channel number and datapoint for device control.
  919. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  920. </li><br/>
  921. <li><b>disable {<u>0</u> | 1}</b><br/>
  922. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  923. </li><br/>
  924. <li><b>hmstatevals &lt;subst-rule&gt;[;...]</b><br/>
  925. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  926. </li><br/>
  927. <li><b>peer [&lt;datapoints&gt;:&lt;condition&gt;:
  928. {ccu:&lt;object&gt;=&lt;value&gt;|hmccu:&lt;object&gt;=&lt;value&gt;|fhem:&lt;command&gt;}</b><br/>
  929. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  930. </li><br/>
  931. <li><b>statechannel &lt;channel-number&gt;</b><br/>
  932. Channel for setting device state by devstate command. Deprecated, use attribute
  933. 'statedatapoint' instead.
  934. </li><br/>
  935. <li><b>statedatapoint [&lt;channel-number&gt;.]&lt;datapoint&gt;</b><br/>
  936. Set state channel and state datapoint for setting device state by devstate command.
  937. Default is STATE. If 'statedatapoint' is not defined at least attribute 'statechannel'
  938. must be set.
  939. </li><br/>
  940. <li><b>statevals &lt;text&gt;:&lt;text&gt;[,...]</b><br/>
  941. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  942. </li><br/>
  943. <li><b>stripnumber {0 | 1 | 2 | -n}</b><br/>
  944. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  945. </li><br/>
  946. <li><b>substexcl &lt;reading-expr&gt;</b><br/>
  947. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  948. </li><br/>
  949. <li><b>substitute &lt;subst-rule&gt;[;...]</b><br/>
  950. <a href="#HMCCUCHNattr">see HMCCUCHN</a>
  951. </li><br/>
  952. </ul>
  953. </ul>
  954. =end html
  955. =cut