• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to check if a time is between two times?
#1
How do you write A rule in pilight that checks if A time is between two times? So for example, I want to check if the current time is between 7am and 22.30 pm. Looking in the manual there is no standard function for this available.
 
Reply
#2
Code:
IF DATE_FORMAT(time, '%H') < 7 AND DATE_FORMAT(time, '%H%M') >= 2230 THEN ...
 
Reply
#3
(10-16-2018, 05:54 PM)curlymo Wrote:
Code:
IF DATE_FORMAT(time, '%H') < 7 AND DATE_FORMAT(time, '%H%M') >= 2230 THEN ...

That simple Smile. Thanks again for your reply, I will give it at Try tonight.
 
Reply
#4
Code:
"rule_nachtModus": {
            "rule": "IF DATE_FORMAT(currentDateTime, '%H') < 7 AND DATE_FORMAT(currentDateTime, '%H%M') >= 2230 THEN switch DEVICE NachtModus TO on ELSE switch DEVICE NachtModus TO off",
            "active": 1
        },
Unfortunately the above rule is not switching my night mode switch to on after 23.30. I build my own rule without the DATE_FORMAT which was also not working. Any new ideas?  
 
Reply
#5
My fault, the AND should be an OR.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Wrong time after switch from DST Rschnauzer 2 627 10-29-2018, 06:00 PM
Last Post: Rschnauzer
  check API in pilight 8 stratege-0815 4 1,986 02-11-2018, 09:34 AM
Last Post: stratege-0815
  Date/time out of sync with pi system time wimd 7 2,622 04-25-2017, 11:30 AM
Last Post: Niek
  pilight-daemon fails to start 2 of 3 times tietze111 4 2,379 12-11-2016, 09:06 PM
Last Post: tietze111
  Running script one time. yabapolido 8 5,566 12-03-2015, 01:48 PM
Last Post: Prutsky
  Sending and receiving at the same time geerttttt 2 2,028 07-09-2014, 01:12 AM
Last Post: scorpydude

Forum Jump:


Browsing: 1 Guest(s)