Metainformationen zur Seite
Perl Modul LoxBerry::LoxoneTemplateBuilder
The class LoxBerry::LoxoneTemplateBuilder is used to more easy generate Loxone Templates for Virtual UDP Inputs, Virtual HTTP Inputs and Virtual Outputs. On usage, you create a VI or VO object, and can add Commands to the VI/VO one by one.
LoxBerry Compatibility
This object class is in available from V2.0. Set the minimum LoxBerry version in your plugin.cfg.
Inclusions
This library automatically includes:
- use HTML::Entities;
Abstract
use LoxBerry::LoxoneTemplateBuilder; ## Virtual HTTP Inputs ## my $VIhttp = LoxBerry::LoxoneTemplateBuilder->VirtualInHttp( Title => "LoxBerry Healthcheck", Address => "http://loxberry:loxberry@loxberry/admin/system/healthcheck.cgi", ); my $linenr = $VIhttp->VirtualInHttpCmd ( Title => "timeepoch", Check => '"timeepoch":\v', ); # Get the content of a specific line number (line 3) my $vicmd = $VIhttp->VirtualInHttpCmd ( 3 ); # Delete a specific line $VIhttp->delete($linenr); # Get the created xml template print $VIhttp->output; ## Virtual UDP Inputs ## my $VIudp = LoxBerry::LoxoneTemplateBuilder->VirtualInUdp( Title => "LoxBerry Weather", Address => "", Port => "12345", ); my $linenr = $VIudp->VirtualInUdpCmd ( Title => "Temperature", Check => '"temperature":\v', ); # Get the content of a specific line number (line 3) my $vicmd = $VIhttp->VirtualInUdpCmd ( 3 ); # Get the created XML template print $VIudp->output; ## Virtual Outputs ## my $VO = LoxBerry::LoxoneTemplateBuilder->VirtualOut( Title => "Sonos", Address => "http://192.168.1.232:1400", ); my $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>', ); print $VO->output;
The creation of the object classes VirtualInHttp
, VirtualInUdp
and VirtualOut
return the pointer to the object.
For adding the commands, use the VirtualInHttpCmd
, VirtualInUdpCmd
or VirtualOutCmd
accordingly to your class. The functions throw an exception, if you mix up class and *Cmd functions (e.g. creating an VI and add an VO Cmd).
The *Cmd functions return the index of the added command. You can use this index to later delete a line. Stored indexes stay consistent, also if you delete elements before.
The delete method deletes a line, using the provided index.
Using the *Cmd
commands with a number as single parameter, returns the Cmd object of that line.
The 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.
Virtual HTTP Input
Virtual HTTP Input Constructor
LoxBerry::LoxoneTemplateBuilder->VirtualInHttp
Parameter | Default value | Description in Loxone Config |
---|---|---|
Title | Name | |
Comment | Description | |
Address | URL | |
PollingTime | 60 | Polling Cycle [s] |
Virtual HTTP Input Command
VirtualInHttp->VirtualInHttpCmd
Parameter | Default value | Description in Loxone Config |
---|---|---|
Title | Name | |
Comment | Description | |
Check | Command recognition | |
Signed | true | Signed values (checkbox) |
Analog | true | (not present) |
SourceValLow | 0 | Input value 1 |
DestValLow | 0 | Target value 1 |
SourceValHigh | 100 | Input value 2 |
DestValHigh | 100 | Target value 2 |
DefVal | 0 | Default value |
MinVal | -2147483647 | Minimum value |
MaxVal | 2147483647 | Maximum value |
Virtual UDP Input
Virtual UDP Input Constructor
LoxBerry::LoxoneTemplateBuilder->VirtualInUdp
Parameter | Default value | Description in Loxone Config |
---|---|---|
Title | Name | |
Comment | Description | |
Address | Sender address | |
Port | UDP receive port |
Virtual UDP Input Command
VirtualInUdp->VirtualInUdpCmd
Parameter | Default value | Description in Loxone Config |
---|---|---|
Title | Name | |
Comment | Description | |
Address | Sender address | |
Check | Command recognition | |
Signed | true | Signed values (checkbox) |
Analog | true | Use as digital input (checkbox) |
SourceValLow | 0 | Input value 1 |
DestValLow | 0 | Target value 1 |
SourceValHigh | 100 | Input value 2 |
DestValHigh | 100 | Target value 2 |
DefVal | 0 | Default value |
MinVal | -2147483647 | Minimum value |
MaxVal | 2147483647 | Maximum value |
Virtual Output
Virtual Output Constructor
LoxBerry::LoxoneTemplateBuilder->VirtualOut
Parameter | Default value | Description in Loxone Config |
---|---|---|
Title | Name | |
Comment | Description | |
Address | Address | |
CmdInit | Command to establish connection | |
CloseAfterSend | true | Close connection after sending (checkbox) |
CmdSep | Separator |
Virtual Output Command
VirtualOut->VirtualOutCmd
Parameter | Default value | Description 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 | |
Analog | false | Use as digital input (checkbox) |
Repeat | 0 | First repetition (s) |
RepeatRate | 0 | Repetition Interval (s) |
Further Hints
Escaping of checks (\v,...)
- Keep in mind, that \v, \i,… syntax is parsed by PHP. Examples:
- If you use single quotes
'\iHallo:\i\v'
, PHP is directly print these strings. - If you use double quotes, you have to escape the backslash char by a backslash:
"\\iHallo\\i\\v"
.