88_HMCCUDEV.pm 37 KB

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