Ankündigung

Einklappen
Keine Ankündigung bisher.

X1 Logic Node: Scripting - One block. Endless possibilities.

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    X1 X1 Logic Node: Scripting - One block. Endless possibilities.

    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.

    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​, Textformatierer, JSON-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!)

    Download: https://www.roelbroersma.nl/media/do...Logic_Node.zip


    X1_Logic_Node_Scripting.png

    Some examples:


    NUMBERS
    PHP-Code:
    OUT1 IN1 1.19;                        // Multiply with Mwst.

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

    OUT1 IN1 IN2OUT2 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(IN10), 100);    // Limit the Input between 0 and 100

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

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

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

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


    String manipulation (text)
    PHP-Code:
    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(05);       // Take the first 5 characters (start at character 0)

    OUT1 IN1.toString().substring(05);       // Trim spaces

    if (IN1.length 10OUT1 IN1.substring(010) + "..."// Shorten text to 10 characters + "..."
    else OUT1 IN1;

    OUT1 IN1.toString().substring(05);         // 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
    PHP-Code:
    if (IN1=1OUT1=1                // Use If to set output ONLY if IN1=1, otherwise do NOT set the output.

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

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

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

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

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

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

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

    JSON
    Let's take the following sample JSON to explain:
    PHP-Code:
    {
      
    "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 }
        ]
      }
    }
    ​​ 
    PHP-Code:
    ​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"


    You can even ask AI (ChatGPT, CoPilot or DeepSeek):

    "Hello, can you generate JavaScript code for the Gira X1 Scripting Logic Module (see examples at https://www.roelbroersma.nl/scripting)?
    I have 2 inputs and 1 output.
    • IN1 = weather information as text
    • IN2 = expected afternoon temperature (number)
    Requirements:
    • Output format: Temp: XX°C - DESCRIPTION
    • DESCRIPTION must be truncated to 20 characters and end with .. if longer
    • Use only plain JavaScript compatible with Jint
    • Assign the result to OUT1"


    CHANGE LOG


    ​v0.1.000018 (01-feb-2026)
    • Initial version




    Zuletzt geändert von Roeller; Heute, 02:31.

    #2
    First comment reserved for future use

    Kommentar


      #3
      Second comment reserved for future use

      Kommentar

      Lädt...
      X