diff --git a/73_NUKIBridge.pm b/73_NUKIBridge.pm index 6f7e1d7..5e61f3d 100755 --- a/73_NUKIBridge.pm +++ b/73_NUKIBridge.pm @@ -371,7 +371,7 @@ sub Attr(@) { Log3( $name, 3, "NUKIBridge ($name) - URL ist: $url" ); # Write( $hash, 'callback/add', $url, undef, undef ) - Write( $hash, 'callback/add', '{"param":"' . $url . '}' ) + Write( $hash, 'callback/add', '{"param":"' . $url . '"}' ) if ($init_done); $hash->{WEBHOOK_REGISTER} = 'sent'; } @@ -483,7 +483,7 @@ sub Set($@) { my $id = ( @args > 0 ? join( ' ', @args ) : 0 ); # Write( $hash, 'callback/remove', $id, undef, undef ) - Write( $hash, 'callback/remove', '{"param":"' . $id . '}' ) + Write( $hash, 'callback/remove', '{"param":"' . $id . '"}' ) if ( !IsDisabled($name) ); return undef; @@ -918,7 +918,7 @@ sub ResponseProcessing($$$) { } } - InfoProcessing( $hash, $decode_json ) + WriteReadings( $hash, $decode_json ) if ( $endpoint eq 'info' ); } else { @@ -987,7 +987,7 @@ matching NukiId at device $name" return ( 'text/plain; charset=utf-8', 'Call failure: ' . $request ); } -sub InfoProcessing($$) { +sub WriteReadings($$) { my ( $hash, $decode_json ) = @_; my $name = $hash->{NAME}; @@ -1010,7 +1010,7 @@ sub InfoProcessing($$) { readingsBulkUpdate( $hash, 'hardwareId', $decode_json->{ids}{hardwareId} ); readingsBulkUpdate( $hash, 'serverId', $decode_json->{ids}{serverId} ); readingsBulkUpdate( $hash, 'uptime', $decode_json->{uptime} ); - readingsBulkUpdate( $hash, 'currentTime', $decode_json->{currentTime} ); + readingsBulkUpdate( $hash, 'currentGMTime', $decode_json->{currentTime} ); readingsBulkUpdate( $hash, 'serverConnected', $decode_json->{serverConnected} ); readingsEndUpdate( $hash, 1 ); @@ -1099,6 +1099,72 @@ sub getCallbackList($$) { Log3( $name, 4, "NUKIBridge ($name) - created Table with log file" ); + my $space = ' '; + my $aHref; + my $header = '' + . '
Callback List
'; + + my $ret = $header.''; + $ret .= '
'; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + + if ( scalar( @{ $decode_json->{callbacks} } ) > 0 ) { + foreach my $cb ( @{ $decode_json->{callbacks} } ) { + $aHref = + "{host} + . "/fhem?cmd=set+" + . $name + . "+callbackRemove+" + . $cb->{id} + . $::FW_CSRF + . "\">X"; + + $ret .= ''; + $ret .= ''; + $ret .= ''; + } + } + else { + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + } + + $ret .= '
URLRemove
' . $cb->{url} . ''.$aHref.'
nonenone
'; + + asyncOutput( $param->{cl}, $ret ) + if ( $param->{cl} and $param->{cl}{canAsyncOutput} ); + return; + } + } +} + +sub getCallbackList2($$) { + my ( $param, $json ) = @_; + + my $hash = $param->{hash}; + my $name = $hash->{NAME}; + + my $decode_json = eval { decode_json($json) }; + if ($@) { + Log3( $name, 3, "NUKIBridge ($name) - JSON error while request: $@" ); + return; + } + + Log3( $name, 4, + "NUKIBridge ($name) - Callback data are collected and processed" ); + + if ( $param->{cl} and $param->{cl}->{TYPE} eq 'FHEMWEB' ) { + if ( ref( $decode_json->{callbacks} ) eq 'ARRAY' ) { + Log3( $name, 4, + "NUKIBridge ($name) - created Table with Callback List" ); + my $j1 = '