Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. [gelöst] places Adapter: type "number" but received type

    NEWS

    • Neues Video "KI im Smart Home" - ioBroker plus n8n

    • Neues Video über Aliase, virtuelle Geräte und Kategorien

    • Wir empfehlen: Node.js 22.x

    [gelöst] places Adapter: type "number" but received type

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

      Ich möchte mal mit diesen Warnungen aufräumen. Bin mir nicht sicher ob es am Adapter liegt (issue auf Github) oder am SCript oder sonst was anderem?

      So sieht das Blockly aus:
      6604ea25-eebf-4033-a6a8-18f15d7ca969-image.png
      ALs Javascript so:

      on({id: 'iot.0.services.custom_lat', change: "any", ack: true}, async function (obj) {
        var value = obj.state.val;
        var oldValue = obj.oldState.val;
        setState("places.0.lobomau.latitude"/*latitude*/, parseFloat(getState("iot.0.services.custom_lat").val));
        setState("places.0.lobomau.longitude"/*longitude*/, parseFloat(getState("iot.0.services.custom_lon").val));
      });
      

      raw von iot.0.services.custom_lat, stört hier vielleicht type "mixed"?

      {
        "_id": "iot.0.services.custom_lat",
        "type": "state",
        "common": {
          "name": "Service for lat",
          "write": false,
          "read": true,
          "type": "mixed",
          "role": "value"
        },
        "native": {},
        "from": "system.adapter.iot.0",
        "user": "system.user.admin",
        "ts": 1646218871311,
        "acl": {
          "object": 1636,
          "state": 1636,
          "owner": "system.user.admin",
          "ownerGroup": "system.group.administrator"
        }
      }
      

      log Info:

      
      places.0
      2022-03-22 08:20:03.851	info	State value to set for "places.0.lobomau.longitude" has to be type "number" but received type "string"
      
      places.0
      2022-03-22 08:20:03.849	info	State value to set for "places.0.lobomau.latitude" has to be type "number" but received type "string"
      
      Ralla66 1 Reply Last reply Reply Quote 0
      • Ralla66
        Ralla66 Most Active @lobomau last edited by

        @lobomau

        habe ich auch immer mit Blockly wenn der Type mixed ist.
        Ändere dann immer den DP weils am einfachsten ist.

        lobomau 1 Reply Last reply Reply Quote 0
        • lobomau
          lobomau @Ralla66 last edited by

          @ralla66 probiere ich mal aus.
          Das Problem habe ich noch wo anders. Da ist es aber string und number. Und da hatte es nichts gebracht das Umstellen.

          lobomau 1 Reply Last reply Reply Quote 0
          • lobomau
            lobomau @lobomau last edited by

            @lobomau log bleibt nach Änderung zu number 😞

            {
              "_id": "iot.0.services.custom_lat",
              "type": "state",
              "common": {
                "name": "Service for lat",
                "write": false,
                "read": true,
                "type": "number",
                "role": "value"
              },
              "native": {},
              "acl": {
                "object": 1636,
                "state": 1636,
                "owner": "system.user.admin",
                "ownerGroup": "system.group.administrator"
              },
              "from": "system.adapter.admin.0",
              "user": "system.user.admin",
              "ts": 1647942354775
            }
            
            
            places.0
            2022-03-22 10:50:05.308	info	State value to set for "places.0.lobomau.latitude" has to be type "number" but received type "string"
            
            haus-automatisierung 1 Reply Last reply Reply Quote 0
            • haus-automatisierung
              haus-automatisierung Developer Most Active @lobomau last edited by

              @lobomau sagte in places Adapter: type "number" but received type "string":

              @lobomau log bleibt nach Änderung zu number

              Es geht um den Datentyp im Ziel-State. Also places.0.lobomau.latitude. Wenn Du iot.0.services.custom_lat zu number änderst, dann hilft das nichts.

              lobomau 1 Reply Last reply Reply Quote 0
              • AlCalzone
                AlCalzone Developer last edited by

                Da die Meldung mit places.0 versehen ist und das Skript oben korrekterweise eine Zahl schreibt (parseFloat) gehe ich grade davon aus, dass das ein Bug im places Adapter ist und nicht im Skript.

                1 Reply Last reply Reply Quote 0
                • lobomau
                  lobomau @haus-automatisierung last edited by lobomau

                  @haus-automatisierung da hatte ich auch geschaut. Da ist die ganze Zeit numbers. Dann können wir das ja ausschließen!?
                  Also vermutlich ein Fehler im places-Adapter wie @AlCalzone meint!?
                  Nur komisch... hab nur ich den Fehler und den Adapter in Betrieb? Den issue hatte ich vor einiger Zeit erstellt.

                  places.0.lobomau.latitude:

                  {
                    "type": "state",
                    "common": {
                      "name": "latitude",
                      "role": "value.gps.latitude",
                      "type": "number",
                      "read": true,
                      "write": true,
                      "custom": {
                        "influxdb.0": {
                          "enabled": true,
                          "changesOnly": true,
                          "debounce": "1000",
                          "retention": "31536000",
                          "changesRelogInterval": 0,
                          "changesMinDelta": 0,
                          "storageType": "",
                          "aliasId": ""
                        }
                      }
                    },
                    "native": {},
                    "from": "system.adapter.places.0",
                    "user": "system.user.admin",
                    "ts": 1545598159836,
                    "_id": "places.0.lobomau.latitude",
                    "acl": {
                      "object": 1636,
                      "owner": "system.user.admin",
                      "ownerGroup": "system.group.administrator",
                      "state": 1636
                    }
                  }
                  
                  haus-automatisierung 1 Reply Last reply Reply Quote 0
                  • haus-automatisierung
                    haus-automatisierung Developer Most Active @lobomau last edited by

                    @lobomau Warum setzt Du die States eigentlich direkt? Laut Doku müsstest Du doch mit messages / sendTo arbeiten um die Position zu aktualisieren?!

                    lobomau 1 Reply Last reply Reply Quote 0
                    • lobomau
                      lobomau @haus-automatisierung last edited by lobomau

                      @haus-automatisierung ok... dann hat wohl jemand die Doku nicht gelesen 🙋‍♂️
                      Mal schauen ob ich das verstehe und umsetzen kann...

                      Edit.: ok.. man kann Adapter auswälhen bei sendTo 😉

                      082b49f7-1791-4e62-816f-ceb99db3932d-image.png

                      lobomau 1 Reply Last reply Reply Quote 0
                      • lobomau
                        lobomau @lobomau last edited by

                        @lobomau ich hatte doch die Doku gelesen und habe es auch im Einsatz. Aber nur im Vorschritt. Die GPS Daten kommen vom iot-Adapter und dieser schickt es zu places. Hier liegt vermutlich der Hund begraben. Denn hier wird ein string verarbeitet.
                        Oh Mann ... den Gedanken hatte ich bereits vor einigen Wochen. Ich wollte hier schon fragen wie ich das unten anpassen muss, damit ein number da raus kommt:

                        on({id: "iot.0.services.custom_geo", change: "ne"}, function (obj) 
                        {
                            var LocationString = obj.state.val;
                            var res = LocationString.split(",");
                            var lat = res[0];
                            var lon = res[1];
                            sendTo('places.0', 
                            {
                                user:       "lobomau", 
                                latitude:   lat, 
                                longitude:  lon, 
                                timestamp:  obj.state.ts
                            }, function (res) { log(JSON.stringify(res)); });
                        });
                        
                        AlCalzone 1 Reply Last reply Reply Quote 0
                        • AlCalzone
                          AlCalzone Developer @lobomau last edited by

                          wie oben auch:

                              var lat = parseFloat(res[0]);
                              var lon = parseFloat(res[1]);
                          
                          lobomau 1 Reply Last reply Reply Quote 0
                          • lobomau
                            lobomau @AlCalzone last edited by

                            @alcalzone kannst du mir noch etwas helfen? Javascript ist nicht meine Welt. Ich weiß schon mal wie es nicht geht:

                            on({id: "iot.0.services.custom_geo", change: "ne"}, function (obj) 
                            {
                                //var LocationString = obj.state.val;
                                //var res = LocationString.split(",");
                                var lat = parseFloat(res[0]);
                                var lon = parseFloat(res[1]);
                                sendTo('places.0', 
                                {
                                    user:       "lobomau", 
                                    latitude:   lat, 
                                    longitude:  lon, 
                                    timestamp:  obj.state.ts
                                }, function (res) { log(JSON.stringify(res)); });
                            });
                            

                            Fehlermeldung:

                            
                            javascript.0
                            2022-03-22 12:30:03.620	error	at processImmediate (internal/timers.js:464:21)
                            
                            javascript.0
                            2022-03-22 12:30:03.619	error	at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/src/lib/adapter/adapter.js:5909:56)
                            
                            javascript.0
                            2022-03-22 12:30:03.619	error	at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:562:29)
                            
                            javascript.0
                            2022-03-22 12:30:03.618	error	at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1160:38)
                            
                            javascript.0
                            2022-03-22 12:30:03.617	error	at Object.<anonymous> (script.js.common.Anwesendheit.iot-places:5:26)
                            
                            javascript.0
                            2022-03-22 12:30:03.616	error	Error in callback: ReferenceError: res is not defined
                            

                            Try & error Versuch 2 geht auch nicht:

                            on({id: "iot.0.services.custom_geo", change: "ne"}, function (obj) 
                            {
                                //var LocationString = obj.state.val;
                                var res = LocationString.split(",");
                                var lat = parseFloat(res[0]);
                                var lon = parseFloat(res[1]);
                                sendTo('places.0', 
                                {
                                    user:       "lobomau", 
                                    latitude:   lat, 
                                    longitude:  lon, 
                                    timestamp:  obj.state.ts
                                }, function (res) { log(JSON.stringify(res)); });
                            });
                            
                            AlCalzone 1 Reply Last reply Reply Quote 0
                            • AlCalzone
                              AlCalzone Developer @lobomau last edited by

                              @lobomau Na jetzt hast du die Variablen auskommentiert, auf die der Code sich bezieht. Ich meinte nur dass du Zeile 5 und 6 anpassen musst wie gezeigt.

                              lobomau 1 Reply Last reply Reply Quote 0
                              • lobomau
                                lobomau @AlCalzone last edited by

                                @alcalzone das war ja einfach! Geht jetzt 🙂

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

                                Support us

                                ioBroker
                                Community Adapters
                                Donate

                                900
                                Online

                                32.1k
                                Users

                                80.7k
                                Topics

                                1.3m
                                Posts

                                4
                                14
                                555
                                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