2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-07 16:59:18 +00:00

HMCCU: new command get deviceinfo

git-svn-id: https://svn.fhem.de/fhem/trunk@10132 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
fhemzap 2015-12-08 18:34:17 +00:00
parent 52e9ffc897
commit d7a4334349

View File

@ -99,6 +99,7 @@ sub HMCCU_StartRPCServer ($);
sub HMCCU_StopRPCServer ($);
sub HMCCU_IsRPCServerRunning ($);
sub HMCCU_CheckProcess ($);
sub HMCCU_GetDeviceInfo ($$);
sub HMCCU_GetDeviceList ($);
sub HMCCU_GetAddress ($$$);
sub HMCCU_GetCCUObjectAttribute ($$);
@ -331,7 +332,7 @@ sub HMCCU_Get ($@)
my ($hash, @a) = @_;
my $name = shift @a;
my $opt = shift @a;
my $options = "devicelist:noArg devstate datapoint vars channel parfile config configdesc";
my $options = "devicelist:noArg devstate datapoint vars channel parfile config configdesc deviceinfo";
my $host = $hash->{host};
my $ccureadingformat = AttrVal ($name, "ccureadingformat", 'name');
@ -431,13 +432,22 @@ sub HMCCU_Get ($@)
HMCCU_SetState ($hash, "OK");
return $ccureadings ? undef : $result;
}
elsif ($opt eq 'deviceinfo') {
my $device = shift @a;
return HMCCU_SetError ($hash, "") if (!defined ($device));
$result = HMCCU_GetDeviceInfo ($hash, $device);
return HMCCU_SetError ($hash, -2) if ($result eq '');
return $result;
}
elsif ($opt eq 'devicelist') {
my $dumplist = shift @a;
$hash->{DevCount} = HMCCU_GetDeviceList ($hash);
if ($hash->{DevCount} < 0) {
return HMCCU_SetError ($hash, "HM Script execution failed");
return HMCCU_SetError ($hash, -2);
}
elsif ($hash->{DevCount} == 0) {
return HMCCU_SetError ($hash, "No devices received from CCU");
@ -912,6 +922,43 @@ sub HMCCU_CheckProcess ($)
return 0;
}
####################################################
# Get channel and datapoints of CCU device
####################################################
sub HMCCU_GetDeviceInfo ($$)
{
my ($hash, $device) = @_;
my $devname = '';
my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($device, 0);
if ($flags == $HMCCU_FLAG_ADDRESS) {
$devname = HMCCU_GetDeviceName ($add, '');
return '' if ($devname eq '');
}
else {
$devname = $nam;
}
my $script = qq(
string chnid;
string sDPId;
object odev = dom.GetObject ("$devname");
foreach (chnid, odev.Channels())
{
object ochn = dom.GetObject(chnid);
WriteLine("Channel " # ochn.Address() # " " # ochn.Name());
foreach(sDPId, ochn.DPs().EnumUsedIDs())
{
object oDP = dom.GetObject(sDPId);
WriteLine (" DP " # oDP.Name() # " = " # oDP.Value());
}
}
);
return HMCCU_HMScript ($hash->{host}, $script);
}
####################################################
# Read list of CCU devices via Homematic Script.
# Update data of client devices if not current.
@ -1756,6 +1803,10 @@ sub HMCCU_RPCSetConfig ($$$)
Get value of datapoint(s). If no datapoint is specified all datapoints of specified
channel are read. &lt;datapoint&gt; can be specified as a regular expression.
</li><br/>
<li>get &lt;name&gt; deviceinfo &lt;device-name&gt;
<br/>
List device channels and datapoints.
</li><br/>
<li>get &lt;name&gt; devicelist [dump]
<br/>
Read list of devices and channels from CCU. This command is executed automatically after device