Skip to end of metadata
Go to start of metadata

list ($value, $respcode, $xmlobject) = mshttp_call($msno, $command);

Sends a HTTP REST request to the specified Miniserver and returns the status code and value, and also a SimpleXML object of the full response.

LoxBerry Compatibility

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

This function is the "raw", generic Miniserver REST function. To send or query data, you should prefer 

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

The second parameter is a string with the full command, but without hostname, e.g. /dev/sps/io/Livingroom/state.


$msnoxNumber of the Miniserver

$commandxThe full command. The parameter must not be URL-encoded.

Return value


1. return

Return "value" from Miniserver

2. returnStatus code
3. return

A SimpleXML object of the full data structure returned by the Miniserver

The function returns an array with three values: The queried "value" (string), The status code (string), and the full SimpleXML object. 

Use PHP's list function to save the three values to different variables (see example).

Status codes not in the 2xx range (below 200 and from 300 upwards) are an error. Normally, Loxone returns a "code" 200 for ok.

As Loxone Miniserver most commonly returns a HTTP statuscode of "200 OK" in the HTTP header - also with wrong syntax or non-existing elements, the function parses the result and returns the "code", a value the Miniserver returns inside of the response XML. 

Therefore, the function may return

  • a LoxBerry-own "error code" in the 6xx area (e.g. "601" for "Miniserver not defined")
  • the HTTP statuscode, if a real HTTP header errorcode is returned
  • the Loxone "code" of the response XML (for errors, most used is the 500)
  • 200 if the request was successful

SimpleXML object

Please consider the difference to LoxBerry::IO::mshttp_call response, as the values need to be accessed different. See the example below.


require_once "loxberry_io.php";
// Only value
list ($value) = mshttp_call(1, "/dev/sps/io/Light_Livingroom/state");

// Value with code
list ($value, $status) = mshttp_call(1, "/dev/sps/io/Light_Livingroom/state");
if ($status != 200) {
	echo "Error retrieving from Miniserver";
} else {
	echo "Value is $value.";

// Using the SimpleXML object 
list ($value, $status, $resp) = mshttp_call(1, "/dev/sps/io/Energymeter_Washingmachine/state");
echo " Code: " . $resp->attributes()->Code;
echo " value: " . $resp->attributes()->value;

// needs to loop the "output" array, or using XPath to search for name="AQ9"

foreach($resp->output as $output) {
	echo $output->attributes()->name . ": " . $output->attributes()->value . "\n";

  • No labels