mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
HMCCU: CCU access modes State and Value
git-svn-id: https://svn.fhem.de/fhem/trunk@10502 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6b0e4cf473
commit
014b4c8ea1
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# Version 2.4
|
# Version 2.5
|
||||||
#
|
#
|
||||||
# (c) 2015 zap (zap01 <at> t-online <dot> de)
|
# (c) 2015 zap (zap01 <at> t-online <dot> de)
|
||||||
#
|
#
|
||||||
@ -105,17 +105,18 @@ sub HMCCU_SetError ($$);
|
|||||||
sub HMCCU_SetState ($$);
|
sub HMCCU_SetState ($$);
|
||||||
sub HMCCU_Substitute ($$$$);
|
sub HMCCU_Substitute ($$$$);
|
||||||
sub HMCCU_SubstRule ($$$);
|
sub HMCCU_SubstRule ($$$);
|
||||||
sub HMCCU_UpdateClients ($$);
|
sub HMCCU_UpdateClients ($$$);
|
||||||
sub HMCCU_UpdateClientReading ($@);
|
sub HMCCU_UpdateClientReading ($@);
|
||||||
sub HMCCU_StartRPCServer ($);
|
sub HMCCU_StartRPCServer ($);
|
||||||
sub HMCCU_StopRPCServer ($);
|
sub HMCCU_StopRPCServer ($);
|
||||||
sub HMCCU_IsRPCServerRunning ($);
|
sub HMCCU_IsRPCServerRunning ($$$);
|
||||||
sub HMCCU_CheckProcess ($);
|
sub HMCCU_CheckProcess ($$);
|
||||||
sub HMCCU_GetDeviceInfo ($$);
|
sub HMCCU_GetDeviceInfo ($$$);
|
||||||
sub HMCCU_GetDeviceList ($);
|
sub HMCCU_GetDeviceList ($);
|
||||||
sub HMCCU_GetAddress ($$$);
|
sub HMCCU_GetAddress ($$$);
|
||||||
sub HMCCU_GetCCUObjectAttribute ($$);
|
sub HMCCU_GetCCUObjectAttribute ($$);
|
||||||
sub HMCCU_GetHash;
|
sub HMCCU_GetHash ($@);
|
||||||
|
sub HMCCU_GetAttribute ($$$$);
|
||||||
sub HMCCU_GetDeviceName ($$);
|
sub HMCCU_GetDeviceName ($$);
|
||||||
sub HMCCU_GetChannelName ($$);
|
sub HMCCU_GetChannelName ($$);
|
||||||
sub HMCCU_GetDeviceType ($$);
|
sub HMCCU_GetDeviceType ($$);
|
||||||
@ -128,7 +129,7 @@ sub HMCCU_GetDatapoint ($@);
|
|||||||
sub HMCCU_SetDatapoint ($$$);
|
sub HMCCU_SetDatapoint ($$$);
|
||||||
sub HMCCU_GetVariables ($$);
|
sub HMCCU_GetVariables ($$);
|
||||||
sub HMCCU_SetVariable ($$$);
|
sub HMCCU_SetVariable ($$$);
|
||||||
sub HMCCU_GetUpdate ($$);
|
sub HMCCU_GetUpdate ($$$);
|
||||||
sub HMCCU_GetChannel ($$);
|
sub HMCCU_GetChannel ($$);
|
||||||
sub HMCCU_RPCGetConfig ($$$);
|
sub HMCCU_RPCGetConfig ($$$);
|
||||||
sub HMCCU_RPCSetConfig ($$$);
|
sub HMCCU_RPCSetConfig ($$$);
|
||||||
@ -151,7 +152,7 @@ sub HMCCU_Initialize ($)
|
|||||||
$hash->{AttrFn} = "HMCCU_Attr";
|
$hash->{AttrFn} = "HMCCU_Attr";
|
||||||
$hash->{ShutdownFn} = "HMCCU_Shutdown";
|
$hash->{ShutdownFn} = "HMCCU_Shutdown";
|
||||||
|
|
||||||
$hash->{AttrList} = "stripchar stripnumber:0,1,2 ccureadings:0,1 ccureadingfilter ccureadingformat:name,address rpcinterval:3,5,10 rpcqueue rpcport rpcserver:on,off parfile statedatapoint statevals substitute updatemode:client,both,hmccu ccutrace loglevel:0,1,2,3,4,5,6 ". $readingFnAttributes;
|
$hash->{AttrList} = "stripchar stripnumber:0,1,2 ccureadings:0,1 ccureadingfilter ccureadingformat:name,address rpcinterval:3,5,10 rpcqueue rpcport rpcserver:on,off parfile statedatapoint statevals substitute updatemode:client,both,hmccu ccutrace ccuget:Value,State loglevel:0,1,2,3,4,5,6 ". $readingFnAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -371,6 +372,7 @@ sub HMCCU_Get ($@)
|
|||||||
my $parfile = AttrVal ($name, "parfile", '');
|
my $parfile = AttrVal ($name, "parfile", '');
|
||||||
my $statedatapoint = AttrVal ($name, "statedatapoint", 'STATE');
|
my $statedatapoint = AttrVal ($name, "statedatapoint", 'STATE');
|
||||||
my $substitute = AttrVal ($name, 'substitute', '');
|
my $substitute = AttrVal ($name, 'substitute', '');
|
||||||
|
my $rpcport = AttrVal ($name, 'rpcport', '2001');
|
||||||
|
|
||||||
my $readname;
|
my $readname;
|
||||||
my $readaddr;
|
my $readaddr;
|
||||||
@ -427,7 +429,7 @@ sub HMCCU_Get ($@)
|
|||||||
push (@chnlist, $objname);
|
push (@chnlist, $objname);
|
||||||
}
|
}
|
||||||
if (@chnlist == 0) {
|
if (@chnlist == 0) {
|
||||||
return HMCCUDEV_SetError ($hash, "Usage: get $name channel {channel-name|channel-address}[.{datapoint-expr}] [...]");
|
return HMCCU_SetError ($hash, "Usage: get $name channel {channel-name|channel-address}[.{datapoint-expr}] [...]");
|
||||||
}
|
}
|
||||||
|
|
||||||
($rc, $result) = HMCCU_GetChannel ($hash, \@chnlist);
|
($rc, $result) = HMCCU_GetChannel ($hash, \@chnlist);
|
||||||
@ -439,8 +441,13 @@ sub HMCCU_Get ($@)
|
|||||||
elsif ($opt eq 'update') {
|
elsif ($opt eq 'update') {
|
||||||
my $devexp = shift @a;
|
my $devexp = shift @a;
|
||||||
$devexp = '.*' if (!defined ($devexp));
|
$devexp = '.*' if (!defined ($devexp));
|
||||||
|
my $ccuget = shift @a;
|
||||||
|
$ccuget = 'Attr' if (!defined ($ccuget));
|
||||||
|
if ($ccuget !~ /^(Attr|State|Value)$/) {
|
||||||
|
return HMCCU_SetError ($hash, "Usage: get $name update [device-expr [{'State'|'Value'}]]");
|
||||||
|
}
|
||||||
|
|
||||||
my ($c_ok, $c_err) = HMCCU_UpdateClients ($hash, $devexp);
|
my ($c_ok, $c_err) = HMCCU_UpdateClients ($hash, $devexp, $ccuget);
|
||||||
|
|
||||||
return "$c_ok client devices successfully updated. Update for $c_err client devices failed";
|
return "$c_ok client devices successfully updated. Update for $c_err client devices failed";
|
||||||
}
|
}
|
||||||
@ -477,16 +484,26 @@ sub HMCCU_Get ($@)
|
|||||||
elsif ($opt eq 'deviceinfo') {
|
elsif ($opt eq 'deviceinfo') {
|
||||||
my $device = shift @a;
|
my $device = shift @a;
|
||||||
|
|
||||||
return HMCCU_SetError ($hash, "Usage: get $name deviceinfo {device-name|device-address}") if (!defined ($device));
|
return HMCCU_SetError ($hash, "Usage: get $name deviceinfo {device-name|device-address} [{'State'|'Value'}]") if (!defined ($device));
|
||||||
|
|
||||||
$result = HMCCU_GetDeviceInfo ($hash, $device);
|
my $ccuget = shift @a;
|
||||||
|
$ccuget = 'Attr' if (!defined ($ccuget));
|
||||||
|
if ($ccuget !~ /^(Attr|State|Value)$/) {
|
||||||
|
return HMCCU_SetError ($hash, "Usage: get $name deviceinfo {device-name|device-address} [{'State'|'Value'}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = HMCCU_GetDeviceInfo ($hash, $device, $ccuget);
|
||||||
return HMCCU_SetError ($hash, -2) if ($result eq '');
|
return HMCCU_SetError ($hash, -2) if ($result eq '');
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
elsif ($opt eq 'rpcstate') {
|
elsif ($opt eq 'rpcstate') {
|
||||||
my $pid = HMCCU_CheckProcess ($hash);
|
my @pidlist;
|
||||||
if ($pid > 0) {
|
foreach my $port (split (',', $rpcport)) {
|
||||||
return "RPC process running with pid $pid";
|
my $pid = HMCCU_CheckProcess ($hash, $port);
|
||||||
|
push (@pidlist, $pid) if ($pid > 0);
|
||||||
|
}
|
||||||
|
if (@pidlist > 0) {
|
||||||
|
return "RPC process(es) running with pid(s) ".join (',', @pidlist);;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "RPC process not running";
|
return "RPC process not running";
|
||||||
@ -513,7 +530,7 @@ sub HMCCU_Get ($@)
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return "Read ".$hash->{DevCount}." devices/channels from CCU";
|
||||||
}
|
}
|
||||||
elsif ($opt eq 'config') {
|
elsif ($opt eq 'config') {
|
||||||
my $ccuobj = shift @a;
|
my $ccuobj = shift @a;
|
||||||
@ -831,9 +848,9 @@ sub HMCCU_SubstRule ($$$)
|
|||||||
# Update all datapoint/readings of all client devices
|
# Update all datapoint/readings of all client devices
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
sub HMCCU_UpdateClients ($$)
|
sub HMCCU_UpdateClients ($$$)
|
||||||
{
|
{
|
||||||
my ($hash, $devexp) = @_;
|
my ($hash, $devexp, $ccuget) = @_;
|
||||||
my $c_ok = 0;
|
my $c_ok = 0;
|
||||||
my $c_err = 0;
|
my $c_err = 0;
|
||||||
|
|
||||||
@ -844,7 +861,7 @@ sub HMCCU_UpdateClients ($$)
|
|||||||
next if ($ch->{NAME} !~ /$devexp/);
|
next if ($ch->{NAME} !~ /$devexp/);
|
||||||
next if (!defined ($ch->{IODev}) || !defined ($ch->{ccuaddr}));
|
next if (!defined ($ch->{IODev}) || !defined ($ch->{ccuaddr}));
|
||||||
|
|
||||||
my $rc = HMCCU_GetUpdate ($ch, $ch->{ccuaddr});
|
my $rc = HMCCU_GetUpdate ($ch, $ch->{ccuaddr}, $ccuget);
|
||||||
if ($rc <= 0) {
|
if ($rc <= 0) {
|
||||||
$c_err++;
|
$c_err++;
|
||||||
}
|
}
|
||||||
@ -955,48 +972,57 @@ sub HMCCU_StartRPCServer ($)
|
|||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
my $modpath = AttrVal ('global', 'modpath', '/opt/fhem');
|
my $modpath = AttrVal ('global', 'modpath', '/opt/fhem');
|
||||||
my $logfile = $modpath."/log/ccurpcd.log";
|
my $logfile = $modpath."/log/ccurpcd";
|
||||||
my $rpcqueue = AttrVal ($name, 'rpcqueue', '/tmp/ccuqueue');
|
my $rpcqueue = AttrVal ($name, 'rpcqueue', '/tmp/ccuqueue');
|
||||||
my $rpcport = AttrVal ($name, 'rpcport', '2001');
|
my $rpcport = AttrVal ($name, 'rpcport', '2001');
|
||||||
|
|
||||||
my $rc = HMCCU_IsRPCServerRunning ($hash);
|
my @hm_pids;
|
||||||
if ($rc > 0) {
|
my @ex_pids;
|
||||||
Log 1, "HMCCU: RPC Server already running";
|
HMCCU_IsRPCServerRunning ($hash, \@hm_pids, \@ex_pids);
|
||||||
return 1;
|
if (@hm_pids > 0) {
|
||||||
|
Log 1, "HMCCU: RPC server(s) already running with PIDs ".join (',', @hm_pids);
|
||||||
|
return scalar (@hm_pids);
|
||||||
}
|
}
|
||||||
elsif ($rc < 0) {
|
elsif (@ex_pids > 0) {
|
||||||
Log 1, "HMCCU: Externally launched RPC server detected. Kill process manually with command kill -SIGINT ".(-$rc);
|
Log 1, "HMCCU: Externally launched RPC server(s) detected. Kill process(es) manually with command kill -SIGINT pid for pid=".join (',', @ex_pids);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if RPC server exists
|
# Check if RPC server exists
|
||||||
my $rpcserver = $modpath."/FHEM/ccurpcd.pl";
|
my $rpcserver = $modpath."/FHEM/ccurpcd.pl";
|
||||||
if (! -e $rpcserver) {
|
if (! -e $rpcserver) {
|
||||||
Log 1, "HMCCU: RPC server not found";
|
Log 1, "HMCCU: RPC server file ccurpcd.pl not found";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fork child process
|
# Fork child process(es)
|
||||||
my $pid = fork ();
|
foreach my $port (split (',', $rpcport)) {
|
||||||
if (!defined ($pid)) {
|
my $rpcqueueport = $rpcqueue."_".$port;
|
||||||
Log 1, "HMCCU: Can't fork child process";
|
my $logfileport = $logfile."_".$port.".log";
|
||||||
return 0;
|
|
||||||
|
my $pid = fork ();
|
||||||
|
if (!defined ($pid)) {
|
||||||
|
Log 1, "HMCCU: Can't fork child process for CCU port $port";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$pid) {
|
||||||
|
# Child process, replace it by RPC server
|
||||||
|
exec ($rpcserver." ".$hash->{host}." ".$port." ".$rpcqueueport." ".$logfileport);
|
||||||
|
|
||||||
|
# When we reach this line start of RPC server failed and child
|
||||||
|
# process can exit.
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
|
push (@hm_pids, $pid);
|
||||||
|
Log 1, "HMCCU: RPC server started with pid ".$pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$pid) {
|
$hash->{RPCPID} = join (',', @hm_pids);
|
||||||
# Child process, replace it by RPC server
|
|
||||||
exec ($rpcserver." ".$hash->{host}." ".$rpcport." ".$rpcqueue." ".$logfile);
|
|
||||||
|
|
||||||
# When we reach this line start of RPC server failed and child
|
|
||||||
# process can exit.
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log 1, "HMCCU: RPC server started with pid ".$pid;
|
|
||||||
$hash->{RPCPID} = $pid;
|
|
||||||
$hash->{RPCPRC} = $rpcserver;
|
$hash->{RPCPRC} = $rpcserver;
|
||||||
|
|
||||||
return $pid;
|
return scalar (@hm_pids);
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
@ -1007,69 +1033,89 @@ sub HMCCU_StopRPCServer ($)
|
|||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
my $rc = HMCCU_IsRPCServerRunning ($hash);
|
my @hm_pids;
|
||||||
if ($rc > 0) {
|
my @ex_pids;
|
||||||
Log 1, "HMCCU: Stopping RPC server";
|
HMCCU_IsRPCServerRunning ($hash, \@hm_pids, \@ex_pids);
|
||||||
kill ('INT', $hash->{RPCPID});
|
if (@hm_pids > 0) {
|
||||||
$hash->{RPCPID} = 0;
|
foreach my $pid (@hm_pids) {
|
||||||
|
Log 1, "HMCCU: Stopping RPC server with PID $pid";
|
||||||
|
kill ('INT', $pid);
|
||||||
|
}
|
||||||
|
$hash->{RPCPID} = '0';
|
||||||
$hash->{RPCPRC} = 'none';
|
$hash->{RPCPRC} = 'none';
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
elsif ($rc < 0) {
|
|
||||||
Log 1, "HMCCU: Externally launched RPC server detected. Kill process manually with command kill -SIGINT ".(-$rc);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log 1, "HMCCU: RPC server not running";
|
Log 1, "HMCCU: RPC server not running";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (@ex_pids > 0) {
|
||||||
|
foreach my $pid (@ex_pids) {
|
||||||
|
Log 1, "HMCCU: Externally launched RPC server detected. Kill process manually with command kill -SIGINT $pid";
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# Check if RPC server is running
|
# Check if RPC server is running. Return list of PIDs:
|
||||||
# 0 = Not running
|
# Empty = No process running.
|
||||||
# 1 = Running
|
# >1 = PID of RPC server launched by HMCCU
|
||||||
# <0 = Externally launched RPC server
|
# <0 = PID of externally launched RPC server
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
sub HMCCU_IsRPCServerRunning ($)
|
sub HMCCU_IsRPCServerRunning ($$$)
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash, $hm_pids, $ex_pids) = @_;
|
||||||
|
|
||||||
my $pid = HMCCU_CheckProcess ($hash);
|
my @rpcpids;
|
||||||
|
if (defined ($hash->{RPCPID}) && $hash->{RPCPID} ne '0') {
|
||||||
|
@rpcpids = split (',', $hash->{RPCPID});
|
||||||
|
}
|
||||||
|
|
||||||
if (defined ($hash->{RPCPID}) && $hash->{RPCPID} > 0) {
|
my $rpcport = AttrVal ($hash->{NAME}, 'rpcport', '2001');
|
||||||
return -$pid if ($pid != $hash->{RPCPID});
|
foreach my $port (split (',', $rpcport)) {
|
||||||
my $procstate = kill (0, $hash->{RPCPID}) ? 1 : 0;
|
my $pid = HMCCU_CheckProcess ($hash, $port);
|
||||||
if (! $procstate) {
|
next if ($pid == 0);
|
||||||
$hash->{RPCPID} = 0;
|
if (grep { $_ eq $pid } @rpcpids) {
|
||||||
$hash->{RPCPRC} = 'none';
|
if (kill (0, $pid)) {
|
||||||
|
push (@$hm_pids, $pid);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
push (@$ex_pids, $pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
push (@$ex_pids, $pid);
|
||||||
}
|
}
|
||||||
return $procstate;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return -$pid if ($pid > 0);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (@$hm_pids > 0 || @$ex_pids > 0) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# Get PID of RPC server process (0=not running)
|
# Get PID of RPC server process (0=not running)
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
sub HMCCU_CheckProcess ($)
|
sub HMCCU_CheckProcess ($$)
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash, $port) = @_;
|
||||||
|
|
||||||
return 0 if (!defined ($hash->{RPCPRC}) || $hash->{RPCPRC} eq 'none');
|
# return 0 if (!defined ($hash->{RPCPRC}) || $hash->{RPCPRC} eq 'none');
|
||||||
|
|
||||||
my $pdump = `ps -ef | grep $hash->{RPCPRC} | grep -v grep`;
|
my $modpath = AttrVal ('global', 'modpath', '/opt/fhem');
|
||||||
|
my $rpcserver = $modpath."/FHEM/ccurpcd.pl";
|
||||||
|
my $pdump = `ps -ef | grep $rpcserver | grep -v grep`;
|
||||||
my @plist = split "\n", $pdump;
|
my @plist = split "\n", $pdump;
|
||||||
|
|
||||||
foreach my $proc (@plist) {
|
foreach my $proc (@plist) {
|
||||||
# Remove leading blanks, fix for MacOS. Thanks to mcdeck
|
# Remove leading blanks, fix for MacOS. Thanks to mcdeck
|
||||||
$proc =~ s/^\s+//;
|
$proc =~ s/^\s+//;
|
||||||
my @procattr = split /\s+/, $proc;
|
my @procattr = split /\s+/, $proc;
|
||||||
return $procattr[1] if ($procattr[1] != $$ && $procattr[7] =~ /perl$/ && $procattr[8] eq $hash->{RPCPRC});
|
return $procattr[1] if ($procattr[1] != $$ && $procattr[7] =~ /perl$/ && $procattr[8] eq $rpcserver &&
|
||||||
|
$procattr[10] eq "$port");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1079,22 +1125,15 @@ sub HMCCU_CheckProcess ($)
|
|||||||
# Get channel and datapoints of CCU device
|
# Get channel and datapoints of CCU device
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
sub HMCCU_GetDeviceInfo ($$)
|
sub HMCCU_GetDeviceInfo ($$$)
|
||||||
{
|
{
|
||||||
my ($hash, $device) = @_;
|
my ($hash, $device, $ccuget) = @_;
|
||||||
my $devname = '';
|
my $devname = '';
|
||||||
my $hmccu_hash;
|
|
||||||
|
|
||||||
if ($hash->{TYPE} ne 'HMCCU') {
|
my $hmccu_hash = HMCCU_GetHash ($hash);
|
||||||
# Get hash of HMCCU IO device
|
return '' if (!defined ($hmccu_hash));
|
||||||
return '' if (!exists ($hash->{IODev}));
|
|
||||||
$hmccu_hash = $hash->{IODev};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# Hash of HMCCU IO device supplied as parameter
|
|
||||||
$hmccu_hash = $hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$ccuget = HMCCU_GetAttribute ($hmccu_hash, $hash, 'ccuget', 'Value') if ($ccuget eq 'Attr');
|
||||||
my $ccutrace = AttrVal ($hmccu_hash->{NAME}, 'ccutrace', '');
|
my $ccutrace = AttrVal ($hmccu_hash->{NAME}, 'ccutrace', '');
|
||||||
|
|
||||||
my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($device, 0);
|
my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($device, 0);
|
||||||
@ -1117,7 +1156,7 @@ foreach (chnid, odev.Channels())
|
|||||||
foreach(sDPId, ochn.DPs().EnumUsedIDs())
|
foreach(sDPId, ochn.DPs().EnumUsedIDs())
|
||||||
{
|
{
|
||||||
object oDP = dom.GetObject(sDPId);
|
object oDP = dom.GetObject(sDPId);
|
||||||
WriteLine (" DP " # oDP.Name() # " = " # oDP.Value());
|
WriteLine (" DP " # oDP.Name() # " = " # oDP.$ccuget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -1125,7 +1164,7 @@ foreach (chnid, odev.Channels())
|
|||||||
my $response = HMCCU_HMScript ($hmccu_hash->{host}, $script);
|
my $response = HMCCU_HMScript ($hmccu_hash->{host}, $script);
|
||||||
if ($ccutrace ne '' && ($device =~ /$ccutrace/ || $devname =~ /$ccutrace/)) {
|
if ($ccutrace ne '' && ($device =~ /$ccutrace/ || $devname =~ /$ccutrace/)) {
|
||||||
Log 1, "HMCCU: Device=$device Devname=$devname";
|
Log 1, "HMCCU: Device=$device Devname=$devname";
|
||||||
Log 1, "HMCCU: Script response = ".$response;
|
Log 1, "HMCCU: Script response = \n".$response;
|
||||||
Log 1, "HMCCU: Script = ".$script;
|
Log 1, "HMCCU: Script = ".$script;
|
||||||
}
|
}
|
||||||
return $response;
|
return $response;
|
||||||
@ -1351,7 +1390,7 @@ sub HMCCU_GetCCUObjectAttribute ($$)
|
|||||||
{
|
{
|
||||||
my ($object, $attr) = @_;
|
my ($object, $attr) = @_;
|
||||||
|
|
||||||
my $hash = HMCCU_GetHash ();
|
my $hash = HMCCU_GetHash (0);
|
||||||
my $url = 'http://'.$hash->{host}.':8181/do.exe?r1=dom.GetObject("'.$object.'").'.$attr;
|
my $url = 'http://'.$hash->{host}.':8181/do.exe?r1=dom.GetObject("'.$object.'").'.$attr;
|
||||||
my $response = GetFileFromURL ($url);
|
my $response = GetFileFromURL ($url);
|
||||||
if (defined ($response) && $response !~ /<r1>null</) {
|
if (defined ($response) && $response !~ /<r1>null</) {
|
||||||
@ -1368,8 +1407,20 @@ sub HMCCU_GetCCUObjectAttribute ($$)
|
|||||||
# Useful for client devices.
|
# Useful for client devices.
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
sub HMCCU_GetHash
|
sub HMCCU_GetHash ($@)
|
||||||
{
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
if (defined ($hash) && $hash != 0) {
|
||||||
|
if ($hash->{TYPE} eq 'HMCCUDEV' || $hash->{TYPE} eq 'HMCCUCHN') {
|
||||||
|
return $hash->{IODev} if (exists ($hash->{IODev}));
|
||||||
|
}
|
||||||
|
elsif ($hash->{TYPE} eq 'HMCCU') {
|
||||||
|
return $hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Search for HMCCU device
|
||||||
foreach my $dn (sort keys %defs) {
|
foreach my $dn (sort keys %defs) {
|
||||||
return $defs{$dn} if ($defs{$dn}->{TYPE} eq 'HMCCU');
|
return $defs{$dn} if ($defs{$dn}->{TYPE} eq 'HMCCU');
|
||||||
}
|
}
|
||||||
@ -1377,10 +1428,32 @@ sub HMCCU_GetHash
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
# Get attribute of client device with fallback to
|
||||||
|
# attribute of IO device.
|
||||||
|
####################################################
|
||||||
|
|
||||||
|
sub HMCCU_GetAttribute ($$$$)
|
||||||
|
{
|
||||||
|
my ($hmccu_hash, $cl_hash, $attr_name, $attr_def) = @_;
|
||||||
|
|
||||||
|
my $value = AttrVal ($cl_hash->{NAME}, $attr_name, '');
|
||||||
|
$value = AttrVal ($hmccu_hash->{NAME}, $attr_name, $attr_def) if ($value eq '');
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
# Submit HTTP request to CCU.
|
||||||
|
# If parameter $val is specified datapoint wil be
|
||||||
|
# set to value.
|
||||||
|
####################################################
|
||||||
|
|
||||||
sub HMCCU_HTTPRequest ($@)
|
sub HMCCU_HTTPRequest ($@)
|
||||||
{
|
{
|
||||||
my ($hash, $int, $add, $chn, $dpt, $val) = @_;
|
my ($hash, $int, $add, $chn, $dpt, $val) = @_;
|
||||||
|
|
||||||
|
my $ccuget = AttrVal ($hash->{NAME}, 'ccuget', 'Value');
|
||||||
my $host = $hash->{host};
|
my $host = $hash->{host};
|
||||||
my $addr = $int.'.'.$add.':'.$chn.'.'.$dpt;
|
my $addr = $int.'.'.$add.':'.$chn.'.'.$dpt;
|
||||||
my $url = 'http://'.$host.':8181/do.exe?r1=dom.GetObject("'.$addr.'")';
|
my $url = 'http://'.$host.':8181/do.exe?r1=dom.GetObject("'.$addr.'")';
|
||||||
@ -1389,7 +1462,7 @@ sub HMCCU_HTTPRequest ($@)
|
|||||||
$url .= '.State("'.$val.'")';
|
$url .= '.State("'.$val.'")';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$url .= '.State()';
|
$url .= '.$ccuget()';
|
||||||
}
|
}
|
||||||
|
|
||||||
my $response = GetFileFromURL ($url);
|
my $response = GetFileFromURL ($url);
|
||||||
@ -1420,38 +1493,42 @@ sub HMCCU_ReadRPCQueue ($)
|
|||||||
my $rpcinterval = AttrVal ($name, 'rpcinterval', 5);
|
my $rpcinterval = AttrVal ($name, 'rpcinterval', 5);
|
||||||
my $ccureadingformat = AttrVal ($name, 'ccureadingformat', 'name');
|
my $ccureadingformat = AttrVal ($name, 'ccureadingformat', 'name');
|
||||||
my $rpcqueue = AttrVal ($name, 'rpcqueue', '/tmp/ccuqueue');
|
my $rpcqueue = AttrVal ($name, 'rpcqueue', '/tmp/ccuqueue');
|
||||||
|
my $rpcport = AttrVal ($name, 'rpcport', '2001');
|
||||||
|
|
||||||
my $queue = new RPCQueue (File => $rpcqueue, Mode => 0666);
|
my @portlist = split (',', $rpcport);
|
||||||
|
foreach my $port (@portlist) {
|
||||||
|
my $queue = new RPCQueue (File => $rpcqueue."_".$port, Mode => 0666);
|
||||||
|
|
||||||
my $element = $queue->deq();
|
my $element = $queue->deq();
|
||||||
while ($element) {
|
while ($element) {
|
||||||
$HMCCU_EventTime = time () if ($eventno == 0);
|
$HMCCU_EventTime = time () if ($eventno == 0);
|
||||||
my @Tokens = split (/\|/, $element);
|
my @Tokens = split (/\|/, $element);
|
||||||
if ($Tokens[0] eq 'EV') {
|
if ($Tokens[0] eq 'EV') {
|
||||||
# Log 2, "HMCCU: Event from ".$Tokens[1]." dp=".$Tokens[2]." val=".$Tokens[3];
|
# Log 2, "HMCCU: Event from ".$Tokens[1]." dp=".$Tokens[2]." val=".$Tokens[3];
|
||||||
my ($add, $chn) = split (/:/, $Tokens[1]);
|
my ($add, $chn) = split (/:/, $Tokens[1]);
|
||||||
my $reading = HMCCU_GetReadingName ('', $add, $chn, $Tokens[2], '',
|
my $reading = HMCCU_GetReadingName ('', $add, $chn, $Tokens[2], '',
|
||||||
$ccureadingformat);
|
$ccureadingformat);
|
||||||
HMCCU_UpdateClientReading ($hash, $add, $chn, $reading, $Tokens[3], 'rpcevent');
|
HMCCU_UpdateClientReading ($hash, $add, $chn, $reading, $Tokens[3], 'rpcevent');
|
||||||
$eventno++;
|
$eventno++;
|
||||||
last if ($eventno == $maxevents);
|
last if ($eventno == $maxevents);
|
||||||
}
|
}
|
||||||
elsif ($Tokens[0] eq 'ND') {
|
elsif ($Tokens[0] eq 'ND') {
|
||||||
# push (@newdevices, $Tokens[1]);
|
# push (@newdevices, $Tokens[1]);
|
||||||
}
|
}
|
||||||
elsif ($Tokens[0] eq 'DD') {
|
elsif ($Tokens[0] eq 'DD') {
|
||||||
# push (@deldevices, $Tokens[1]);
|
# push (@deldevices, $Tokens[1]);
|
||||||
}
|
}
|
||||||
elsif ($Tokens[0] eq 'EX') {
|
elsif ($Tokens[0] eq 'EX') {
|
||||||
Log 1, "HMCCU: Received EX event. RPC server terminated.";
|
Log 1, "HMCCU: Received EX event. RPC server terminated.";
|
||||||
$f = 1;
|
$f = 1;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Log 1,"HMCCU: Unknown RPC event type ".$Tokens[0];
|
# Log 1,"HMCCU: Unknown RPC event type ".$Tokens[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$element = $queue->deq();
|
$element = $queue->deq();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($HMCCU_EventTime > 0 && time()-$HMCCU_EventTime > 300) {
|
if ($HMCCU_EventTime > 0 && time()-$HMCCU_EventTime > 300) {
|
||||||
@ -1461,18 +1538,23 @@ sub HMCCU_ReadRPCQueue ($)
|
|||||||
# HMCCU_DeleteDevices (\@deldevices) if (@deldevices > 0);
|
# HMCCU_DeleteDevices (\@deldevices) if (@deldevices > 0);
|
||||||
# HMCCU_NewDevices (\@newdevices) if (@newdevices > 0);
|
# HMCCU_NewDevices (\@newdevices) if (@newdevices > 0);
|
||||||
|
|
||||||
my $rc = HMCCU_IsRPCServerRunning ($hash);
|
my @hm_pids;
|
||||||
if ($f == 0 && $rc > 0) {
|
my @ex_pids;
|
||||||
|
HMCCU_IsRPCServerRunning ($hash, \@hm_pids, \@ex_pids);
|
||||||
|
if ($f == 0 && @hm_pids > 0) {
|
||||||
|
if (scalar (@hm_pids) != scalar (@portlist)) {
|
||||||
|
Log 1, "HMCCU: Number of RPC server process differs from number of CCU destination ports";
|
||||||
|
}
|
||||||
InternalTimer (gettimeofday()+$rpcinterval, 'HMCCU_ReadRPCQueue', $hash, 0);
|
InternalTimer (gettimeofday()+$rpcinterval, 'HMCCU_ReadRPCQueue', $hash, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($rc < 0) {
|
if (@ex_pids > 0) {
|
||||||
Log 1, "HMCCU: Externally launched RPC server detected. Kill process manually with command kill -SIGINT ".(-$rc);
|
Log 1, "HMCCU: Externally launched RPC server(s) detected. Kill process(es) manually with command kill -SIGINT pid for pids ".join (',', @ex_pids);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log 1, "HMCCU: RPC server has been shut down. f=$f";
|
Log 1, "HMCCU: RPC server has been shut down. f=$f";
|
||||||
}
|
}
|
||||||
$hash->{RPCPID} = 0;
|
$hash->{RPCPID} = '0';
|
||||||
$hash->{RPCPRC} = 'none';
|
$hash->{RPCPRC} = 'none';
|
||||||
$attr{$name}{rpcserver} = "off";
|
$attr{$name}{rpcserver} = "off";
|
||||||
}
|
}
|
||||||
@ -1514,31 +1596,25 @@ sub HMCCU_GetDatapoint ($@)
|
|||||||
my $hmccu_hash;
|
my $hmccu_hash;
|
||||||
my $value = '';
|
my $value = '';
|
||||||
|
|
||||||
|
$hmccu_hash = HMCCU_GetHash ($hash);
|
||||||
|
return (-3, $value) if (!defined ($hmccu_hash));
|
||||||
|
|
||||||
my $ccureadings = AttrVal ($name, 'ccureadings', 1);
|
my $ccureadings = AttrVal ($name, 'ccureadings', 1);
|
||||||
my $readingformat = AttrVal ($name, 'ccureadingformat', 'name');
|
my $readingformat = AttrVal ($name, 'ccureadingformat', 'name');
|
||||||
my $substitute = AttrVal ($name, 'substitute', '');
|
my $substitute = AttrVal ($name, 'substitute', '');
|
||||||
my $statedpt = AttrVal ($name, 'statedatapoint', 'STATE');
|
my $statedpt = AttrVal ($name, 'statedatapoint', 'STATE');
|
||||||
my $statechn = AttrVal ($name, 'statechannel', '');
|
my $statechn = AttrVal ($name, 'statechannel', '');
|
||||||
|
|
||||||
if ($hash->{TYPE} ne 'HMCCU') {
|
my $ccuget = HMCCU_GetAttribute ($hmccu_hash, $hash, 'ccuget', 'Value');
|
||||||
# Get hash of HMCCU IO device
|
|
||||||
return (-3, $value) if (!exists ($hash->{IODev}));
|
|
||||||
$hmccu_hash = $hash->{IODev};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# Hash of HMCCU IO device supplied as parameter
|
|
||||||
$hmccu_hash = $hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $ccutrace = AttrVal ($hmccu_hash->{NAME}, 'ccutrace', '');
|
my $ccutrace = AttrVal ($hmccu_hash->{NAME}, 'ccutrace', '');
|
||||||
|
|
||||||
my $url = 'http://'.$hmccu_hash->{host}.':8181/do.exe?r1=dom.GetObject("';
|
my $url = 'http://'.$hmccu_hash->{host}.':8181/do.exe?r1=dom.GetObject("';
|
||||||
my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($param, $HMCCU_FLAG_INTERFACE);
|
my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($param, $HMCCU_FLAG_INTERFACE);
|
||||||
if ($flags == $HMCCU_FLAGS_IACD) {
|
if ($flags == $HMCCU_FLAGS_IACD) {
|
||||||
$url .= $int.'.'.$add.':'.$chn.'.'.$dpt.'").State()';
|
$url .= $int.'.'.$add.':'.$chn.'.'.$dpt.'").$ccuget()';
|
||||||
}
|
}
|
||||||
elsif ($flags == $HMCCU_FLAGS_NCD) {
|
elsif ($flags == $HMCCU_FLAGS_NCD) {
|
||||||
$url .= $nam.'").DPByHssDP("'.$dpt.'").State()';
|
$url .= $nam.'").DPByHssDP("'.$dpt.'").$ccuget()';
|
||||||
($add, $chn) = HMCCU_GetAddress ($nam, '', '');
|
($add, $chn) = HMCCU_GetAddress ($nam, '', '');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1589,17 +1665,9 @@ sub HMCCU_GetDatapoint ($@)
|
|||||||
sub HMCCU_SetDatapoint ($$$)
|
sub HMCCU_SetDatapoint ($$$)
|
||||||
{
|
{
|
||||||
my ($hash, $param, $value) = @_;
|
my ($hash, $param, $value) = @_;
|
||||||
my $hmccu_hash;
|
|
||||||
|
|
||||||
if ($hash->{TYPE} ne 'HMCCU') {
|
my $hmccu_hash = HMCCU_GetHash ($hash);;
|
||||||
# Get hash of HMCCU IO device
|
return -3 if (!defined ($hmccu_hash));
|
||||||
return -3 if (!exists ($hash->{IODev}));
|
|
||||||
$hmccu_hash = $hash->{IODev};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# Hash of HMCCU IO device supplied as parameter
|
|
||||||
$hmccu_hash = $hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $url = 'http://'.$hmccu_hash->{host}.':8181/do.exe?r1=dom.GetObject("';
|
my $url = 'http://'.$hmccu_hash->{host}.':8181/do.exe?r1=dom.GetObject("';
|
||||||
my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($param, $HMCCU_FLAG_INTERFACE);
|
my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($param, $HMCCU_FLAG_INTERFACE);
|
||||||
@ -1680,21 +1748,24 @@ sub HMCCU_SetVariable ($$$)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################
|
########################################################
|
||||||
# Update all datapoints / readings of device or
|
# Update all datapoints / readings of device or
|
||||||
# channel considering attribute ccureadingfilter.
|
# channel considering attribute ccureadingfilter.
|
||||||
####################################################
|
# Parameter $ccuget can be 'State', 'Value' or 'Attr'.
|
||||||
|
########################################################
|
||||||
|
|
||||||
sub HMCCU_GetUpdate ($$)
|
sub HMCCU_GetUpdate ($$$)
|
||||||
{
|
{
|
||||||
my ($cl_hash, $addr) = @_;
|
my ($cl_hash, $addr, $ccuget) = @_;
|
||||||
|
|
||||||
|
my $hmccu_hash = HMCCU_GetHash ($cl_hash);
|
||||||
|
return -3 if (!defined ($hmccu_hash));
|
||||||
|
|
||||||
return -3 if (!exists ($cl_hash->{IODev}));
|
|
||||||
my $hmccu_hash = $cl_hash->{IODev};
|
|
||||||
my $nam = '';
|
my $nam = '';
|
||||||
my $script;
|
my $script;
|
||||||
|
|
||||||
my $cn = $cl_hash->{NAME};
|
my $cn = $cl_hash->{NAME};
|
||||||
|
$ccuget = HMCCU_GetAttribute ($hmccu_hash, $cl_hash, 'ccuget', 'Value') if ($ccuget eq 'Attr');
|
||||||
my $ccutrace = AttrVal ($hmccu_hash->{NAME}, 'ccutrace', '');
|
my $ccutrace = AttrVal ($hmccu_hash->{NAME}, 'ccutrace', '');
|
||||||
my $ccureadings = AttrVal ($cn, 'ccureadings', 1);
|
my $ccureadings = AttrVal ($cn, 'ccureadings', 1);
|
||||||
my $ccureadingfilter = AttrVal ($cn, 'ccureadingfilter', '.*');
|
my $ccureadingfilter = AttrVal ($cn, 'ccureadingfilter', '.*');
|
||||||
@ -1714,7 +1785,7 @@ object oChannel = dom.GetObject (sChnName);
|
|||||||
foreach(sDPId, oChannel.DPs().EnumUsedIDs())
|
foreach(sDPId, oChannel.DPs().EnumUsedIDs())
|
||||||
{
|
{
|
||||||
object oDP = dom.GetObject(sDPId);
|
object oDP = dom.GetObject(sDPId);
|
||||||
WriteLine (sChnName # "=" # oDP.Name() # "=" # oDP.Value());
|
WriteLine (sChnName # "=" # oDP.Name() # "=" # oDP.$ccuget());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1732,7 +1803,7 @@ foreach (chnid, odev.Channels())
|
|||||||
foreach(sDPId, ochn.DPs().EnumUsedIDs())
|
foreach(sDPId, ochn.DPs().EnumUsedIDs())
|
||||||
{
|
{
|
||||||
object oDP = dom.GetObject(sDPId);
|
object oDP = dom.GetObject(sDPId);
|
||||||
WriteLine (ochn.Name() # "=" # oDP.Name() # "=" # oDP.Value());
|
WriteLine (ochn.Name() # "=" # oDP.Name() # "=" # oDP.$ccuget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -1744,8 +1815,8 @@ foreach (chnid, odev.Channels())
|
|||||||
my $response = HMCCU_HMScript ($hmccu_hash->{host}, $script);
|
my $response = HMCCU_HMScript ($hmccu_hash->{host}, $script);
|
||||||
if ($ccutrace ne '' && ($addr =~ /$ccutrace/ || $nam =~ /$ccutrace/)) {
|
if ($ccutrace ne '' && ($addr =~ /$ccutrace/ || $nam =~ /$ccutrace/)) {
|
||||||
Log 1, "HMCCU: Addr=$addr Name=$nam";
|
Log 1, "HMCCU: Addr=$addr Name=$nam";
|
||||||
Log 1, "HMCCU: Script response = ".$response;
|
Log 1, "HMCCU: Script response = \n".$response;
|
||||||
Log 1, "HMCCU: Script = ".$script;
|
Log 1, "HMCCU: Script = \n".$script;
|
||||||
}
|
}
|
||||||
return -2 if ($response eq '');
|
return -2 if ($response eq '');
|
||||||
|
|
||||||
@ -1795,27 +1866,20 @@ sub HMCCU_GetChannel ($$)
|
|||||||
my ($hash, $chnref) = @_;
|
my ($hash, $chnref) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
my $hmccu_hash;
|
|
||||||
my %chnpars;
|
my %chnpars;
|
||||||
my $chnlist = '';
|
my $chnlist = '';
|
||||||
my $result = '';
|
my $result = '';
|
||||||
|
|
||||||
|
my $hmccu_hash = HMCCU_GetHash ($hash);
|
||||||
|
return (-3, $result) if (!defined ($hmccu_hash));;
|
||||||
|
|
||||||
|
my $ccuget = HMCCU_GetAttribute ($hmccu_hash, $hash, 'ccuget', 'Value');
|
||||||
my $ccureadings = AttrVal ($name, 'ccureadings', 1);
|
my $ccureadings = AttrVal ($name, 'ccureadings', 1);
|
||||||
my $readingformat = AttrVal ($name, 'ccureadingformat', 'name');
|
my $readingformat = AttrVal ($name, 'ccureadingformat', 'name');
|
||||||
my $defsubstitute = AttrVal ($name, 'substitute', '');
|
my $defsubstitute = AttrVal ($name, 'substitute', '');
|
||||||
my $statedpt = AttrVal ($name, 'statedatapoint', 'STATE');
|
my $statedpt = AttrVal ($name, 'statedatapoint', 'STATE');
|
||||||
my $statechn = AttrVal ($name, 'statechannel', '');
|
my $statechn = AttrVal ($name, 'statechannel', '');
|
||||||
|
|
||||||
if ($hash->{TYPE} ne 'HMCCU') {
|
|
||||||
# Get hash of HMCCU IO device
|
|
||||||
return (-3, $result) if (!exists ($hash->{IODev}));
|
|
||||||
$hmccu_hash = $hash->{IODev};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# Hash of HMCCU IO device supplied as parameter
|
|
||||||
$hmccu_hash = $hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Build channel list
|
# Build channel list
|
||||||
foreach my $chndef (@$chnref) {
|
foreach my $chndef (@$chnref) {
|
||||||
my ($channel, $substitute) = split /\s+/, $chndef;
|
my ($channel, $substitute) = split /\s+/, $chndef;
|
||||||
@ -1850,7 +1914,7 @@ foreach (sChannel, sChnList.Split(","))
|
|||||||
foreach(sDPId, oChannel.DPs().EnumUsedIDs())
|
foreach(sDPId, oChannel.DPs().EnumUsedIDs())
|
||||||
{
|
{
|
||||||
object oDP = dom.GetObject(sDPId);
|
object oDP = dom.GetObject(sDPId);
|
||||||
WriteLine (sChannel # "=" # oDP.Name() # "=" # oDP.Value());
|
WriteLine (sChannel # "=" # oDP.Name() # "=" # oDP.$ccuget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -1904,21 +1968,13 @@ sub HMCCU_RPCGetConfig ($$$)
|
|||||||
my ($hash, $param, $mode) = @_;
|
my ($hash, $param, $mode) = @_;
|
||||||
|
|
||||||
my $addr;
|
my $addr;
|
||||||
my $hmccu_hash;
|
|
||||||
my $result = '';
|
my $result = '';
|
||||||
|
|
||||||
my $ccureadings = AttrVal ($hash->{NAME}, 'ccureadings', 1);
|
my $ccureadings = AttrVal ($hash->{NAME}, 'ccureadings', 1);
|
||||||
my $readingformat = AttrVal ($hash->{NAME}, 'ccureadingformat', 'name');
|
my $readingformat = AttrVal ($hash->{NAME}, 'ccureadingformat', 'name');
|
||||||
|
|
||||||
if ($hash->{TYPE} ne 'HMCCU') {
|
my $hmccu_hash = HMCCU_GetHash ($hash);
|
||||||
# Get hash of HMCCU IO device
|
return (-3, $result) if (!defined ($hmccu_hash));
|
||||||
return (-3, $result) if (!exists ($hash->{IODev}));
|
|
||||||
$hmccu_hash = $hash->{IODev};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# Hash of HMCCU IO device supplied as parameter
|
|
||||||
$hmccu_hash = $hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $name = $hmccu_hash->{NAME};
|
my $name = $hmccu_hash->{NAME};
|
||||||
my $port = AttrVal ($name, 'rpcport', 2001);
|
my $port = AttrVal ($name, 'rpcport', 2001);
|
||||||
@ -2154,13 +2210,11 @@ sub HMCCU_Dewpoint ($$$$)
|
|||||||
<b>Get</b><br/><br/>
|
<b>Get</b><br/><br/>
|
||||||
<ul>
|
<ul>
|
||||||
<br/>
|
<br/>
|
||||||
<li>get <name> devstate {[<interface>.]<channel-address>|<channel-name>} [<reading>]
|
<li>get <name> devstate {[<interface>.]<channel-address>|<channel-name>} [<reading>]<br/>
|
||||||
<br/>
|
|
||||||
Get state of a CCU device. Specified channel must have a datapoint STATE. If <reading>
|
Get state of a CCU device. Specified channel must have a datapoint STATE. If <reading>
|
||||||
is specified the value will be stored using this name.
|
is specified the value will be stored using this name.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>get <name> vars <regexp>
|
<li>get <name> vars <regexp><br/>
|
||||||
<br/>
|
|
||||||
Get CCU system variables matching <regexp> and store them as readings.
|
Get CCU system variables matching <regexp> and store them as readings.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>get <name> channel {[<interface>.]<channel-address>[.<datapoint-expr>]|<channel-name>[.<datapoint-expr>]}[=[regexp1:subst1[,...]]] [...]
|
<li>get <name> channel {[<interface>.]<channel-address>[.<datapoint-expr>]|<channel-name>[.<datapoint-expr>]}[=[regexp1:subst1[,...]]] [...]
|
||||||
@ -2168,18 +2222,15 @@ sub HMCCU_Dewpoint ($$$$)
|
|||||||
Get value of datapoint(s). If no datapoint is specified all datapoints of specified
|
Get value of datapoint(s). If no datapoint is specified all datapoints of specified
|
||||||
channel are read. <datapoint> can be specified as a regular expression.
|
channel are read. <datapoint> can be specified as a regular expression.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>get <name> deviceinfo <device-name>
|
<li>get <name> deviceinfo <device-name> [{'State'|'Value'}]<br/>
|
||||||
<br/>
|
|
||||||
List device channels and datapoints.
|
List device channels and datapoints.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>get <name> devicelist [dump]
|
<li>get <name> devicelist [dump]<br/>
|
||||||
<br/>
|
|
||||||
Read list of devices and channels from CCU. This command is executed automatically after device
|
Read list of devices and channels from CCU. This command is executed automatically after device
|
||||||
definition. Must be executed after module HMCCU is reloaded. With option dump devices are displayed
|
definition. Must be executed after module HMCCU is reloaded. With option dump devices are displayed
|
||||||
in browser window.
|
in browser window.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>get <name> parfile [<parfile>]
|
<li>get <name> parfile [<parfile>]<br/>
|
||||||
<br/>
|
|
||||||
Get values of all channels / datapoints specified in <parfile>. <parfile> can also
|
Get values of all channels / datapoints specified in <parfile>. <parfile> can also
|
||||||
be defined as an attribute. The file must contain one channel / datapoint definition per line.
|
be defined as an attribute. The file must contain one channel / datapoint definition per line.
|
||||||
Datapoints are optional (for syntax see command <i>get channel</i>). After the channel definition
|
Datapoints are optional (for syntax see command <i>get channel</i>). After the channel definition
|
||||||
@ -2191,12 +2242,10 @@ sub HMCCU_Dewpoint ($$$$)
|
|||||||
<br/><br/>
|
<br/><br/>
|
||||||
Empty lines or lines starting with a # are ignored.
|
Empty lines or lines starting with a # are ignored.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>get <name> rpcstate
|
<li>get <name> rpcstate<br/>
|
||||||
<br/>
|
|
||||||
Check if RPC server process is running.
|
Check if RPC server process is running.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>get <name> update [<devexp>]
|
<li>get <name> update [<devexp> [<'State'|'Value'>]]<br/>
|
||||||
<br/>
|
|
||||||
Update all datapoint / readings of client devices with device name matching <devexp>
|
Update all datapoint / readings of client devices with device name matching <devexp>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -2206,60 +2255,56 @@ sub HMCCU_Dewpoint ($$$$)
|
|||||||
<b>Attributes</b><br/>
|
<b>Attributes</b><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<ul>
|
<ul>
|
||||||
<li>ccureadingformat <name | address>
|
<li>ccuget <State | Value><br/>
|
||||||
<br/>
|
Set read access method for CCU channel datapoints. Method 'State' is slower than 'Value' because
|
||||||
Format of reading names (channel name or channel address)
|
each request is sent to the device. With method 'Value' only CCU is queried. Default is 'Value'.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>ccureadings <0 | 1>
|
<li>ccureadingformat <name | address><br/>
|
||||||
<br/>
|
Format of reading names (channel name or channel address)
|
||||||
If set to 1 values read from CCU will be stored as readings. Otherwise output
|
|
||||||
is displayed in browser window.
|
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>parfile <filename>
|
<li>ccureadings <0 | 1><br/>
|
||||||
<br/>
|
If set to 1 values read from CCU will be stored as readings. Otherwise output
|
||||||
Define parameter file for command <i>get parfile</i>.
|
is displayed in browser window.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>rpcinterval <3 | 5 | 10>
|
<li>ccutrace <ccu-devname-exp|ccu-address-exp><br/>
|
||||||
<br/>
|
Turn on trace mode for devices matching specified expression. Will write extended
|
||||||
Specifiy how often RPC queue is read. Default is 5 seconds.
|
information into FHEM log (level 1).
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>rpcport <value>
|
<li>parfile <filename><br/>
|
||||||
<br/>
|
Define parameter file for command <i>get parfile</i>.
|
||||||
Specify RPC port on CCU. Default is 2001.
|
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>rpcqueue <queue-file>
|
<li>rpcinterval <3 | 5 | 10><br/>
|
||||||
<br/>
|
Specifiy how often RPC queue is read. Default is 5 seconds.
|
||||||
Specify name of RPC queue file. This parameter is only a prefix for the
|
|
||||||
queue files with extension .idx and .dat. Default is /tmp/ccuqueue.
|
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>rpcserver <on | off>
|
<li>rpcport <value[,...]><br/>
|
||||||
<br/>
|
Specify list of RPC ports on CCU. Default is 2001.
|
||||||
Start or stop RPC server.
|
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>statedatapoint <datapoint>
|
<li>rpcqueue <queue-file><br/>
|
||||||
<br/>
|
Specify name of RPC queue file. This parameter is only a prefix for the
|
||||||
Set datapoint for devstate commands. Default is 'STATE'.
|
queue files with extension .idx and .dat. Default is /tmp/ccuqueue.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>statevals <text:substext[,...]</i>>
|
<li>rpcserver <on | off><br/>
|
||||||
<br/>
|
Start or stop RPC server.
|
||||||
Define substitutions for values in <i>set devstate/datapoint</i> command.
|
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>substitude <expression>:<substext>[,...]
|
<li>statedatapoint <datapoint><br/>
|
||||||
<br/>
|
Set datapoint for devstate commands. Default is 'STATE'.
|
||||||
Define substitions for reading values. Substitutions for parfile values must
|
|
||||||
be specified in parfiles.
|
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>stripchar <character>
|
<li>statevals <text:substext[,...]</i>><br/>
|
||||||
<br/>
|
Define substitutions for values in <i>set devstate/datapoint</i> command.
|
||||||
Strip the specified character from variable or device name in set commands. This
|
|
||||||
is useful if a variable should be set in CCU using the reading with trailing colon.
|
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>updatemode { client | both | hmccu }
|
<li>substitude <expression>:<substext>[,...]<br/>
|
||||||
<br/>
|
Define substitions for reading values. Substitutions for parfile values must
|
||||||
Set update mode for readings.<br/>
|
be specified in parfiles.
|
||||||
'client' = update only readings of client devices<br/>
|
</li><br/>
|
||||||
'both' = update readings of client devices and IO device<br/>
|
<li>stripchar <character><br/>
|
||||||
'hmccu' = update readings of IO device
|
Strip the specified character from variable or device name in set commands. This
|
||||||
|
is useful if a variable should be set in CCU using the reading with trailing colon.
|
||||||
|
</li><br/>
|
||||||
|
<li>updatemode { client | both | hmccu }<br/>
|
||||||
|
Set update mode for readings.<br/>
|
||||||
|
'client' = update only readings of client devices<br/>
|
||||||
|
'both' = update readings of client devices and IO device<br/>
|
||||||
|
'hmccu' = update readings of IO device
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user