Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. [gelöst]Zufällige Zahl generieren

    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]Zufällige Zahl generieren

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

      @jwedenig sagte: Zufallskomponente einbauen, damit ich dann mehrere Variablen zufällig abwechselnd auslösen kann?

      Beispiel mit 3 SV:

      Bild_2022-09-15_175054586.png

      J 2 Replies Last reply Reply Quote 0
      • K
        klassisch Most Active last edited by

        Für JScript gibt es dort was zum Abspicken. Incl. der Konvertierung in eine natürliche Zahl, die dann als Index für ein Array dienen kann.

        J 1 Reply Last reply Reply Quote 0
        • J
          jwedenig Most Active @paul53 last edited by

          @paul53
          danke dir

          1 Reply Last reply Reply Quote 0
          • J
            jwedenig Most Active @klassisch last edited by

            @klassisch
            danke sehr

            1 Reply Last reply Reply Quote 0
            • J
              jwedenig Most Active @paul53 last edited by

              @paul53
              eine Frage, da ich erst heute dazu komme es zu testen:

              der erste Block mit erzeuge Liste mit und den 3 Objekten => die 3 Objekte sind die SV von Homematic?
              Liebe Grüße

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

                @jwedenig sagte: die 3 Objekte sind die SV von Homematic?

                Ja.

                J 1 Reply Last reply Reply Quote 0
                • J
                  jwedenig Most Active @paul53 last edited by

                  @paul53
                  Hi!
                  Also ich habe das Skript kopiert, beim ersten Druck des Tasters wir eine SV auf wahr gestellt und somit "klingelt" es.
                  Beim zweiten Druck passiert nichts.
                  Wenn ich das Skript stoppe und dann wieder starte passiert wieder das Gleiche.
                  Einmal funmktioniert es, danacxh nicht mehr.
                  Hier der Fehlercode

                  17.9.2022, 19:30:36.914	[info ]: javascript.0 (16692) Start javascript script.js.Weldscripts.Taster_1_Klingelzufall
                  17.9.2022, 19:30:36.952	[info ]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: registered 1 subscription, 0 schedules, 0 messages, 0 logs and 0 file subscriptions
                  17.9.2022, 19:31:14.066	[warn ]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:19:52)
                  17.9.2022, 19:31:14.070	[warn ]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:20:5)
                  17.9.2022, 19:31:14.533	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '0' of undefined
                  17.9.2022, 19:31:14.533	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:31:20.022	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '0' of undefined
                  17.9.2022, 19:31:20.023	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:31:20.819	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '2' of undefined
                  17.9.2022, 19:31:20.819	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:31:28.814	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '2' of undefined
                  17.9.2022, 19:31:28.815	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:31:29.570	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '0' of undefined
                  17.9.2022, 19:31:29.571	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:31:35.430	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '2' of undefined
                  17.9.2022, 19:31:35.430	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:31:36.232	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '1' of undefined
                  17.9.2022, 19:31:36.233	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:31:41.364	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '1' of undefined
                  17.9.2022, 19:31:41.364	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:31:42.160	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '2' of undefined
                  17.9.2022, 19:31:42.160	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:32:13.033	[info ]: javascript.0 (16692) Stop script script.js.Weldscripts.Taster_1_Klingelzufall
                  17.9.2022, 19:32:15.291	[info ]: javascript.0 (16692) Start javascript script.js.Weldscripts.Taster_1_Klingelzufall
                  17.9.2022, 19:32:15.324	[info ]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: registered 1 subscription, 0 schedules, 0 messages, 0 logs and 0 file subscriptions
                  17.9.2022, 19:32:54.622	[warn ]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:19:52)
                  17.9.2022, 19:32:54.629	[warn ]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:20:5)
                  17.9.2022, 19:32:55.424	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '0' of undefined
                  17.9.2022, 19:32:55.424	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:32:57.740	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '0' of undefined
                  17.9.2022, 19:32:57.741	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:32:58.539	[error]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: TypeError: Cannot read property '2' of undefined
                  17.9.2022, 19:32:58.540	[error]: javascript.0 (16692)     at Object.<anonymous> (script.js.Weldscripts.Taster_1_Klingelzufall:18:10)
                  17.9.2022, 19:33:07.838	[info ]: javascript.0 (16692) Stop script script.js.Weldscripts.Taster_1_Klingelzufall
                  17.9.2022, 19:33:09.181	[info ]: javascript.0 (16692) Start javascript script.js.Weldscripts.Taster_1_Klingelzufall
                  17.9.2022, 19:33:09.188	[info ]: javascript.0 (16692) script.js.Weldscripts.Taster_1_Klingelzufall: registered 1 subscription, 0 schedules, 0 messages, 0 logs and 0 file subscriptions
                  17.9.2022, 19:33:27.846	[info ]: javascript.0 (16692) Stop script script.js.Weldscripts.Taster_1_Klingelzufall
                  

                  Hier das Skript:
                  Bildschirmfoto 2022-09-18 um 19.17.37.png

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

                    @jwedenig
                    Du verwendest die gleiche Variable id sowohl für die Liste als auch für die Einzel-ID. Die Liste ids darf nicht verändert werden.

                    J 1 Reply Last reply Reply Quote 0
                    • J
                      jwedenig Most Active @paul53 last edited by

                      @paul53
                      dh ich brauche eine 2te Variable?
                      Sorry, ich behirne das Skript leider nicht ganz

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

                        @jwedenig sagte: dh ich brauche eine 2te Variable?

                        Ja.

                        J 2 Replies Last reply Reply Quote 0
                        • J
                          jwedenig Most Active @paul53 last edited by

                          @paul53
                          super, es funktioniert!!!
                          vielen Dank!!!

                          1 Reply Last reply Reply Quote 0
                          • J
                            jwedenig Most Active @paul53 last edited by

                            @paul53
                            Eine Frage habe ich doch noch:
                            Ich habe nun 5 verschiedene Klingeltöne, welche auch funktionieren, nach 7 Sekunden wird auch die SV wieder auf falsch gestellt.
                            Die Idee dahinter war auch wenn einer gleich 2 mal drückt, nicht immer der Klingelton von neuen beginnt.
                            Nun habe ich aber eine Zufallszahl, somit wird bei einem 2ten Druck sofort der nächste Sound abgespielt und unterbricht den ersten.
                            Hast du dafür auch eine Lösung? Das der Taster quasi für mindestens 7 Sekunden keine weitere Aktion ausführt?
                            Danke Dir
                            Bildschirmfoto 2022-09-19 um 10.11.37.png

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

                              @jwedenig sagte: Taster quasi für mindestens 7 Sekunden keine weitere Aktion ausführt?

                              Versuche es mal so:

                              Bild_2022-09-19_102901115.png

                              J 1 Reply Last reply Reply Quote 0
                              • J
                                jwedenig Most Active @paul53 last edited by

                                @paul53
                                hm, folgendes passiert:
                                Die SVs werden sofort auf true geschalten, also wird somit auch der Sound unterbrochen und sie bleiben auf true, gehen nicht mehr auf false!
                                Bildschirmfoto 2022-09-19 um 12.19.18.png

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

                                  @jwedenig sagte: gehen nicht mehr auf false!

                                  Das ist so, wenn "stop timeout2" falsch platziert wird.

                                  J 1 Reply Last reply Reply Quote 0
                                  • J
                                    jwedenig Most Active @paul53 last edited by

                                    @paul53
                                    sorry dafür, so jetzt richtig, folgendes passiert:

                                    Die Sounds werden nicht mehr unterbrochen aber die SVs bleiben dann auf True!
                                    Bildschirmfoto 2022-09-19 um 12.27.27.png

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

                                      @jwedenig sagte: die SVs bleiben dann auf True!

                                      Ach ja, weil die ID zwischendurch wechselt. Dann schiebe "setze id ..." in die mache-Klammer:

                                      Bild_2022-09-19_124720675.png

                                      J 1 Reply Last reply Reply Quote 0
                                      • J
                                        jwedenig Most Active @paul53 last edited by

                                        @paul53

                                        das wars!Perfekt! Danke Dir!

                                        Schade, dass ich es nicht verstehe aber trotzdem vielen Dank dafür!
                                        Liebe Grüße
                                        Jürgen

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

                                        Support us

                                        ioBroker
                                        Community Adapters
                                        Donate

                                        874
                                        Online

                                        31.9k
                                        Users

                                        80.2k
                                        Topics

                                        1.3m
                                        Posts

                                        3
                                        19
                                        438
                                        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