2017-05-01 15:31:35 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
#
|
|
|
|
# 88_HMCCUDEV.pm
|
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
2021-10-26 16:45:01 +00:00
|
|
|
# Version 5.0
|
2016-09-12 11:21:12 +00:00
|
|
|
#
|
2022-02-13 15:00:07 +00:00
|
|
|
# (c) 2022 zap (zap01 <at> t-online <dot> de)
|
2016-09-12 11:21:12 +00:00
|
|
|
#
|
2017-05-01 15:31:35 +00:00
|
|
|
######################################################################
|
2019-01-04 15:48:08 +00:00
|
|
|
# Client device for Homematic devices.
|
2021-10-26 16:45:01 +00:00
|
|
|
# Requires module 88_HMCCU.pm
|
2017-05-01 15:31:35 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
|
|
|
|
package main;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2021-10-26 16:45:01 +00:00
|
|
|
# use Data::Dumper;
|
2016-09-12 11:21:12 +00:00
|
|
|
use SetExtensions;
|
|
|
|
|
2022-02-13 15:00:07 +00:00
|
|
|
# require "$attr{global}{modpath}/FHEM/88_HMCCU.pm";
|
2021-10-26 16:45:01 +00:00
|
|
|
|
2018-09-11 07:54:43 +00:00
|
|
|
sub HMCCUDEV_Initialize ($);
|
2016-09-12 11:21:12 +00:00
|
|
|
sub HMCCUDEV_Define ($@);
|
2018-09-11 07:54:43 +00:00
|
|
|
sub HMCCUDEV_InitDevice ($$);
|
2021-10-26 16:45:01 +00:00
|
|
|
sub HMCCUDEV_Undef ($$);
|
|
|
|
sub HMCCUDEV_Rename ($$);
|
2016-09-12 11:21:12 +00:00
|
|
|
sub HMCCUDEV_Set ($@);
|
|
|
|
sub HMCCUDEV_Get ($@);
|
|
|
|
sub HMCCUDEV_Attr ($@);
|
|
|
|
|
2022-10-20 12:24:12 +00:00
|
|
|
my $HMCCUDEV_VERSION = '5.0 222930908';
|
2021-10-26 16:45:01 +00:00
|
|
|
|
2019-01-04 15:48:08 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
# Initialize module
|
2019-01-04 15:48:08 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
|
|
|
|
sub HMCCUDEV_Initialize ($)
|
|
|
|
{
|
|
|
|
my ($hash) = @_;
|
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
$hash->{version} = $HMCCUDEV_VERSION;
|
|
|
|
|
|
|
|
$hash->{DefFn} = 'HMCCUDEV_Define';
|
|
|
|
$hash->{UndefFn} = 'HMCCUDEV_Undef';
|
|
|
|
$hash->{RenameFn} = 'HMCCUDEV_Rename';
|
|
|
|
$hash->{SetFn} = 'HMCCUDEV_Set';
|
|
|
|
$hash->{GetFn} = 'HMCCUDEV_Get';
|
|
|
|
$hash->{AttrFn} = 'HMCCUDEV_Attr';
|
2017-01-13 16:24:52 +00:00
|
|
|
$hash->{parseParams} = 1;
|
2016-09-12 11:21:12 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
$hash->{AttrList} = 'IODev ccuaggregate:textField-long ccucalculate:textField-long '.
|
2022-10-02 13:58:29 +00:00
|
|
|
'ccuflags:multiple-strict,ackState,hideStdReadings,replaceStdReadings,noBoundsChecking,logCommand,noReadings,trace,simulate,showMasterReadings,showLinkReadings,showDeviceReadings,showServiceReadings '.
|
2021-10-26 16:45:01 +00:00
|
|
|
'ccureadingfilter:textField-long '.
|
|
|
|
'ccureadingformat:name,namelc,address,addresslc,datapoint,datapointlc '.
|
2022-01-03 16:00:44 +00:00
|
|
|
'ccureadingname:textField-long ccuSetOnChange ccuReadingPrefix devStateFlags '.
|
2021-10-26 16:45:01 +00:00
|
|
|
'ccuget:State,Value ccuscaleval ccuverify:0,1,2 disable:0,1 '.
|
|
|
|
'hmstatevals:textField-long statevals substexcl substitute:textField-long statechannel statedatapoint '.
|
|
|
|
'controlchannel controldatapoint stripnumber peer:textField-long traceFilter '.
|
2018-10-28 11:31:20 +00:00
|
|
|
$readingFnAttributes;
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
|
2019-01-04 15:48:08 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
# Define device
|
2019-01-04 15:48:08 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
|
|
|
|
sub HMCCUDEV_Define ($@)
|
|
|
|
{
|
2017-01-13 16:24:52 +00:00
|
|
|
my ($hash, $a, $h) = @_;
|
2016-09-12 11:21:12 +00:00
|
|
|
my $name = $hash->{NAME};
|
2017-01-13 16:24:52 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
my $usage = "Usage: define $name HMCCUDEV device [control-channel] ".
|
|
|
|
"['readonly'] ['noDefaults'|'defaults'] [forceDev] [iodev={iodev-name}] ".
|
|
|
|
"[sd={state-datapoint}] [cd={control-datapoint}]";
|
|
|
|
return $usage if (scalar(@$a) < 3);
|
2018-09-19 11:39:04 +00:00
|
|
|
|
|
|
|
my @errmsg = (
|
|
|
|
"OK",
|
|
|
|
"Invalid or unknown CCU device name or address",
|
|
|
|
"Can't assign I/O device",
|
|
|
|
"No devices in group",
|
|
|
|
"No matching CCU devices found",
|
|
|
|
"Type of virtual device not defined",
|
2018-10-28 11:31:20 +00:00
|
|
|
"Device type not found",
|
2021-10-26 16:45:01 +00:00
|
|
|
"Too many virtual devices",
|
|
|
|
"Use HMCCUCHN instead"
|
2018-09-19 11:39:04 +00:00
|
|
|
);
|
2016-09-12 11:21:12 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
my @warnmsg = (
|
|
|
|
"OK",
|
|
|
|
"Control channel ambiguous. You can change the default control channel in device definition or with attribute controldatapoint",
|
|
|
|
"Device type not known by HMCCU. Please set control and/or state channel with attributes controldatapoint and statedatapoint"
|
|
|
|
);
|
2018-10-28 11:31:20 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
my ($devname, $devtype, $devspec) = splice (@$a, 0, 3);
|
|
|
|
my $ioHash = undef;
|
2018-09-11 07:54:43 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
# Handle some legacy options
|
|
|
|
return 'Virtual devices are no longer supported. Use FHEM built in features like readingsgroup or structure'
|
|
|
|
if ($devspec eq 'virtual');
|
|
|
|
HMCCU_Log ($hash, 2, "Found old device definition syntax using group or groupexp. Group options will be ignored in future versions.")
|
|
|
|
if (exists($h->{group}) || exists($h->{groupexp}));
|
|
|
|
|
|
|
|
# Store some definitions for delayed initialization
|
|
|
|
$hash->{readonly} = 'no';
|
|
|
|
$hash->{hmccu}{devspec} = $devspec;
|
|
|
|
$hash->{hmccu}{groupexp} = $h->{groupexp} if (exists($h->{groupexp}));
|
|
|
|
$hash->{hmccu}{group} = $h->{group} if (exists($h->{group}));
|
|
|
|
$hash->{hmccu}{nodefaults} = $init_done ? 0 : 1;
|
|
|
|
$hash->{hmccu}{forcedev} = 0;
|
|
|
|
$hash->{hmccu}{detect} = 0;
|
|
|
|
$hash->{hmccu}{defSDP} = $h->{sd} if (exists($h->{sd}));
|
|
|
|
$hash->{hmccu}{defCDP} = $h->{cd} if (exists($h->{cd}));
|
2021-11-10 17:51:58 +00:00
|
|
|
$hash->{hmccu}{setDefaults} = 0;
|
2018-09-11 07:54:43 +00:00
|
|
|
|
|
|
|
# Parse optional command line parameters
|
|
|
|
foreach my $arg (@$a) {
|
2021-10-26 16:45:01 +00:00
|
|
|
if (lc($arg) eq 'readonly') { $hash->{readonly} = 'yes'; }
|
|
|
|
elsif (lc($arg) eq 'nodefaults') { $hash->{hmccu}{nodefaults} = 1 if ($init_done); }
|
|
|
|
elsif (lc($arg) eq 'defaults') { $hash->{hmccu}{nodefaults} = 0 if ($init_done); }
|
|
|
|
elsif (lc($arg) eq 'forcedev') { $hash->{hmccu}{forcedev} = 1; }
|
|
|
|
elsif ($arg =~ /^[0-9]+$/) { $attr{$name}{controlchannel} = $arg; }
|
|
|
|
else { return $usage; }
|
2018-09-11 07:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# IO device can be set by command line parameter iodev, otherwise try to detect IO device
|
2021-10-26 16:45:01 +00:00
|
|
|
if (exists($h->{iodev})) {
|
|
|
|
return "IO device $h->{iodev} does not exist" if (!exists($defs{$h->{iodev}}));
|
|
|
|
return "Type of device $h->{iodev} is not HMCCU" if ($defs{$h->{iodev}}->{TYPE} ne 'HMCCU');
|
|
|
|
$ioHash = $defs{$h->{iodev}};
|
2017-01-13 16:24:52 +00:00
|
|
|
}
|
2018-09-11 07:54:43 +00:00
|
|
|
else {
|
2018-10-28 11:31:20 +00:00
|
|
|
# The following call will fail for non virtual devices during FHEM start if CCU is not ready
|
2021-10-26 16:45:01 +00:00
|
|
|
$ioHash = $devspec eq 'virtual' ? HMCCU_GetHash (0) : HMCCU_FindIODevice ($devspec);
|
2018-09-11 07:54:43 +00:00
|
|
|
}
|
2018-10-28 11:31:20 +00:00
|
|
|
|
2018-09-11 07:54:43 +00:00
|
|
|
if ($init_done) {
|
|
|
|
# Interactive define command while CCU not ready
|
2021-10-26 16:45:01 +00:00
|
|
|
if (!defined($ioHash)) {
|
2018-09-11 07:54:43 +00:00
|
|
|
my ($ccuactive, $ccuinactive) = HMCCU_IODeviceStates ();
|
2021-10-26 16:45:01 +00:00
|
|
|
return $ccuinactive > 0 ? 'CCU and/or IO device not ready. Please try again later' :
|
|
|
|
'Cannot detect IO device';
|
2018-09-11 07:54:43 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-12 11:21:12 +00:00
|
|
|
else {
|
2018-09-11 07:54:43 +00:00
|
|
|
# CCU not ready during FHEM start
|
2021-10-26 16:45:01 +00:00
|
|
|
if (!defined($ioHash) || $ioHash->{ccustate} ne 'active') {
|
|
|
|
HMCCU_Log ($hash, 3, "Cannot detect IO device, maybe CCU not ready or device doesn't exist on CCU");
|
2018-09-11 07:54:43 +00:00
|
|
|
$hash->{ccudevstate} = 'pending';
|
|
|
|
return undef;
|
|
|
|
}
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 07:54:43 +00:00
|
|
|
# Initialize FHEM device, set IO device
|
2021-10-26 16:45:01 +00:00
|
|
|
my $rc = HMCCUDEV_InitDevice ($ioHash, $hash);
|
|
|
|
if (HMCCU_IsIntNum ($rc)) {
|
|
|
|
return $errmsg[$rc] if ($rc > 0 && $rc < scalar(@errmsg));
|
|
|
|
HMCCU_LogDisplay ($hash, 2, $warnmsg[-$rc]) if ($rc < 0 && -$rc < scalar(@warnmsg));
|
|
|
|
return undef;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return $rc;
|
|
|
|
}
|
2018-09-11 07:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Initialization of FHEM device.
|
|
|
|
# Called during Define() or by HMCCU after CCU ready.
|
|
|
|
# Return 0 on successful initialization or >0 on error:
|
|
|
|
# 1 = Invalid channel name or address
|
|
|
|
# 2 = Cannot assign IO device
|
|
|
|
# 3 = No devices in group
|
2018-09-19 11:39:04 +00:00
|
|
|
# 4 = No matching CCU devices found
|
|
|
|
# 5 = Type of virtual device not defined
|
|
|
|
# 6 = Device type not found
|
2018-10-28 11:31:20 +00:00
|
|
|
# 7 = Too many virtual devices
|
2021-10-26 16:45:01 +00:00
|
|
|
# -1 = Control channel ambiguous
|
|
|
|
# -2 = Device type not known by HMCCU
|
2018-09-11 07:54:43 +00:00
|
|
|
######################################################################
|
|
|
|
|
|
|
|
sub HMCCUDEV_InitDevice ($$)
|
|
|
|
{
|
2021-10-26 16:45:01 +00:00
|
|
|
my ($ioHash, $devHash) = @_;
|
|
|
|
my $name = $devHash->{NAME};
|
|
|
|
my $devspec = $devHash->{hmccu}{devspec};
|
2018-09-11 07:54:43 +00:00
|
|
|
my $gdcount = 0;
|
|
|
|
my $gdname = $devspec;
|
2021-10-26 16:45:01 +00:00
|
|
|
|
|
|
|
# Check if device is valid
|
|
|
|
return 1 if (!HMCCU_IsValidDevice ($ioHash, $devspec, 7));
|
|
|
|
|
|
|
|
my ($di, $da, $dn, $dt, $dc) = HMCCU_GetCCUDeviceParam ($ioHash, $devspec);
|
|
|
|
return 1 if (!defined($da));
|
|
|
|
|
|
|
|
$gdname = $dn;
|
|
|
|
$devHash->{ccuif} = $di;
|
|
|
|
$devHash->{ccuaddr} = $da;
|
|
|
|
$devHash->{ccuname} = $dn;
|
|
|
|
$devHash->{ccutype} = $dt;
|
|
|
|
$devHash->{hmccu}{channels} = $dc;
|
|
|
|
|
|
|
|
# Inform HMCCU device about client device
|
|
|
|
return 2 if (!HMCCU_AssignIODevice ($devHash, $ioHash->{NAME}));
|
|
|
|
|
|
|
|
$devHash->{ccudevstate} = 'active';
|
2018-09-11 07:54:43 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
my $rc = 0;
|
|
|
|
|
2021-11-24 18:16:24 +00:00
|
|
|
if ($init_done && !HMCCU_IsDelayedInit ($ioHash)) {
|
2021-10-26 16:45:01 +00:00
|
|
|
my $detect = HMCCU_DetectDevice ($ioHash, $da, $di);
|
|
|
|
return "Specify option 'forceDev' for HMCCUDEV or use HMCCUCHN instead (recommended). Command: define $name HMCCUCHN $detect->{defAdd}"
|
|
|
|
if (defined($detect) && $detect->{defMod} eq 'HMCCUCHN' && $devHash->{hmccu}{forcedev} == 0);
|
|
|
|
|
|
|
|
# Interactive device definition
|
|
|
|
HMCCU_SetSCAttributes ($ioHash, $devHash, $detect); # Set selection lists for attributes statedatapoint and controldatapoint
|
|
|
|
HMCCU_AddDevice ($ioHash, $di, $da, $devHash->{NAME}); # Add device to internal IO device hashes
|
|
|
|
HMCCU_UpdateDevice ($ioHash, $devHash); # Set device information like firmware and links
|
|
|
|
HMCCU_UpdateDeviceRoles ($ioHash, $devHash); # Set CCU type, CCU subtype and roles
|
|
|
|
HMCCU_SetInitialAttributes ($ioHash, $name); # Set global attributes as defined in IO device attribute ccudef-attributes
|
|
|
|
|
|
|
|
if (defined($detect) && $detect->{level} > 0) {
|
|
|
|
$rc = -1 if ($detect->{level} != 5 && $detect->{controlRoleCount} > 1);
|
|
|
|
if (defined($devHash->{hmccu}{defSDP})) {
|
|
|
|
my ($chn, $dpt) = split /\./, $devHash->{hmccu}{defSDP};
|
|
|
|
if (defined($dpt)) {
|
|
|
|
$detect->{defSCh} = $chn;
|
|
|
|
$detect->{defSDP} = $devHash->{hmccu}{defSDP};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (defined($devHash->{hmccu}{defCDP})) {
|
|
|
|
my ($chn, $dpt) = split /\./, $devHash->{hmccu}{defCDP};
|
|
|
|
if (defined($dpt)) {
|
|
|
|
$detect->{defCCh} = $chn;
|
|
|
|
$detect->{defCDP} = $devHash->{hmccu}{defCDP};
|
2018-10-28 11:31:20 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-11 07:54:43 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
my ($sc, $sd, $cc, $cd, $rsd, $rcd) = HMCCU_SetDefaultSCDatapoints ($ioHash, $devHash, $detect, 1);
|
|
|
|
HMCCU_Log ($devHash, 2, "Cannot set default state- and/or control datapoints. Maybe device type not known by HMCCU")
|
|
|
|
if ($rsd == 0 && $rcd == 0);
|
|
|
|
|
|
|
|
if (!exists($devHash->{hmccu}{nodefaults}) || $devHash->{hmccu}{nodefaults} == 0) {
|
|
|
|
my $chn = $detect->{defCCh} != -1 ? $detect->{defCCh} : $detect->{defSCh};
|
2021-11-10 17:51:58 +00:00
|
|
|
# Don't let device definition fail if default attributes cannot be set
|
|
|
|
my ($rc, $retMsg) = HMCCU_SetDefaultAttributes ($devHash, {
|
2021-10-26 16:45:01 +00:00
|
|
|
mode => 'update', role => undef, roleChn => $chn,
|
2021-11-10 17:51:58 +00:00
|
|
|
});
|
|
|
|
if (!$rc) {
|
|
|
|
HMCCU_Log ($devHash, 2, $retMsg);
|
|
|
|
HMCCU_Log ($devHash, 2, 'No HMCCU 4.3 default attributes found during device definition')
|
|
|
|
if (!HMCCU_SetDefaults ($devHash));
|
2021-10-26 16:45:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$rc = -2; # Device type not known by HMCCU
|
|
|
|
}
|
2017-01-13 16:24:52 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
# Update readings
|
2021-12-12 13:01:01 +00:00
|
|
|
HMCCU_GetUpdate ($devHash, $da);
|
2018-09-19 11:39:04 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
|
2017-01-13 16:24:52 +00:00
|
|
|
# Parse group options
|
2021-10-26 16:45:01 +00:00
|
|
|
if ($devHash->{ccuif} eq 'VirtualDevices') {
|
2018-09-19 11:39:04 +00:00
|
|
|
my @devlist = ();
|
2021-10-26 16:45:01 +00:00
|
|
|
if (exists ($devHash->{hmccu}{groupexp})) {
|
2018-09-19 11:39:04 +00:00
|
|
|
# Group devices specified by name expression
|
2021-10-26 16:45:01 +00:00
|
|
|
$gdcount = HMCCU_GetMatchingDevices ($ioHash, $devHash->{hmccu}{groupexp}, 'dev', \@devlist);
|
2018-09-19 11:39:04 +00:00
|
|
|
return 4 if ($gdcount == 0);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif (exists ($devHash->{hmccu}{group})) {
|
2018-09-19 11:39:04 +00:00
|
|
|
# Group devices specified by comma separated name list
|
2021-10-26 16:45:01 +00:00
|
|
|
my @gdevlist = split (',', $devHash->{hmccu}{group});
|
|
|
|
$devHash->{ccugroup} = '' if (scalar(@gdevlist) > 0);
|
2016-09-12 11:21:12 +00:00
|
|
|
foreach my $gd (@gdevlist) {
|
2021-10-26 16:45:01 +00:00
|
|
|
return 1 if (!HMCCU_IsValidDevice ($ioHash, $gd, 7));
|
|
|
|
my ($gda, $gdc) = HMCCU_GetAddress ($ioHash, $gd);
|
|
|
|
push @devlist, $gdc eq '' ? "$gda:$gdc" : $gda;
|
2017-01-13 16:24:52 +00:00
|
|
|
$gdcount++;
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-11 07:54:43 +00:00
|
|
|
else {
|
2018-09-19 11:39:04 +00:00
|
|
|
# Group specified by CCU virtual group name
|
2021-10-26 16:45:01 +00:00
|
|
|
@devlist = HMCCU_GetGroupMembers ($ioHash, $gdname);
|
2018-09-11 07:54:43 +00:00
|
|
|
$gdcount = scalar (@devlist);
|
|
|
|
}
|
2018-09-19 11:39:04 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
$devHash->{ccugroup} = join (',', @devlist) if (scalar(@devlist) > 0);
|
2017-01-13 16:24:52 +00:00
|
|
|
}
|
2016-09-12 11:21:12 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
return $rc;
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
|
2019-10-27 16:49:53 +00:00
|
|
|
######################################################################
|
2018-10-28 11:31:20 +00:00
|
|
|
# Delete device
|
2019-10-27 16:49:53 +00:00
|
|
|
######################################################################
|
2018-10-28 11:31:20 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
sub HMCCUDEV_Undef ($$)
|
2018-10-28 11:31:20 +00:00
|
|
|
{
|
2021-10-26 16:45:01 +00:00
|
|
|
my ($hash, $arg) = @_;
|
2018-10-28 11:31:20 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
if ($hash->{IODev}) {
|
|
|
|
HMCCU_RemoveDevice ($hash->{IODev}, $hash->{ccuif}, $hash->{ccuaddr}, $hash->{NAME});
|
|
|
|
}
|
|
|
|
|
2018-10-28 11:31:20 +00:00
|
|
|
return undef;
|
|
|
|
}
|
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
######################################################################
|
|
|
|
# Rename device
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
sub HMCCUDEV_Rename ($$)
|
|
|
|
{
|
|
|
|
my ($newName, $oldName) = @_;
|
|
|
|
|
|
|
|
my $clHash = $defs{$newName};
|
|
|
|
my $ioHash = defined($clHash) ? $clHash->{IODev} : undef;
|
|
|
|
|
|
|
|
HMCCU_RenameDevice ($ioHash, $clHash, $oldName);
|
|
|
|
}
|
|
|
|
|
2019-10-27 16:49:53 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
# Set attribute
|
2019-10-27 16:49:53 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
|
|
|
|
sub HMCCUDEV_Attr ($@)
|
|
|
|
{
|
|
|
|
my ($cmd, $name, $attrname, $attrval) = @_;
|
2021-10-26 16:45:01 +00:00
|
|
|
my $clHash = $defs{$name};
|
|
|
|
my $ioHash = HMCCU_GetHash ($clHash);
|
2021-11-10 17:51:58 +00:00
|
|
|
my $clType = $clHash->{TYPE};
|
2016-09-12 11:21:12 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
if ($cmd eq 'set') {
|
2021-11-10 17:51:58 +00:00
|
|
|
return "$clType [$name] Missing value of attribute $attrname" if (!defined($attrval));
|
2016-09-12 11:21:12 +00:00
|
|
|
if ($attrname eq 'IODev') {
|
2021-10-26 16:45:01 +00:00
|
|
|
$clHash->{IODev} = $defs{$attrval};
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($attrname eq 'statevals') {
|
2021-11-10 17:51:58 +00:00
|
|
|
return "$clType [$name] Attribute statevals ignored. Device is read only" if ($clHash->{readonly} eq 'yes');
|
|
|
|
return "$clType [$name] Attribute statevals ignored. Device type is known by HMCCU" if ($clHash->{hmccu}{detect} > 0);
|
2021-10-26 16:45:01 +00:00
|
|
|
if ($init_done && !HMCCU_IsValidControlDatapoint ($clHash)) {
|
|
|
|
HMCCU_LogDisplay ($clHash, 2, 'Warning: Attribute controldatapoint not set or set to invalid datapoint');
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($attrname =~ /^(state|control)(channel|datapoint)$/) {
|
|
|
|
my $chn = $attrval;
|
|
|
|
if ($attrname eq 'statedatapoint' || $attrname eq 'controldatapoint') {
|
|
|
|
if ($attrval =~ /^([0-9]{1,2})\.(.+)$/) {
|
|
|
|
$chn = $1;
|
|
|
|
}
|
|
|
|
else {
|
2021-11-10 17:51:58 +00:00
|
|
|
return "$clType [$name] Value of attribute $attrname must be in format channel.datapoint";
|
2021-10-26 16:45:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2021-11-10 17:51:58 +00:00
|
|
|
return "$clType [$name] Value of attribute $attrname must be a valid channel number" if (!HMCCU_IsIntNum ($attrval));
|
2021-10-26 16:45:01 +00:00
|
|
|
$chn = $attrval;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $role = HMCCU_GetChannelRole ($clHash, $chn);
|
2021-11-10 17:51:58 +00:00
|
|
|
return "$clType [$name] Invalid value $attrval for attribute $attrname"
|
|
|
|
if (!HMCCU_SetSCDatapoints ($clHash, $attrname, $attrval, $role, 1));
|
2021-10-26 16:45:01 +00:00
|
|
|
}
|
2022-01-03 16:00:44 +00:00
|
|
|
elsif ($attrname eq 'devStateFlags') {
|
|
|
|
my @t = split(':', $attrval);
|
|
|
|
return "$clType [$name] Missing flag and/or value expression in attribute $attrname" if (scalar(@t) != 3);
|
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
}
|
|
|
|
elsif ($cmd eq 'del') {
|
|
|
|
if ($attrname =~ /^(state|control)(channel|datapoint)$/) {
|
|
|
|
# Reset value
|
|
|
|
HMCCU_SetSCDatapoints ($clHash, $attrname);
|
|
|
|
delete $clHash->{hmccu}{roleCmds}
|
|
|
|
if (exists($clHash->{hmccu}{roleCmds}) &&
|
|
|
|
(!exists($clHash->{hmccu}{control}{chn}) || $clHash->{hmccu}{control}{chn} eq ''));
|
2021-11-10 17:51:58 +00:00
|
|
|
if ($init_done && $clHash->{hmccu}{setDefaults} == 0) {
|
2021-10-26 16:45:01 +00:00
|
|
|
# Try to set default state and control datapoint and update command list
|
|
|
|
my ($sc, $sd, $cc, $cd, $rsd, $rcd) = HMCCU_SetDefaultSCDatapoints ($ioHash, $clHash, undef, 1);
|
2021-11-10 17:51:58 +00:00
|
|
|
HMCCU_Log ($clHash, 2, "Deleted attribute $attrname but cannot set default state- and/or control datapoints")
|
2021-10-26 16:45:01 +00:00
|
|
|
if ($rsd == 0 && $rcd == 0);
|
|
|
|
}
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-16 16:55:32 +00:00
|
|
|
|
2016-09-12 11:21:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-27 16:49:53 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
# Set commands
|
2019-10-27 16:49:53 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
|
|
|
|
sub HMCCUDEV_Set ($@)
|
|
|
|
{
|
2017-01-13 16:24:52 +00:00
|
|
|
my ($hash, $a, $h) = @_;
|
|
|
|
my $name = shift @$a;
|
2021-10-26 16:45:01 +00:00
|
|
|
my $opt = shift @$a // return 'No set command specified';
|
|
|
|
my $lcopt = lc($opt);
|
|
|
|
|
|
|
|
# Check device state
|
|
|
|
return "Device state doesn't allow set commands"
|
|
|
|
if (!defined($hash->{ccudevstate}) || $hash->{ccudevstate} eq 'pending' || !defined($hash->{IODev}) ||
|
|
|
|
($hash->{readonly} eq 'yes' && $opt !~ /^(\?|clear|config|defaults)$/) ||
|
|
|
|
AttrVal ($name, 'disable', 0) == 1);
|
|
|
|
|
|
|
|
my $ioHash = $hash->{IODev};
|
|
|
|
my $ioName = $ioHash->{NAME};
|
|
|
|
return ($opt eq '?' ? undef : 'Cannot perform set commands. CCU busy')
|
|
|
|
if (HMCCU_IsRPCStateBlocking ($ioHash));
|
|
|
|
|
|
|
|
# Build set command syntax
|
2021-11-10 17:51:58 +00:00
|
|
|
my $syntax = 'clear defaults:reset,update,old,forceReset';
|
2021-10-26 16:45:01 +00:00
|
|
|
|
|
|
|
# Command readingFilter depends on readable datapoints
|
|
|
|
my @dpRList = ();
|
|
|
|
my $dpRCount = HMCCU_GetValidDatapoints ($hash, $hash->{ccutype}, -1, 5, \@dpRList);
|
|
|
|
$syntax .= ' readingFilter:multiple-strict,'.join(',', @dpRList) if ($dpRCount > 0);
|
|
|
|
|
|
|
|
# Commands only available in read/write mode
|
|
|
|
if ($hash->{readonly} ne 'yes') {
|
|
|
|
$syntax .= ' config';
|
|
|
|
my $dpWCount = HMCCU_GetValidDatapoints ($hash, $hash->{ccutype}, -1, 2);
|
|
|
|
$syntax .= ' datapoint' if ($dpWCount > 0);
|
|
|
|
my $addCmds = $hash->{hmccu}{cmdlist}{set} // '';
|
|
|
|
$syntax .= " $addCmds" if ($addCmds ne '');
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
|
2019-10-27 16:49:53 +00:00
|
|
|
# Log commands
|
2021-10-26 16:45:01 +00:00
|
|
|
HMCCU_Log ($hash, 3, "set $name $opt ".join (' ', @$a))
|
|
|
|
if ($opt ne '?' && (HMCCU_IsFlag ($name, 'logCommand') || HMCCU_IsFlag ($ioName, 'logCommand')));
|
2019-10-27 16:49:53 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
if ($lcopt eq 'control') {
|
|
|
|
return HMCCU_ExecuteSetControlCommand ($hash, $a, $h);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($lcopt eq 'datapoint') {
|
|
|
|
return HMCCU_ExecuteSetDatapointCommand ($hash, $a, $h);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($lcopt eq 'toggle') {
|
|
|
|
return HMCCU_ExecuteToggleCommand ($hash);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif (exists($hash->{hmccu}{roleCmds}{set}{$opt})) {
|
|
|
|
return HMCCU_ExecuteRoleCommand ($ioHash, $hash, 'set', $opt, $a, $h);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($lcopt eq 'clear') {
|
|
|
|
return HMCCU_ExecuteSetClearCommand ($hash, $a);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($lcopt =~ /^(config|values)$/) {
|
|
|
|
return HMCCU_ExecuteSetParameterCommand ($ioHash, $hash, $opt, $a, $h);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-12-12 13:01:01 +00:00
|
|
|
elsif ($lcopt eq 'readingfilter') {
|
2021-10-26 16:45:01 +00:00
|
|
|
my $filter = shift @$a // return HMCCU_SetError ($hash, "Usage: set $name readingFilter {datapointList}");
|
|
|
|
$filter = join(';', map { (my $f = $_) =~ s/\.(.+)/\.\^$1\$/; $f } split(',', $filter));
|
|
|
|
return CommandAttr (undef, "$name ccureadingfilter $filter");
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($lcopt eq 'defaults') {
|
|
|
|
my $mode = shift @$a // 'update';
|
2021-11-10 17:51:58 +00:00
|
|
|
return HMCCU_SetError ($hash, "Usage: get $name defaults [forceReset|old|reset|update]")
|
|
|
|
if ($mode !~ /^(forceReset|reset|old|update)$/);
|
2021-10-26 16:45:01 +00:00
|
|
|
my $rc = 0;
|
2021-11-10 17:51:58 +00:00
|
|
|
my $retMsg = '';
|
2021-11-16 16:55:32 +00:00
|
|
|
$hash->{hmccu}{setDefaults} = 1; # Make sure that readings are not refreshed after each set attribute command
|
2021-11-10 17:51:58 +00:00
|
|
|
($rc, $retMsg) = HMCCU_SetDefaultAttributes ($hash, { mode => $mode, role => undef, roleChn => undef }) if ($mode ne 'old');
|
|
|
|
if (!$rc) {
|
|
|
|
$rc = HMCCU_SetDefaults ($hash);
|
|
|
|
$retMsg .= $rc ? "\nSet version 4.3 attributes" : "\nNo version 4.3 default attributes found";
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-11-10 17:51:58 +00:00
|
|
|
$retMsg = 'OK' if ($retMsg eq '');
|
2021-11-16 16:55:32 +00:00
|
|
|
$hash->{hmccu}{setDefaults} = 0;
|
2021-10-26 16:45:01 +00:00
|
|
|
HMCCU_RefreshReadings ($hash) if ($rc);
|
2021-11-10 17:51:58 +00:00
|
|
|
return HMCCU_SetError ($hash, $retMsg);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
else {
|
2021-10-26 16:45:01 +00:00
|
|
|
return "Unknown argument $opt choose one of $syntax";
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-27 16:49:53 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
# Get commands
|
2019-10-27 16:49:53 +00:00
|
|
|
######################################################################
|
2016-09-12 11:21:12 +00:00
|
|
|
|
|
|
|
sub HMCCUDEV_Get ($@)
|
|
|
|
{
|
2017-01-13 16:24:52 +00:00
|
|
|
my ($hash, $a, $h) = @_;
|
|
|
|
my $name = shift @$a;
|
2021-10-26 16:45:01 +00:00
|
|
|
my $opt = shift @$a // return 'No get command specified';
|
|
|
|
my $lcopt = lc($opt);
|
2019-08-18 17:21:33 +00:00
|
|
|
|
2017-01-13 16:24:52 +00:00
|
|
|
# Get I/O device
|
2021-10-26 16:45:01 +00:00
|
|
|
return "Device state doesn't allow set commands"
|
|
|
|
if (!defined ($hash->{ccudevstate}) || $hash->{ccudevstate} eq 'pending' ||
|
|
|
|
!defined ($hash->{IODev}) || AttrVal ($name, "disable", 0) == 1);
|
|
|
|
my $ioHash = $hash->{IODev};
|
|
|
|
my $ioName = $ioHash->{NAME};
|
2016-09-12 11:21:12 +00:00
|
|
|
|
2017-01-13 16:24:52 +00:00
|
|
|
# Check if CCU is busy
|
2021-10-26 16:45:01 +00:00
|
|
|
return $opt eq '?' ? undef : 'Cannot perform get commands. CCU busy'
|
|
|
|
if (HMCCU_IsRPCStateBlocking ($ioHash));
|
|
|
|
|
2017-01-13 16:24:52 +00:00
|
|
|
# Get parameters of current device
|
2016-09-12 11:21:12 +00:00
|
|
|
my $ccutype = $hash->{ccutype};
|
|
|
|
my $ccuaddr = $hash->{ccuaddr};
|
|
|
|
my $ccuif = $hash->{ccuif};
|
2019-10-27 16:49:53 +00:00
|
|
|
my $ccuflags = AttrVal ($name, 'ccuflags', 'null');
|
2016-09-12 11:21:12 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
# Build set command syntax
|
|
|
|
my $syntax = 'update config paramsetDesc:noArg deviceInfo:noArg values extValues';
|
|
|
|
|
|
|
|
# Command datapoint depends on readable datapoints
|
|
|
|
my @dpRList;
|
|
|
|
my $dpRCount = HMCCU_GetValidDatapoints ($hash, $ccutype, -1, 1, \@dpRList);
|
|
|
|
$syntax .= ' datapoint:'.join(",", @dpRList) if ($dpRCount > 0);
|
|
|
|
|
|
|
|
# Additional device specific commands
|
|
|
|
my $addCmds = $hash->{hmccu}{cmdlist}{get} // '';
|
|
|
|
$syntax .= " $addCmds" if ($addCmds ne '');
|
|
|
|
|
2019-10-27 16:49:53 +00:00
|
|
|
# Log commands
|
2021-10-26 16:45:01 +00:00
|
|
|
HMCCU_Log ($hash, 3, "get $name $opt ".join (' ', @$a))
|
|
|
|
if ($opt ne '?' && $ccuflags =~ /logCommand/ || HMCCU_IsFlag ($ioName, 'logCommand'));
|
2016-09-12 11:21:12 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
if ($lcopt eq 'datapoint') {
|
|
|
|
my $objname = shift @$a // return HMCCU_SetError ($hash, "Usage: get $name datapoint [{channel-number}.]{datapoint}");
|
2021-11-10 17:51:58 +00:00
|
|
|
my $chn;
|
|
|
|
my $dpt;
|
|
|
|
if ($objname =~ /^([0-9]+)\.(.+)$/) {
|
|
|
|
($chn, $dpt) = ($1, $2);
|
2021-10-26 16:45:01 +00:00
|
|
|
return HMCCU_SetError ($hash, -7) if ($chn >= $hash->{hmccu}{channels});
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
else {
|
2021-10-26 16:45:01 +00:00
|
|
|
my ($sc, $sd, $cc, $cd) = HMCCU_GetSCDatapoints ($hash);
|
2016-09-12 11:21:12 +00:00
|
|
|
return HMCCU_SetError ($hash, -11) if ($sc eq '');
|
2021-11-10 17:51:58 +00:00
|
|
|
($chn, $dpt) = ($sc, $objname);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
return HMCCU_SetError ($hash, -8, $objname)
|
2021-11-10 17:51:58 +00:00
|
|
|
if (!HMCCU_IsValidParameter ($hash, HMCCU_GetChannelAddr ($hash, $chn), 'VALUES', $dpt, 1));
|
2016-09-12 11:21:12 +00:00
|
|
|
|
2021-11-10 17:51:58 +00:00
|
|
|
$objname = "$ccuif.$ccuaddr:$chn.$dpt";
|
2021-10-26 16:45:01 +00:00
|
|
|
my ($rc, $result) = HMCCU_GetDatapoint ($hash, $objname, 0);
|
2016-09-12 11:21:12 +00:00
|
|
|
|
2017-04-25 15:40:51 +00:00
|
|
|
return HMCCU_SetError ($hash, $rc, $result) if ($rc < 0);
|
2021-10-26 16:45:01 +00:00
|
|
|
return $result;
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($lcopt eq 'deviceinfo') {
|
|
|
|
my $extended = shift @$a;
|
|
|
|
return HMCCU_ExecuteGetDeviceInfoCommand ($ioHash, $hash, $ccuaddr, defined($extended) ? 1 : 0);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($lcopt =~ /^(config|values|update)$/) {
|
|
|
|
my $filter = shift @$a;
|
|
|
|
my @addList = ($ccuaddr);
|
2016-12-12 07:08:20 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $ccuaddr, $ccuif);
|
|
|
|
return HMCCU_SetError ($hash, "Can't get device description") if (!defined($devDesc));
|
|
|
|
push @addList, split (',', $devDesc->{CHILDREN});
|
2016-09-12 11:21:12 +00:00
|
|
|
|
2021-10-26 16:45:01 +00:00
|
|
|
my $result = HMCCU_ExecuteGetParameterCommand ($ioHash, $hash, $lcopt, \@addList, $filter);
|
|
|
|
return HMCCU_SetError ($hash, "Can't get device description") if (!defined($result));
|
|
|
|
return HMCCU_DisplayGetParameterResult ($ioHash, $hash, $result);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($lcopt eq 'extvalues') {
|
|
|
|
my $filter = shift @$a;
|
|
|
|
my $rc = HMCCU_GetUpdate ($hash, $ccuaddr, $filter);
|
|
|
|
return $rc < 0 ? HMCCU_SetError ($hash, $rc) : 'OK';
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
2021-10-26 16:45:01 +00:00
|
|
|
elsif ($lcopt eq 'paramsetdesc') {
|
|
|
|
my $result = HMCCU_ParamsetDescToStr ($ioHash, $hash);
|
|
|
|
return defined($result) ? $result : HMCCU_SetError ($hash, "Can't get device model");
|
|
|
|
}
|
|
|
|
elsif (exists($hash->{hmccu}{roleCmds}{get}{$opt})) {
|
|
|
|
return HMCCU_ExecuteRoleCommand ($ioHash, $hash, 'get', $opt, $a, $h);
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
else {
|
2021-10-26 16:45:01 +00:00
|
|
|
return "Unknown argument $opt choose one of $syntax";
|
2016-09-12 11:21:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
|
|
|
|
=pod
|
|
|
|
=item device
|
2021-10-26 16:45:01 +00:00
|
|
|
=item summary controls HMCCU client devices for Homematic CCU - FHEM integration
|
2016-09-12 11:21:12 +00:00
|
|
|
=begin html
|
|
|
|
|
|
|
|
<a name="HMCCUDEV"></a>
|
|
|
|
<h3>HMCCUDEV</h3>
|
|
|
|
<ul>
|
|
|
|
The module implements Homematic CCU devices as client devices for HMCCU. A HMCCU I/O device must
|
|
|
|
exist before a client device can be defined. If a CCU channel is not found execute command
|
|
|
|
'get devicelist' in I/O device.<br/>
|
|
|
|
This reference contains only commands and attributes which differ from module
|
|
|
|
<a href="#HMCCUCHN">HMCCUCHN</a>.
|
|
|
|
</br></br>
|
|
|
|
<a name="HMCCUDEVdefine"></a>
|
|
|
|
<b>Define</b><br/><br/>
|
|
|
|
<ul>
|
2021-10-26 16:45:01 +00:00
|
|
|
<code>define <name> HMCCUDEV <device> [<controlchannel>]
|
|
|
|
[readonly] [<u>defaults</u>|noDefaults] [forceDev] [iodev=<iodev-name>]</code>
|
2016-09-12 11:21:12 +00:00
|
|
|
<br/><br/>
|
|
|
|
If option 'readonly' is specified no set command will be available. With option 'defaults'
|
2016-11-10 21:03:03 +00:00
|
|
|
some default attributes depending on CCU device type will be set. Default attributes are only
|
2018-09-11 07:54:43 +00:00
|
|
|
available for some device types. The option is ignored during FHEM start.
|
2021-10-26 16:45:01 +00:00
|
|
|
Option 'forceDev' must be specified to define a HMCCUDEV device even if the preferred and
|
|
|
|
recommended type is HMCCUCHN.<br/>
|
|
|
|
Parameter <i>controlchannel</i> corresponds to attribute 'controlchannel'. If a device
|
|
|
|
has several identical channels, some commands need to know the channel number for
|
|
|
|
controlling the device.<br/>
|
|
|
|
<br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
Examples:<br/>
|
|
|
|
<code>
|
|
|
|
# Simple device by using CCU device name<br/>
|
|
|
|
define window_living HMCCUDEV WIN-LIV-1<br/>
|
|
|
|
# Simple device by using CCU device address and with state channel<br/>
|
|
|
|
define temp_control HMCCUDEV BidCos-RF.LEQ1234567 1<br/>
|
|
|
|
# Simple read only device by using CCU device address and with default attributes<br/>
|
|
|
|
define temp_sensor HMCCUDEV BidCos-RF.LEQ2345678 1 readonly defaults
|
|
|
|
</code>
|
2021-10-26 16:45:01 +00:00
|
|
|
<br/><br/>
|
|
|
|
Internals:<br/>
|
|
|
|
<ul>
|
|
|
|
<li>ccuaddr: Address of device in CCU</li>
|
|
|
|
<li>ccudevstate: State of device in CCU (active/inactive/dead)</li>
|
|
|
|
<li>ccuif: Interface of device</li>
|
|
|
|
<li>ccuname: Name of device in CCU</li>
|
|
|
|
<li>ccurole: Role of device</li>
|
|
|
|
<li>ccusubtype: Homematic subtype of device (different from ccutype for HmIP devices)</li>
|
|
|
|
<li>ccutype: Homematic type of device</li>
|
|
|
|
<li>readonly: Indicates whether FHEM device is writeable</li>
|
|
|
|
<li>receiver: List of peered devices with role 'receiver'. If no FHEM device exists for a receiver, the
|
|
|
|
name of the CCU device is displayed preceeded by 'ccu:'</li>
|
|
|
|
<li>sender: List of peered devices with role 'sender'. If no FHEM device exists for a sender, the
|
|
|
|
name of the CCU device is displayed preceeded by 'ccu:'</li>
|
|
|
|
</ul>
|
|
|
|
</ul>
|
2016-09-12 11:21:12 +00:00
|
|
|
<br/>
|
|
|
|
|
|
|
|
<a name="HMCCUDEVset"></a>
|
|
|
|
<b>Set</b><br/><br/>
|
|
|
|
<ul>
|
|
|
|
<li><b>set <name> clear [<reading-exp>]</b><br/>
|
|
|
|
<a href="#HMCCUCHNset">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>set <name> config [<channel-number>] <parameter>=<value>
|
2016-11-10 21:03:03 +00:00
|
|
|
[...]</b><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
Set configuration parameter of CCU device or channel. Valid parameters can be listed by
|
|
|
|
using command 'get configdesc'.
|
|
|
|
</li><br/>
|
2021-10-26 16:45:01 +00:00
|
|
|
<li><b>set <name> control <value></b><br/>
|
|
|
|
Set value of control datapoint. This command is available for compatibility reasons.
|
|
|
|
It should not be used any more.
|
|
|
|
</li><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<li><b>set <name> datapoint [<channel-number>.]<datapoint>
|
2018-01-29 16:07:43 +00:00
|
|
|
<value> [...]</b><br/>
|
|
|
|
Set datapoint values of a CCU device channel. If channel number is not specified
|
2016-09-12 11:21:12 +00:00
|
|
|
state channel is used. String \_ is substituted by blank.
|
|
|
|
<br/><br/>
|
|
|
|
Example:<br/>
|
2018-01-29 16:07:43 +00:00
|
|
|
<code>set temp_control datapoint 2.SET_TEMPERATURE 21</code><br/>
|
|
|
|
<code>set temp_control datapoint 2.AUTO_MODE 1 2.SET_TEMPERATURE 21</code>
|
2016-09-12 11:21:12 +00:00
|
|
|
</li><br/>
|
2021-10-26 16:45:01 +00:00
|
|
|
<li><b>set <name> defaults ['reset'|'old'|'<u>update</u>']</b><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
Set default attributes for CCU device type. Default attributes are only available for
|
2021-10-26 16:45:01 +00:00
|
|
|
some device types and for some channels of a device type. If option 'reset' is specified,
|
|
|
|
the following attributes are deleted before the new attributes are set:
|
|
|
|
'ccureadingname', 'ccuscaleval', 'eventMap', 'substexcl', 'webCmd', 'widgetOverride'.
|
|
|
|
During update to version 4.4 it's recommended to use option 'reset'. With option 'old'
|
|
|
|
the attributes are set according to HMCCU 4.3 defaults mechanism.
|
2016-09-12 11:21:12 +00:00
|
|
|
</li><br/>
|
2019-01-04 15:48:08 +00:00
|
|
|
<li><b>set <name> down [<value>]</b><br/>
|
|
|
|
<a href="#HMCCUCHNset">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<li><b>set <name> on-for-timer <ontime></b><br/>
|
|
|
|
<a href="#HMCCUCHNset">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>set <name> on-till <timestamp></b><br/>
|
|
|
|
<a href="#HMCCUCHNset">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>set <name> pct <value;> [<ontime> [<ramptime>]]</b><br/>
|
|
|
|
<a href="#HMCCUCHNset">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2021-10-26 16:45:01 +00:00
|
|
|
<li><b>set <name> readingFilter <datapoint-list></b><br/>
|
|
|
|
Set attribute ccureadingfilter by selecting a list of datapoints. Parameter <i>datapoint-list</i>
|
|
|
|
is a comma seperated list of datapoints. The datapoints must be specifed in format
|
|
|
|
"channel-number.datapoint-name".
|
|
|
|
</li><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<li><b>set <name> <statevalue></b><br/>
|
|
|
|
State datapoint of a CCU device channel is set to 'statevalue'. State channel and state
|
|
|
|
datapoint must be defined as attribute 'statedatapoint'. Values for <i>statevalue</i>
|
|
|
|
are defined by setting attribute 'statevals'.
|
|
|
|
<br/><br/>
|
|
|
|
Example:<br/>
|
|
|
|
<code>
|
|
|
|
attr myswitch statedatapoint 1.STATE<br/>
|
|
|
|
attr myswitch statevals on:true,off:false<br/>
|
|
|
|
set myswitch on
|
|
|
|
</code>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>set <name> toggle</b><br/>
|
|
|
|
<a href="#HMCCUCHNset">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2019-01-04 15:48:08 +00:00
|
|
|
<li><b>set <name> up [<value>]</b><br/>
|
|
|
|
<a href="#HMCCUCHNset">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<li><b>ePaper Display</b><br/><br/>
|
|
|
|
This display has 5 text lines. The lines 1,2 and 4,5 are accessible via config parameters
|
2021-11-13 17:37:14 +00:00
|
|
|
TEXTLINE_1 and TEXTLINE_2 in channels 1 and 2.<br/>
|
|
|
|
Example:<br/><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<code>
|
|
|
|
define HM_EPDISP HMCCUDEV CCU_EPDISP<br/>
|
2021-11-13 17:37:14 +00:00
|
|
|
set HM_EPDISP config 2 TEXTLINE_1=Line1 # Set line 1 to "Line1"<br/>
|
|
|
|
set HM_EPDISP config 2 TEXTLINE_2=Line2 # Set line 2 to "Line2"<br/>
|
|
|
|
set HM_EPDISP config 1 TEXTLINE_1=Line4 # Set line 4 to "Line4"<br/>
|
|
|
|
set HM_EPDISP config 1 TEXTLINE_2=Line5 # Set line 5 to "Line5"<br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
</code>
|
|
|
|
<br/>
|
2021-11-13 17:37:14 +00:00
|
|
|
The lines 2,3 and 4 of the display can be modified by setting the datapoint SUBMIT of the
|
|
|
|
display to a string containing command tokens in format 'parameter:value'. The following
|
2016-09-12 11:21:12 +00:00
|
|
|
commands are allowed:
|
|
|
|
<br/><br/>
|
|
|
|
<ul>
|
2022-02-13 15:00:07 +00:00
|
|
|
<li>text1-3:Text - Content of display line 2-4</li>
|
|
|
|
<li>icon1-3:IconCode - Icons of display line 2-4</li>
|
|
|
|
<li>sound:SoundCode - Sound</li>
|
|
|
|
<li>signal:SignalCode - Optical signal</li>
|
|
|
|
<li>pause:Seconds - Pause between signals (1-160)</li>
|
|
|
|
<li>repeat:Count - Repeat count for sound (0-15)</li>
|
2016-09-12 11:21:12 +00:00
|
|
|
</ul>
|
|
|
|
<br/>
|
|
|
|
IconCode := ico_off, ico_on, ico_open, ico_closed, ico_error, ico_ok, ico_info,
|
|
|
|
ico_newmsg, ico_svcmsg<br/>
|
|
|
|
SignalCode := sig_off, sig_red, sig_green, sig_orange<br/>
|
|
|
|
SoundCode := snd_off, snd_longlong, snd_longshort, snd_long2short, snd_short, snd_shortshort,
|
|
|
|
snd_long<br/><br/>
|
|
|
|
Example:<br/>
|
|
|
|
<code>
|
2022-02-13 15:00:07 +00:00
|
|
|
set HM_EPDISP datapoint 3.SUBMIT text1:Line2,text2:Has Blank,text3:10:05:21,sound:snd_short,signal:sig_red
|
2016-09-12 11:21:12 +00:00
|
|
|
</code>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<a name="HMCCUDEVget"></a>
|
|
|
|
<b>Get</b><br/><br/>
|
|
|
|
<ul>
|
2021-10-26 16:45:01 +00:00
|
|
|
<li><b>get <name> config [<filter-expr>]</b><br/>
|
|
|
|
Get configuration parameters of CCU device and all its channels. If ccuflag noReadings is set
|
2016-12-12 07:08:20 +00:00
|
|
|
parameters are displayed in browser window (no readings set). Parameters can be filtered
|
|
|
|
by <i>filter-expr</i>.
|
2016-09-12 11:21:12 +00:00
|
|
|
</li><br/>
|
|
|
|
<li><b>get <name> datapoint [<channel-number>.]<datapoint></b><br/>
|
|
|
|
Get value of a CCU device datapoint. If <i>channel-number</i> is not specified state
|
|
|
|
channel is used.
|
|
|
|
</li><br/>
|
|
|
|
<li><b>get <name> defaults</b><br/>
|
2016-11-10 21:03:03 +00:00
|
|
|
<a href="#HMCCUCHNget">see HMCCUCHN</a>
|
2016-09-12 11:21:12 +00:00
|
|
|
</li><br/>
|
2021-10-26 16:45:01 +00:00
|
|
|
<li><b>get <name> deviceinfo ['extended']</b><br/>
|
|
|
|
Display information about device and channels:<br/>
|
|
|
|
<ul>
|
|
|
|
<li>all channels and datapoints of device with datapoint values and types</li>
|
|
|
|
<li>statedatapoint and controldatapoint</li>
|
|
|
|
<li>device and channel description</li>
|
|
|
|
</ul>
|
2016-09-12 11:21:12 +00:00
|
|
|
</li><br/>
|
2021-10-26 16:45:01 +00:00
|
|
|
<li><b>get <name> extValues [<filter-expr>]</b><br/>
|
|
|
|
<a href="#HMCCUCHNget">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>get <name> update [{State | <u>Value</u>}]</b><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<a href="#HMCCUCHNget">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2021-10-26 16:45:01 +00:00
|
|
|
<li><b>get <name> weekProgram [<program-number>|<u>all</u>]</b><br/>
|
|
|
|
Display week programs. This command is only available if a device supports week programs.
|
|
|
|
</li>
|
2016-09-12 11:21:12 +00:00
|
|
|
</ul>
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<a name="HMCCUDEVattr"></a>
|
|
|
|
<b>Attributes</b><br/><br/>
|
|
|
|
<ul>
|
|
|
|
To reduce the amount of events it's recommended to set attribute 'event-on-change-reading'
|
|
|
|
to '.*'.<br/><br/>
|
2017-05-01 15:31:35 +00:00
|
|
|
<li><b>ccucalculate <value-type>:<reading>[:<dp-list>[;...]</b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
2017-01-26 17:02:17 +00:00
|
|
|
</li><br/>
|
|
|
|
<li><b>ccuflags {nochn0, trace}</b><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>ccuget {State | <u>Value</u>}</b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>ccureadingfilter <filter-rule[,...]></b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>ccureadingformat {address[lc] | name[lc] | datapoint[lc]}</b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>ccureadingname <old-readingname-expr>:<new-readingname>[,...]</b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>ccuscaleval <datapoint>:<factor>[,...]</b><br/>
|
|
|
|
ccuscaleval <[!]datapoint>:<min>:<max>:<minn>:<maxn>[,...]<br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2018-11-04 12:40:18 +00:00
|
|
|
<li><b>ccuSetOnChange <expression></b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<li><b>ccuverify {0 | 1 | 2}</b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2021-10-26 16:45:01 +00:00
|
|
|
<li><b>controlchannel <channel-number></b><br/>
|
|
|
|
Channel used for setting device states.
|
|
|
|
</li><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<li><b>controldatapoint <channel-number.datapoint></b><br/>
|
|
|
|
Set channel number and datapoint for device control.
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2022-01-03 16:00:44 +00:00
|
|
|
<li><b>devStateFlags <datapoint>:<value-expr>:<flag></b><br/>
|
|
|
|
Define flags for datapoint values which should appear in reading 'devstate'.
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<li><b>disable {<u>0</u> | 1}</b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2017-01-13 16:24:52 +00:00
|
|
|
<li><b>hmstatevals <subst-rule>[;...]</b><br/>
|
2017-07-12 14:22:34 +00:00
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>peer [<datapoints>:<condition>:
|
2021-10-26 16:45:01 +00:00
|
|
|
{ccu:<object>=<value>|hmccu:<object>=<value>}</b><br/>
|
2017-01-13 16:24:52 +00:00
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<li><b>statechannel <channel-number></b><br/>
|
2021-10-26 16:45:01 +00:00
|
|
|
Channel for getting device state. Deprecated, use attribute 'statedatapoint' instead.
|
2016-09-12 11:21:12 +00:00
|
|
|
</li><br/>
|
|
|
|
<li><b>statedatapoint [<channel-number>.]<datapoint></b><br/>
|
2021-10-26 16:45:01 +00:00
|
|
|
Set state channel and state datapoint.
|
2016-09-12 11:21:12 +00:00
|
|
|
Default is STATE. If 'statedatapoint' is not defined at least attribute 'statechannel'
|
|
|
|
must be set.
|
|
|
|
</li><br/>
|
|
|
|
<li><b>statevals <text>:<text>[,...]</b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
|
|
|
<li><b>stripnumber {0 | 1 | 2 | -n}</b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2016-11-10 21:03:03 +00:00
|
|
|
<li><b>substexcl <reading-expr></b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
<li><b>substitute <subst-rule>[;...]</b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2021-10-26 16:45:01 +00:00
|
|
|
<li><b>traceFilter <filter-expr></b><br/>
|
|
|
|
<a href="#HMCCUCHNattr">see HMCCUCHN</a>
|
|
|
|
</li><br/>
|
2016-09-12 11:21:12 +00:00
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
=end html
|
|
|
|
=cut
|
|
|
|
|