Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Script läuft einfach nicht!

    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 läuft einfach nicht!

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

      @paul53 danke für deine Antwort ih schick dir das andere script mal, könntest da mal schauen wie ich den Service Schalter integrieren kann?!

      danke dir

      var logging = true;
      
      const idpoolpumpe = getState('sonoff.0.Poolpumpe.POWER').val;
      var poolpumpe = idpoolpumpe;
      var poolstate = 'javascript.0.Pool.Pumpe_Status'
      
      createState(poolstate, {
      type: 'string',
      name: ' ',
      desc: ' ',
      def: ' ',
      role: 'value'
      });
      
      function pool () {
          (idpoolpumpe);
          if(poolpumpe) poolstate = "Ein";
          else poolstate = "Aus";
          if(logging) log(poolstate);
      }
      
      on('sonoff.0.Poolpumpe.POWER', function(dp) {
          poolpumpe = dp.state.val;
          pool();
      });
      
      schedule('0 1,5,9,13,17,21 * * *', function (dp) {    // um 6, 14, 0 Uhr auf true
          setState('sonoff.0.Poolpumpe.POWER', true);
          pool();
      });
        
      schedule('0 2,6,10,14,18,22 * * *', function (dp) {    // um 2, 8, 16 Uhr auf true
          setState('sonoff.0.Poolpumpe.POWER', false);
          pool();
      
      });
      
      pool();
      

      versteh das gerade nicht, du meinst ich sollte alles in 1 script packen? puh kannst mir da helfen 👍

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

        @fischi87 sagte:

        wie ich den Service Schalter integrieren kann?!

        var logging = true;
         
        const idpoolpumpe = 'sonoff.0.Poolpumpe.POWER';
        const idservice = 'javascript.0.Pool.Pool_Service';
         
        var poolstate = "Aus"
        if(getState(idpoolpumpe).val) poolstate = "Ein";
        if(logging) log(poolstate);
        
        var service = false;
        if(existsState(idservice)) service = getState(idservice).val;
        else createState(idservice, false, {
          type: 'boolean',
          name: 'Service Poolpumpe',
          role: 'switch'
        });
        
        on(idservice, function(dp) {
            service = dp.state.val;
            if(service) setState(idpoolpumpe, false);
        });
         
        on('sonoff.0.Poolpumpe.POWER', function(dp) {
            if(dp.state.val) poolstate = "Ein";
            else poolstate = "Aus";
            if(logging) log(poolstate);
        });
         
        schedule('0 1,5,9,13,17,21 * * *', function () {
            if(!service) setState(idpoolpumpe, true);
        });
          
        schedule('0 2,6,10,14,18,22 * * *', function () { 
            setState(idpoolpumpe, false);
        });
        
        fischi87 2 Replies Last reply Reply Quote 0
        • fischi87
          fischi87 @paul53 last edited by

          @paul53

          wie immer besten dank 👍

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

            @paul53

            hallo paul, ich muss deine überarbeitung des skripts nochmal aufgreifen.

            fehlt da nicht der createstate für das poolstate? bzw hab ich das gefühl das dieses „Ein“ „Aus“ nicht in den objekten geschrieben wird?!

            grüße

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

              @fischi87 sagte:

              das dieses „Ein“ „Aus“ nicht in den objekten geschrieben wird?!

              So etwas war in Deinem Script nicht vorhanden, sondern nur das Log von "Aus"/"Ein", was mich auch gewundert hat.

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

                @paul53

                doch hier: das stand mit drin

                
                var logging = true;
                 
                const idpoolpumpe = getState('sonoff.0.Poolpumpe.POWER').val;
                var poolpumpe = idpoolpumpe;
                var poolstate = 'javascript.0.Pool.Pumpe_Status'
                 
                createState(poolstate, {
                type: 'string',
                name: ' ',
                desc: ' ',
                def: ' ',
                role: 'value'
                });
                 
                function pool () {
                    (idpoolpumpe);
                    if(poolpumpe) poolstate = "Ein";
                    else poolstate = "Aus";
                    if(logging) log(poolstate);
                }
                 
                on('sonoff.0.Poolpumpe.POWER', function(dp) {
                    poolpumpe = dp.state.val;
                    pool();
                });
                 
                schedule('0 1,5,9,13,17,21 * * *', function (dp) {    // um 6, 14, 0 Uhr auf true
                     setState('sonoff.0.Poolpumpe.POWER', true);
                     pool();
                 });
                   
                 schedule('0 2,6,10,14,18,22 * * *', function (dp) {    // um 2, 8, 16 Uhr auf true
                     setState('sonoff.0.Poolpumpe.POWER', false);
                     pool();
                  
                 });
                  
                 pool();
                
                

                in dem script als ich dich bat den service schalter mit zu integrieren. oder ist das nicht korrekt?!

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

                  @fischi87 sagte:

                  oder ist das nicht korrekt?!

                  Nein, ist es nicht. Dann ergänze

                  const idpoolstate = 'javascript.0.Pool.Pumpe_Status';
                  

                  und hinter if(logging) Zeile 27

                      setState(idpoolstate, poolstate, true);
                  
                  fischi87 1 Reply Last reply Reply Quote 0
                  • fischi87
                    fischi87 @paul53 last edited by

                    @paul53

                    und den createstate mit am anfang, muss ja den state erstmal erstellen als string oder?

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

                      @fischi87 sagte:

                      muss ja den state erstmal erstellen als string oder?

                      Existiert der Datenpunkt nicht bereits ? Wenn Du das ursprüngliche Script einmal gestartet hattest, wurde der Datenpunkt erzeugt.

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

                        @paul53

                        das ist richtig aber ich habe ja dein script dann verwendet und d status gelöscht nachdem mir aufgefallen ist das diese nicht mehr geändert wurde.

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

                          @fischi87 sagte in Script läuft einfach nicht!:

                          status gelöscht

                          Dann muss der Datenpunkt wieder erstellt werden. Das kann man aber auch manuell im Tab "Objekte" machen. Ansonsten hinter if(logging), Zeile 8/9

                          if(!existsState(idpoolstate)) createState(idpoolstate, poolstate, {type: 'string', name: 'Status Poolpumpe', role: 'state'});
                          
                          fischi87 1 Reply Last reply Reply Quote 0
                          • fischi87
                            fischi87 @paul53 last edited by

                            @paul53

                            besten dank

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

                              @paul53 sagte in Script läuft einfach nicht!:
                              hallo paul, ich muss dich nochmal um deine Hilfe bitten.

                              ich habe jetzt für meine Zisterne etwas ähnliches geschrieben, dies funktioniert soweit auch nur das Problem ist, das das script mir den Status nicht in die Objekte schreibt. im log sehe ich das geschaltet wird und das der Status "Ein" bzw auch "Aus" geschaltet wird nur wie gesagt in den Objekten halt nicht.

                              const idzisternenpumpe = 'sonoff.0.Zisternenpumpe.POWER'
                              const idzisternenstatus = 'javascript.0.Zisterne.Pumpe_Status'
                              
                              var zisternenpumpe = getState(idzisternenpumpe).val;
                              var zisternenstatus = "Aus"
                              
                              function zisterne() {
                                  if(zisternenpumpe) zisternenstatus = "Ein";
                                  else zisternenstatus = "Aus";
                              
                                  log(zisternenstatus);
                              }
                              
                              on(idzisternenpumpe, function(dp) {
                                  zisternenpumpe = dp.state.val
                                  zisterne();
                              });
                              
                              zisterne();
                              
                              paul53 1 Reply Last reply Reply Quote 0
                              • paul53
                                paul53 @fischi87 last edited by

                                @fischi87
                                Zeile 10:

                                    setState(idzisternenstatus, zisternenstatus, true);
                                
                                fischi87 1 Reply Last reply Reply Quote 0
                                • fischi87
                                  fischi87 @paul53 last edited by

                                  @paul53 sagte in Script läuft einfach nicht!:

                                  @fischi87
                                  Zeile 10:

                                      setState(idzisternenstatus, zisternenstatus, true);
                                  

                                  ergänzen?

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

                                    @fischi87 sagte:

                                    ergänzen?

                                    Ja.

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

                                    Support us

                                    ioBroker
                                    Community Adapters
                                    Donate

                                    850
                                    Online

                                    31.8k
                                    Users

                                    80.0k
                                    Topics

                                    1.3m
                                    Posts

                                    javascript
                                    3
                                    20
                                    599
                                    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