Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. Blockly
  5. Problem mit Astro-Funktion

NEWS

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    22
    1
    1.2k

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    9.2k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    14
    1
    2.5k

Problem mit Astro-Funktion

Scheduled Pinned Locked Moved Blockly
1 Posts 1 Posters 191 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cbr
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    Support us

    ioBroker
    Community Adapters
    Donate

    756

    Online

    32.5k

    Users

    81.7k

    Topics

    1.3m

    Posts
    Community
    Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
    ioBroker Community 2014-2025
    logo
    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Home
    • Recent
    • Tags
    • Unread 0
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe