sunrise/sunset to be used in rule

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

sunrise/sunset to be used in rule

#1 Post by TungstenE2 » 30 May 2018, 08:35

Hi all,

I would like to use sunrise/sunset time in a rule (eg sunrise + 30min) on a Wemos D1 mini using latest mega build.
How to do this? An external HTTP request would be good, but not to a lokal controler.
I want to be independent from another controler.

Any ideas or tipps?

thx

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: sunrise/sunset to be used in rule

#2 Post by enesbcs » 01 Jun 2018, 13:48

TungstenE2 wrote: 30 May 2018, 08:35 Hi all,
I would like to use sunrise/sunset time in a rule (eg sunrise + 30min) on a Wemos D1 mini using latest mega build.
How to do this? An external HTTP request would be good, but not to a lokal controler.
I want to be independent from another controler.
Any ideas or tipps?
thx
You need to know the date and time at least (NTP or RTC), and you based on it you could use something like this library:
https://github.com/dmkishi/Dusk2Dawn

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: sunrise/sunset to be used in rule

#3 Post by papperone » 01 Jun 2018, 16:45

enesbcs wrote: 01 Jun 2018, 13:48
TungstenE2 wrote: 30 May 2018, 08:35 Hi all,
I would like to use sunrise/sunset time in a rule (eg sunrise + 30min) on a Wemos D1 mini using latest mega build.
How to do this? An external HTTP request would be good, but not to a lokal controler.
I want to be independent from another controler.
Any ideas or tipps?
thx
You need to know the date and time at least (NTP or RTC), and you based on it you could use something like this library:
https://github.com/dmkishi/Dusk2Dawn
you need as well Longitude and Latitute, I think it's too much to implement this in EspEasy, I do this already for my garden lights but I do it in my NodeRed@RasPi :mrgreen:
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sunrise/sunset to be used in rule

#4 Post by TD-er » 01 Jun 2018, 22:32

I think it is a useful feature, so could you add an issue for it?


hooijschuur
New user
Posts: 3
Joined: 27 Sep 2015, 09:01

Re: sunrise/sunset to be used in rule

#6 Post by hooijschuur » 01 Jul 2018, 18:21

Is IT also possible tot post An example rule
There are examples but not for Sunset etc.

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: sunrise/sunset to be used in rule

#7 Post by TungstenE2 » 04 Jul 2018, 08:41

I was just about to test it.

New %sunrise% and %sunset% variables were added, but I am not sure about the syntax to be used in rules.

Is there a way to test the variables?

https://www.letscontrolit.com/wiki/inde ... _Variables

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: sunrise/sunset to be used in rule

#8 Post by TungstenE2 » 04 Jul 2018, 14:47

could someone give an example rule how to use %sunrise% and %sunset% variables?

on this page nothing is mentioned on how to use variables:
https://www.letscontrolit.com/wiki/inde ... rial_Rules

would this be something like this?

Code: Select all

on  %sunrise% do
 if <test>
   <action>
   <action>
 endif
endon

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: sunrise/sunset to be used in rule

#9 Post by enesbcs » 04 Jul 2018, 18:04

TungstenE2 wrote: 04 Jul 2018, 14:47 could someone give an example rule how to use %sunrise% and %sunset% variables?

on this page nothing is mentioned on how to use variables:
https://www.letscontrolit.com/wiki/inde ... rial_Rules

would this be something like this?

Code: Select all

on  %sunrise% do
 if <test>
   <action>
   <action>
 endif
endon
I am pretty sure that variables do not ment to be used in that way.
I think that Clock#Time event need to be used:
https://www.letscontrolit.com/wiki/inde ... .29_events

xury
Normal user
Posts: 44
Joined: 02 Apr 2018, 12:54

Re: sunrise/sunset to be used in rule

#10 Post by xury » 04 Jul 2018, 22:17

Perhaps that way:

Code: Select all

on Clock#Time=All,%sunrise% do
 if <test>
   <action>
   <action>
 endif
endon

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: sunrise/sunset to be used in rule

#11 Post by TungstenE2 » 06 Jul 2018, 12:45

this is working great! thx!

Code: Select all

 On Clock#Time=All,%sunrise% do 
   <action>                               
endon

That makes it possible to do something at sunrise or sunset and also start a timer to do something at those moments + N seconds.

Code: Select all

//at sunrise time set timer1 for 1 hour
On Clock#Time=All,%sunrise% do 
        timerSet,1,3600                               
endon



//When Timer1 expires, <action>
 On Rules#Timer=1 do  
    <action>
 endon
 
 
 //at sunset set timer2 for 0,5 hour
On Clock#Time=All,%sunset% do 
        timerSet,2,1800                               
endon



//When Timer2 expires,  <action>
 On Rules#Timer=2 do  
    <action>
 endon

reliable
New user
Posts: 2
Joined: 09 Nov 2018, 10:56

Re: sunrise/sunset to be used in rule

#12 Post by reliable » 09 Nov 2018, 11:00

Hey.
I would like to use the state of sunrise or sunset when reloading ESP.
I write this rule:

Code: Select all

On System#Wake do
  if[Clock#Time=All,%sunrise%]=1
    TaskValueSet 4,3,0
  endif
endon
On System#Wake do
  if[Clock#Time=All,%sunset%]=1
    TaskValueSet 4,3,1
  endif
endon
but it does not work.
Tell me how to write the rules correctly?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: sunrise/sunset to be used in rule

#13 Post by grovkillen » 09 Nov 2018, 12:24

Try this one instead:

Code: Select all

On Time#Initialized do
  if %systime%>%sunrise% and %systime%<%sunset%
    TaskValueSet,4,3,0
   else
    TaskValueSet,4,3,1
  endif
endon
Just as an example. I really think it would be unique if you have the system booted at the exact minute of either sunset or sunrise...

Or if you want the rule to check each minute:

Code: Select all

On Clock#Time=All,%sunrise% do
    TaskValueSet 4,3,0
endon

On Clock#Time=All,%sunset% do
    TaskValueSet 4,3,1
endon
I think that last rule should work.. haven't tested it myself though.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

reliable
New user
Posts: 2
Joined: 09 Nov 2018, 10:56

Re: sunrise/sunset to be used in rule

#14 Post by reliable » 10 Nov 2018, 11:26

Thanks for the help. It really works as I need!

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: sunrise/sunset to be used in rule

#15 Post by grovkillen » 10 Nov 2018, 11:42

Great, thanks for the feedback.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#16 Post by Metatron » 23 Mar 2021, 07:33

Hello,

I try to define a rule to open my shutters according to sunrise, but no earlier then 6am. Later during weekends.
However, it doeas not work. Can somebody see my mistake, please?

Code: Select all

On Clock#Time=All,%sunrise-15m% do 
 If %systime% > 06:00:00
   if %sysweekday%=1 or %sysweekday%=7
     timerSet,1,3600
   else 
     timerSet,1,1
   endif
 endif                               
endon

On Clock#Time=All,06:00:00 do
   If %systime% > %sunrise-15m%
    if %sysweekday%=1 or %sysweekday%=7
      timerSet,1,3600
    else 
      timerSet,1,1
    endif
   endif
endon
It is a bit annoying, to have only one chance a day for debugging! :?

Regards, Metatron

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sunrise/sunset to be used in rule

#17 Post by Ath » 23 Mar 2021, 08:25

This condition won't work as expected:

Code: Select all

    If %systime% > %sunrise-15m%
this is a 'known issue', only the first %-encoded variable is expanded
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sunrise/sunset to be used in rule

#18 Post by TD-er » 23 Mar 2021, 09:14

For now it is best to store "computations" in a variable using let.
I don't know if only "the first" %-encoded variable is expanded in rules parsing, but there seems to be something fishy happening here.

Code: Select all

let,1,%systime%
let,2,%sunrise-15m%
if [var#1] > [var#2]
  ...

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#19 Post by Metatron » 23 Mar 2021, 17:57

Thank you!
Does this expanding problem also apply to

Code: Select all

if %sysweekday%=1 or %sysweekday%=7
i.e. in general per line/expression?

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sunrise/sunset to be used in rule

#20 Post by TD-er » 23 Mar 2021, 18:20

Well it was intended to work, but apparently there is an issue with it.
So you should try to know for sure and when in doubt store it in a variable.

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sunrise/sunset to be used in rule

#21 Post by Ath » 23 Mar 2021, 22:28

Ath wrote: 23 Mar 2021, 08:25 This condition won't work as expected:

Code: Select all

    If %systime% > %sunrise-15m%
this is a 'known issue', only the first %-encoded variable is expanded
Did some more testing, but all should be working. I was probably misled by another issue, that I fixed today, and seemed applicable here too, but it wasn't.

You may want to check if your rules use Windows Cr/Lf on all lines, my test-script had some invalid line-ends, and after fixing that it all works as intended.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sunrise/sunset to be used in rule

#22 Post by TD-er » 23 Mar 2021, 23:11

If the rules are saved using the web interface (and thus not uploaded as rules file) then the CRLF should be correct as that's being dealt with in the JavaScript.

What can be an issue is that the rules may have some strange characters in them if you copied them from a website or used a program like Word as a notepad.
But that should result in errors in the log when parsing the rules.

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sunrise/sunset to be used in rule

#23 Post by Ath » 24 Mar 2021, 08:00

TD-er wrote: 23 Mar 2021, 23:11 ...the rules may have some strange characters in them if you copied them from a website ...
But that should result in errors in the log when parsing the rules.
I did copy a part of that script from a forum post, so that was most likely the cause, nothing visible in the log though, just some script lines seemed to be ignored.
TD-er wrote: 23 Mar 2021, 23:11 ...or used a program like Word as a notepad.
You'll not catch me attempting that, ever :lol:
/Ton (PayPal.me)

User avatar
iron
Normal user
Posts: 221
Joined: 24 Sep 2016, 08:37
Location: Greece
Contact:

Re: sunrise/sunset to be used in rule

#24 Post by iron » 24 Mar 2021, 18:41

Hey... Vanila Ice said it !!!
Last edited by iron on 03 Apr 2021, 21:26, edited 1 time in total.
-D

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#25 Post by Metatron » 24 Mar 2021, 19:17

Hello,

thank you so much for your feedback and support!
This morning, nothing happened - and then I got an idea:
My timezone was wrong! It did not play a role, while only dealing with sunrise/sunset, but for 6:00 it does!
Sorry, my very own fault!
I removed the variables, again. Now let's wait for the next morning!

Regards, Metatron

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sunrise/sunset to be used in rule

#26 Post by TD-er » 24 Mar 2021, 19:49

Make sure the GPS coordinates are also set correct.
You can print the %sunrise% variable via something like the "logitem" command.
Or if you have a "normal" or "custom" build you can also chech the system variables page.

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sunrise/sunset to be used in rule

#27 Post by TD-er » 24 Mar 2021, 19:52

Ath wrote: 24 Mar 2021, 08:00 [...]
You'll not catch me attempting that, ever :lol:
Wordpad? Write? WP6.0-for-Windows?
Or are you more like a vi/nano/emacs/elle/ted/edlin kinda guy? ;)

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sunrise/sunset to be used in rule

#28 Post by Ath » 24 Mar 2021, 20:33

TD-er wrote: 24 Mar 2021, 19:52 Wordpad? Write? WP6.0-for-Windows?
Or are you more like a vi/nano/emacs/elle/ted/edlin kinda guy? ;)
Well, Word (and WP for Dos) is for writing letters and stuff like that, text files need to be done using a tool that doesn't mock them up, so Notepad++ and VSCode are my current go to's, but I used to be quite skilled in edlin, back in the day (when MS-Dos 3 was king :D), though I haven't started that for 20-odd years I think. Vi I also have quite some experience in using, as that was the only general available editor on HP-UX in my previous job, so I also use it out of habit on other *nix systems like RPi and Redhat that I maintain. The other editors you mention I have heard of, but (almost) never used.
/Ton (PayPal.me)

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#29 Post by Metatron » 27 Mar 2021, 16:49

Hello,

sorry to bother you again, but I am still struggling with my rules for sunrise, currently, nothing happens.
Coordinates timezone etc. are fine. I also checked system variables - fine. Wiring is fine, manually all works.
These are the rules:

Code: Select all

On Clock#Time=All,%sunrise-15m% do 
 If %systime%>06:00:00
   if %sysweekday%=1 or %sysweekday%=7
     timerSet,1,3600
   else 
     timerSet,1,1
   endif
 endif                               
endon

On Clock#Time=All,06:00:00 do
//  let,1,%systime%
// let,2,
   If   %sunrise-15m%<06:00:00
    if %sysweekday%=1 or %sysweekday%=7
      timerSet,1,3690
    else 
      timerSet,1,90
    endif
   endif
endon

//When Timer1 expires,  <action>
On Rules#Timer=1 do  
   event,alleauf     
endon
Today I removed the spaces before and after ">", do they matter?
Do small or capital letters matter?

Regards, Metatron

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sunrise/sunset to be used in rule

#30 Post by Ath » 27 Mar 2021, 17:22

I think you have some logical error, the event on Clock#Time=All,%sunrise-15m% do is fired exactly 1 time, every day. What if sunrise-15m is after 06:00?
Metatron wrote: 23 Mar 2021, 07:33 I try to define a rule to open my shutters according to sunrise, but no earlier then 6am. Later during weekends.
I'd go for something like this:
(Added a Dummy Device at task 12 and named that Shutters, first variable named Opened)

Code: Select all

On Clock#Time=All,**:** do // Check every minute
  If %systime% >= %sunrise-15m% and %systime% > 06:00:00 and [Shutters#Opened] = 0
    TaskValueSet,12,1,1 // Set Opened state (to avoid resetting the timer every minute)
    if %sysweekday%=1 or %sysweekday%=7 // Saturdays and Sundays
      timerSet,1,3600 // Delay for an hour
    else 
      timerSet,1,1 // Delay for 1 second
    endif
  endif
  if %systime% >= %sunset+2h% and [Shutters#Opened] = 1 // Close shutters 2h after sunset, and when not closed yet
    asyncevent,allenieder
  endif
endon

on CloseButton#State do // When the button changes state close or open the shutters
  if [Shutters#Opened] = 1
    asyncevent,allenieder
  else
    asyncevent,alleauf
  endif
endon

on Rules#Timer=1 do
  asyncevent,alleauf
endon

on alleauf do
  TaskValueSet,12,1,1 // Set opened
  // Open all shutters
endon

on allenieder do
  TaskValueSet,12,1,0 // Reset opened
  // Other actions to close the shutters
endon
/Ton (PayPal.me)

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#31 Post by Metatron » 27 Mar 2021, 17:40

First of all, thank you for you reply. I will need some time to think it through.
I think you have some logical error, the event on Clock#Time=All,%sunrise-15m% do is fired exactly 1 time, every day. What if sunrise-15m is after 06:00?
Well, I wrote:

Code: Select all

On Clock#Time=All,%sunrise-15m% do 
 if %systime%>06:00:00
   if %sysweekday%=1 or %sysweekday%=7
     timerSet,1,3600
   else 
     timerSet,1,1
   endif
 endif                               
endon
If this is fired once a day 15min before sunrise, it checks if it is later then 6am with the second "if" and opens the shutter, no?
The the

Code: Select all

On Clock#Time=All,06:00:00 do
//  let,1,%systime%
// let,2,
   if   %sunrise-15m%<06:00:00
   ...
Checks every day at 6am, if sunrise-15m is before 6am, and if yes, opens the shutter at 6am. This is, what I am trying to do, but this does not work.

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#32 Post by Metatron » 28 Mar 2021, 19:40

Hallo,

something I just realized in the system variables, that %sunrise% and %sunset% don't have seconds, only hours and minutes.
Could the problem be that

Code: Select all

 If   %sunrise-15m%<06:00:00
does not work, but should be:

Code: Select all

 If   %sunrise-15m%<06:00
??

Regards, Metatron

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sunrise/sunset to be used in rule

#33 Post by Ath » 28 Mar 2021, 19:49

The function that parses the time, calculates that back to seconds, and knows about the 2 and 3 parts variants of time, and (for obvious reasons) assumes the seconds part to be 00 when absent.
When comparing using '=' to a HH:MM:SS time, you can't be off-by-a-second, so changing that to 06:00 seams to be an easy improvement to make that test less exact.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sunrise/sunset to be used in rule

#34 Post by Ath » 28 Mar 2021, 19:51

NB: Have you tried to use my proposed rules?
You could add some LogEntry statements to see in the log what's going on, during testing.
/Ton (PayPal.me)

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#35 Post by Metatron » 28 Mar 2021, 19:57

No, sorry, because I don't understand the task 12 device. Could you please send me a screenshot of the definition of that task?

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#36 Post by Metatron » 02 Apr 2021, 20:23

Hello,

my ESPEasy started to behave odd. Closing shutters at 6:21pm, far to early, like 30min before sunset, opening shutters at midnight.
I checked cr/lf, all fine. No reboots of the esp either (online since 11 days).
Is there any other thing/character, which could confuse my esp?
Should I use a different version, like a "stable" one?

I went back zu simple 7am shutters up, sunset+30m shuttern down.
Now I will observe what happens.

Ah, closing right now, that is fine.

Regards, Metatron

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sunrise/sunset to be used in rule

#37 Post by Ath » 02 Apr 2021, 21:15

Can you post your complete set of rules here, AFAICS, there are currently only snippets available here, making it impossible to assess what's happening.
/Ton (PayPal.me)

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#38 Post by Metatron » 02 Apr 2021, 21:32

Sure, I took a copy, before simplifying it, I hope it is not a stupid mistake!
But because there are only a few events ...

Code: Select all

On testpins do
GPIO,13,1
Delay 1000
GPIO,13,0
Delay 2000
GPIO,12,1
Delay 1000
GPIO,12,0
Delay 2000
GPIO,4,1
Delay 1000
GPIO,4,0
Delay 2000
GPIO,5,1
Delay 1000
GPIO,5,0
endon
On Clock#Time=All,%sunrise-30m% do
 if %systime%>06:00:00
   if %sysweekday%=1 or %sysweekday%=7
     timerSet,1,3600
   else
     timerSet,1,1
   endif
 endif
endon
On Clock#Time=All,06:30:00 do
  if %sysweekday%=5
   timerSet,1,1800
  else
   timerSet,1,1
  endif
endon
On Clock#Time=All,06:00:00 do
   if %systime%<%sunrise-15m%
    if %sysweekday%=1 or %sysweekday%=7
      timerSet,1,3690
    else
      timerSet,1,90
    endif
   endif
endon
//When Timer1 expires, <action>
On Rules#Timer=1 do
   event,alleauf
endon
// 30min nach untergang
On Clock#Time=All,%sunset+30m% do
    event,einszu
endon
On alleauf do
GPIO,13,1
Delay 1000
GPIO,13,0
endon
On allezu do
GPIO,12,1
Delay 500
GPIO,12,0
endon
On allestop do
GPIO,12,1
GPIO,13,1
Delay 500
GPIO,12,0
GPIO,13,0
endon
On einsauf do
GPIO,4,1
GPIO,13,1
Delay 500
GPIO,4,0
GPIO,13,0
endon
On einszu do
GPIO,4,1
GPIO,12,1
Delay 1000
GPIO,4,0
GPIO,12,0
endon
On einsstop do
GPIO,4,1
GPIO,12,1
GPIO,13,1
Delay 500
GPIO,4,0
GPIO,12,0
GPIO,13,0
endon
On zweiauf do
GPIO,5,1
GPIO,13,1
Delay 500
GPIO,5,0
GPIO,13,0
endon
On zweizu do
GPIO,5,1
GPIO,12,1
Delay 500
GPIO,5,0
GPIO,12,0
endon
On zweistop do
GPIO,5,1
GPIO,12,1
GPIO,13,1
Delay 500
GPIO,5,0
GPIO,12,0
GPIO,13,0
endon
On dreiauf do
GPIO,4,1
GPIO,5,1
GPIO,13,1
Delay 500
GPIO,4,0
GPIO,5,0
GPIO,13,0
endon
On dreizu do
GPIO,4,1
GPIO,5,1
GPIO,12,1
Delay 500
GPIO,4,0
GPIO,5,0
GPIO,12,0
endon
On dreistop do
GPIO,4,1
GPIO,5,1
GPIO,12,1
GPIO,13,1
Delay 500
GPIO,4,0
GPIO,5,0
GPIO,12,0
GPIO,13,0
endon
Thank you a lot for your will to help me!

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#39 Post by Metatron » 03 Apr 2021, 11:52

This night, all the shutters went up again. I think a will take out all "On"-Events, to make sure, it is not a hardware issue.

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sunrise/sunset to be used in rule

#40 Post by TD-er » 03 Apr 2021, 12:03

First a little tip, as you can have multiple matches based on the day of the week.

Code: Select all

On Clock#Time=All,06:00:00 do
   if %systime%<%sunrise-15m%
    if %sysweekday%=1 or %sysweekday%=7
      timerSet,1,3690
    else
      timerSet,1,90
    endif
   endif
endon
I do notice the documentation is a bit limited here, but the "All" can be one of these:
all
sun
mon
tue
wed
thu
fri
sat
wrk (weekday/workday)
wkd (weekend

Also make sure to check your DST and timezone and whether you have set your latitude/longitude coordinates as those are used for computing the sunrise/sunset.
I can't see why your setup might perform actions at midnight while it should do them at sunrise.
The only thing I can think of is that the new sunrise are not yet computed for the new day when the rules are being evaluated, but I've never heard any issue with that. (or a reboot after which the unit did not (yet) get time synced via NTP)

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sunrise/sunset to be used in rule

#41 Post by Ath » 03 Apr 2021, 13:48

@Metatron I tried to analyze your set of rules, but as I can't comprehend how the GPIO's are connected, c.q. what they are supposed to do/control, it is very hard to understand. Can you elaborate on that?

Also, I don't understand the use of the delay commands, where you set a couple of GPIO's to 1, wait a short time, and turn them back to 0.
/Ton (PayPal.me)

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#42 Post by Metatron » 06 Apr 2021, 12:13

Very strange, since I don't have a "On Clock#Time=All,06:30:00 do" type of entry, no confusing opening of the shutters anymore. (For some days now)
Has anyone an idea, why?
I believe to have proven, that it is not a hardware issue.

I have set ntp, timezone, coordinates, DST correctly, closing at sunset is working very good.
As I stated, no reboots.

So what do the rules do? The GPIOs are soldered to a remote control called ZB40 of shutters called Superrollo GW60.
Details can be found here: https://forum.fhem.de/index.php/topic,17125.0.html
Lets say, I "press buttons".
All the commands work fine, i.e. mqtt or REST.

I simply thought, I could use the rules and have a simple, self-sufficient solution.

Thanks to the hint with the weekend, I am new to ESPEasy.

Regards, Metatron

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sunrise/sunset to be used in rule

#43 Post by TD-er » 06 Apr 2021, 13:01

If you're having issues with (remote) switches triggering on the remote, you may also have a look at how the GPIO pin is connected.
Is there a long wire between a switch and the GPIO pin?
Then the wire may act as an antenna and sending false pulses to the connected remote.

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sunrise/sunset to be used in rule

#44 Post by Ath » 06 Apr 2021, 13:12

Metatron wrote: 06 Apr 2021, 12:13 Very strange, since I don't have a "On Clock#Time=All,06:30:00 do" type of entry, no confusing opening of the shutters anymore. (For some days now)
You could re-enable that rule but then using only HH:MM for the check like:

Code: Select all

On Clock#Time=All,06:30 do
It is a possibillity that 2 rules are clashing when running at almost the same time.

You haven't reported yet on what release of ESPEasy you are running your ESP, the name of the .bin file used would be most informative.
/Ton (PayPal.me)

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#45 Post by Metatron » 06 Apr 2021, 13:22

Hello,
thanks, I will try with 06:30, or later, we have vacation. ;)

I also had problems, where clashing was impossible, only one opening scenario active.

as I said, using MQTT, triggering the shutters works fine, in all the cases.
I use
ESP_Easy_mega_20210223_normal_ESP8266_4M1M.bin
I use a NodeMCU LoLin

User avatar
Metatron
Normal user
Posts: 39
Joined: 20 Mar 2021, 09:38

Re: sunrise/sunset to be used in rule

#46 Post by Metatron » 11 Apr 2021, 22:16

Hello,

so far, it is working fine with 7:30. Thanks!
Now I start to make it more complicated, again.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 34 guests