Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. cbr

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    C
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Groups 0

    cbr

    @cbr

    0
    Reputation
    8
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    cbr Follow

    Latest posts made by cbr

    • Problem mit Astro-Funktion

      Hallo zusammen,

      ich reposte das hier (siehe letzter Post in: https://forum.iobroker.net/topic/22607/astro-function-does-not-work-again/51). Ich glaube aber dass ich im Deutschen Forum schneller zu einer Lösung komme.

      Ich bin Neuling was ioBroker angeht (habe es seit ein paar Tagen auf einem Raspberry Pi 4 am laufen - bisher ohne Docker).

      Aktuell habe ich zwei Skripte:

      Switch by ping

      var bool_NightTime;

      function HS100_switch() {
      if (bool_NightTime == true && getState("ping.0.raspberrypi.IP").val == true) {
      setState("hs100.0.IP.state"/HS100_Arbeitszimmer/, true);
      } else {
      setState("hs100.0.IP.state"/HS100_Arbeitszimmer/, false);
      }
      }

      bool_NightTime = compareTime(getAstroDate("sunrise", undefined, 0), getAstroDate("sunset", undefined, -20), "not between", null);
      console.log(('NightTime: ' + String(('' + bool_NightTime))));

      schedule({astro: "sunset", shift: -20}, function () {
      console.log('Sonne untergegangen -20 Min');
      bool_NightTime = true;
      HS100_switch();
      });

      schedule({astro: "sunrise", shift: 0}, function () {
      bool_NightTime = false;
      HS100_switch();
      });

      on({id: "ping.0.raspberrypi.IP"/Rechnername/, change: "ne"}, function (obj) {
      var value = obj.state.val;
      var oldValue = obj.oldState.val;
      HS100_switch();
      });


      Switch by power
      var _const_val_PowerLimit, bool_NightTime;

      function HS100_switch() {
      if (getState("hs100.0.IP.power").val < _const_val_PowerLimit && bool_NightTime == true && getState("fb-checkpresence.0.presence").val == true) {
      setState("hs100.0.IP.state"/HS100/, true);
      } else {
      setState("hs100.0.IP.state"/HS100/, false);
      }
      }

      _const_val_PowerLimit = 90;
      bool_NightTime = compareTime(getAstroDate("sunset", undefined, -20), '23:00', "between", null) && compareTime('22:30', null, "<", getAstroDate("sunset", undefined, -20));
      console.log(('NightTime: ' + String(('' + bool_NightTime))));

      schedule({astro: "sunset", shift: -20}, function () {
      console.log('Sonne untergegangen -20 Min');
      if (compareTime("22:30", "null", "<")) {
      bool_NightTime = true;
      }
      HS100_switch();
      });

      schedule("0 23 * * *", function () {
      bool_NightTime = false;
      HS100_switch();
      });

      on({id: "hs100.0.IP.power"/HS110/, change: "ne"}, function (obj) {
      var value = obj.state.val;
      var oldValue = obj.oldState.val;
      HS100_switch();
      });

      on({id: "fb-checkpresence.0.presence"/presence/, change: "ne"}, function (obj) {
      var value = obj.state.val;
      var oldValue = obj.oldState.val;
      HS100_switch();
      });

      In beiden benutze ich folgende Astro-Funktion:

      schedule({astro: "sunset", shift: -20}, function () {
        console.log('Sonne untergegangen -20 Min');
        /* additional code */
      });
      

      Allerdings wurde die Astro-Funktion gestern nur für "Switch by ping" ausgeführt - siehe Logfile:

      2020-04-01 19:35:27.992  - ^[[32minfo^[[39m: javascript.0 (665) script.js.common.Switch_by_ping: Sonne untergegangen -20 Min
      

      Am Tag davor und heute hat es für beide Skripte funktioniert. (Allerdings war es bereits die Tage zuvor sehr inkonsistent. Ich hatte zu dem Zeitpunkt aber nur das Skript "Switch by power" aktiv.)
      Ich starte meinen raspberry jede Nacht neu.

      Hier noch die Logs von heute:

      2020-04-02 19:36:56.922  - ^[[32minfo^[[39m: javascript.0 (665) script.js.common.Switch_by_power: Sonne untergegangen -20 Min
      2020-04-02 19:36:56.924  - ^[[32minfo^[[39m: javascript.0 (665) script.js.common.Switch_by_ping: Sonne untergegangen -20 Min
      

      Hat jemand eine Idee was das Problem ist?

      posted in Blockly
      C
      cbr
    • RE: ASTRO function. Does not work again

      Hello everybody,

      first of all I'm new to ioBroker (I installed it on a Raspberry Pi 4 just recently).
      However I'm having a similar problem.

      I have two scripts:

      Switch by ping

      var bool_NightTime;

      function HS100_switch() {
      if (bool_NightTime == true && getState("ping.0.raspberrypi.IP").val == true) {
      setState("hs100.0.IP.state"/HS100_Arbeitszimmer/, true);
      } else {
      setState("hs100.0.IP.state"/HS100_Arbeitszimmer/, false);
      }
      }

      bool_NightTime = compareTime(getAstroDate("sunrise", undefined, 0), getAstroDate("sunset", undefined, -20), "not between", null);
      console.log(('NightTime: ' + String(('' + bool_NightTime))));

      schedule({astro: "sunset", shift: -20}, function () {
      console.log('Sonne untergegangen -20 Min');
      bool_NightTime = true;
      HS100_switch();
      });

      schedule({astro: "sunrise", shift: 0}, function () {
      bool_NightTime = false;
      HS100_switch();
      });

      on({id: "ping.0.raspberrypi.IP"/Rechnername/, change: "ne"}, function (obj) {
      var value = obj.state.val;
      var oldValue = obj.oldState.val;
      HS100_switch();
      });


      Switch by power
      var _const_val_PowerLimit, bool_NightTime;

      function HS100_switch() {
      if (getState("hs100.0.IP.power").val < _const_val_PowerLimit && bool_NightTime == true && getState("fb-checkpresence.0.presence").val == true) {
      setState("hs100.0.IP.state"/HS100/, true);
      } else {
      setState("hs100.0.IP.state"/HS100/, false);
      }
      }

      _const_val_PowerLimit = 90;
      bool_NightTime = compareTime(getAstroDate("sunset", undefined, -20), '23:00', "between", null) && compareTime('22:30', null, "<", getAstroDate("sunset", undefined, -20));
      console.log(('NightTime: ' + String(('' + bool_NightTime))));

      schedule({astro: "sunset", shift: -20}, function () {
      console.log('Sonne untergegangen -20 Min');
      if (compareTime("22:30", "null", "<")) {
      bool_NightTime = true;
      }
      HS100_switch();
      });

      schedule("0 23 * * *", function () {
      bool_NightTime = false;
      HS100_switch();
      });

      on({id: "hs100.0.IP.power"/HS110/, change: "ne"}, function (obj) {
      var value = obj.state.val;
      var oldValue = obj.oldState.val;
      HS100_switch();
      });

      on({id: "fb-checkpresence.0.presence"/presence/, change: "ne"}, function (obj) {
      var value = obj.state.val;
      var oldValue = obj.oldState.val;
      HS100_switch();
      });

      In both of them I use:

      schedule({astro: "sunset", shift: -20}, function () {
        console.log('Sonne untergegangen -20 Min');
        /* additional code */
      });
      

      However the astro function today only triggered for the "Switch by ping" script- see logfile:

      2020-04-01 19:35:27.992  - ^[[32minfo^[[39m: javascript.0 (665) script.js.common.Switch_by_ping: Sonne untergegangen -20 Min
      

      Yesterday it was working for both scripts. (Also the days before it was already inconsistent - however I only had the "Switch by power" script at that time.)
      I'm restarting my raspberry every night and only added the console.log by today so I cannot tell about the recent days.

      Any idea what could cause this issue?

      posted in Blockly
      C
      cbr
    Community
    Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
    The ioBroker Community 2014-2023
    logo