Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Script fürTabelle der Batterie Zustände

    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

    Script fürTabelle der Batterie Zustände

    This topic has been deleted. Only users with topic management privileges can see it.
    • Homoran
      Homoran Global Moderator Administrators @liv-in-sky last edited by

      @liv-in-sky
      Seltsam:

      tradfri Namen.png

      Da muss ich mal @AlCalzone an den Hammelbeinen packen.

      Ich hatte versucht den common.name davon zu erhalten

      @liv-in-sky sagte in Script mit Tabelle der Batterie Zustände:

      da bleibt nur "RC-65537"

      1 Reply Last reply Reply Quote 0
      • Homoran
        Homoran Global Moderator Administrators @liv-in-sky last edited by Homoran

        @liv-in-sky sagte in Script mit Tabelle der Batterie Zustände:

        müßte der sein

        Dachte ich auch, aber da kommt undefined

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

          @Homoran ich denke

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

            @Homoran zeile 176 auskommentieren - der name ist der stern in tradfri.0.*.batteryPercentage

            split ist:
            tradfri
            0
            *
            batteryPercentage

            daher ida[2]

            der split wird in zeile 171 schon gemacht

            Homoran 1 Reply Last reply Reply Quote 0
            • Homoran
              Homoran Global Moderator Administrators @liv-in-sky last edited by Homoran

              @liv-in-sky Ja!

              aber ich wollte den common Name vom device bekommen - kann den Teil vorher im Skript nicht ganz nachvollziehen und umwandeln, dass er den ausliest.

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

                @Homoran aber der common name ist bei allen gleich - aus dem raw "name": "Battery percentage",

                der einzige unterschied ist wohl was sich hinter dem stern verbirgt - denke ich

                Homoran 1 Reply Last reply Reply Quote 0
                • Homoran
                  Homoran Global Moderator Administrators @liv-in-sky last edited by Homoran

                  @liv-in-sky sagte in Script mit Tabelle der Batterie Zustände:

                  was sich hinter dem stern verbirgt - denke ich

                  Ja!
                  liest das Skript beim Iterieren diesen Wert nicht aus, dass man davon den common.name auslesen kann

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

                    @Homoran doch - aber der common name ist percentage batterie - und das ist ja kein name, der in der tabelle weiterhilft

                    wenn aber eine ebene höher noch irgendwo ein name steht - dann müssen wir uns den holen - mach doch mal einen JSON export der ikea instanz - und poste es -

                    Image 11.png

                    Homoran 1 Reply Last reply Reply Quote 0
                    • Homoran
                      Homoran Global Moderator Administrators @liv-in-sky last edited by

                      @liv-in-sky sagte in Script mit Tabelle der Batterie Zustände:

                      eine ebene höher noch irgendwo ein name steht - dann müssen wir uns den holen

                      Das meinte ich - habe ich wieder zu verschwurbelt geschrieben?

                      {
                        "from": "system.adapter.tradfri.1",
                        "user": "system.user.admin",
                        "ts": 1574188716996,
                        "common": {
                          "name": "TRADFRI remote control",
                          "icon": "icons/remote.png"
                        },
                        "native": {
                          "manufacturer": "IKEA of Sweden",
                          "firmwareVersion": "2.3.014",
                          "modelNumber": "TRADFRI remote control",
                          "type": "remote",
                          "serialNumber": "",
                          "instanceId": 65549
                        },
                        "acl": {
                          "object": 1636,
                          "owner": "system.user.admin",
                          "ownerGroup": "system.group.administrator"
                        },
                        "_id": "tradfri.1.RC-65549",
                        "type": "device"
                      }
                      
                      liv-in-sky 1 Reply Last reply Reply Quote 0
                      • liv-in-sky
                        liv-in-sky @Homoran last edited by

                        @Homoran ok verstehe - ... einen moment

                        1 Reply Last reply Reply Quote 0
                        • D
                          darkiop Most Active last edited by

                          Interessante Projekt habt ihr da!
                          Kann jemand ne aktuelle Version posten? Dann kann ich ggf. auch durch Tests etwas dazu beitragen.

                          Homoran liv-in-sky 2 Replies Last reply Reply Quote 0
                          • Homoran
                            Homoran Global Moderator Administrators @darkiop last edited by

                            Hallo @darkiop

                            Hier
                            https://forum.iobroker.net/topic/28789/script-mit-tabelle-der-batterie-zustände/83
                            im Spoiler

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

                              @Homoran

                              Image 12.png

                              val0=getObject(ida[0]+"."+ida[1]+"."+ida[2]).common.name ;
                              
                              Homoran 1 Reply Last reply Reply Quote 0
                              • Homoran
                                Homoran Global Moderator Administrators @liv-in-sky last edited by

                                @liv-in-sky sagte in Script mit Tabelle der Batterie Zustände:

                                val0=getObject(ida[0]+"."+ida[1]+"."+ida[2]).common.name ;

                                ich werde es versuchen, aber wie gesagt brachte ida[2] immer undefined

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

                                  @Homoran bin gespannt 🙂

                                  Homoran 1 Reply Last reply Reply Quote 0
                                  • Homoran
                                    Homoran Global Moderator Administrators @liv-in-sky last edited by Homoran

                                    @liv-in-sky 😢

                                    
                                    2020-01-11 18:54:40.716 - warn: javascript.0 (4615) Object "Battery percentage.undefined.undefined" does not exist
                                    2020-01-11 18:54:40.717 - error: javascript.0 (4615) script.js.Batterien: script.js.Batterien:179
                                    2020-01-11 18:54:40.718 - error: javascript.0 (4615) val0=getObject(ida[0]+"."+ida[1]+"."+ida[2]).common.name ;
                                    2020-01-11 18:54:40.718 - error: javascript.0 (4615) ^
                                    2020-01-11 18:54:40.719 - error: javascript.0 (4615) TypeError: Cannot read property 'common' of null
                                    2020-01-11 18:54:40.719 - error: javascript.0 (4615) at script.js.Batterien:179:56
                                    2020-01-11 18:54:40.719 - error: javascript.0 (4615) at Object.result.each (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:846:29)
                                    2020-01-11 18:54:40.719 - error: javascript.0 (4615) at writeHTML (script.js.Batterien:170:36)
                                    2020-01-11 18:54:40.720 - error: javascript.0 (4615) at script.js.Batterien:365:1
                                    2020-01-11 18:54:40.720 - error: javascript.0 (4615) at Script.runInContext (vm.js:133:20)
                                    
                                    

                                    code:

                                    $('tradfri.0.*.batteryPercentage').each(function(id, i) {           // hier eigene schleife definieren und den wert counter++ nicht vergessen  !!!
                                            var ida = id.split('.');
                                           
                                            
                                              counter++;                                       // SEHR WICHTIG - MUSS IN JEDER SCHLEIFE INTEGRIERT SEIN
                                             
                                             val0=getObject(id).common.name ; //ida[2]+"."+ida[3];
                                               var ida = val0.split('.');
                                               //val0=ida[0];
                                               val0=getObject(ida[0]+"."+ida[1]+"."+ida[2]).common.name ;
                                               log(val0+"   "+id);
                                              val1help=getState(id).val;
                                              val1help=parseFloat((getState(id).val));
                                              if (val1help<=battAlarm) {val1=(" <font color=\"red\"> ")+val1help.toString()} else{val1=(" <font color=\"green\"> ")+val1help.toString()} 
                                              if (val1help>battAlarm && val1help<=battAlarmWarning) {val1=(" <font color=\"yellow\"> ")+val1help.toString()}
                                              if (getState(id).val==null) {val2="never used"}; //log(id)}; 
                                              if (val1help<=battAlarm) {val2="✘"} else{val2="✔"}         
                                              if (val1help>battAlarm && val1help<=battAlarmWarning) val2="⚠️"
                                    
                                    
                                    liv-in-sky 2 Replies Last reply Reply Quote 0
                                    • liv-in-sky
                                      liv-in-sky @Homoran last edited by

                                      @Homoran die zeile 7 und 8 gehört weg

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

                                        @Homoran

                                        der wichtige split ist in zeile 2 - den überschreibst du mit zeile 7 und 8

                                        Homoran 1 Reply Last reply Reply Quote 0
                                        • Homoran
                                          Homoran Global Moderator Administrators @liv-in-sky last edited by Homoran

                                          @liv-in-sky

                                          (4615) script.js.Batterien: TRADFRI remote control 2 tradfri.0.RC-65537.batteryPercentage

                                          und

                                          (4615) script.js.Batterien: Stehlampe Arcade tradfri.0.RC-65536.batteryPercentage

                                          Batterie_04.png

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

                                            @Homoran paßt so oder ?

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            697
                                            Online

                                            31.8k
                                            Users

                                            80.0k
                                            Topics

                                            1.3m
                                            Posts

                                            javascript monitoring template
                                            67
                                            1379
                                            414783
                                            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