Sunrise/sunset info in the script

  • Hi all,

    I know that is possible to create schedule where is possible to use sunrise/sunset info as a condition for some action but Is it possible to use these informations also on the custom script??

    Thx

    Tom

  • Hello Tom,

    I think that's impossible. But why do you want to do this?

    You can use a shedule job with method "Script.Eval" and the code value contains a funtion call "foo(parameter)".

    So your script function "foo()" will be called at the wished time.

    Also in foo() you can write into a global Variable, e.g. a Status structure. So another function or eventhandler can use this information ...

    Is there any additional behavior you would like to implement?

    An Cloud-/Szenen-Benutzer (insbesondere für Regelungen): Was erwartest du, wenn Internet oder Cloud sabotiert werden? Nicht nur dafür meine kleine Skripteinführung  8)

    Die einzig existierende Konstante ist der Wandel. Oft liegt die größte Schwierigkeit darin, das Anliegen des Klienten zu verstehen.

  • Hi Tom,

    the mongoose OS on the Shelly itself use a library to calculate the sunrise/sunset times, based on your correct geo-data and timezone.

    I‘ve not found any variables in the Shelly API scripting docs, but I can’t believe, that the Shelly script can’t handle this values.

    eiche say‘s that you can use global variables in Shelly scripts.

    Pardon my half-knowledge - these are just thoughts that go through my head when I think about this topic.

    The sunriset library you can find on GitHub

    https://github.com/mongoose-os-libs/cron/tree/master/src

    As workaround you can generate some events or set variables on sunrise/sunset and reuse this output in your script.

    elektroman:~#

    Mein Zoo: 15xShelly2.5, 7xShellyPlugS, 4xShellyDimmer2, 2xShelly1PM, 8xShelly1, 2xShellyi3, 1xShellyPlus i4, 2xShellyFlood, 2xShellyDoorWindow2, 2xShellyButton1, 2xShellyButton, 2xSOnOff4CH, 1xSOnOff2CH, Nanoleaf, Meross, Govee, Tado, Tuya, Xiaomi, SwitchBot ...

    Raspberry's, OpenHAB, Pi-hole

  • I've already placed a feature request to add sunrise / sunset infos to Shelly.GetStatus REST-API call which was accepted, so this will probably be implemented with a future firmware version.

    >100 Shellies, darunter so gut wie alles was der Hersteller produziert hat. ;)
    :!: ich beantworte grundsätzlich keine Fragen per persönlicher Nachricht:!:

  • Thanks for update.

    How do you mean global variables? Could you please share some example with me. I think that this should work for me :-).

    Also thanks for update regarding feature request - that will be nice in future but I need to find some solution now.

    I have shelly 4pm and I would like to use it for lights which will be driven by information if its night (so between sunset-sunrise with some defined offset) and also by shelly inputs through buttons or motion sensors. So in case when input changed its state to ON some event handler on my script will be called. This handler will check if its "night" and then have to decide to set some shelly switch.

    Tom

  • Dieses Thema enthält 8 weitere Beiträge, die nur für registrierte Benutzer sichtbar sind.