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. Blockly
  5. (Gelöst) Zeichenkette in Zahl umwandeln (Aqara/Deconz/Vibrationssensor/Winkel)

NEWS

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    18
    1
    710

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    18
    1
    5.9k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    1.5k

(Gelöst) Zeichenkette in Zahl umwandeln (Aqara/Deconz/Vibrationssensor/Winkel)

Scheduled Pinned Locked Moved Blockly
blockly
32 Posts 5 Posters 4.1k Views 3 Watching
  • 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.
  • M muckel

    @OliverW
    Danke für den Input.
    Leider ist das Ergebnis nicht so wie gewünscht. Ich mache sicher etwas falsch.

    Blockly generiert folgenden Code:

    /**

    • Beschreibe diese Funktion …
      */
      function etwas_tun() {
      parseInt("deconz.0.Sensors.34.orientation".split(",")[1])
      return 1;
      }

    on({id: 'deconz.0.Sensors.34.orientation', change: "ne"}, function (obj) {
    var value = obj.state.val;
    var oldValue = obj.oldState.val;
    if (etwas_tun() < -20) {
    console.log((etwas_tun()));
    setState("javascript.0.Garage"/Garage/, 'Geschlossen', true);
    } else if (etwas_tun() > 0) {
    console.log((etwas_tun()));
    setState("javascript.0.Garage"/Garage/, 'Offen', true);
    }
    });

    Hast du eine Idee in Blockly?

    OliverIOO Offline
    OliverIOO Offline
    OliverIO
    wrote on last edited by
    #5

    @muckel Blockly ist nicht so meins.
    Aber @paul53 hat glaub ich das in blockly umgesetzt

    Meine Adapter und Widgets
    TVProgram, SqueezeboxRPC, OpenLiga, RSSFeed, MyTime,, pi-hole2, vis-json-template, skiinfo, vis-mapwidgets, vis-2-widgets-rssfeed
    Links im Profil

    M 1 Reply Last reply
    0
    • paul53P paul53

      @muckel sagte:

      Idee in Blockly?

      Blockly_Text3Werte_nach_Zahl.JPG

      Wert ist eine Eigenschaft des Triggerdatenpunktes (unter Blöcke Trigger).

      M Offline
      M Offline
      muckel
      wrote on last edited by
      #6

      @paul53

      Hallo Paul! Danke für deine Unterstützung. Ich habe dein Blockly nachgebaut.
      Leider bekomme ich bei Bewegung des Sensors immer folgenden Fehler:

      23:35:24.428 error javascript.0 at Object.<anonymous> (script.js.Garage_Offen_Zu:7:57)

      paul53P 1 Reply Last reply
      0
      • OliverIOO OliverIO

        @muckel Blockly ist nicht so meins.
        Aber @paul53 hat glaub ich das in blockly umgesetzt

        M Offline
        M Offline
        muckel
        wrote on last edited by
        #7

        @OliverW
        Danke trotzdem. :-)

        1 Reply Last reply
        0
        • M muckel

          @OliverW
          Danke für den Input.
          Leider ist das Ergebnis nicht so wie gewünscht. Ich mache sicher etwas falsch.

          Blockly generiert folgenden Code:

          /**

          • Beschreibe diese Funktion …
            */
            function etwas_tun() {
            parseInt("deconz.0.Sensors.34.orientation".split(",")[1])
            return 1;
            }

          on({id: 'deconz.0.Sensors.34.orientation', change: "ne"}, function (obj) {
          var value = obj.state.val;
          var oldValue = obj.oldState.val;
          if (etwas_tun() < -20) {
          console.log((etwas_tun()));
          setState("javascript.0.Garage"/Garage/, 'Geschlossen', true);
          } else if (etwas_tun() > 0) {
          console.log((etwas_tun()));
          setState("javascript.0.Garage"/Garage/, 'Offen', true);
          }
          });

          Hast du eine Idee in Blockly?

          T Offline
          T Offline
          tim3trick
          wrote on last edited by
          #8

          @muckel Deine Funktion "etwas_tun" erzeugt den Wert und returned dann 1.
          Soll das so?

          M 1 Reply Last reply
          0
          • M muckel

            @paul53

            Hallo Paul! Danke für deine Unterstützung. Ich habe dein Blockly nachgebaut.
            Leider bekomme ich bei Bewegung des Sensors immer folgenden Fehler:

            23:35:24.428 error javascript.0 at Object.<anonymous> (script.js.Garage_Offen_Zu:7:57)

            paul53P Offline
            paul53P Offline
            paul53
            wrote on last edited by
            #9

            @muckel sagte:

            script.js.Garage_Offen_Zu:7:57

            Poste bitte den Javascript-Code ohne die letzte Zeile in Code tags.

            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

            M 1 Reply Last reply
            0
            • T tim3trick

              @muckel Deine Funktion "etwas_tun" erzeugt den Wert und returned dann 1.
              Soll das so?

              M Offline
              M Offline
              muckel
              wrote on last edited by
              #10

              @tim3trick
              Nein, das soll es natürlich nicht.
              Paul hat glaube ich den richtigen Ansatz, aber etwas funktioniert noch nicht so richtig.
              Oder ich habe im Blockly Mist gebaut.

              1 Reply Last reply
              0
              • paul53P paul53

                @muckel sagte:

                script.js.Garage_Offen_Zu:7:57

                Poste bitte den Javascript-Code ohne die letzte Zeile in Code tags.

                M Offline
                M Offline
                muckel
                wrote on last edited by muckel
                #11

                @paul53

                var Winkel;
                
                
                on({id: 'deconz.0.Sensors.34.orientation', change: "ne"}, function (obj) {
                  var value = obj.state.val;
                  var oldValue = obj.oldState.val;
                  Winkel = parseFloat(((obj.state ? obj.state.val : "").split(',')[1]));
                  if (Winkel < -20) {
                    console.log(Winkel);
                    setState("javascript.0.Garage"/*Garage*/, 'Geschlossen', true);
                  } else if (Winkel > 0) {
                    console.log(Winkel);
                    setState("javascript.0.Garage"/*Garage*/, 'Offen', true);
                  }
                });
                

                edit: sorry, finger waren schneller als das hirn.

                T paul53P 2 Replies Last reply
                0
                • M muckel

                  @paul53

                  var Winkel;
                  
                  
                  on({id: 'deconz.0.Sensors.34.orientation', change: "ne"}, function (obj) {
                    var value = obj.state.val;
                    var oldValue = obj.oldState.val;
                    Winkel = parseFloat(((obj.state ? obj.state.val : "").split(',')[1]));
                    if (Winkel < -20) {
                      console.log(Winkel);
                      setState("javascript.0.Garage"/*Garage*/, 'Geschlossen', true);
                    } else if (Winkel > 0) {
                      console.log(Winkel);
                      setState("javascript.0.Garage"/*Garage*/, 'Offen', true);
                    }
                  });
                  

                  edit: sorry, finger waren schneller als das hirn.

                  T Offline
                  T Offline
                  tim3trick
                  wrote on last edited by
                  #12

                  @muckel sollte obj.state nicht gesetzt sein, nimmt er den Leerstring, splitted ihn nach Komma und nimmt das zweite Element des Arrays, um das nach Float zu Parsen. Es gibt aber kein zweites Element, entweder ist das schon der Fehler, oder zumindest ein potentieller Bug.

                  Alternative: als "Else" nimmst du "0,0,0"

                  1 Reply Last reply
                  0
                  • M muckel

                    @paul53

                    var Winkel;
                    
                    
                    on({id: 'deconz.0.Sensors.34.orientation', change: "ne"}, function (obj) {
                      var value = obj.state.val;
                      var oldValue = obj.oldState.val;
                      Winkel = parseFloat(((obj.state ? obj.state.val : "").split(',')[1]));
                      if (Winkel < -20) {
                        console.log(Winkel);
                        setState("javascript.0.Garage"/*Garage*/, 'Geschlossen', true);
                      } else if (Winkel > 0) {
                        console.log(Winkel);
                        setState("javascript.0.Garage"/*Garage*/, 'Offen', true);
                      }
                    });
                    

                    edit: sorry, finger waren schneller als das hirn.

                    paul53P Offline
                    paul53P Offline
                    paul53
                    wrote on last edited by paul53
                    #13

                    @muckel .split(',') kann nicht auf den Wert des Datenpunktes angewendet werden. Füge mal vor setze Winkel einen debug output Wert ein. Was erscheint dann im Log ?

                    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

                    M T 2 Replies Last reply
                    0
                    • paul53P paul53

                      @muckel .split(',') kann nicht auf den Wert des Datenpunktes angewendet werden. Füge mal vor setze Winkel einen debug output Wert ein. Was erscheint dann im Log ?

                      M Offline
                      M Offline
                      muckel
                      wrote on last edited by
                      #14

                      @paul53

                      undefined :-(

                      paul53P 1 Reply Last reply
                      0
                      • M muckel

                        @paul53

                        undefined :-(

                        paul53P Offline
                        paul53P Offline
                        paul53
                        wrote on last edited by
                        #15

                        @muckel sagte:

                        undefined

                        Du hast an debug output eine Variable Wert übergeben ? Es muss die Eigenschaft Wert des Triggerdatenpunktes sein.

                        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

                        M 1 Reply Last reply
                        0
                        • paul53P paul53

                          @muckel sagte:

                          undefined

                          Du hast an debug output eine Variable Wert übergeben ? Es muss die Eigenschaft Wert des Triggerdatenpunktes sein.

                          M Offline
                          M Offline
                          muckel
                          wrote on last edited by
                          #16

                          @paul53
                          wie recht du hast:

                          23:58:27.903 info javascript.0 script.js.Garage_Offen_Zu: 7,-80,7

                          paul53P 1 Reply Last reply
                          0
                          • paul53P paul53

                            @muckel .split(',') kann nicht auf den Wert des Datenpunktes angewendet werden. Füge mal vor setze Winkel einen debug output Wert ein. Was erscheint dann im Log ?

                            T Offline
                            T Offline
                            tim3trick
                            wrote on last edited by
                            #17

                            @paul53 interessehalber, wieso nicht?

                            1 Reply Last reply
                            0
                            • M muckel

                              @paul53
                              wie recht du hast:

                              23:58:27.903 info javascript.0 script.js.Garage_Offen_Zu: 7,-80,7

                              paul53P Offline
                              paul53P Offline
                              paul53
                              wrote on last edited by
                              #18

                              @muckel sagte:

                              7,-80,7

                              Das sieht eigentlich gut aus, garantiert aber nicht, dass der Datenpunkt tatsächlich einen String enthält. Logge mal den Typ von Wert (unter Konvertierung).

                              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

                              M 1 Reply Last reply
                              0
                              • paul53P paul53

                                @muckel sagte:

                                7,-80,7

                                Das sieht eigentlich gut aus, garantiert aber nicht, dass der Datenpunkt tatsächlich einen String enthält. Logge mal den Typ von Wert (unter Konvertierung).

                                M Offline
                                M Offline
                                muckel
                                wrote on last edited by muckel
                                #19

                                @paul53
                                00:04:59.382 info javascript.0 script.js.Garage_Offen_Zu: object

                                {
                                "from": "system.adapter.deconz.0",
                                "user": "system.user.admin",
                                "ts": 1556892868113,
                                "common": {
                                "name": "Garagentor orientation",
                                "type": "string",
                                "read": true,
                                "write": false
                                },
                                "native": {},
                                "acl": {
                                "object": 1636,
                                "owner": "system.user.admin",
                                "ownerGroup": "system.group.administrator",
                                "state": 1636
                                },
                                "_id": "deconz.0.Sensors.34.orientation",
                                "type": "state"
                                }

                                paul53P 2 Replies Last reply
                                0
                                • T Offline
                                  T Offline
                                  tim3trick
                                  wrote on last edited by
                                  #20

                                  Oder wir schummeln und casten den Wert implizit mit (""+obj.state.val) der implizite Cast bei console scheint ja zu klappen

                                  1 Reply Last reply
                                  0
                                  • M muckel

                                    @paul53
                                    00:04:59.382 info javascript.0 script.js.Garage_Offen_Zu: object

                                    {
                                    "from": "system.adapter.deconz.0",
                                    "user": "system.user.admin",
                                    "ts": 1556892868113,
                                    "common": {
                                    "name": "Garagentor orientation",
                                    "type": "string",
                                    "read": true,
                                    "write": false
                                    },
                                    "native": {},
                                    "acl": {
                                    "object": 1636,
                                    "owner": "system.user.admin",
                                    "ownerGroup": "system.group.administrator",
                                    "state": 1636
                                    },
                                    "_id": "deconz.0.Sensors.34.orientation",
                                    "type": "state"
                                    }

                                    paul53P Offline
                                    paul53P Offline
                                    paul53
                                    wrote on last edited by
                                    #21

                                    @muckel sagte:

                                    object

                                    Dann enthält er schon ein Array und muss nicht mehr gesplittet werden. Damit vereinfacht sich die Umwandlung:
                                    setze Winkel auf nach Zahl in der Liste Wert nimm das 2. Element.

                                    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

                                    M 1 Reply Last reply
                                    0
                                    • paul53P paul53

                                      @muckel sagte:

                                      object

                                      Dann enthält er schon ein Array und muss nicht mehr gesplittet werden. Damit vereinfacht sich die Umwandlung:
                                      setze Winkel auf nach Zahl in der Liste Wert nimm das 2. Element.

                                      M Offline
                                      M Offline
                                      muckel
                                      wrote on last edited by
                                      #22

                                      @paul53

                                      Perfekt! Das wars! ☺
                                      Auf das wäre ich im Leben nicht gekommen. Danke schön.
                                      Ich stelle es auf gelöst.

                                      CU and good night!

                                      paul53P 1 Reply Last reply
                                      0
                                      • M muckel

                                        @paul53
                                        00:04:59.382 info javascript.0 script.js.Garage_Offen_Zu: object

                                        {
                                        "from": "system.adapter.deconz.0",
                                        "user": "system.user.admin",
                                        "ts": 1556892868113,
                                        "common": {
                                        "name": "Garagentor orientation",
                                        "type": "string",
                                        "read": true,
                                        "write": false
                                        },
                                        "native": {},
                                        "acl": {
                                        "object": 1636,
                                        "owner": "system.user.admin",
                                        "ownerGroup": "system.group.administrator",
                                        "state": 1636
                                        },
                                        "_id": "deconz.0.Sensors.34.orientation",
                                        "type": "state"
                                        }

                                        paul53P Offline
                                        paul53P Offline
                                        paul53
                                        wrote on last edited by
                                        #23

                                        @muckel sagte:

                                        "type": "string",

                                        Das garantiert nicht, dass der Wert tatsächlich einen String enthält. Wodurch wird der Wert des Datenpunktes geschrieben ?

                                        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

                                        M 1 Reply Last reply
                                        0
                                        • paul53P paul53

                                          @muckel sagte:

                                          "type": "string",

                                          Das garantiert nicht, dass der Wert tatsächlich einen String enthält. Wodurch wird der Wert des Datenpunktes geschrieben ?

                                          M Offline
                                          M Offline
                                          muckel
                                          wrote on last edited by
                                          #24

                                          @paul53
                                          Vom Deconz Adapter (Vibrationssensor von Aqara)

                                          paul53P 2 Replies Last reply
                                          0

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          554

                                          Online

                                          32.7k

                                          Users

                                          82.6k

                                          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