Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. English
    3. Scripting / Logic
    4. JavaScript
    5. [Question] restart causes empty values are written

    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

    [Question] restart causes empty values are written

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

      @bananajoe said in [Question] restart causes empty values are written:

      @europe da du sonst auch auf deutsch geschrieben hast:

      This is the english forum section.

      So PLEASE use english languge here, especially if TE writes in english - so this topic is put intentionally into the english section. For german langugage postiungs theres the german area.

      Thanks

      P.S. Even if @europe can read/write in german, others might not be capable to do so, Thats why we have an english section

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

        i edit my post

        1 Reply Last reply Reply Quote 1
        • E
          europe @BananaJoe last edited by europe

          @bananajoe Thanks... with empty entries I meant null values
          273aa300-d54a-454a-bfd1-ab0c28300d3c-image.png

          Once without Ack once with.

          I just want to understand it before commenting that part out...

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

            You have a function haupt.
            Your function will started via scheduled timers and different parameter - ok.
            But in your function Haupt you also have an on Trigger-reaction in line 44
            So everytime (!) your function is called, a new(!) trigger instance is added. for cronH 24 on a day. If the value change, all 24 instances of the trigger will start. so the script will cause a slow death of the system ...

            so move the on part to a separete section an be sure it will be called only once.

            i did not now if this is the problem, but it is a problem

            1 Reply Last reply Reply Quote 0
            • E
              europe last edited by

              @bananajoe ok, I'm completely stuck here now. I have like 10 of these crons running and the system is up and running sine more than 100 days on a simple TV box. So it might be a problem, but it didn't kill me yet...

              I just start the script once. If I modify it, I stop it and then start it again. You say while its running is it basically forking all the time?!

              Do you have a link to some basics that I can educate myself on this matter?

              "move the on part to a separate section", I have not the faintest clue how to implement that. Is there maybe a general function which implements what I want? A cron.tab like behaviour?

              BananaJoe Asgothian 2 Replies Last reply Reply Quote 0
              • BananaJoe
                BananaJoe Most Active @europe last edited by

                @europe sagte in [Question] restart causes empty values are written:

                I just start the script once. If I modify it, I stop it and then start it again. You say while its running is it basically forking all the time?!

                if you stop the script, all "childs / sub-instances" are also stopped.

                separte section: remove the on expression from the function and create this for every datapoint separate.

                i am sorry, but i know no learning sites for this in english.

                1 Reply Last reply Reply Quote 0
                • E
                  europe last edited by

                  @bananajoe okay, thanks, a link to a german one is fine as well 🙂
                  Do you know a better script which implements this kind of cron tab like behaviour?

                  BananaJoe 1 Reply Last reply Reply Quote 0
                  • BananaJoe
                    BananaJoe Most Active @europe last edited by

                    @europe you could just use the "SourceAnalytix" Adapter. This Adapter will create all data you want with your script i think

                    I learned JavaScript / JavaScript with ioBroker/nodeJS and Blocky by 1.001 Websites and Examples from this forum.
                    I am sorry, but do not have "this one" site for learning this.
                    There are many videos on youtube for different themes (trigger, crontabs)

                    You don`t do it the wrong way. you wrote a script, you have problems and ask here. same as i do at the beginning.

                    1 Reply Last reply Reply Quote 0
                    • Asgothian
                      Asgothian Developer @europe last edited by

                      @europe sagte in [Question] restart causes empty values are written:

                      @bananajoe ok, I'm completely stuck here now. I have like 10 of these crons running and the system is up and running sine more than 100 days on a simple TV box. So it might be a problem, but it didn't kill me yet...

                      I just start the script once. If I modify it, I stop it and then start it again. You say while its running is it basically forking all the time?!

                      Do you have a link to some basics that I can educate myself on this matter?

                      "move the on part to a separate section", I have not the faintest clue how to implement that. Is there maybe a general function which implements what I want? A cron.tab like behaviour?

                      Actually, in your case the ’on’ construct is ok - due to the fast that once triggar is activated you unsubscribe from the triggar (line 46 in your code)
                      This does not get us closer to the null values, but explains why all is running fine.

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

                        @Asgothian

                        unsubscribe

                        damned, i missed the unsubscribe, so after the on is created it will immediately destroyed?

                        Asgothian 1 Reply Last reply Reply Quote 0
                        • Asgothian
                          Asgothian Developer @BananaJoe last edited by

                          @bananajoe sagte in [Question] restart causes empty values are written:

                          @Asgothian

                          unsubscribe

                          damned, i missed the unsubscribe, so after the on is created it will immediately destroyed?

                          The first time the trigger fires, yes.

                          E 1 Reply Last reply Reply Quote 0
                          • E
                            europe @Asgothian last edited by

                            @asgothian

                            Okay, I just found the history adapter writes null at start and stop. I deactivated that.
                            I still had all those null entries though, which messed up with certain plotting routines.

                            I also wrote a script which goes through all objects (incl. 3 level of nesting according to the doc) and removes items in a certain timeframe of 1 minute.

                            Here's the code:

                            // 21-10-2024. Works perfectly!!
                            // To see log entries, set log level of javascript instance to silly
                            var startTimestamp = new Date('2023-12-14T09:40:00.000');
                            var endTimestamp = new Date(startTimestamp.getTime() + 1*60000);
                            
                            //log(startTimestamp.toISOString())
                            //log(endTimestamp.toISOString())
                            
                            $('0_userdata.0.Haus.*').each(function(id) { 
                                //log(id.toString())
                            //var currentElement = $(this);
                               //console.log(currentElement);
                              sendTo('history.0', 'deleteRange', [{ id: id.toString(), start: startTimestamp, end: endTimestamp }]);
                            });
                            
                            
                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post

                            Support us

                            ioBroker
                            Community Adapters
                            Donate

                            694
                            Online

                            31.9k
                            Users

                            80.1k
                            Topics

                            1.3m
                            Posts

                            javascript
                            4
                            14
                            705
                            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