Metainformationen zur Seite
Communication LoxBerry to Miniserver - Perl
LoxBerry to Miniserver
HTTPS (SSL/TLS)
All information about communication by https (ssl/tls) to the Miniserver is valid from LoxBerry V2.0.2+. LoxBerry below V2.0.2 does not support Miniserver https.
https to Miniserver is only supported on Miniservers supporting https. Miniserver Gen1 and Miniserver Go do not support https.
Communication via MQTT and MQTT Gateway plugin
LoxBerry-Core team currently prefers the communication via MQTT to the Loxone Miniserver.
The MQTT Gateway automatically uses the preferred communication channel configured by the user, and supports https/ssl communication (without any user interaction/implementation in your plugin) . Using MQTT for communication makes your plugin more flexible, because also other devices and home automation software can make use of the data your plugin delivers.
To communicate to MQTT directly, or the MQTT Gateway, LoxBerry and the MQTT Gateway plugin offers Perl functions to aquire the communication channel, and an http and udp interface, as well as direct communication to the mqtt broker.
Communication via LoxBerry::IO library
LoxBerry provides an own library to easify the communication with the Miniserver. The library automatically uses https/ssl if the user has "Prefer https" configured in the Miniserver widget.
The LoxBerry synergy is thought as follows:
- Your plugin webif offers a Miniserver selection dropdown to configure what Miniserver is the receiver of your data. The dropdown is easily integrated to your web form: LoxBerry::Web::mslist_select_html
- The dropdown form submits the Miniserver number (1, 2,….) that you save in your plugin configuration.
- Using LoxBerry::IO functions, the first parameter of all functions is this Miniserver number. Therefore, there is no need to query any further information about the configured Miniserver in your scripts.
- LoxBerry::IO functions use the user-configured information from the Miniserver widget to submit the data.
- LoxBerry::IO functions using http for data transfer, automatically use https/ssl if the user has "Prefer https" selected in the Miniserver widget.
- CloudDNS-configured Miniservers are automatically resolved and used, without special handling in your plugin.
See LoxBerry::IO module and the functions explained in sub-pages: https://loxwiki.atlassian.net/wiki/x/M4GZS
Own communication methods with Miniservers configured in LoxBerry (using LoxBerry::System)
If you do not want to use MQTT or LoxBerry::IO for communication, but want to use the settings about the Miniservers defined by the user, you can:
- Offer a Miniserver selection dropdown in your plugin: LoxBerry::Web::mslist_select_html
- Use the LoxBerry function LoxBerry::System::get_miniservers to request all communication parameters the user defined in the Miniserver widget.
From the network and credentials information returned by get_miniservers, you can build your own communication channel to the Miniserver.
https/ssl hints
- The PREFERSSL setting should be obeyed. An SSL port may be defined, but the user may have disabled "Prefer HTTPS". A set SSL port in that case may be unavailable.
- The certificate the user has installed on the Miniserver may not be issued by a globally trusted CA, or may not have a correct FQDN hostname.
- Therefore, it might be required in your implementation to disable certificate chain check, and hostname check.
Own communication methods with Miniserver configured in LoxBerry (parsing general.cfg)
This is the most difficult and fault-prone way to get Miniserver information out of LoxBerry's configuration. As LoxBerry's libraries have implemented all the stuff required to handle special chars, whitespaces, correct encoding,… you or some users may fail in corner cases if you do not handle these circumstances correctly.
- Get the environment variable $LBHOMEDIR
- Read $LBHOMEDIR/config/system/general.cfg with an ini parser
- Read the numbers of Miniservers from BASE.MINISERVERS (Section [ BASE ], parameter MINISERVERS
- Read the sections [ MINISERVER1 ], [ MINISERVER2 ] accordingly to the configured number of Miniservers
- Use the data from the MINISERVERx section.
Generate Loxone templates in the plugin
To easify the configuration for your users in Loxone Config to communicate from and to your plugin, your Perl (or PHP) implementation can create ready-to-use Loxone Config templates that can be imported to Loxone Config.
With LoxBerry's module Perl Modul LoxBerry::LoxoneTemplateBuilder you can create these templates directly with information from your plugin. The user only needs to import the template and can send/deliver data from your plugin.