mshttp_send

(string) $response = mshttp_send($msno, (string) $input, (string) $value);

(array) $response = mshttp_send($msno, (array) $inputsAndValues);

 

Sends a value to a Loxone Miniserver input, or sends multiple values to multiple inputs.

You should prefer the function mshttp_send_mem to take care for the Miniserver.

LoxBerry Compatibility

This feature first is available with LoxBerry 1.2.5. Set your LB_MINIMUM version in your plugin.cfg accordingly.

The input format in the heading seems to be confusing - see the examples below, it's easy!

The function uses the Miniserver HTTP REST webservice to send data to inputs. It can be used for a single value, and for multiple values. 

The first parameter is the Miniserver number (numbers are equal to LBSystem::get_miniservers, starting with 1).

For a single value, and multiple values, use the following syntax:

Parameter

Single value

ParameterRequiredBeschreibung
$msno x Number of the Miniserver


$input x The name of the Miniserver input. The parameter must not be URL-encoded.
$value x The value to send. The parameter must not be URL-encoded.

You always can use the array format explained below, also with a single value!

Multiple values

Parameter RequiredBeschreibung
$msno x Number of the Miniserver


$inputsAndValuesx An associative array with input ⇒ value pairs. The parameters must not be URL-encoded.


Return value

On a single value call, the function returns a value on success, or null on error.

On a multiple value call, the function returns an associative array with the input as key and the return value as value. If the value of an input key has a value, it was successful. If the input key is null, it was an error.

Usage

Single value

require_once "loxberry_io.php";
 
$response = mshttp_send(1, "Light Livingroom", "On");
if (isempty($response)) {
    echo "Error sending to Miniserver";
} else {
    echo "Sent ok.";
}

The return code is defined to be null, if the call was unsuccessful.

If the code is not undef, it was successful. (the returned value of the Miniserver is returned)

Multiple values

require_once "loxberry_io.php";
 
$response = mshttp_send(1, [ 'Light Livingroom' => "On", 'Light_Bath' => "Off" ] );
if (isempty($response['Light Livingroom'])) {
    echo "Error switching Livingroom";
} 
if (!isempty($response['Light_Bath'])) {
    echo "Error switching Bath";
} 

Every array key has a value on success (the return value of the Miniserver), or is null on error.