mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-07 22:29:19 +00:00
72_TA_CMI_JSON: added readOutputStates and according attributes
git-svn-id: https://svn.fhem.de/fhem/trunk@23768 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6cc14e5649
commit
e5c19009a8
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 72_TA_CMI_JSON: added readOutputStates and according attributes
|
||||||
- feature: 73_km200: Errorcodes implemented
|
- feature: 73_km200: Errorcodes implemented
|
||||||
- change: 98_weekprofile: don't display '°C' by temperature keywords
|
- change: 98_weekprofile: don't display '°C' by temperature keywords
|
||||||
- change: 70_CanOverEthernet: changed indirect object notation (Perl 7 comp)
|
- change: 70_CanOverEthernet: changed indirect object notation (Perl 7 comp)
|
||||||
|
@ -43,11 +43,12 @@ use warnings;
|
|||||||
sub TA_CMI_JSON_Initialize {
|
sub TA_CMI_JSON_Initialize {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
$hash->{GetFn} = "TA_CMI_JSON::TA_CMI_JSON_Get";
|
$hash->{GetFn} = "TA_CMI_JSON::Get";
|
||||||
$hash->{DefFn} = "TA_CMI_JSON::TA_CMI_JSON_Define";
|
$hash->{DefFn} = "TA_CMI_JSON::Define";
|
||||||
$hash->{UndefFn} = "TA_CMI_JSON::TA_CMI_JSON_Undef";
|
$hash->{UndefFn} = "TA_CMI_JSON::Undef";
|
||||||
|
$hash->{NotifyFn} = "TA_CMI_JSON::Notify";
|
||||||
|
|
||||||
$hash->{AttrList} = "username password interval readingNamesInputs readingNamesOutputs readingNamesDL-Bus readingNamesLoggingAnalog readingNamesLoggingDigital includePrettyReadings:0,1 includeUnitReadings:0,1 " . $readingFnAttributes;
|
$hash->{AttrList} = "username password outputStatesInterval interval readingNamesInputs readingNamesOutputs readingNamesDL-Bus readingNamesLoggingAnalog readingNamesLoggingDigital includePrettyReadings:0,1 includeUnitReadings:0,1 prettyOutputStates:0,1 " . $readingFnAttributes;
|
||||||
|
|
||||||
Log3 '', 3, "TA_CMI_JSON - Initialize done ...";
|
Log3 '', 3, "TA_CMI_JSON - Initialize done ...";
|
||||||
}
|
}
|
||||||
@ -67,7 +68,12 @@ my %deviceNames = (
|
|||||||
'89' => 'CAN-I/O45',
|
'89' => 'CAN-I/O45',
|
||||||
'8B' => 'CAN-EZ2',
|
'8B' => 'CAN-EZ2',
|
||||||
'8C' => 'CAN-MTx2',
|
'8C' => 'CAN-MTx2',
|
||||||
'8D' => 'CAN-BC2'
|
'8D' => 'CAN-BC2',
|
||||||
|
'8E' => 'UVR65',
|
||||||
|
'8F' => 'CAN-EZ3',
|
||||||
|
'91' => 'UVR610',
|
||||||
|
'92' => 'UVR67',
|
||||||
|
'A3' => 'BL_NET'
|
||||||
);
|
);
|
||||||
|
|
||||||
my %versions = (
|
my %versions = (
|
||||||
@ -75,7 +81,8 @@ my %versions = (
|
|||||||
2 => '1.26.1 2017-02-24',
|
2 => '1.26.1 2017-02-24',
|
||||||
3 => '1.28.0 2017-11-09',
|
3 => '1.28.0 2017-11-09',
|
||||||
4 => '1.34.2 2019-04-04',
|
4 => '1.34.2 2019-04-04',
|
||||||
5 => '1.35.1 2019-07-02'
|
5 => '1.35.1 2019-07-02',
|
||||||
|
6 => '1.38.1 2021-02-04'
|
||||||
);
|
);
|
||||||
|
|
||||||
my %units = (
|
my %units = (
|
||||||
@ -97,6 +104,14 @@ my %rasStates = (
|
|||||||
3 => 'Standby/frost pr.'
|
3 => 'Standby/frost pr.'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my %outputStates = (
|
||||||
|
0 => 'n/a',
|
||||||
|
1 => 'Auto-Off',
|
||||||
|
3 => 'Auto-On',
|
||||||
|
5 => 'Manual-Off',
|
||||||
|
7 => 'Manual-On'
|
||||||
|
);
|
||||||
|
|
||||||
## Import der FHEM Funktionen
|
## Import der FHEM Funktionen
|
||||||
BEGIN {
|
BEGIN {
|
||||||
GP_Import(qw(
|
GP_Import(qw(
|
||||||
@ -118,7 +133,7 @@ BEGIN {
|
|||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
sub TA_CMI_JSON_Define {
|
sub Define {
|
||||||
my ( $hash, $def ) = @_;
|
my ( $hash, $def ) = @_;
|
||||||
my @a = split( "[ \t][ \t]*", $def );
|
my @a = split( "[ \t][ \t]*", $def );
|
||||||
|
|
||||||
@ -128,9 +143,9 @@ sub TA_CMI_JSON_Define {
|
|||||||
my $nodeId = $a[3];
|
my $nodeId = $a[3];
|
||||||
my $queryParams = $a[4];
|
my $queryParams = $a[4];
|
||||||
|
|
||||||
if(@a != 5) {
|
if(@a != 4 && @a != 5) {
|
||||||
my $msg = "TA_CMI_JSON ($name) - Wrong syntax: define <name> TA_CMI_JSON CMI-URL CAN-Node-ID QueryParameters";
|
my $msg = "TA_CMI_JSON ($name) - Wrong syntax: define <name> TA_CMI_JSON CMI-URL CAN-Node-ID <QueryParameters>";
|
||||||
Log3 undef, 2, $msg;
|
Log3 $name, 0, $msg;
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,25 +153,58 @@ sub TA_CMI_JSON_Define {
|
|||||||
$hash->{CMIURL} = $cmiUrl;
|
$hash->{CMIURL} = $cmiUrl;
|
||||||
$hash->{NODEID} = $nodeId;
|
$hash->{NODEID} = $nodeId;
|
||||||
$hash->{QUERYPARAM} = $queryParams;
|
$hash->{QUERYPARAM} = $queryParams;
|
||||||
$hash->{INTERVAL} = AttrVal( $name, "interval", "60" );
|
|
||||||
|
|
||||||
Log3 $name, 5, "TA_CMI_JSON ($name) - Define done ... module=$module, CMI-URL=$cmiUrl, nodeId=$nodeId, queryParams=$queryParams";
|
|
||||||
|
|
||||||
|
Log3 $name, 0, "TA_CMI_JSON ($name) - Define ... module=$module, CMI-URL=$cmiUrl, nodeId=$nodeId";
|
||||||
readingsSingleUpdate($hash, 'state', 'defined', 1);
|
readingsSingleUpdate($hash, 'state', 'defined', 1);
|
||||||
|
|
||||||
TA_CMI_JSON_GetStatus( $hash, 2 );
|
SetupIntervals($hash) if ($main::init_done);
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub TA_CMI_JSON_GetStatus {
|
sub Notify {
|
||||||
my ( $hash, $delay ) = @_;
|
my ($own_hash, $dev_hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $ownName = $own_hash->{NAME}; # own name / hash
|
||||||
|
|
||||||
TA_CMI_JSON_PerformHttpRequest($hash);
|
return "" if(main::IsDisabled($ownName)); # Return without any further action if the module is disabled
|
||||||
|
|
||||||
|
my $devName = $dev_hash->{NAME}; # Device that created the events
|
||||||
|
my $events = main::deviceEvents($dev_hash, 1);
|
||||||
|
|
||||||
|
if($devName eq "global" && grep(m/^INITIALIZED|REREADCFG$/, @{$events})) {
|
||||||
|
SetupIntervals($own_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub TA_CMI_JSON_Undef {
|
}
|
||||||
|
|
||||||
|
sub SetupIntervals {
|
||||||
|
my ($hash) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
my $queryParams = $hash->{QUERYPARAM};
|
||||||
|
if ( defined $queryParams ) {
|
||||||
|
$hash->{INTERVAL} = AttrVal( $name, "interval", "60" );
|
||||||
|
Log3 $name, 0, "TA_CMI_JSON ($name) - queryParam interval: ".$hash->{INTERVAL};
|
||||||
|
Log3 $name, 0, "TA_CMI_JSON ($name) - queryParams=$queryParams";
|
||||||
|
GetStatus( $hash );
|
||||||
|
}
|
||||||
|
|
||||||
|
my $outputStatesInterval = AttrVal( $name, 'outputStatesInterval', undef);
|
||||||
|
Log3 $name, 0, "TA_CMI_JSON ($name) - Define::outputStatesInterval: $outputStatesInterval";
|
||||||
|
if ( defined $outputStatesInterval ) {
|
||||||
|
RequestOutputStates ( $hash );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sub GetStatus {
|
||||||
|
my ( $hash ) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
PerformHttpRequest($hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub Undef {
|
||||||
my ($hash, $arg) = @_;
|
my ($hash, $arg) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
@ -166,7 +214,7 @@ sub TA_CMI_JSON_Undef {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub TA_CMI_JSON_PerformHttpRequest {
|
sub PerformHttpRequest {
|
||||||
my ($hash, $def) = @_;
|
my ($hash, $def) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $url = "http://$hash->{CMIURL}/INCLUDE/api.cgi?jsonnode=$hash->{NODEID}&jsonparam=$hash->{QUERYPARAM}";
|
my $url = "http://$hash->{CMIURL}/INCLUDE/api.cgi?jsonnode=$hash->{NODEID}&jsonparam=$hash->{QUERYPARAM}";
|
||||||
@ -181,13 +229,13 @@ sub TA_CMI_JSON_PerformHttpRequest {
|
|||||||
header => "User-Agent: FHEM\r\nAccept: application/json",
|
header => "User-Agent: FHEM\r\nAccept: application/json",
|
||||||
user => $username,
|
user => $username,
|
||||||
pwd => $password,
|
pwd => $password,
|
||||||
callback => \&TA_CMI_JSON_ParseHttpResponse
|
callback => \&ParseHttpResponse
|
||||||
};
|
};
|
||||||
|
|
||||||
HttpUtils_NonblockingGet($param);
|
HttpUtils_NonblockingGet($param);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub TA_CMI_JSON_ParseHttpResponse {
|
sub ParseHttpResponse {
|
||||||
my ($param, $err, $data) = @_;
|
my ($param, $err, $data) = @_;
|
||||||
my $hash = $param->{hash};
|
my $hash = $param->{hash};
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
@ -202,10 +250,10 @@ sub TA_CMI_JSON_ParseHttpResponse {
|
|||||||
} elsif($data ne "") {
|
} elsif($data ne "") {
|
||||||
my $keyValues = json2nameValue($data);
|
my $keyValues = json2nameValue($data);
|
||||||
|
|
||||||
my $canDevice = TA_CMI_JSON_extractDeviceName($keyValues->{Header_Device});
|
my $canDevice = extractDeviceName($keyValues->{Header_Device});
|
||||||
$hash->{CAN_DEVICE} = $canDevice;
|
$hash->{CAN_DEVICE} = $canDevice;
|
||||||
$hash->{model} = $canDevice;
|
$hash->{model} = $canDevice;
|
||||||
$hash->{CMI_API_VERSION} = TA_CMI_JSON_extractVersion($keyValues->{Header_Version});
|
$hash->{CMI_API_VERSION} = extractVersion($keyValues->{Header_Version});
|
||||||
CommandDeleteReading(undef, "$name error");
|
CommandDeleteReading(undef, "$name error");
|
||||||
|
|
||||||
readingsBeginUpdate($hash);
|
readingsBeginUpdate($hash);
|
||||||
@ -213,12 +261,12 @@ sub TA_CMI_JSON_ParseHttpResponse {
|
|||||||
if ( $keyValues->{Status} eq 'OK' ) {
|
if ( $keyValues->{Status} eq 'OK' ) {
|
||||||
my $queryParams = $hash->{QUERYPARAM};
|
my $queryParams = $hash->{QUERYPARAM};
|
||||||
|
|
||||||
TA_CMI_JSON_extractReadings($hash, $keyValues, 'Inputs', 'Inputs') if ($queryParams =~ /I/);
|
extractReadings($hash, $keyValues, 'Inputs', 'Inputs') if ($queryParams =~ /I/);
|
||||||
TA_CMI_JSON_extractReadings($hash, $keyValues, 'Outputs', 'Outputs') if ($queryParams =~ /O/);
|
extractReadings($hash, $keyValues, 'Outputs', 'Outputs') if ($queryParams =~ /O/);
|
||||||
|
|
||||||
if ($queryParams =~ /D/) {
|
if ($queryParams =~ /D/) {
|
||||||
if ($canDevice eq 'UVR16x2' or $canDevice eq 'RSM610' ) {
|
if ($canDevice eq 'UVR16x2' or $canDevice eq 'RSM610' ) {
|
||||||
TA_CMI_JSON_extractReadings($hash, $keyValues, 'DL-Bus', 'DL-Bus');
|
extractReadings($hash, $keyValues, 'DL-Bus', 'DL-Bus');
|
||||||
} else {
|
} else {
|
||||||
Log3 $name, 0, "TA_CMI_JSON ($name) - Reading DL-Bus input is not supported on $canDevice";
|
Log3 $name, 0, "TA_CMI_JSON ($name) - Reading DL-Bus input is not supported on $canDevice";
|
||||||
}
|
}
|
||||||
@ -226,7 +274,7 @@ sub TA_CMI_JSON_ParseHttpResponse {
|
|||||||
|
|
||||||
if ($queryParams =~ /La/) {
|
if ($queryParams =~ /La/) {
|
||||||
if ($canDevice eq 'UVR16x2') {
|
if ($canDevice eq 'UVR16x2') {
|
||||||
TA_CMI_JSON_extractReadings($hash, $keyValues, 'LoggingAnalog', 'Logging_Analog');
|
extractReadings($hash, $keyValues, 'LoggingAnalog', 'Logging_Analog');
|
||||||
} else {
|
} else {
|
||||||
Log3 $name, 0, "TA_CMI_JSON ($name) - Reading Logging Analog data is not supported on $canDevice";
|
Log3 $name, 0, "TA_CMI_JSON ($name) - Reading Logging Analog data is not supported on $canDevice";
|
||||||
}
|
}
|
||||||
@ -234,7 +282,7 @@ sub TA_CMI_JSON_ParseHttpResponse {
|
|||||||
|
|
||||||
if ($queryParams =~ /Ld/) {
|
if ($queryParams =~ /Ld/) {
|
||||||
if ($canDevice eq 'UVR16x2') {
|
if ($canDevice eq 'UVR16x2') {
|
||||||
TA_CMI_JSON_extractReadings($hash, $keyValues, 'LoggingDigital', 'Logging_Digital');
|
extractReadings($hash, $keyValues, 'LoggingDigital', 'Logging_Digital');
|
||||||
} else {
|
} else {
|
||||||
Log3 $name, 0, "TA_CMI_JSON ($name) - Reading Logging Digital data is not supported on $canDevice";
|
Log3 $name, 0, "TA_CMI_JSON ($name) - Reading Logging Digital data is not supported on $canDevice";
|
||||||
}
|
}
|
||||||
@ -246,24 +294,24 @@ sub TA_CMI_JSON_ParseHttpResponse {
|
|||||||
# Log3 $name, 3, "TA_CMI_JSON ($name) - Device: $keyValues->{Header_Device}";
|
# Log3 $name, 3, "TA_CMI_JSON ($name) - Device: $keyValues->{Header_Device}";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $functionName = "TA_CMI_JSON::TA_CMI_JSON_GetStatus";
|
my $functionName = "TA_CMI_JSON::GetStatus";
|
||||||
RemoveInternalTimer($hash, $functionName);
|
RemoveInternalTimer($hash, $functionName);
|
||||||
InternalTimer( gettimeofday() + $hash->{INTERVAL}, $functionName, $hash, 0 );
|
InternalTimer( gettimeofday() + $hash->{INTERVAL}, $functionName, $hash, 0 );
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub TA_CMI_JSON_extractDeviceName {
|
sub extractDeviceName {
|
||||||
my ($input) = @_;
|
my ($input) = @_;
|
||||||
return (defined($deviceNames{$input}) ? $deviceNames{$input} : 'unknown: ' . $input);
|
return (defined($deviceNames{$input}) ? $deviceNames{$input} : 'unknown: ' . $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub TA_CMI_JSON_extractVersion {
|
sub extractVersion {
|
||||||
my ($input) = @_;
|
my ($input) = @_;
|
||||||
return (defined($versions{$input}) ? $versions{$input} : 'unknown: ' . $input);
|
return (defined($versions{$input}) ? $versions{$input} : 'unknown: ' . $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub TA_CMI_JSON_extractReadings {
|
sub extractReadings {
|
||||||
my ( $hash, $keyValues, $id, $dataKey ) = @_;
|
my ( $hash, $keyValues, $id, $dataKey ) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
@ -312,19 +360,106 @@ sub TA_CMI_JSON_extractReadings {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub TA_CMI_JSON_Get {
|
sub Get {
|
||||||
my ( $hash, $name, $opt, $args ) = @_;
|
my ( $hash, $name, $opt, $args ) = @_;
|
||||||
|
|
||||||
if ("update" eq $opt) {
|
if ("update" eq $opt) {
|
||||||
TA_CMI_JSON_PerformHttpRequest($hash);
|
PerformHttpRequest($hash);
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("readOutputStates" eq $opt) {
|
||||||
|
RequestOutputStates($hash); #unless $hash->{CAN_DEVICE} ne 'UVR1611';
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Log3 $name, 3, "ZoneMinder ($name) - Get done ...";
|
# Log3 $name, 3, "ZoneMinder ($name) - Get done ...";
|
||||||
return "Unknown argument $opt, choose one of update";
|
return "Unknown argument $opt, choose one of update readOutputStates";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub RequestOutputStates {
|
||||||
|
my ($hash) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my $nodeId = $hash->{NODEID};
|
||||||
|
my $hexNodeId = sprintf('%1x',$nodeId);
|
||||||
|
$hexNodeId = "0$hexNodeId" unless length($hexNodeId) == 2;
|
||||||
|
|
||||||
|
my $url = "http://$hash->{CMIURL}/INCLUDE/agx2.cgi?nodex2=$hexNodeId";
|
||||||
|
my $username = AttrVal($name, 'username', 'admin');
|
||||||
|
my $password = AttrVal($name, 'password', 'admin');
|
||||||
|
|
||||||
|
my $param = {
|
||||||
|
url => "$url",
|
||||||
|
timeout => 5,
|
||||||
|
hash => $hash,
|
||||||
|
method => "GET",
|
||||||
|
header => "User-Agent: FHEM\r\nAccept: application/json",
|
||||||
|
user => $username,
|
||||||
|
pwd => $password,
|
||||||
|
callback => \&ParseOutputStateResponse
|
||||||
|
};
|
||||||
|
|
||||||
|
Log3 $name, 4, "TA_CMI_JSON ($name) - RequestOutputStates $url";
|
||||||
|
HttpUtils_NonblockingGet($param);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub ParseOutputStateResponse {
|
||||||
|
my ($param, $err, $data) = @_;
|
||||||
|
my $hash = $param->{hash};
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my $return;
|
||||||
|
|
||||||
|
if($err ne "") {
|
||||||
|
Log3 $name, 0, "error while requesting output data ".$param->{url}." - $err";
|
||||||
|
readingsBeginUpdate($hash);
|
||||||
|
readingsBulkUpdate($hash, 'state', 'ERROR', 0);
|
||||||
|
readingsBulkUpdate($hash, 'error', $err, 0);
|
||||||
|
readingsEndUpdate($hash, 0);
|
||||||
|
} elsif($data ne "") {
|
||||||
|
|
||||||
|
my @values = split(';', $data);
|
||||||
|
my $nrValues = @values -2;
|
||||||
|
|
||||||
|
my $prettyOutputStates = AttrVal( $name, "prettyOutputStates", '0' );
|
||||||
|
my $readingNames = AttrVal($name, "readingNamesOutputs", undef);
|
||||||
|
if ( ! defined $readingNames ) {
|
||||||
|
Log3 $name, 0, "TA_CMI_JSON ($name) - Unable to assign output states, please set attribute readingNamesOutputs";
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
my @readingsArray = split(/ /, $readingNames); #1:T.Kollektor 5:T.Vorlauf
|
||||||
|
|
||||||
|
readingsBeginUpdate($hash);
|
||||||
|
foreach (@readingsArray) {
|
||||||
|
my ( $readingNameIndex, $readingName ) = split(/\:/, $_);
|
||||||
|
my $i = $readingNameIndex+1;
|
||||||
|
|
||||||
|
$readingName = makeReadingName($readingName);
|
||||||
|
my $readingValue = $values[$i];
|
||||||
|
readingsBulkUpdateIfChanged($hash, $readingName.'_State', $readingValue);
|
||||||
|
if ($prettyOutputStates eq '1') {
|
||||||
|
|
||||||
|
my $prettyValue = (defined($outputStates{$readingValue}) ? $outputStates{$readingValue} : '?:'.$readingValue);
|
||||||
|
readingsBulkUpdateIfChanged($hash, $readingName.'_State_Pretty', $prettyValue);
|
||||||
|
}
|
||||||
|
Log3 $name, 5, "readingName: $readingName, readingNameIndex: $readingNameIndex, valueIndex: $i, value: $readingValue";
|
||||||
|
}
|
||||||
|
readingsEndUpdate($hash, 0);
|
||||||
|
|
||||||
|
Log3 $name, 5, "TA_CMI_JSON ($name) - Output Data $nrValues: $data";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $outputStatesInterval = AttrVal($name, 'outputStatesInterval', undef);
|
||||||
|
if ( defined $outputStatesInterval ) {
|
||||||
|
Log3 $name, 5, "TA_CMI_JSON ($name) - outputStatesInterval $outputStatesInterval";
|
||||||
|
my $functionName = "TA_CMI_JSON::RequestOutputStates";
|
||||||
|
RemoveInternalTimer($hash, $functionName);
|
||||||
|
InternalTimer( gettimeofday() + $outputStatesInterval, $functionName, $hash, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Eval-Rückgabewert für erfolgreiches
|
# Eval-Rückgabewert für erfolgreiches
|
||||||
# Laden des Moduls
|
# Laden des Moduls
|
||||||
1;
|
1;
|
||||||
@ -351,7 +486,7 @@ sub TA_CMI_JSON_Get {
|
|||||||
<br>
|
<br>
|
||||||
Example:
|
Example:
|
||||||
<ul>
|
<ul>
|
||||||
<code>defmod cmi TA_CMI_JSON 192.168.4.250 1 I,O,D</code><br>
|
<code>defmod cmi TA_CMI_JSON 192.168.4.250 1 <I,O,D></code><br>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
It's mandatory to define which values should be mapped to readings.<br/>
|
It's mandatory to define which values should be mapped to readings.<br/>
|
||||||
@ -364,6 +499,8 @@ sub TA_CMI_JSON_Get {
|
|||||||
<ul>
|
<ul>
|
||||||
<li><code>update</code><br>Triggers querying of values from the CMI. Please note that the request rate is limited to one query per minute.
|
<li><code>update</code><br>Triggers querying of values from the CMI. Please note that the request rate is limited to one query per minute.
|
||||||
</li>
|
</li>
|
||||||
|
<li><code>readOutputStates</code><br>Reads Output states (eg Manual-On, Auto-Off) per defined output. Can be automated by setting <code>outputStatesInterval</code>.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
@ -379,6 +516,8 @@ sub TA_CMI_JSON_Get {
|
|||||||
<li><code>includeUnitReadings [0:1]</code><br>Adds another reading per value, which just contains the according unit of that reading.</li>
|
<li><code>includeUnitReadings [0:1]</code><br>Adds another reading per value, which just contains the according unit of that reading.</li>
|
||||||
<li><code>includePrettyReadings [0:1]</code><br>Adds another reading per value, which contains value plus unit of that reading.</li>
|
<li><code>includePrettyReadings [0:1]</code><br>Adds another reading per value, which contains value plus unit of that reading.</li>
|
||||||
<li><code>interval</code><br>Query interval in seconds. Minimum query interval is 60 seconds.</li>
|
<li><code>interval</code><br>Query interval in seconds. Minimum query interval is 60 seconds.</li>
|
||||||
|
<li><code>outputStatesInterval</code><br>Request interval in seconds for getting output states.</li>
|
||||||
|
<li><code>prettyOutputStates [0:1]</code><br>If set, generates a reading _State_Pretty for output states (eg Auto-On, Manual-Off)</li>
|
||||||
<li><code>username</code><br>Username for querying the JSON-API. Needs to be either admin or user privilege.</li>
|
<li><code>username</code><br>Username for querying the JSON-API. Needs to be either admin or user privilege.</li>
|
||||||
<li><code>password</code><br>Password for querying the JSON-API.</li>
|
<li><code>password</code><br>Password for querying the JSON-API.</li>
|
||||||
|
|
||||||
@ -407,7 +546,7 @@ Weitere Informationen zu diesem Modul im <a href="https://wiki.fhem.de/wiki/UVR1
|
|||||||
<br>
|
<br>
|
||||||
Beispiel:
|
Beispiel:
|
||||||
<ul>
|
<ul>
|
||||||
<code>defmod cmi TA_CMI_JSON 192.168.4.250 1 I,O,D</code><br>
|
<code>defmod cmi TA_CMI_JSON 192.168.4.250 1 <I,O,D></code><br>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
Daneben muss auch noch das mapping angegeben werden, welche Werte in welches Reading geschrieben werden sollen.<br/>
|
Daneben muss auch noch das mapping angegeben werden, welche Werte in welches Reading geschrieben werden sollen.<br/>
|
||||||
@ -420,6 +559,8 @@ Weitere Informationen zu diesem Modul im <a href="https://wiki.fhem.de/wiki/UVR1
|
|||||||
<ul>
|
<ul>
|
||||||
<li><code>update</code><br>Hiermit kann sofort eine Abfrage der API ausgeführt werden. Das Limit von einer Anfrage pro Minute besteht trotzdem.
|
<li><code>update</code><br>Hiermit kann sofort eine Abfrage der API ausgeführt werden. Das Limit von einer Anfrage pro Minute besteht trotzdem.
|
||||||
</li>
|
</li>
|
||||||
|
<li><code>readOutputStates</code><br>Liest Ausgangs-Stati, zB Auto-Ein, Hand-Aus. Kann mittels <code>outputStatesInterval</code> automatisch ausgeführt werden. Das Zeitlimit von 60 Sekunden trifft hier nicht zu.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
@ -435,9 +576,10 @@ Weitere Informationen zu diesem Modul im <a href="https://wiki.fhem.de/wiki/UVR1
|
|||||||
<li><code>includeUnitReadings [0:1]</code><br>Definiert, ob zu jedem Reading ein zusätzliches Reading _Name geschrieben werden soll, welches die Einheit enthält.</li>
|
<li><code>includeUnitReadings [0:1]</code><br>Definiert, ob zu jedem Reading ein zusätzliches Reading _Name geschrieben werden soll, welches die Einheit enthält.</li>
|
||||||
<li><code>includePrettyReadings [0:1]</code><br>Definiert, ob zu jedem Reading zusätzlich ein Reading, welches Wert und Einheit enthält, geschrieben werden soll.</li>
|
<li><code>includePrettyReadings [0:1]</code><br>Definiert, ob zu jedem Reading zusätzlich ein Reading, welches Wert und Einheit enthält, geschrieben werden soll.</li>
|
||||||
<li><code>interval</code><br>Abfrage-Intervall in Sekunden. Muss mindestens 60 sein.</li>
|
<li><code>interval</code><br>Abfrage-Intervall in Sekunden. Muss mindestens 60 sein.</li>
|
||||||
|
<li><code>outputStatesInterval</code><br>Abfrage-Intervall für Ausgangs-Stati in Sekunden.</li>
|
||||||
|
<li><code>prettyOutputStates [0:1]</code><br>Definiert, ob zu einem Ausgangs-Status ein zusätzliches Reading _State_Pretty geschrieben werden soll (liefert zB Auto-On, Manual-Off)</li>
|
||||||
<li><code>username</code><br>Username zur Abfrage der JSON-API. Muss die Berechtigungsstufe admin oder user haben.</li>
|
<li><code>username</code><br>Username zur Abfrage der JSON-API. Muss die Berechtigungsstufe admin oder user haben.</li>
|
||||||
<li><code>password</code><br>Passwort zur Abfrage der JSON-API.</li>
|
<li><code>password</code><br>Passwort zur Abfrage der JSON-API.</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user