Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. [gelöst]Howto createState als Bool?

NEWS

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    8.8k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    13
    1
    2.2k

  • Neues Video "KI im Smart Home" - ioBroker plus n8n
    BluefoxB
    Bluefox
    16
    1
    3.2k

[gelöst]Howto createState als Bool?

Scheduled Pinned Locked Moved Skripten / Logik
4 Posts 3 Posters 11.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fitti
    wrote on last edited by
    #1

    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

    "Es wird die Zeit kommen, da ihr euch entscheiden müsst zwischen dem, was richtig ist, und dem, was bequem ist."
    Plural von Status ist auch Status!

    1 Reply Last reply
    0
    • paul53P Offline
      paul53P Offline
      paul53
      wrote on last edited by
      #2
      createState(name, false, {
        read: true, 
        write: true, 
        desc: "Beschreibung", 
        type: "boolean", 
        def: false
      });
      

      Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
      Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fitti
        wrote on last edited by
        #3

        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
        });
        

        "Es wird die Zeit kommen, da ihr euch entscheiden müsst zwischen dem, was richtig ist, und dem, was bequem ist."
        Plural von Status ist auch Status!

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pix
          wrote on last edited by
          #4

          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

          ioBroker auf Ubuntu in Proxmox (früher Mac mini (bis OS X 10.12.6 Sierra), VIS via iOS; angeschlossen: Homematic CCU2, Homepilot 1, ConBee II, einige Wemos, Sonos, Unifi CK+Protect, Homekit, Homebridge; KEIN blockly! Github-Profil

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          Support us

          ioBroker
          Community Adapters
          Donate

          834

          Online

          32.4k

          Users

          81.5k

          Topics

          1.3m

          Posts
          Community
          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
          ioBroker Community 2014-2025
          logo
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Home
          • Recent
          • Tags
          • Unread 0
          • Categories
          • Unreplied
          • Popular
          • GitHub
          • Docu
          • Hilfe