Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. [gelöst]Howto createState als Bool?

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [gelöst]Howto createState als Bool?

    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      Fitti last edited by

      Hi,

      wie kann ich eine Boolsche Variable anlegen, so dass diese auch boolisch in den Objekten vorhanden ist?
      578_bool1.png

      Mit

      createState("pfad.object1", false, {name: 'Ich will ein Bool sein', type: 'state'});
      

      Geht es nicht. Wobei letzteres (type: 'state') einfach nur einer meiner Versuche war. Ebenso type: 'bool' versucht. Finde auch nichts bei der Javascript Beschreibung im git. Wahrscheinlich suche ich wieder falsch.

      Bei mir steht immer der Text 'false' drinnen.
      578_bool2.png

      Danke im Voraus,

      Fitti

      1 Reply Last reply Reply Quote 0
      • paul53
        paul53 last edited by

        createState(name, false, {
          read: true, 
          write: true, 
          desc: "Beschreibung", 
          type: "boolean", 
          def: false
        });
        
        1 Reply Last reply Reply Quote 0
        • F
          Fitti last edited by

          Danke! Mann muss vorher die Variable löschen, sonst greift es nicht (als Tipp an andere, die das vielleicht hier lesen).

          Einzig, ich musste aus 'desc' 'name' machen, sonst wird einfach der gesamte Objectpfad in die Beschriebung geschrieben.

          So ging es dannn:

          createState(name, false, {
            read: true, 
            write: true, 
            name: "Beschreibung", 
            type: "boolean", 
            def: false
          });
          
          1 Reply Last reply Reply Quote 0
          • P
            pix last edited by

            Hallo,

            ich glaube, mit forceCreation wird der Datenpunkt neu angelegt, egal, ob schon vorhanden oder nicht. Bin im Zug und kann es nicht ausprobieren.

            ` > createState

            createState(name, initialValue, forceCreation, common, native, callback)

            Create state and object in javascript space if does not exist, e.g. "javascript.0.mystate".

            ####Parameters:

            name: name of the state without namespace, e.g. "mystate"

            initialValue: variable can be initialized after created. Value "undefined" means do not initialize value.

            forceCreation: create state independent of if state yet exists or not.

            common: common description of object see description here

            native: native description of object. Any specific information.

            callback: called after state is created and initialized.

            It is possible short type of createState:

            createState('myVariable') - simply create variable if does not exist

            createState('myVariable', 1) - create variable if does not exist and initialize it with value 1

            createState('myVariable', {name: 'My own variable', unit: '°C'}, function () {log('created');});

            createState('myVariable', 1, {name: 'My own variable', unit: '°C'}) - create variable if does not exist with specific name and units `

            Hier kann man noch tiefer eintauchen:

            https://github.com/ioBroker/ioBroker/bl … A.md#state

            Pix

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            Support us

            ioBroker
            Community Adapters
            Donate

            562
            Online

            31.7k
            Users

            79.7k
            Topics

            1.3m
            Posts

            3
            4
            11087
            Loading More Posts
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes
            Reply
            • Reply as topic
            Log in to reply
            Community
            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
            The ioBroker Community 2014-2023
            logo