Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleLoxBerry Compatibility

This module is available from LoxBerry V2.0. Set the minimum LoxBerry version in your plugin.cfg.

Inclusion

require_once "loxberry_loxonetemplatebuilder.php";

loxberry_loxonetemplatebuilder.php has no dependencies. It's not required to add a path to the PHP library's filename.

Abstract

Code Block
languagephp
linenumberstrue
require_once "loxberry_loxonetemplatebuilder.php";

/* Virtual HTTP Inputs */
/* =================== */

$VIhttp = new VirtualInHttp( [
	"Title" => "LoxBerry Healthcheck",
	"Address" => "http://loxberry:loxberry@loxberry/admin/system/healthcheck.cgi"
] );

// Create a VI Command. (the return value represents the line number that was created)
$linenr = $VIhttp->VirtualInHttpCmd ( [
	"Title" => "timeepoch",
	"Check" => '"timeepoch":\v'
] );

// Get the created xml template
echo $VIhttp->output();

// Get the content of a specific line number (line 3)
$vicmd = $VIhttp->VirtualInHttpCmd ( 3 );
// You now can access it's properties, like $vicmd->Title

// Delete a specific line
$VIhttp->delete($linenr);
// Despite of the deletion, all indexes stay intact


/* Virtual UDP Inputs */
/* ================== */

$VIudp = new VirtualInUdp( [
	"Title" => "LoxBerry Weather",
	"Address" => "",
	"Port" => "12345"
] );

$linenr = $VIudp->VirtualInUdpCmd( [
	"Title" => "Temperature",
	"Check" => '"temperature":\v',
	"Analog" => true
] );

// Get the content of a specific line number (line 3)
$vicmd = $VIhttp->VirtualInUdpCmd ( 3 );

// Get the created XML template
echo $VIudp->output();

/* Virtual Outputs */
/* =============== */

$VO = new VirtualOut( [
	"Title" => "Sonos",
	"Address" => "http://192.168.1.232:1400"
] );

$linenr = $VO->VirtualOutCmd( [
	"Title" => "Play",
	"CmdOnMethod" => "post", 
	"CmdOn" => '/MediaRenderer/AVTransport/Control',
	"CmdOnHTTP" => 'SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Play"',
	"CmdOnPost" => 	'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'.
					'<s:Body><u:Play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Speed>1</Speed></u:Play></s:Body></s:Envelope>'
] );

echo $VO->output();

...