• 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
Sunset state check parse error
#1
Dear all,

I'm a long time and very happy user of pilight. pilight was working like a charm for many years, managing the lights in my house. It runs on a Raspberry Pi, until the SD card stopped working recently. I've now replaced the SD card and re-installed the latest version of pilight . I had to fix some minor rules, but surprisingly this wasn't that much work. There is one rule though that refuses to work in version 8, which worked fine in version 5.

Whenever I want to test if the sun has status 'set' or 'rise' in a rule, the parser throws an error and refuses to start pilight:

Code:
(/home/pilight/source/daemon-dev/libs/pilight/events/events.c #285) [Sep 21 17:09:17:376111] ERROR:
... sunrisesetdevice.sun IS set AND currentdatetime.second ...
                            ^ unexpected symbol, expected a condition

The rule looks as follows:

Code:
"rules": {
   "opstaan": {
       "rule": "IF sunrisesetdevice.sun IS set AND currentdatetime.second == 0 AND currentdatetime.minute == 30 AND currentdatetime.hour == 7 AND currentdatetime.weekday != 1 AND currentdatetime.weekday != 7 THEN switch DEVICE front TO on",
       "active": 1
    }
},

When I remove the rule, it starts fine. 

Below you can find my config (the essential part of it). Who knows what I'm doing wrong here? I've looked everywhere and spent hours, but can't find a solution that works. It used to work in an old version of pilight.

Thanks in advance for your help and ideas!

Kind regards,

Dennis.

Code:
{
  "devices": {
      "currentdatetime": {
          "protocol": [ "datetime" ],
          "id": [{
              "longitude": 1.2345,
              "latitude": 12.3456
          }],
          "year": 2019,
          "month": 9,
          "day": 21,
          "hour": 18,
          "minute": 50,
          "second": 19,
          "weekday": 7,
          "dst": 0
      },
      "sunrisesetdevice": {
          "protocol": [ "sunriseset" ],
          "id": [{
               "longitude": 1.2345,
               "latitude": 12.34567
          }],
          "sunrise": 7.55,
          "sunset": 17.55,
          "sun": "rise"
      },
      "front": {
          "protocol": [ "kaku_switch" ],
          "id": [{
               "id": 1234567,
               "unit": 0
          }],
          "state": "off"
      },
   },
   "rules": {
      "opstaan": {
          "rule": "IF sunrisesetdevice.sun IS set AND currentdatetime.second == 0 AND currentdatetime.minute == 30 AND currentdatetime.hour == 7 AND currentdatetime.weekday != 1 AND currentdatetime.weekday != 7 THEN switch DEVICE front TO on",
          "active": 1
      }
   },
   "gui": {},
   "settings": {
      "log-level": 6,
      "pid-file": "/var/run/pilight.pid",
      "log-file": "/var/log/pilight.log",
      "webserver-enable": 0,
      "gpio-platform": "raspberrypi2",
   },
   "hardware": {
      "433gpio": {
          "sender": 0,
          "receiver": 1
      }
   },
   "registry": {
      "pilight": {
          "version": {
              "current": "8.1.5"
          }
      }
   }
}
 
Reply
#2
If you check the manual you see that the IS and ISNOT are deprecated:
https://manual.pilight.org/eventing/operators.html

IS can be replaced with just == from now on.
 
Reply
#3
Sorry, must have read over that. Thanks for pointing it out in a friendly way! As a suggestion you might want to check the rest of your website, as it still contains examples using IS instead of ==.
 
Reply
#4
Can you give me an example of those wrong examples. It's always great to receive feedback on how the documentation can be improved, that's why I'm referring to it in all my answers Smile
 
Reply
#5
Yes, for instance here:

(sorry, can't place clickable links because of the forum policy)

Manual/config/rules
Manual/config/example
Manual/Protocols/Api/Weather/sunriseset

I hope this helps..
 
Reply
#6
Thanks for the pointer. I indeed missed those.
 
Reply
#7
And fixed.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [solved] sunset rule doesn't work fleisch 4 295 10-26-2019, 07:05 AM
Last Post: fleisch
  [8.1.2] variables in rules -> error terrar 1 466 09-14-2018, 05:28 PM
Last Post: curlymo
  Can't switch Relay device by rules: Error switch.lua:77 wobbi 6 949 07-31-2018, 06:25 AM
Last Post: curlymo
  Program can't be set to state running Gisto 7 1,093 07-17-2018, 12:51 PM
Last Post: Gisto
  Error in Actions with 8.1.0 tomk 1 703 05-30-2018, 06:20 AM
Last Post: curlymo
  Rule Sunset works, Sunrise not apartmedia 1 1,107 12-05-2017, 07:09 PM
Last Post: apartmedia
  Always trigger event on any device state Phil 8 2,186 03-22-2017, 07:30 PM
Last Post: Phil
  ERROR: rule #21 invalid: variable "label" of device "WindMax" cannot be used in even koos147 2 1,840 04-02-2016, 10:24 PM
Last Post: koos147
  Difference switching device or state droptix 3 2,101 10-29-2015, 05:52 PM
Last Post: terrar
Question [SOLVED] - How to switch a device 15 minutes after sunset with newest nightly Seebueb 8 4,440 08-02-2015, 11:03 AM
Last Post: curatio

Forum Jump:


Browsing: 1 Guest(s)