• 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
[Solved ]Turn off device at random time
#1
Hi Guys,

i been trying to get this rule working for days now and im kinda lost in the syntax of howto do it.


Code:
"tunoff": {

            "rule": "IF (datetime_dev == (datetime.hour == 23 AND
datetime.minute == RANDOM(10, 13, 15, 19, 25) AND lamp.state IS on) THEN
switch DEVICE lamp TO off",   

            "active": 1

        }


im trying to turn off the light at a random minutes after 23:00.
Hopefully someone can point me in the right direction cuz im lost at the moment.
 
Reply
#2
Please add code tags to your post according to the forum rules.

Code:
"IF DATE_FORMAT(dt, %H.%M%S) == 23.00 THEN switch DEVICE lamp TO off AFTER RANDOM(0, 90) MINUTE"

This will switch your lamp off at a random time between 0 and 90 minutes after 23:00.

Ofc you can change the min and max values in the RANDOM function according to your needs.
 
Reply
#3
Thanks niek, i used the code wrong tried to paste the text in and did not notice it faded. but fixed it now.

I tried your example rule but somehow i get the following error

Code:
[Jul 27 09:53:56:946082] pilight-daemon: ERROR: DATE_FORMAT requires at least three parameters when passing a datetime string e.g. DATE_FORMAT(01-01-2015, %d-%m-%Y, %Y-%m-%d)

i tried a few diffrent time formants but cant fix it do you have an idea?
 
Reply
#4
The "dt" in the DATE_FORMAT function of my example must be the name of your configured datetime device. Mine is called "dt", but probably yours has a different name.

Note that the name of a device must never be the same as a protocol name. So in this case the name of your datetime device should not be "datetime", but something else.
 
Reply
#5
(07-27-2016, 01:32 PM)Niek Wrote: The "dt" in the DATE_FORMAT function of my example must be the name of your configured datetime device. Mine is called "dt", but probably yours has a different name.

Note that the name of a device must never be the same as a protocol name. So in this case the name of your datetime device should not be "datetime", but something else.

Thanks Niek, i tought i already tried that, but i just did again and apperantly that was all there was wrong.

Thanks a lot for your help.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Solved] On and Off for one device in one rule Oliver 3 305 10-28-2019, 06:55 PM
Last Post: Oliver
  [solved] sunset rule doesn't work fleisch 4 289 10-26-2019, 07:05 AM
Last Post: fleisch
  Can't switch Relay device by rules: Error switch.lua:77 wobbi 6 946 07-31-2018, 06:25 AM
Last Post: curlymo
  Rule with&without device. One working not the other... Tamadite 9 1,135 07-24-2018, 08:55 AM
Last Post: curlymo
  Always trigger event on any device state Phil 8 2,182 03-22-2017, 07:30 PM
Last Post: Phil
  Rule executed at wrong time philipp81 1 896 02-25-2017, 10:43 PM
Last Post: curlymo
  event at randomized time after another event Emiks5 3 1,519 05-07-2016, 09:10 AM
Last Post: Thunder84
  Time interval between two rule checks muecke 3 1,842 04-21-2016, 02:31 PM
Last Post: pilino1234
  ERROR: rule #21 invalid: variable "label" of device "WindMax" cannot be used in even koos147 2 1,837 04-02-2016, 10:24 PM
Last Post: koos147
  Triggering device at specific time or sunrise if sunrise is after OrTiN 3 1,597 03-24-2016, 11:11 PM
Last Post: OrTiN

Forum Jump:


Browsing: 1 Guest(s)