Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [Gelöst] JS Funktion

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    [Gelöst] JS Funktion

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

      Hallo Zusammen,

      komme leider nicht weiter. Möchte den Alias Datenpunkt so konfigurieren, dass er:

      true als true
      uncertain als true
      false als false

      anzeigt. Schreiben soll er allerdings nur true und false.

      af4e385b-b337-419f-b355-992d0d7b5993-image.png

      Kann jemand helfen?

      Danke 🙂

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

        @firechumper sagte: uncertain

        Ist der Original-DP vom Typ "string"? Denn boolesche Werte kennen kein uncertain.

        F 1 Reply Last reply Reply Quote 0
        • F
          firechumper @paul53 last edited by

          @paul53 Ist eine Scene Welche aber die Werte "True" "Uncertain" und "False" ausgibt

          {
            "common": {
              "name": "Wohnzimmerbeleuchtung Komplett",
              "type": "mixed",
              "role": "scene.state",
              "desc": "",
              "enabled": true,
              "read": true,
              "write": true,
              "def": false,
              "engine": "system.adapter.scenes.0"
            },
            "native": {
              "onTrue": {
                "trigger": {},
                "cron": null,
                "astro": null
              },
              "onFalse": {
                "enabled": false,
                "trigger": {},
                "cron": null,
                "astro": null
              },
              "easy": true,
              "virtualGroup": true,
              "burstInterval": 0,
              "members": [
                {
                  "id": "alias.0.Licht.Wohnzimmer_Hue_Schwarz.ON",
                  "setIfTrue": false,
                  "setIfFalse": null,
                  "stopAllDelays": true,
                  "desc": null,
                  "disabled": false,
                  "delay": 0
                },
                {
                  "id": "alias.0.Licht.Wohnzimmer_Hue_Weiß.ON",
                  "setIfTrue": false,
                  "setIfFalse": null,
                  "stopAllDelays": true,
                  "desc": null,
                  "disabled": false,
                  "delay": 0
                },
                {
                  "id": "alias.0.Licht.Wohnzimmer_Steckdose_Fenster.SET",
                  "setIfTrue": false,
                  "setIfFalse": null,
                  "stopAllDelays": true,
                  "desc": null,
                  "disabled": false,
                  "delay": 0
                },
                {
                  "id": "alias.0.Licht.Wohnzimmer_Stehlampe.SET",
                  "setIfTrue": false,
                  "setIfFalse": null,
                  "stopAllDelays": true,
                  "desc": null,
                  "disabled": false,
                  "delay": 0
                },
                {
                  "id": "alias.0.Licht.Wohnzimmer_TV_Beleuchtung.SET",
                  "setIfTrue": false,
                  "setIfFalse": null,
                  "stopAllDelays": true,
                  "desc": null,
                  "disabled": false,
                  "delay": 0
                },
                {
                  "id": "alias.0.Licht.Wohnzimmer_Tannenbaum.SET",
                  "setIfTrue": false,
                  "setIfFalse": null,
                  "stopAllDelays": true,
                  "desc": null,
                  "disabled": false,
                  "delay": 0
                }
              ]
            },
            "type": "state",
            "_id": "scene.0.Wohnzimmerbeleuchtung_Komplett",
            "from": "system.adapter.admin.0",
            "user": "system.user.admin",
            "ts": 1737140200148,
            "acl": {
              "object": 1636,
              "state": 1636,
              "owner": "system.user.admin",
              "ownerGroup": "system.group.administrator"
            }
          }
          
          paul53 1 Reply Last reply Reply Quote 0
          • paul53
            paul53 @firechumper last edited by

            @firechumper sagte: Ist eine Scene Welche aber die Werte "True" "Uncertain" und "False" ausgibt

            Typ "mixed" kann alles enthalten. Prüfe den Typ von allen 3 Werten:

            on('scene.0.Wohnzimmerbeleuchtung_Komplett', function(dp) {
                log('Wert: ' + dp.state.val + ', Typ: ' + typeof dp.state.val);
            });
            
            F 1 Reply Last reply Reply Quote 0
            • F
              firechumper @paul53 last edited by

              @paul53

              true = boolean
              uncertain = string
              flase = boolean

              bin da leider grün hinter den Ohren... wo füge ich das hier ein?

              on('scene.0.Wohnzimmerbeleuchtung_Komplett', function(dp) {
                  log('Wert: ' + dp.state.val + ', Typ: ' + typeof dp.state.val);
              });
              
              paul53 1 Reply Last reply Reply Quote 0
              • paul53
                paul53 @firechumper last edited by

                @firechumper sagte: wo füge ich das hier ein?

                Als Test-Skript im Javascript-Adapter.

                @firechumper sagte in JS Funktion:

                true = boolean
                uncertain = string
                flase = boolean

                Lesekonvertierung:

                !!val
                

                Schreibkonvertierung wird nicht benötigt, wenn der Alias-Typ "boolean" ist.

                F 1 Reply Last reply Reply Quote 0
                • F
                  firechumper @paul53 last edited by

                  @paul53 said in JS Funktion:

                  !!val

                  Es ist bitter wie einfach die Lösung sein kann 🎯

                  Vielen Dank! 🙂

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

                  Support us

                  ioBroker
                  Community Adapters
                  Donate

                  460
                  Online

                  31.8k
                  Users

                  79.9k
                  Topics

                  1.3m
                  Posts

                  2
                  7
                  308
                  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