• 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
puzzled by syntax when using RANDOM time
#1
Finally I am migrating from version 7 to 8.1.5. But I am struggling with the syntax in the following code-line.

Code:
"rule": "IF wordtdonker.state == on THEN switch DEVICE bank TO on AFTER RANDOM(0,10). ' MINUTE' AND switch DEVICE tv TO on AFTER RANDOM(5,20). ' MINUTE'"
This gives a parsing error : ^ unexpected symbol, expected an operand, got an action
But the following code-lines  seem to be correct:

Code:
"rule": "IF wordtdonker.state == on THEN switch DEVICE bank TO on AFTER '10 MINUTE' AND switch DEVICE tv TO on AFTER '20 MINUTE'"

Code:
"rule": "IF wordtdonker.state == on THEN switch DEVICE bank TO on AFTER RANDOM(0,10). ' MINUTE'"
Code:
"rule": "IF wordtdonker.state == on THEN switch DEVICE bank TO on AFTER RANDOM(0,10). ' MINUTE' FOR '8 HOUR' AND switch DEVICE tv TO on AFTER RANDOM(5,20). ' MINUTE' FOR '8 HOUR'"

Now I can probably live with the last solution, but I do not understand what is wrong with the first code-line
 
Reply
#2
Can you post more of your config?
 
Reply
#3
(03-03-2020, 09:31 PM)curlymo Wrote: Can you post more of your config?

This is my  config, reduced to the elements in the problematic code-line

Code:
{
       "devices": {
               "bank": {
                       "protocol": [ "kaku_switch_old" ],
                       "id": [{
                               "id": 2,
                               "unit": 1
                       }],
                       "state": "off"
               },
               "tv": {
                       "protocol": [ "kaku_dimmer" ],
                       "id": [{
                               "id": 7,
                               "unit": 2
                       }],
                       "state": "off",
                       "dimlevel": 0
               },
               "wordtdonker": {
                       "protocol": [ "generic_switch" ],
                       "id": [{
                               "id": 106
                       }],
                       "state": "off"
               }
       },
       "rules": {
               "lampenaan": {
                       "rule": "IF wordtdonker.state == on THEN switch DEVICE bank TO on AFTER RANDOM(0,10). ' MINUTE' AND switch DEVICE tv TO on AFTER RANDOM(5,20). ' MINUTE' ",
                       "active": 1
               }
       },
       "gui": {
               "bank": {
                       "name": "Lamp naast bank",
                       "group": [ "Lampen" ],
                       "media": [ "all" ],
                       "readonly": 0
               },
               "tv": {
                       "name": "Lamp naast TV",
                       "group": [ "Lampen" ],
                       "media": [ "all" ],
                       "readonly": 0
               },
               "wordtdonker": {
                       "name": "WordtDonker",
                       "group": [ "Status" ],
                       "media": [ "all" ],
                       "readonly": 0
               }
       },
       "settings": {
               "log-level": 6,
               "pid-file": "/var/run/pilight.pid",
               "log-file": "/var/log/pilight.log",
               "standalone": 1,
               "webserver-enable": 1,
               "webserver-root": "/usr/local/share/pilight/webgui",
               "webserver-http-port": 5001,
               "webserver-https-port": 5002,
               "webserver-cache": 1,
               "whitelist": "",
               "gpio-platform": "raspberrypi1b2"
       },
       "hardware": {
               "433gpio": {
                       "sender": 0,
                       "receiver": 1
               }
       },
       "registry": {
               "webserver": {
                       "ssl": {
                               "certificate": {
                                       "location": "/etc/pilight/pilight.pem"
                               }
                       }
               },
               "pilight": {
                       "version": {
                               "current": "8.1.5"
                       }
               },
               "hardware": {
                       "RF433": {
                               "mingaplen": 4420,
                               "maxgaplen": 72900,
                               "minrawlen": 26,
                               "maxrawlen": 400
                       }
               }
       }
}
 
Reply
#4
I think you just found a bug Smile

I would say you make them into two rules until i found a solution.
 
Reply
#5
(03-04-2020, 07:25 PM)curlymo Wrote: I think you just found a bug Smile

I would say you make them into two rules until i found a solution.

Happy to be of a kind of help here.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Rule executed at wrong time philipp81 1 1,095 02-25-2017, 10:43 PM
Last Post: curlymo
  [Solved ]Turn off device at random time manmetdehamer 4 2,464 07-27-2016, 03:35 PM
Last Post: manmetdehamer
  event at randomized time after another event Emiks5 3 1,781 05-07-2016, 09:10 AM
Last Post: Thunder84
  Time interval between two rule checks muecke 3 2,119 04-21-2016, 02:31 PM
Last Post: pilino1234
  Triggering device at specific time or sunrise if sunrise is after OrTiN 3 1,860 03-24-2016, 11:11 PM
Last Post: OrTiN
  rules time interval kniazio 8 4,033 03-12-2016, 04:49 PM
Last Post: kniazio
  Howto: easy eventing via crontab (incl. scheduling of sun/device/time dependencies) hasselh 0 1,570 11-13-2015, 09:43 AM
Last Post: hasselh
  Syntax needed Sunrise Alex 2 2,054 09-08-2015, 05:49 PM
Last Post: terrar
  pilight eventing - sunset/sunrise/time Niek 14 11,984 04-27-2015, 05:20 PM
Last Post: troccolo
  Reley time controlled benny279 1 1,747 03-23-2015, 12:38 PM
Last Post: wo_rasp

Forum Jump:


Browsing: 1 Guest(s)