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] Mal wieder IDs vom Selektor

    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

    [Gelöst] Mal wieder IDs vom Selektor

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

      @ofbeqnpolkkl6mby5e13 sagte: hmip.0.devices.

      Das ist ein anderer Adapter mit wahrscheinlich einer anderen Objektstruktur als hm-rpc.

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

        @paul53
        Ja, das ist richtig (Siehe Spoiler). Aber der Aufruf geht doch, Objekt ID wird zurückgeliefert.

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

          @ofbeqnpolkkl6mby5e13 sagte: Objekt ID wird zurückgeliefert.

          Wie sieht die Objektstruktur aus? Ich kenne nur hm-rpc.

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

            @paul53
            Siehe zweiter Spoiler.

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

              @ofbeqnpolkkl6mby5e13
              Da ist noch der Ordner "channels" zwischen "device" und "channel". Deshalb funktioniert es nicht.

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

                @paul53
                Dachte ich mir schon fast. Wie kann man das lösen?

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

                  @ofbeqnpolkkl6mby5e13 sagte: Wie kann man das lösen?

                  Mit einer JS-Funktion mit Ergebnis:

                  id = id.substring(0, id.lastIndexOf('.'));
                  id = id.substring(0, id.lastIndexOf('.'));
                  id = id.substring(0, id.lastIndexOf('.'));
                  if(existsObject(id)) return getObject(id).common.name;
                  

                  EDIT: Schließende Klammer korrigiert.

                  Bild_2021-03-11_205544.png

                  O 1 Reply Last reply Reply Quote 1
                  • O
                    oFbEQnpoLKKl6mbY5e13 @paul53 last edited by

                    @paul53
                    Muss ich noch was anpassen?

                    javascript.0	2021-03-11 21:04:13.491	error	(343) at processImmediate (internal/timers.js:458:21)
                    javascript.0	2021-03-11 21:04:13.491	error	(343) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.javascript/main.js:1238:17)
                    javascript.0	2021-03-11 21:04:13.491	error	(343) at /opt/iobroker/node_modules/iobroker.javascript/main.js:1722:17
                    javascript.0	2021-03-11 21:04:13.491	error	(343) at prepareScript (/opt/iobroker/node_modules/iobroker.javascript/main.js:1621:37)
                    javascript.0	2021-03-11 21:04:13.490	error	(343) at createVM (/opt/iobroker/node_modules/iobroker.javascript/main.js:1383:28)
                    javascript.0	2021-03-11 21:04:13.490	error	(343) at Object.createScript (vm.js:263:10)
                    javascript.0	2021-03-11 21:04:13.490	error	(343) at new Script (vm.js:88:7)
                    javascript.0	2021-03-11 21:04:13.489	error	(343) SyntaxError: missing ) after argument list
                    javascript.0	2021-03-11 21:04:13.489	error	(343) ^
                    javascript.0	2021-03-11 21:04:13.489	error	(343) id = id.substring(0, id.lastIndexOf('.');
                    javascript.0	2021-03-11 21:04:13.488	error	(343) script.js.common.Tests.Test_3 compile failed: at script.js.common.Tests.Test_3:5
                    
                    M paul53 2 Replies Last reply Reply Quote 0
                    • M
                      MCU @oFbEQnpoLKKl6mbY5e13 last edited by

                      @ofbeqnpolkkl6mby5e13 sagte in Mal wieder IDs vom Selektor:

                      id = id.substring(0, id.lastIndexOf('.');

                      Es fehlt noch eine Klammer hinten:

                      id = id.substring(0, id.lastIndexOf('.'));
                      
                      1 Reply Last reply Reply Quote 1
                      • paul53
                        paul53 @oFbEQnpoLKKl6mbY5e13 last edited by

                        @ofbeqnpolkkl6mby5e13 sagte: missing ) after argument list

                        Sorry, habe schließende Klammern vergessen: Ist oben korrigiert.

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

                          @paul53
                          Das hatte ich auch schon versucht, aber dann kommt:

                          javascript.0	2021-03-11 21:19:49.768	error	(343) at Script.runInContext (vm.js:131:20)
                          javascript.0	2021-03-11 21:19:49.767	error	(343) at script.js.common.Tests.Test_3:34:3
                          javascript.0	2021-03-11 21:19:49.767	error	(343) at script.js.common.Tests.Test_3:31:2
                          javascript.0	2021-03-11 21:19:49.767	error	(343) script.js.common.Tests.Test_3: ReferenceError: obj is not defined
                          
                          paul53 1 Reply Last reply Reply Quote 0
                          • paul53
                            paul53 @oFbEQnpoLKKl6mbY5e13 last edited by paul53

                            @ofbeqnpolkkl6mby5e13 sagte: ReferenceError: obj is not defined

                            Wo wird die Variable obj verwendet?
                            Erzeugter Javascript-Code?

                            O 2 Replies Last reply Reply Quote 0
                            • O
                              oFbEQnpoLKKl6mbY5e13 @paul53 last edited by

                              @paul53
                              Ach Mist, ein freischwebendes "Objekt ID" vergessen zu deaktivieren. 🤦‍♂️

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

                                @paul53

                                javascript.0	2021-03-11 21:25:14.031	info	(343) script.js.common.Tests.Test_3: Fenster Rechts
                                

                                Ganz herzlichen Dank! 👍

                                1 Reply Last reply Reply Quote 0
                                • O
                                  oFbEQnpoLKKl6mbY5e13 last edited by

                                  @paul53

                                  Ich habe noch mal eine Frage, die nur indirekt mit IDs vom Selektor zusammenhängt. Wenn ich alle Mitglieder (members) einer Aufzählung mit der id "enum.functions.Button" ausgeben will, dann kann ich das problemlos im Selektor mit (functions=Button) machen.
                                  Aber wie adressiert man eine verschachtelte Aufzählung wie "enum.functions.house.light"?

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

                                    @ofbeqnpolkkl6mby5e13 sagte: wie adressiert man eine verschachtelte Aufzählung wie "enum.functions.house.light"?

                                    Ich habe zwar keine "verschachtelten" Aufzählungen, aber funktioniert es nicht mit (functions=house.light)?
                                    Ich würde auch nicht verschachteln, sondern "enum.rooms.house" zuweisen.

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

                                      @paul53
                                      Nein, das funktioniert leider nicht.

                                      Ich muss ein Zweifamilienhaus mit 3 Wohnungen abdecken. Ohne eine strukturierte Aufzählung bin ich "verloren".

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

                                        @ofbeqnpolkkl6mby5e13 sagte: Ohne eine strukturierte Aufzählung bin ich "verloren".

                                        Die Aufzählungen sind nicht für "Verschachtelung" ausgelegt. Man kann höchstens über die Namen strukturieren, z.B. mittels Unterstrich im Namen "house_light".

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

                                          @paul53
                                          Okay, danke!

                                          Allerdings stellt sich dann schon die Frage, weshalb man die dann überhaupt verschachteln kann...

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

                                            @ofbeqnpolkkl6mby5e13 sagte: weshalb man die dann überhaupt verschachteln kann...

                                            Kann man das? Wenn ich eine ID mit Punkt eingebe, wird daraus automatisch ein Unterstrich. Bei Erstellung im Tab "Objekte" wird allerdings nicht geprüft.

                                            Bild_2022-01-12_192800.png

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            786
                                            Online

                                            31.7k
                                            Users

                                            79.9k
                                            Topics

                                            1.3m
                                            Posts

                                            5
                                            33
                                            1884
                                            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