Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Datenpunkt von sek nach min direkt wandeln

    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

    Datenpunkt von sek nach min direkt wandeln

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

      Hallo,

      mal wieder ein kurze Frage an die Experten.

      Ich habe einen Datenpunkt der mir die Werte in Sekunden ausgibt. Diese möchte ich jetzt für eine Balkenanzeige direkt in Minuten umwandeln.
      D.h. bei Balkenanzeige habe ich als Schalter den Datenpunkt angegeben:
      “homeconnect.0.BOSCH-WAYH2791-68A40E13A88D.programs.active.options.BSH_Common_Option_ProgramProgress”
      Geht auch nur eben in Sekunden

      Jetzt habe ich folgendes versucht
      {wert: homeconnect.0.BOSCH-WAYH2791-68A40E13A88D.programs.active.options.BSH_Common_Option_ProgramProgress;wert = wert/60}
      Da kommt aber 0 bei raus.
      Kann mir jemand eine Tipp zur Syntax geben

      liv-in-sky OliverIO 2 Replies Last reply Reply Quote 0
      • liv-in-sky
        liv-in-sky @heinzie last edited by

        @heinzie sagte in Datenpunkt von sek nach min direkt wandeln:

        wert: homeconnect.0.BOSCH-WAYH2791-68A40E13A88D.programs.active.options.BSH_Common_Option_ProgramProgress;wert = wert/60

        {wert:controll-own.0.AAATEST.TestZahl2;Math.floor(wert/60)}
        
        H 1 Reply Last reply Reply Quote 0
        • H
          heinzie @liv-in-sky last edited by

          @liv-in-sky sagte in Datenpunkt von sek nach min direkt wandeln:

          @heinzie sagte in Datenpunkt von sek nach min direkt wandeln:

          wert: homeconnect.0.BOSCH-WAYH2791-68A40E13A88D.programs.active.options.BSH_Common_Option_ProgramProgress;wert = wert/60

          {wert:controll-own.0.AAATEST.TestZahl2;Math.floor(wert/60)}
          

          Danke, geht aber so noch nicht. Ich vermute das es an der Variablen selber liegt. Das ist kein Typ "number" sondern "Objekt" Weiß aber nicht wie ich das ansprechen kann.

          {
            "type": "state",
            "common": {
              "name": "Verbleibende Programmlaufzeit",
              "type": "object",
              "role": "indicator",
              "write": true,
              "read": true,
              "unit": "seconds"
            },
            "native": {},
            "from": "system.adapter.homeconnect.0",
            "user": "system.user.admin",
            "ts": 1561880548279,
            "_id": "homeconnect.0.BOSCH-WAYH2791-68A40E13A88D.programs.active.options.BSH_Common_Option_RemainingProgramTime",
            "acl": {
              "object": 1636,
              "state": 1636,
              "owner": "system.user.admin",
              "ownerGroup": "system.group.administrator"
            }
          }
          
          liv-in-sky 2 Replies Last reply Reply Quote 0
          • liv-in-sky
            liv-in-sky @heinzie last edited by

            @heinzie poste mal den state (wert)- wie sieht der den aus - muss ich erst testen, ob man object direct ansprechen kann

            1 Reply Last reply Reply Quote 0
            • liv-in-sky
              liv-in-sky @heinzie last edited by

              @heinzie was z.b. geht ist

              {wert:controll-own.0.AAATEST.Rasenmaeher;Math.floor(wert[0].id/60)}
              

              state dazu sieht so aus:
              Image 1.png

              H 1 Reply Last reply Reply Quote 0
              • H
                heinzie @liv-in-sky last edited by

                @liv-in-sky geht leider auch nicht

                Der state sieht bei mir so aus:

                08a17655-615f-4dea-a914-8d4b5d99982d-grafik.png

                liv-in-sky 3 Replies Last reply Reply Quote 0
                • liv-in-sky
                  liv-in-sky @heinzie last edited by

                  @heinzie ist seconds die einheit oder ein teil des wertes

                  1 Reply Last reply Reply Quote 0
                  • liv-in-sky
                    liv-in-sky @heinzie last edited by

                    @heinzie steht ja oben im object - ist einheit

                    1 Reply Last reply Reply Quote 0
                    • liv-in-sky
                      liv-in-sky @heinzie last edited by liv-in-sky

                      @heinzie

                      bei mir geht's, wenn ich den datenpunkt richtig nachgebaut habe

                      {wert:controll-own.0.testObject;Math.floor(wert/60)}
                      
                      {
                        "from": "system.adapter.admin.0",
                        "user": "system.user.admin",
                        "ts": 1609433147437,
                        "common": {
                          "name": "testObject",
                          "role": "",
                          "type": "object",
                          "desc": "Manually created",
                          "read": true,
                          "unit": "seconds",
                          "write": true
                        },
                        "native": {},
                        "acl": {
                          "object": 1636,
                          "owner": "system.user.admin",
                          "ownerGroup": "system.group.administrator",
                          "state": 1636
                        },
                        "_id": "controll-own.0.testObject",
                        "type": "state"
                      }
                      

                      Image 2.png

                      ist getestet mit einem html widget - welches widget möchtest du verwenden ?

                      Image 3.png

                      H Scrounger 2 Replies Last reply Reply Quote 0
                      • H
                        heinzie @liv-in-sky last edited by

                        @liv-in-sky Soll mit dem materialdesign-Progress laufen.
                        Könntest Du mir ggf einfach dein Widget einmal exportieren.
                        Dann könnte ich direkt damit prüfen

                        liv-in-sky 1 Reply Last reply Reply Quote 0
                        • liv-in-sky
                          liv-in-sky @heinzie last edited by

                          @heinzie ich denke, da müssen wir mit einem alias arbeiten - als object id scheint das nicht zu funktionieren

                          kennst du alias

                          1 Reply Last reply Reply Quote 0
                          • OliverIO
                            OliverIO @heinzie last edited by

                            @heinzie
                            Evtl ist de4 wert ein String und muss vorher in eine Zahl umgewandelt werden
                            parseInt

                            liv-in-sky 1 Reply Last reply Reply Quote 0
                            • liv-in-sky
                              liv-in-sky @OliverIO last edited by liv-in-sky

                              @OliverIO ich glaube, man kann das nicht als ObjectID nehmen

                              @heinzie
                              habe es mit alias nachgebaut:

                              Image 4.png

                              und in der vis das alias als object id genommen

                              anim-gif29.gif

                              1 Reply Last reply Reply Quote 0
                              • H
                                heinzie last edited by heinzie

                                Danke euch. Mit alias habe ich noch nichts gemacht.
                                Werde mir das dann Morgen noch einmal ansehen.

                                Scheint aber wirklich ein String zu sein, wenn in der Variable 10000 steht wird mir 10.000 angezeigt.
                                Habe aber leine Plan wie ich die parseInt() Funktion in mein Konstrukt :

                                {wert: homeconnect.0.BOSCH-WAYH2791-68A40E13A88D.programs.active.options.BSH_Common_Option_ProgramProgress;wert = wert/60}
                                

                                reinbekomme

                                liv-in-sky OliverIO 3 Replies Last reply Reply Quote 0
                                • liv-in-sky
                                  liv-in-sky @heinzie last edited by liv-in-sky

                                  @heinzie du kannst einen string so verwandeln

                                  wert=Number(wert)/60
                                  

                                  oder:

                                  wert=parseInt(wert)/60
                                  
                                  1 Reply Last reply Reply Quote 0
                                  • liv-in-sky
                                    liv-in-sky @heinzie last edited by

                                    @heinzie

                                    das mit einem alias ist nicht so schwer. du legst einen neuen datenpunkt unter alias.0 an. im raw bereich des neuen dp fügst du dann den alias teil hinzu.

                                    https://www.iobroker.net/#en/documentation/dev/aliases.md
                                    https://forum.iobroker.net/topic/25772/fragen-antworten-rund-um-die-neue-alias-funktion/7
                                    erstellen:
                                    anim-gif32.gif

                                    in nutzung:
                                    anim-gif34.gif

                                    H 1 Reply Last reply Reply Quote 0
                                    • OliverIO
                                      OliverIO @heinzie last edited by

                                      @heinzie sagte in Datenpunkt von sek nach min direkt wandeln:

                                      {wert: homeconnect.0.BOSCH-WAYH2791-68A40E13A88D.programs.active.options.BSH_Common_Option_ProgramProgress;wert = wert/60}

                                      Das müsste eigentlich dann so heissen.

                                      {wert: homeconnect.0.BOSCH-WAYH2791-68A40E13A88D.programs.active.options.BSH_Common_Option_ProgramProgress; parseInt(wert/60)}
                                      

                                      Das wert= Wäre hier falsch.

                                      liv-in-sky 1 Reply Last reply Reply Quote 0
                                      • liv-in-sky
                                        liv-in-sky @OliverIO last edited by

                                        @OliverIO muss nicht der wert geparst werden und dann durch 60 geteilt

                                        parseInt(wert)/60
                                        
                                        
                                        OliverIO H 2 Replies Last reply Reply Quote 0
                                        • OliverIO
                                          OliverIO @liv-in-sky last edited by

                                          @liv-in-sky
                                          Ja stimmt

                                          liv-in-sky 1 Reply Last reply Reply Quote 0
                                          • liv-in-sky
                                            liv-in-sky @OliverIO last edited by

                                            @OliverIO aber das ganze funktioniert eh nicht, weil man im widget bei der object id das nicht eingeben kann - daher alias

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            875
                                            Online

                                            31.9k
                                            Users

                                            80.2k
                                            Topics

                                            1.3m
                                            Posts

                                            javascript
                                            4
                                            30
                                            948
                                            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