Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. source does not exist for "read" function

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    source does not exist for "read" function

    This topic has been deleted. Only users with topic management privileges can see it.
    • mickym
      mickym Most Active @Thomas Braun last edited by mickym

      @thomas-braun In Mosquitto ist alles gut - der macht keine Konvertierung, sondern das ist ein Objekt. Dann ist es auch richtig, dass unter 0_userdata.0...Datenpunkt ein String ist, da das dann ein JSON ist. Das extrahieren der Zahl machst Du dann im Alias - aber ich würde es halt nicht im Adapter machen, sondern direkt im Alias.

      Das heißt in deinem 0_userdata.0 Datenpunkt sollte eigentlich ein JSON String stehen. Poste den mal, dann können wir uns überlegen wie die Readfunktion im Alias auszusehen hat.

      Normalerweise extrahiert man die Eigenschaft mit

      (JSON.parse(val).Eigenschaft) * 100
      
      Thomas Braun 1 Reply Last reply Reply Quote 0
      • Thomas Braun
        Thomas Braun Most Active @mickym last edited by

        @mickym

        0_userdata.0.solix.solarbank_info.total_battery_power

        Objekt schaut wohl so aus:

        {
          "common": {
            "name": "total_battery_power",
            "type": "string",
            "role": "value",
            "read": true,
            "write": true
          },
          "native": {},
          "type": "state",
          "from": "system.adapter.javascript.0",
          "user": "system.user.admin",
          "ts": 1738344042869,
          "_id": "0_userdata.0.solix.solarbank_info.total_battery_power",
          "acl": {
            "object": 1636,
            "state": 1636,
            "owner": "system.user.admin",
            "ownerGroup": "system.group.administrator"
          }
        }
        
        mickym 1 Reply Last reply Reply Quote 0
        • mickym
          mickym Most Active @Thomas Braun last edited by mickym

          @thomas-braun Nein das ist der Pfad oder die ID des Objektes. Geh mal bitte unter objekte und auf den Datenpunkt
          solix.solarbank_info.total_battery_power unter 0_userdata.0 und dann kopiere mal den JSON String der als Wert in dem Datenpunkt steht hier rein.

          69f2aac4-7b00-4231-b9b4-648e5b13ce6a-image.png

          Thomas Braun 1 Reply Last reply Reply Quote 0
          • Thomas Braun
            Thomas Braun Most Active @mickym last edited by Thomas Braun

            @mickym

            Keine Ahnung was du brauchst...

            0_userdata.0.solix.solarbank_info.total_battery_power
            
            total_battery_power
            

            Da steht sonst unter value nur noch

            0.61

            drin. Und den will ich ja mit 100 multiplizieren. Das JSON wird davor noch per skript in Einzelerte zerlegt. Fällt mir gerade ein... g

            mickym 1 Reply Last reply Reply Quote 0
            • mickym
              mickym Most Active @Thomas Braun last edited by mickym

              @thomas-braun

              Da steht sonst nur noch

              0.61

              Ah OK dann ist das aber kein JSON mehr sondern wirklich ein numerischer Wert. Dann stell doch einfach mal den Datenpunkt auf Typ Zahl um.
              Also Bleistift rechts und dann Typ ändern.

              7e59f085-599a-4ee0-bb41-e9754774ac17-image.png

              Thomas Braun 1 Reply Last reply Reply Quote 0
              • Thomas Braun
                Thomas Braun Most Active @mickym last edited by

                @mickym sagte in source does not exist for "read" function:

                Ah OK dann ist das aber kein JSON mehr sondern wirklich ein numerischer Wert.

                Das JSON wird zuvor schon in Einzelwerte zerlegt.

                Dann stell doch einfach mal den Datenpunkt auf Typ Zahl um.

                Das funktioniert genau einmal. Die nächste Übermittlung des Wertes ist wieder ein String.

                mickym 1 Reply Last reply Reply Quote 0
                • mickym
                  mickym Most Active @Thomas Braun last edited by

                  @thomas-braun OK dann fallen mit noch 2 Möglichkeiten ein.

                  1. Du stellst den Datentyp auf "Mixed" - würde ich präferieren
                  2. Du konvertierst halt dann in der Aliasfunktion noch
                  Number(val) * 100
                  

                  Ich schau mal ob man dem mqtt-Client noch was einstellen kann.

                  Thomas Braun 1 Reply Last reply Reply Quote 0
                  • Thomas Braun
                    Thomas Braun Most Active @mickym last edited by

                    @mickym

                    Ich glaube, jetzt geht es...
                    Hab noch 'irgendwo irgendwas' umgestellt, jetzt erscheint auch im echarts der richtige Prozentwert.
                    Mal schauen ob es einen Neustart auch übersteht...

                    mickym 1 Reply Last reply Reply Quote 0
                    • mickym
                      mickym Most Active @Thomas Braun last edited by

                      @thomas-braun Welche Methode hast Du verwendet?

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

                        @thomas-braun sagte: Wo in der Kette konvertiere ich den String am besten in ein Zahlenformat

                        Die Multiplikation mit 100 im Alias konvertiert implizit den String in eine Zahl.
                        Die Meldung "does not exist" sieht eher danach aus, als dass es den DP "0_userdata.0.solix.solarbank_info.total_battery_power" nicht (mehr) gibt.

                        Thomas Braun Homoran 2 Replies Last reply Reply Quote 0
                        • Thomas Braun
                          Thomas Braun Most Active @mickym last edited by

                          @mickym

                          Ich kann es wirklich nicht sagen.
                          Planloses herumgeklicke von mir in der Admin-GUI.

                          mickym 1 Reply Last reply Reply Quote 0
                          • Thomas Braun
                            Thomas Braun Most Active @paul53 last edited by

                            @paul53 sagte in source does not exist for "read" function:

                            Die Meldung "does not exist" sieht eher danach aus, als dass es den DP "0_userdata.0.solix.solarbank_info.total_battery_power" nicht (mehr) gibt.

                            Doch, den gibt und gab es.

                            1 Reply Last reply Reply Quote 0
                            • mickym
                              mickym Most Active @Thomas Braun last edited by

                              @thomas-braun sagte in source does not exist for "read" function:

                              Planloses herumgeklicke von mir in der Admin-GUI.

                              😀 😂 🤣

                              1 Reply Last reply Reply Quote 0
                              • Homoran
                                Homoran Global Moderator Administrators @paul53 last edited by Homoran

                                @paul53 sagte in source does not exist for "read" function:

                                nicht (mehr) gibt.

                                das hatte ich etwas differenzierter interpretiert, da die Meldung noch mit 'for read' weiterging.
                                Dachte daher dass der read=false sei, was er nicht ist.

                                Möglich aber, dass es nur um den in der Lesekonvertierung angegebenen DP geht

                                Thomas Braun 1 Reply Last reply Reply Quote 0
                                • Thomas Braun
                                  Thomas Braun Most Active @Homoran last edited by

                                  Leider nix. Mein Log wird immer noch geflutet:

                                  2025-02-01 15:44:53.948  - warn: javascript.0 (888) You are assigning a string to the state "0_userdata.0.solix.solarbank_info.total_battery_power" which expects a number. Please fix your code to use a number or change the state type to string. This warning might become an error in future versions.
                                  2025-02-01 15:44:53.949  - warn: javascript.0 (888)     at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:2090:20)
                                  2025-02-01 15:44:53.950  - warn: javascript.0 (888)     at createObjectsRecursively (script.js.solix2mqtt:74:11)
                                  2025-02-01 15:44:53.950  - warn: javascript.0 (888)     at createObjectsRecursively (script.js.solix2mqtt:38:9)
                                  2025-02-01 15:44:53.950  - warn: javascript.0 (888)     at Object.<anonymous> (script.js.solix2mqtt:84:4)
                                  2025-02-01 15:44:53.950  - warn: javascript.0 (888)     at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1452:38)
                                  2025-02-01 15:44:53.950  - warn: javascript.0 (888)     at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:645:29)
                                  2025-02-01 15:44:53.950  - warn: javascript.0 (888)     at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/src/lib/adapter/adapter.ts:11048:62)
                                  2025-02-01 15:44:53.950  - warn: javascript.0 (888)     at processImmediate (node:internal/timers:483:21)
                                  2025-02-01 15:44:54.003  - info: javascript.0 (888) State value to set for "0_userdata.0.solix.solarbank_info.total_battery_power" has to be type "number" but received type "string" 
                                  2025-02-01 15:44:54.066  - error: history.0 (857) source in "alias.0.0_userdata.0.solix.solarbank_info.total_battery_power" does not exist for "read" function: "val*100"
                                  2025-02-01 15:44:54.066  - error: javascript.0 (888) source in "alias.0.0_userdata.0.solix.solarbank_info.total_battery_power" does not exist for "read" function: "val*100"
                                  2025-02-01 15:45:53.952  - warn: javascript.0 (888) You are assigning a string to the state "0_userdata.0.solix.solarbank_info.total_battery_power" which expects a number. Please fix your code to use a number or change the state type to string. This warning might become an error in future versions.
                                  2025-02-01 15:45:53.954  - warn: javascript.0 (888)     at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:2090:20)
                                  2025-02-01 15:45:53.954  - warn: javascript.0 (888)     at createObjectsRecursively (script.js.solix2mqtt:74:11)
                                  2025-02-01 15:45:53.954  - warn: javascript.0 (888)     at createObjectsRecursively (script.js.solix2mqtt:38:9)
                                  2025-02-01 15:45:53.954  - warn: javascript.0 (888)     at Object.<anonymous> (script.js.solix2mqtt:84:4)
                                  2025-02-01 15:45:53.955  - warn: javascript.0 (888)     at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1452:38)
                                  2025-02-01 15:45:53.955  - warn: javascript.0 (888)     at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:645:29)
                                  2025-02-01 15:45:53.955  - warn: javascript.0 (888)     at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/src/lib/adapter/adapter.ts:11048:62)
                                  2025-02-01 15:45:53.955  - warn: javascript.0 (888)     at processImmediate (node:internal/timers:483:21)
                                  2025-02-01 15:45:54.007  - info: javascript.0 (888) State value to set for "0_userdata.0.solix.solarbank_info.total_battery_power" has to be type "number" but received type "string" 
                                  2025-02-01 15:45:54.074  - error: history.0 (857) source in "alias.0.0_userdata.0.solix.solarbank_info.total_battery_power" does not exist for "read" function: "val*100"
                                  2025-02-01 15:45:54.074  - error: javascript.0 (888) source in "alias.0.0_userdata.0.solix.solarbank_info.total_battery_power" does not exist for "read" function: "val*100"
                                  
                                  
                                  mickym Homoran 2 Replies Last reply Reply Quote 0
                                  • mickym
                                    mickym Most Active @Thomas Braun last edited by

                                    @thomas-braun na wenn du aber auf mixed umstellst, dann sollte der Fehler nicht mehr kommen

                                    1 Reply Last reply Reply Quote 0
                                    • Homoran
                                      Homoran Global Moderator Administrators @Thomas Braun last edited by Homoran

                                      @thomas-braun sagte in source does not exist for "read" function:

                                      You are assigning a string to the state "0_userdata.0.solix.solarbank_info.total_battery_power" which expects a number

                                      woher bekommt der DP seinen Wert

                                      wie sehen denn die beiden angemeckerten alias-Konfigurationen aus?

                                      Thomas Braun 1 Reply Last reply Reply Quote 0
                                      • Thomas Braun
                                        Thomas Braun Most Active @Homoran last edited by

                                        @homoran sagte in source does not exist for "read" function:

                                        woher bekommt der DP seinen Wert

                                        Aus einem JSON, das zuvor aber noch über ein enstprechendes Skript läuft und dann dort in Einzelwerte zerlegt wird.

                                        Homoran mickym 2 Replies Last reply Reply Quote 0
                                        • Homoran
                                          Homoran Global Moderator Administrators @Thomas Braun last edited by

                                          @thomas-braun sagte in source does not exist for "read" function:

                                          ein enstprechendes Skript läuft und dann dort in Einzelwerte zerlegt wird.

                                          zei gen!

                                          Thomas Braun 1 Reply Last reply Reply Quote 0
                                          • mickym
                                            mickym Most Active @Thomas Braun last edited by mickym

                                            @thomas-braun sagte in source does not exist for "read" function:

                                            @homoran sagte in source does not exist for "read" function:

                                            woher bekommt der DP seinen Wert

                                            Aus einem JSON, das zuvor aber noch über ein enstprechendes Skript läuft und dann dort in Einzelwerte zerlegt wird.

                                            Na dann ist es doch das Skript - und wenn Du schon mit Alias arbeitest, dann würde ich es auch nicht über Einzelwerte vorher zerlegen, sondern direkt im Alias auseinandernehmen.
                                            Von einem Skript hast Du vorher ja gar nichts gesagt.
                                            Ausser Du nimmst meinen NodeRed Flow - der zerlegt auch in die richtigen Datentypen. 😉

                                            Aber Spaß beiseite - ich würde nichts auseinander nehmen sondern das Objekt speichern und im Alias auseinandernehmen.

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            789
                                            Online

                                            31.7k
                                            Users

                                            79.7k
                                            Topics

                                            1.3m
                                            Posts

                                            4
                                            52
                                            1088
                                            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