Stats4Lox::msget_value

($respcode, $dataarray) = msget_value( $msno, $block );


Sends a HTTP REST request to the specified Miniserver and get all values of the specified block. All values including additional outputs are get back as a hash. It is the same as sending a request to Loxone's HTTP API with /all in the request url.

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

The second parameter is a string with the block name, description or UUID, e.g. Aussentemperatur or a6da627a-6677-11e3-a77d9c3de0c5866d or alternatively a full URL path starting with /jdev/


Make sure, that your block name/description or full url is correctly URI-encoded, especially with Loxone block names ("Küche"), or names with blanks ("Light livingroom"). 

Parameter

ParameterRequiredBeschreibung
$msno x Number of the Miniserver
$block x The block's name, description or UUID or alternatively a full URL path starting with /jdev/. The parameter must be URL-encoded correctly (except slashes in the path).

Return value

ParameterDescription
1. returnThe http response code
2. returnAn arrayref of hashes of all available values. undef on any error.


The first return value is the http response code.

The second return value is an arrayref of hashes of all returned values.

A function call looks like this:

my ( $respcode, $dataarray ) = msget_value( 1, "a6da627a-6677-11e3-a77d9c3de0c5866d" );

The $respcode status may contain 

  • a LoxBerry-own "error code" in the 6xx area (e.g. "601" for "Miniserver not defined")
  • the HTTP statuscode
    • 200 if the request was successful
    • 404 if the requested resource was not found
    • 500 if you have no permissions to access this resource

For details please see LoxBerry::IO::mshttp_call2

Each hash of the $dataarray contains the following keys:

Key Description Example
Code The http response code. Available only in the first hash of the Default value. 200
Unit The unit of the default value. Available only in the first hash of the Default value."°C"
ValueThe value 21.7
Name The name of the output. Available only in the first hash of the Default value. "AQ"
Key The key of the output. Available only in the first hash of the Default value. "output0"

Usage

#!/usr/bin/perl
 
use LoxBerry::System;
require "$lbpbindir/libs/Stats4Lox.pm";
 
# Debug: Set to 1 for debug output to STDERR.
$Stats4Lox::DEBUG = 0;
$Stats4Lox::DUMP = 0;
 
my ($respcode, $dataarray) = Stats4Lox::msget_value( 1, "a6da627a-6677-11e3-a77d9c3de0c5866d" );
 
print "Response Code is: $respcode\n\n";
 
# Loop through all returned values
my $i = "0";
foreach (@$dataarray) {
        print "=== $i. Dataset: ===\n";
        foreach $key ( keys %$_ ) {
                my $value = $_->{$key};
                print "Value of $key is: $value\n";
        }
        $i++;
}
 
# Access a single value
print "Default value is " . @$dataarray[0]{"Value"} . "\n";