www/js/homematic-manager.js
function rpcDialogShift() {
    if (rpcDialogQueue.length === 0) {
        $dialogRpc.dialog('close');
        return;
    }
    rpcDialogPending = true;

    const {daemon, cmd, params, callback} = rpcDialogQueue.shift();

    const paramText = JSON.stringify(JSON.parse(JSON.stringify(params).replace(/{"explicitDouble":([0-9.]+)}/g, '$1')), null, '  ');

    $('#rpc-command').html(cmd + ' ' + paramText);
    $('#rpc-message').html('');
    $dialogRpc.dialog('open');
    $('#rpc-progress').show();

    ipcRpc.send('rpc', [daemon, cmd, params], (err, res) => {
        $('#rpc-progress').hide();
        if (err) {
            $dialogRpc.parent().children().children('.ui-dialog-titlebar-close').show();
            $('#rpc-message').html('<span style="color: red; font-weight: bold;">' + (err.faultString ? err.faultString : JSON.stringify(err)) + '</span>');
        } else if (res && res.faultCode) {
            $dialogRpc.parent().children().children('.ui-dialog-titlebar-close').show();
            $('#rpc-message').html('<span style="color: orange; font-weight: bold;">' + res.faultString + ' (' + res.faultCode + ')</span>');
        } else {
            $dialogRpc.parent().children().children('.ui-dialog-titlebar-close').hide();
            const resText = res ? ('<br>' + (typeof res === 'string' ? res : JSON.stringify(res, null, '  '))) : '';
            $('#rpc-message').html('<span style="color: green;">success</span><br>' + resText);
        }
        setTimeout(() => {
            rpcDialogPending = false;
            rpcDialogShift();
            if (typeof callback === 'function') {
                callback(err, res);
            }
        }, config.rpcDelay);
    });
}
function rpcDialogShift() {
    if (rpcDialogQueue.length === 0) {
        $dialogRpc.dialog('close');
        return;
    }
    rpcDialogPending = true;

    const {daemon, cmd, params, callback} = rpcDialogQueue.shift();

    const paramText = JSON.stringify(JSON.parse(JSON.stringify(params).replace(/{"explicitDouble":([0-9.]+)}/g, '$1')), null, '  ');

    $('#rpc-command').html(cmd + ' ' + paramText);
    $('#rpc-message').html('');
    $dialogRpc.dialog('open');
    $('#rpc-progress').show();

    ipcRpc.send('rpc', [daemon, cmd, params], (err, res) => {
        $('#rpc-progress').hide();
        if (err) {
            $dialogRpc.parent().children().children('.ui-dialog-titlebar-close').show();
            $('#rpc-message').html('<span style="color: red; font-weight: bold;">' + (err.faultString ? err.faultString : JSON.stringify(err)) + '</span>');
        } else if (res && res.faultCode) {
            $dialogRpc.parent().children().children('.ui-dialog-titlebar-close').show();
            $('#rpc-message').html('<span style="color: orange; font-weight: bold;">' + res.faultString + ' (' + res.faultCode + ')</span>');
        } else {
            $dialogRpc.parent().children().children('.ui-dialog-titlebar-close').hide();
            const resText = res ? ('<br>' + (typeof res === 'string' ? res : JSON.stringify(res, null, '  '))) : '';
            $('#rpc-message').html('<span style="color: green;">success</span><br>' + resText);
        }
        setTimeout(() => {
            rpcDialogPending = false;
            rpcDialogShift();
            if (typeof callback === 'function') {
                callback(err, res);
            }
        }, config.rpcDelay);
    });
}
function rpcDialogShift ( ) { if ( rpcDialogQueue . length === 0 ) { $dialogRpc . dialog ( 'close' ) ; return ; } rpcDialogPending = true ; const { daemon , cmd , params , callback } = rpcDialogQueue . shift ( ) ; const paramText = JSON . stringify ( JSON . parse ( JSON . stringify ( params ) . replace ( / {"explicitDouble":([0-9.]+)} / g , '$1' ) ) , null , '  ' ) ; $ ( '#rpc-command' ) . html ( cmd + ' ' + paramText ) ; $ ( '#rpc-message' ) . html ( '' ) ; $dialogRpc . dialog ( 'open' ) ; $ ( '#rpc-progress' ) . show ( ) ; ipcRpc . send ( 'rpc' , [ daemon , cmd , params ] , ( err , res ) => { $ ( '#rpc-progress' ) . hide ( ) ; if ( err ) { $dialogRpc . parent ( ) . children ( ) . children ( '.ui-dialog-titlebar-close' ) . show ( ) ; $ ( '#rpc-message' ) . html ( '<span style="color: red; font-weight: bold;">' + ( err . faultString ? err . faultString : JSON . stringify ( err ) ) + '</span>' ) ; } else if ( res && res . faultCode ) { $dialogRpc . parent ( ) . children ( ) . children ( '.ui-dialog-titlebar-close' ) . show ( ) ; $ ( '#rpc-message' ) . html ( '<span style="color: orange; font-weight: bold;">' + res . faultString + ' (' + res . faultCode + ')</span>' ) ; } else { $dialogRpc . parent ( ) . children ( ) . children ( '.ui-dialog-titlebar-close' ) . hide ( ) ; const resText = res ? ( '<br>' + ( typeof res === 'string' ? res : JSON . stringify ( res , null , '  ' ) ) ) : '' ; $ ( '#rpc-message' ) . html ( '<span style="color: green;">success</span><br>' + resText ) ; } setTimeout ( ( ) => { rpcDialogPending = false ; rpcDialogShift ( ) ; if ( typeof callback === 'function' ) { callback ( err , res ) ; } } , config . rpcDelay ) ; } ) ; }
RPC execution Wrappers
RPC execution Wrappers