Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. English
    3. Scripting / Logic
    4. JavaScript
    5. Zeitstempel entfernen

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Zeitstempel entfernen

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

      @mp24 sagte: 17-3-2022_20:30 39
      Ich möchte das nur die 39 übrig bleibt.

      Wenn die SV vom Typ "Zahl" ist:

          setState(idSysvar, parseFloat(dp.state.val.split(' ')[1]));
      
      1 Reply Last reply Reply Quote 1
      • M
        mp24 last edited by

        @paul53

        Ich habe es jetzt so abgeändert und eine neue Variable Typ Zahl erstellt. Ob es funktioniert sehe ich ja erst bei Wertänderung. Bei einer Zisterne kann das dauern.
        Vielen, vielen Dank
        mp24

        var idAdapter = 'mqtt.0.Zisterne.Hoehenstand'/**/
        var idSysvar = 'hm-rega.0.1768'/**/
        
        
        
        
        // Skriptstart
        
        setState(idSysvar, getState(idAdapter).val);
        
         
        
        // Aktualisierung bei Wertänderung
        
        on(idAdapter, function(dp) {
        
           /*setState(idSysvar, dp.state.val);*/
             setState(idSysvar, parseFloat(dp.state.val.split(' ')[1])); 
        
        });
        
        paul53 1 Reply Last reply Reply Quote 0
        • paul53
          paul53 @mp24 last edited by

          @mp24 sagte: Ob es funktioniert sehe ich ja erst bei Wertänderung.

          Nicht unbedingt (Zeile 9):

          setState(idSysvar, parseFloat(getState(idAdapter).val.split(' ')[1]));
          
          M 3 Replies Last reply Reply Quote 0
          • M
            mp24 @paul53 last edited by

            @paul53
            Oh. Da habe ich Anfänger aber einen Bock geschossen.
            Zeile 9 wurde durch: setState(idSysvar, parseFloat(getState(idAdapter).val.split(' ')[1])); ersetzt.
            Vielen Dank für die Korrektur
            mp24

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

              @paul53
              Kaum macht Man(n) es richtig, dann klappt es auch. Die 38 % stehen über dem Tank in der Vis.
              Und ich habe es stundenlang mit trim, ltrim, replace usw. versucht.
              Vielen Dank nochmal
              mp24

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

                @paul53
                Ich erhalte Warnungen:
                javascript.0 (16643) at script.js.common.von_IOBroker_nach_Homematic.Zisterne_Hoehenstand_ohne_Zeit:10:1
                Bzw. 21:3
                Was könnte das bedeuten ?

                Vielen Dank
                mp24

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

                  @mp24 sagte: javascript.0 (16643) at script.js.common.von_IOBroker_nach_Homematic.Zisterne_Hoehenstand_ohne_Zeit:10:1

                  Mehr nicht? Schau mal in den Tab "Protokolle", ob es dort nicht mehr Informationen gibt.

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

                    @paul53
                    Die Fehlermeldungen:
                    You are assigning a number to the state "hm-rega.0.1740" which expects a string. Please fix your code to use a string or change the state type to number. This warning might become an error in future versions

                    at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1437:20)

                    Der Wert der vom Broker übermittelt wird ist vom Typ string. In der Homematic Zahl.
                    Muss erst noch gewandelt werden ?

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

                      @mp24 sagte: You are assigning a number to the state "hm-rega.0.1740"

                      Ändere den Typ des Datenpunktes in "Zahl".

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

                        @paul53
                        Der Datenpunkt in der Homematic ist Zahl. Aber von MQTT kommt String an

                        Homoran paul53 2 Replies Last reply Reply Quote 0
                        • Homoran
                          Homoran Global Moderator Administrators @mp24 last edited by Homoran

                          @mp24 sagte in Zeitstempel entfernen:

                          Der Datenpunkt in der Homematic ist Zahl. Aber von MQTT kommt String an

                          das log sagt aber was anderes 😞
                          und das Skript von @paul53 schreibt eine Zahl

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

                            @mp24 sagte: Der Datenpunkt in der Homematic ist Zahl.

                            Das hat die Instanz "hm-rega.0" aber noch nicht mitbekommen.

                            M 2 Replies Last reply Reply Quote 1
                            • M
                              mp24 @paul53 last edited by

                              @paul53
                              Genau. Der Rega Adapter stand noch auf String. Rega Adapter neu gestartet - steht nuun auf Zahl. Aber neue Fehler:

                              at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1082:38)
                              
                              at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/src/lib/adapter/adapter.js:5909:56)
                              1 Reply Last reply Reply Quote 0
                              • M
                                mp24 @paul53 last edited by

                                @paul53
                                Noch mehr Fehlermeldungen:
                                javascript.0
                                2022-03-18 18:32:05.739 info State value to set for "hm-rega.0.1740" has to be type "number" but received type "string"
                                javascript.0
                                2022-03-18 18:32:05.713 warn at processImmediate (internal/timers.js:464:21)
                                javascript.0
                                2022-03-18 18:32:05.713 warn at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/src/lib/adapter/adapter.js:5909:56)
                                javascript.0
                                2022-03-18 18:32:05.713 warn at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:530:29)
                                javascript.0
                                2022-03-18 18:32:05.713 warn at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1082:38)
                                javascript.0
                                2022-03-18 18:32:05.713 warn at Object.<anonymous> (script.js.common.von_IOBroker_nach_Homematic.Zisterne_Hoehenstand_ohne_Zeit:17:4)
                                javascript.0
                                2022-03-18 18:32:05.712 warn at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1437:20)
                                javascript.0
                                2022-03-18 18:32:05.393 warn You are assigning a string to the state "hm-rega.0.1740" 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.

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

                                  @mp24 sagte: warn You are assigning a string to the state "hm-rega.0.1740" which expects a number.

                                  parseFloat() macht eine Zahl aus dem String-Teil hinter dem Leerzeichen. Hast Du was am Skript geändert?

                                  const idAdapter = 'mqtt.0.Zisterne.Hoehenstand';
                                  const idSysvar = 'hm-rega.0.1740';
                                   
                                  // Skriptstart
                                  setState(idSysvar, parseFloat(getState(idAdapter).val.split(' ')[1]));
                                   
                                  // Aktualisierung bei Wertänderung
                                  on(idAdapter, function(dp) {
                                      setState(idSysvar, parseFloat(dp.state.val.split(' ')[1])); 
                                  });
                                  
                                  M 2 Replies Last reply Reply Quote 0
                                  • M
                                    mp24 @paul53 last edited by

                                    @paul53
                                    So sieht das Script aus:

                                    var idAdapter = 'mqtt.0.Zisterne.Hoehenstand'/*Quelle*/
                                    var idSysvar = 'hm-rega.0.1740'/*Ziel*/
                                    
                                    
                                    
                                    
                                    // Skriptstart
                                    
                                    // setState(idSysvar, getState(idAdapter).val);
                                    setState(idSysvar, parseFloat(getState(idAdapter).val.split(' ')[1])); 
                                     
                                    
                                    // Aktualisierung bei Wertänderung
                                    
                                    on(idAdapter, function(dp) {
                                    
                                       setState(idSysvar, dp.state.val);
                                        
                                    
                                    });
                                    
                                    paul53 1 Reply Last reply Reply Quote 0
                                    • M
                                      mp24 @paul53 last edited by

                                      @paul53
                                      Und so die hmrega 1740:

                                      
                                        "_id": "hm-rega.0.1740",
                                        "type": "state",
                                        "common": {
                                          "name": "SV_Zisterne-Hoehenstand",
                                          "type": "number",
                                          "read": true,
                                          "write": true,
                                          "role": "state",
                                          "min": 0,
                                          "max": 100,
                                          "unit": "%",
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • paul53
                                        paul53 @mp24 last edited by paul53

                                        @mp24 sagte: So sieht das Script aus:

                                        Zeile 17:

                                            setState(idSysvar, parseFloat(dp.state.val.split(' ')[1])); 
                                        

                                        Hattest Du doch schon.

                                        M 1 Reply Last reply Reply Quote 1
                                        • M
                                          mp24 @paul53 last edited by

                                          @paul53 said in Zeitstempel entfernen:

                                          setState(idSysvar, parseFloat(dp.state.val.split(' ')[1])); 
                                          

                                          Aus dem Hinweis gestern Zeile 9:
                                          habe ich geschlossen. das nur der Befehl in Zeike 9 gehört.
                                          Das es zweimal gesetzt werden muss habe ich falsch verstanden.

                                          Ich senke demütig mein Haupt und bitte um Entschuldigung
                                          mp24

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

                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          983
                                          Online

                                          31.6k
                                          Users

                                          79.6k
                                          Topics

                                          1.3m
                                          Posts

                                          3
                                          20
                                          1068
                                          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