Skip to end of metadata
Go to start of metadata

The module loxberry_loxonetemplatebuilder.php is used to more easily generate Loxone Templates for Virtual UDP Inputs, Virtual HTTP Inputs and Virtual Outputs. On usage, you create an VI or VO object, and can add Commands to the VI/VO one by one.

Parameters for the VI/VO and the VI/CO-Cmds are sent as named array. See the table at the bottom for supported parameters for every VI/VO and VI/VO Cmd type.


LoxBerry 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

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();

Classes

new VirtualInHttp( array $params ) : object

new VirtualInUdp ( array $params ) : object

new VirtualOut ( array $params ) : object

Methods

These methods create the commands in the VI/VO. Using a method not fitting to the correct class throws an exception (e.g. using the class VirtualInHttp and creating a command of type VirtualInUdpCmd). The methods return an int that represents the line number of the object.

->VirtualInHttpCmd ( array $params ) : int

->VirtualInUdpCmd ( array $params ) : int

->VirtualOutCmd ( array $params ) : int

If $params is not an array but a single int, the method returns an object with the given line number. You then can access the values with e.g. $lineobj->Title.

->delete ( int $linenr )

The delete method deletes a line, using the provided index. Despite of the deletion, the index of all other Cmds stay intact (e.g. after deleting line 3, line 4 still is line 4) 

->output()

output returns the string of the created VirtualInHttp/VirtualInUdp/VirtualOut in the correct encoding and quotation.

See the tables below, what parameters and default values the classes provide.

  • Omitting a parameter uses the default value.
  • Parameters are case-sensitive.
  • Boolean values may be written in your favour as true/false, "true"/"false" or 1/0.
  • Using a parameter that does not exist, is (currently) ignored (but may throw an exception in the future)

Virtual HTTP Input

Virtual HTTP Input Constructor

new VirtualInHttp

ParameterDefault valueDescription in Loxone Config
Title
Name
Comment
Description
Address
URL
PollingTime60Polling Cycle [s]

Virtual HTTP Input Command

VirtualInHttp->VirtualInHttpCmd

ParameterDefault valueDescription in Loxone Config
Title
Name
Comment
Description
Check
Command recognition
SignedtrueSigned values (checkbox)
Analogtrue(not present)
SourceValLow0Input value 1
DestValLow0Target value 1
SourceValHigh100Input value 2
DestValHigh100Target value 2
DefVal0Default value
MinVal-2147483647Minimum value
MaxVal2147483647Maximum value

Virtual UDP Input

Virtual UDP Input Constructor

new VirtualInUdp

ParameterDefault valueDescription in Loxone Config
Title
Name
Comment
Description
Address
Sender address
Port
UDP receive port

Virtual UDP Input Command

VirtualInUdp->VirtualInUdpCmd

ParameterDefault valueDescription in Loxone Config
Title
Name
Comment
Description
Address
Sender address
Check
Command recognition
SignedtrueSigned values (checkbox)
AnalogtrueUse as digital input (checkbox)
SourceValLow0Input value 1
DestValLow0Target value 1
SourceValHigh100Input value 2
DestValHigh100Target value 2
DefVal0Default value
MinVal-2147483647Minimum value
MaxVal2147483647Maximum value

Virtual Output

Virtual Output Constructor

new VirtualOut

ParameterDefault valueDescription in Loxone Config
Title
Name
Comment
Description
Address
Address
CmdInit
Command to establish connection
CloseAfterSendtrueClose connection after sending (checkbox)
CmdSep
Separator

Virtual Output Command

VirtualOut->VirtualOutCmd

ParameterDefault valueDescription in Loxone Config
Title
Name
Comment
Description
CmdOnMethod
HTTP method for ON (dropdown)
CmdOn
Command for ON
CmdOnHTTP
HTTP extensions for ON
CmdOnPost
HTTP Post command for ON
CmdOffMethod
HTTP method for OFF (dropdown)
CmdOff
Command for OFF
CmdOffHTTP
HTTP extensions for OFF
CmdOffPost
HTTP Post command for OFF
AnalogfalseUse as digital input (checkbox)
Repeat0First repetition (s)
RepeatRate0Repetition Interval (s)
  • No labels