Display Off via rule

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
marstu
Normal user
Posts: 37
Joined: 29 May 2021, 02:15

Display Off via rule

#1 Post by marstu » 19 Jun 2021, 22:07

Hi all,

It's again me, with a new question. I try to switch my small OLED display via the following rule:

Code: Select all

on %sysweekday%>0 and %sysweekday%<6 do
 If %systm_hm% < 19:00 and %systm_hm% > 08:00
  OledFramedCmd,display,on
 else
  OledFramedCmd,display,off
 endif
endon
But obviously it is not working. Display should be off during 19:00 and 8:00 from Monday to Friday, and completely in the weekend. Where is the mistake? Do I need another trigger?


Thanks already and kind regards
marstu
--
ESP8266, ESPEasy (always latest mega release in use :D ), and Domoticz (only beta versions :) )

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Display Off via rule

#2 Post by ThomasB » 20 Jun 2021, 04:29

Display should be off during 19:00 and 8:00 from Monday to Friday, and completely in the weekend. Where is the mistake? Do I need another trigger?
I'm a bit unsure what you want (OLED off during daytime or off during night time). From your code I think you want the display only on during the daytime and always off on the weekend. So that's what I coded. You can change it if that's not what you need.

Code: Select all

on Clock#Time=All,**:** do
 LogEntry,"Processing One-Minute Clock Event: Time is %systm_hm%, Day=%sysweekday%"
  if %sysweekday%>1 and %sysweekday%<7  // Allowed Date Range, Mon=2, Fri=6 
   LogEntry,"Mon(2)-Fri(6) Detected, (Day=%sysweekday%)"
   if %systm_hm% > 08:00 and %systm_hm% < 19:00 // 8AM - 7:00PM Time Range
     LogEntry,"Oled Display Turn On Time"
     OledFramedCmd,display,on
   else
     LogEntry,"Oled Display Turn Off Time"
     OledFramedCmd,display,off
   endif
  else
     LogEntry,"Weekend:Turn Off Oled Display"
     OledFramedCmd,display,off
  endif
endon

The Clock#Time event will be triggered once per minute. This is what runs the rule.

I can't verify the rule since I don't use an OLED. If doesn't work then use serial log to assist with the debugging.

- Thomas

marstu
Normal user
Posts: 37
Joined: 29 May 2021, 02:15

Re: Display Off via rule

#3 Post by marstu » 20 Jun 2021, 13:02

ThomasB wrote: 20 Jun 2021, 04:29
Display should be off during 19:00 and 8:00 from Monday to Friday, and completely in the weekend. Where is the mistake? Do I need another trigger?
I'm a bit unsure what you want (OLED off during daytime or off during night time). From your code I think you want the display only on during the daytime and always off on the weekend. So that's what I coded. You can change it if that's not what you need.

The Clock#Time event will be triggered once per minute. This is what runs the rule.

I can't verify the rule since I don't use an OLED. If doesn't work then use serial log to assist with the debugging.

- Thomas
Wow, thanks it is working, well done.

marstu
--
ESP8266, ESPEasy (always latest mega release in use :D ), and Domoticz (only beta versions :) )

Post Reply

Who is online

Users browsing this forum: No registered users and 35 guests