SCRIPTING for X1/L1

Introducing the SCRIPTING Logic Node for Gira X1 and L1

With the SCRIPTING Logic Node you can combine calculations, text processing and custom logic into a single powerful block, replacing multiple formula, formatter and parser modules at once. Save yourself all those other blocks, wiring and using many datapoints! Keep it simple and organized in 1 block!

Build compact logic flows, reduce wiring complexity and create advanced automations with just a few lines of code. From smart data handling to dynamic text generation and complex conditions: everything runs inside one fast, flexible node.

Finally, real JavaScript scripting inside your logic project!​
This logic node crushes the Formelberechnung​, TextformatiererJSON-Parser and many other logic nodes with it’s easy, flexible and lightweight use.

One block. Endless possibilities.

All examples and a code editor can be found here: https://www.roelbroersma.nl/scripting (see there for the very handy code editor which makes your scripts 1-liners)

The logic node has an Auto Update Check (during validation in the GPA) and during operation on the X1/L1 so you will get notified of updates!

Tip: Ask AI for a script (see below!)

This logic node is also available for the Gira Homeserver as a Baustein, so you can exchange scripts between X1/L1 and the Homeserver!

 

How it works:

Sending any value to the Trigger port (bool/number/text, even false or zero) will execute the script.

Output ports will always be set if you trigger the script. If the script doesn’t have a value for it, it will be 0.

Some examples:

Numbers

OUT1 = IN1 * 1.19; // Multiply with Mwst.

OUT1 = IN1 + IN2 + IN3 + (IN4+2) // Set Output sum.

OUT1 = IN1 + IN2; OUT2 = IN1 - IN2; // Set multiple outputs in one time

OUT1 = (IN1 / 255) * 100; // Devide and use ( and )

OUT1 = Math.round(IN1 * 100) / 100; // Math.round will always round on whole number, to have two decimals, device by 100.

OUT1 = Math.min(Math.max(IN1, 0), 100); // Limit the Input between 0 and 100

OUT1 = Math.abs(IN1); // Inverse: -5 -> 5

OUT1 = -IN1; // Also 5 -> -5

OUT1 = Math.pow(IN1, 2); // (power of 2): IN1²

OUT1 = Math.sqrt(IN1); // (taking the root): √IN1

Strings (text)

OUT1 = "Hello there!"; // Set a simple text to Output1

OUT1 = "Value is: " + IN1;      // Set combined text+value. Example: "Value is: 10"

OUT1 = "My " + IN1 + " has " + IN2 + " homes";   // Concatenate Strings. Example: "My Son has 2 homes"

OUT1 = IN1.toString().substring(0, 5);    // Take the first 5 characters (start at character 0)

OUT1 = IN1.toString().substring(0, 5);    // Trim spaces

if (IN1.length > 10) OUT1 = IN1.substring(0, 10) + "..."; // Shorten text to 10 characters + "..."
else OUT1 = IN1;

OUT1 = IN1.toString().substring(0, 5);    // Take the first 5 characters (start at character 0)

OUT1 = IN1.replace(/,/g,"."); // Replace all commas by dots.

OUT1 = IN1.slice(-3); // Remove last 3 characters

Logic

if (IN1=1) OUT1=1 // Use If to set output if IN1=1, otherwise OUT1 will be default/0.

var temp = IN1; // Declare a variable and use it or
OUT1 = tempt;

i=1;
OUT1 = this["IN"+1] // Computed variabe: OUT1=IN1

if (IN1 >= 50) OUT1 = 1; // Use if else
else OUT1 = 0;

if (IN1==1) OUT1 = 1; // Use if, elseif, else
else if (IN2==1) OUT1 = 2;
else if (IN3==1) OUT1 = 3;
else OUT1 = 0;

if (OUT1==1 && IN2==0) OUT2 = 123; // Read the value of OUT1

switch(IN1) { // Switch Logic (easier than if/elseif/else)
   case 0: OUT1 = "OFF"; break;
   case 1: OUT1 = "AUTO"; break;
   case 2: OUT1 = "MANUAL"; break;
   default: OUT1 = "UNKNOWN";
}

for (var i = 1; i <= 5; i++) { // A FOR Loop
   if (this["IN" + i] == true) { // The computed variable IN1...IN5
      OUT1 = i;
      break;
   }
}

JSON (extract data easily!)
Let’s assume the following sample JSON:

{
   "device": {
      "name": "LivingRoomController",
      "status": "online",
      "metrics": {
         "temperature": 21.6,
         "humidity": 48,
         "power": 312.4
      },
      "modes": [
         { "id": 1, "name": "Auto", "active": true },
         { "id": 2, "name": "Eco", "active": false },
         { "id": 3, "name": "Boost", "active": false }
      ]
   }

We can do the following:


var obj = JSON.parse(IN1); // Read Input1 as JSON

OUT1 = obj.device.name; // "LivingRoomController"

OUT2 = obj.device.metrics.temperature; // 21.6

OUT3 = obj.device.modes[0].name; // "Auto"

OUT4 = obj.device.modes[2].active; // false

OUT5 = obj.device.modes.length; // 3

OUT6 = obj.device.status + " / " + obj.device.metrics.power + "W";

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

  • Logikbaustein | Alle

    ​MIELE integration for HomeServer

    Rated 0 out of 5
    0,00 
    Enthält 19% MwSt.
    Kostenloser Versand
    Lieferzeit: nicht angegeben
    Bei Lieferungen in Nicht-EU-Länder können zusätzliche Zölle, Steuern und Gebühren anfallen.
  • Logikbaustein | Alle

    ​MIELE integration for X1 or L1

    Rated 0 out of 5
    0,00 
    Enthält 19% MwSt.
    Kostenloser Versand
    Lieferzeit: nicht angegeben
    Bei Lieferungen in Nicht-EU-Länder können zusätzliche Zölle, Steuern und Gebühren anfallen.
  • Logikbaustein | Alle

    TextSelector XL for HomeServer

    Rated 0 out of 5
    0,00 
    Enthält 19% MwSt.
    Kostenloser Versand
    Lieferzeit: nicht angegeben
    Bei Lieferungen in Nicht-EU-Länder können zusätzliche Zölle, Steuern und Gebühren anfallen.
  • Logikbaustein | Alle

    SCRIPTING for HomeServer/FacilityServer

    Rated 0 out of 5
  • Logikbaustein | Alle

    ​Counter Plus Logic Node for Gira X1/L1

    Rated 0 out of 5
    0,00 
    Enthält 19% MwSt.
    Kostenloser Versand
    Lieferzeit: nicht angegeben
    Bei Lieferungen in Nicht-EU-Länder können zusätzliche Zölle, Steuern und Gebühren anfallen.
  • Logikbaustein | Alle

    SAMSUNG TV (<2016) for HomeServer

    Rated 0 out of 5
    0,00 
    Enthält 19% MwSt.
    Kostenloser Versand
    Lieferzeit: nicht angegeben
    Bei Lieferungen in Nicht-EU-Länder können zusätzliche Zölle, Steuern und Gebühren anfallen.
Warenkorb
Nach oben scrollen