From 27deb1ead3528bdf68240afb2f85d4e20e6bcee0 Mon Sep 17 00:00:00 2001 From: delmar <> Date: Thu, 18 Feb 2021 14:01:01 +0000 Subject: [PATCH] 72_TA_CMI_JSON: added readOutputStates and according attributes git-svn-id: https://svn.fhem.de/fhem/trunk@23769 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/72_TA_CMI_JSON.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fhem/FHEM/72_TA_CMI_JSON.pm b/fhem/FHEM/72_TA_CMI_JSON.pm index ceb9df8d3..d077f73b4 100755 --- a/fhem/FHEM/72_TA_CMI_JSON.pm +++ b/fhem/FHEM/72_TA_CMI_JSON.pm @@ -190,8 +190,8 @@ sub SetupIntervals { } my $outputStatesInterval = AttrVal( $name, 'outputStatesInterval', undef); - Log3 $name, 0, "TA_CMI_JSON ($name) - Define::outputStatesInterval: $outputStatesInterval"; if ( defined $outputStatesInterval ) { + Log3 $name, 0, "TA_CMI_JSON ($name) - Define::outputStatesInterval: $outputStatesInterval"; RequestOutputStates ( $hash ); } @@ -217,7 +217,10 @@ sub Undef { sub PerformHttpRequest { my ($hash, $def) = @_; my $name = $hash->{NAME}; - my $url = "http://$hash->{CMIURL}/INCLUDE/api.cgi?jsonnode=$hash->{NODEID}&jsonparam=$hash->{QUERYPARAM}"; + + my $queryParam = $hash->{QUERYPARAM}; + $queryParam = '' unless defined $queryParam; + my $url = "http://$hash->{CMIURL}/INCLUDE/api.cgi?jsonnode=$hash->{NODEID}&jsonparam=$queryParam"; my $username = AttrVal($name, 'username', 'admin'); my $password = AttrVal($name, 'password', 'admin'); @@ -260,6 +263,7 @@ sub ParseHttpResponse { readingsBulkUpdateIfChanged($hash, 'state', $keyValues->{Status}); if ( $keyValues->{Status} eq 'OK' ) { my $queryParams = $hash->{QUERYPARAM}; + $queryParams = '' unless defined $queryParams; extractReadings($hash, $keyValues, 'Inputs', 'Inputs') if ($queryParams =~ /I/); extractReadings($hash, $keyValues, 'Outputs', 'Outputs') if ($queryParams =~ /O/); @@ -294,9 +298,11 @@ sub ParseHttpResponse { # Log3 $name, 3, "TA_CMI_JSON ($name) - Device: $keyValues->{Header_Device}"; } - my $functionName = "TA_CMI_JSON::GetStatus"; - RemoveInternalTimer($hash, $functionName); - InternalTimer( gettimeofday() + $hash->{INTERVAL}, $functionName, $hash, 0 ); + if ( defined $hash->{QUERYPARAM} ) { + my $functionName = "TA_CMI_JSON::GetStatus"; + RemoveInternalTimer($hash, $functionName); + InternalTimer( gettimeofday() + $hash->{INTERVAL}, $functionName, $hash, 0 ); + } return undef; }