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
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?
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
As workaround you can generate some events or set variables on sunrise/sunset and reuse this output in your script.
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.
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