• 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
Rule with datetime will not work
#1
Dear pilight users,

i have a problem with my ruleset, using pilight 7 on a RaspberrPi 3. As far as i can see, i cannot find any error.

I have added a datetime device with the name date_time, so i have not the same name as the protocol.

But everytime i get an error when i start pilight:
Code:
[Sep 23 15:28:15:876415] pilight-daemon: INFO: rule #1 RolloSonneAb was parsed in 0.000336 seconds
[Sep 23 15:28:15:876668] pilight-daemon: INFO: rule #2 RolloSonneAuf was parsed in 0.000189 seconds
[Sep 23 15:28:15:876734] pilight-daemon: ERROR: rule #3 invalid: operator "date_time.second" does not exist
[Sep 23 15:28:15:876788] pilight-daemon: INFO: rule #3 was parsed until: ... (IF date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 14) THEN switch DEVICE Switch1 TO on
[Sep 23 15:28:15:876840] pilight-daemon: INFO: rule #3 AquariumAn was parsed in 0.000183 seconds

Here is my config.json
Code:
{
    "devices": {
        "date_time": {
            "protocol": [ "datetime" ],
            "id": [{
                "longitude": 11.11919,
                "latitude": 49.34463
            }],
            "year": 2016,
            "month": 9,
            "day": 23,
            "hour": 14,
            "minute": 53,
            "second": 45,
            "dst": 1,
            "weekday": 6
        },
        "temperature": {
            "protocol": [ "dht11" ],
            "id": [{
                "gpio": 0
            }],
            "humidity": 43.0,
            "temperature": 18.0,
            "poll-interval": 60
        },
        "outside": {
            "protocol": [ "openweathermap" ],
            "id": [{
                "country": "de",
                "location": "wendelstein"
            }],
            "humidity": 68.00,
            "temperature": 16.37,
            "sunrise": 7.00,
            "sunset": 19.15,
            "sun": "rise",
            "update": 1
        },
        "sunrise": {
            "protocol": [ "sunriseset" ],
            "id": [{
                "longitude": 11.11919,
                "latitude": 49.34463
            }],
            "sunrise": 7.04,
            "sunset": 19.12,
            "sun": "rise"
        },
        "Wohnzimmer": {
            "protocol": [ "intertechno_old" ],
            "id": [{
                "id": 14,
                "unit": 0
            }],
            "state": "off"
        },
        "WZRollo": {
            "protocol": [ "kaku_switch" ],
            "id": [{
                "id": 15888370,
                "unit": 1
            }],
            "state": "on"
        },
        "Esszimmer": {
            "protocol": [ "intertechno_old" ],
            "id": [{
                "id": 0,
                "unit": 0
            }],
            "state": "off"
        },
        "Switch1": {
            "protocol": [ "kaku_switch" ],
            "id": [{
                "id": 15888386,
                "unit": 0
            }],
            "state": "off"
        },
        "Switch2": {
            "protocol": [ "kaku_switch" ],
            "id": [{
                "id": 15888386,
                "unit": 1
            }],
            "state": "off"
        },
        "Switch3": {
            "protocol": [ "kaku_switch" ],
            "id": [{
                "id": 15888386,
                "unit": 2
            }],
            "state": "off"
        }
    },
    "rules": {
        "RolloSonneAb": {
            "rule": "IF sunrise.sun IS set THEN switch DEVICE WZRollo TO off",
            "active": 1
        },
        "RolloSonneAuf": {
            "rule": "IF sunrise.sun IS rise THEN switch DEVICE WZRollo TO on",
            "active": 1
        },
        "AquariumAn": {
            "rule": "IF (date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 6) OR (IF date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 14) THEN switch DEVICE Switch1 TO on",
            "active": 1
        },
        "AquariumAus": {
            "rule": "IF (date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 10) OR (IF date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 19) THEN switch DEVICE Switch1 TO off",
            "active": 1
        }
    },
    "gui": {
        "date_time": {
            "name": "Date - Time",
            "group": [ "Outdoor" ],
            "media": [ "all" ],
            "format": "YYYY-MM-DD HH:mm:ss"
        },
        "temperature": {
            "name": "Temperature Sensor",
            "group": [ "Outdoor" ],
            "media": [ "all" ]
        },
        "outside": {
            "name": "Wettervorhersage",
            "group": [ "Outdoor" ],
            "media": [ "all" ]
        },
        "sunrise": {
            "name": "Sonnenauf- und -untergang",
            "group": [ "Outdoor" ],
            "media": [ "all" ]
        },
        "WZRollo": {
            "name": "Rollo Wohnzimmer",
            "group": [ "Rollos" ],
            "media": [ "all" ]
        },
        "Switch1": {
            "name": "Aquarium",
            "group": [ "Lichter" ],
            "media": [ "all" ]
        },
        "Switch2": {
            "name": "Switch Nr 2",
            "group": [ "Outdoor" ],
            "media": [ "all" ]
        },
        "Switch3": {
            "name": "Switch Nr 3",
            "group": [ "Outdoor" ],
            "media": [ "all" ]
        },
        "Wohnzimmer": {
            "name": "Wohnzimmer",
            "group": [ "Lichter" ],
            "media": [ "all" ]
        },
        "Esszimmer": {
            "name": "Esszimmer",
            "group": [ "Lichter" ],
            "media": [ "all" ]
        }
    },
    "settings": {
        "log-level": 6,
        "pid-file": "/var/run/pilight.pid",
        "log-file": "/var/log/pilight.log",
        "webserver-enable": 1,
        "webserver-root": "/usr/local/share/pilight/",
        "webserver-http-port": 5001,
        "webserver-cache": 1,
        "ntp-servers": [ "0.pool.ntp.org", "1.pool.ntp.org", "2.europe.pool.ntp.org", "3.europe.pool.ntp.org" ]
    },
    "hardware": {
        "433gpio": {
            "sender": 3,
            "receiver": 7
        }
    },
    "registry": {
        "pilight": {
            "firmware": {
                "version": 62145,
                "lpf": 491670,
                "hpf": 596470
            },
            "version": {
                "current": "7.0"
            }
        },
        "webgui": {
            "tabs": 0
        }
    }
}

Many thansk for any tipps you can gave to me.

Best Regards
Thomas Pfaffinger
 
Reply
#2
You've got an IF too many in your rule; IF's are only found at the beginning of the rule. But you have another one in the hook starting after the OR. Your rules should actually read like this:

Code:
"AquariumAn": {
            "rule": "IF (date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 6) OR (date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 14) THEN switch DEVICE Switch1 TO on",
            "active": 1
        },
        "AquariumAus": {
            "rule": "IF (date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 10) OR (date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 19) THEN switch DEVICE Switch1 TO off",
            "active": 1
        }
 
Reply
#3
Hello pilino1234,
thanks fot eh hint. I have removed the 2nd IF, and now one errormessage is gone. But the second appers again:

Code:
[Sep 23 17:45:45:458615] pilight-daemon: INFO: rule #1 RolloSonneAb was parsed in 0.000230 seconds
[Sep 23 17:45:45:458815] pilight-daemon: INFO: rule #2 RolloSonneAuf was parsed in 0.000178 seconds
[Sep 23 17:45:45:458873] pilight-daemon: ERROR: rule #3 invalid: trying to compare string variable "date_time.second" to an integer
[Sep 23 17:45:45:458928] pilight-daemon: INFO: rule #3 was parsed until: ... (date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 6) OR (date_time.second == 0 AND date_time.minute == 0 AND date_time.hour == 14) THEN switch DEVICE Switch1 TO on

I am really dont know, why, its exact the syntax of all exaples.

BR
Thomas Pfaffinger
 
Reply
#4
Hmm, it works for me. Can you make sure that the rule is entered as a single line in your config.json (no line breaks) and no extra spaces?
 
Reply
#5
Hello Pilino,
i have retyped the name of the Devie to date_time on all poitns in the config.json, and now it seems to work.

Thansk for your help.

BR
Thomas Pfaffinger
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Rule triggers twice Thorben653 13 1,657 02-05-2020, 01:06 PM
Last Post: VicktorKopf
  Exclude Weekend from a rule PT-Biker 1 531 12-08-2019, 10:22 AM
Last Post: curlymo
  [Solved] On and Off for one device in one rule Oliver 3 589 10-28-2019, 06:55 PM
Last Post: Oliver
  [solved] sunset rule doesn't work fleisch 4 579 10-26-2019, 07:05 AM
Last Post: fleisch
  Rules wont work bdb 2 1,012 08-12-2018, 06:25 PM
Last Post: bdb
  Rule with&without device. One working not the other... Tamadite 9 1,593 07-24-2018, 08:55 AM
Last Post: curlymo
  rule executed once at start up segalion 3 850 07-12-2018, 05:28 PM
Last Post: curlymo
  Problem with executing bash script via rule/program dYna 1 1,158 02-15-2018, 09:06 PM
Last Post: dYna
  Rule Sunset works, Sunrise not apartmedia 1 1,297 12-05-2017, 07:09 PM
Last Post: apartmedia
  Problem with a Rule for a One Button Switch martin-dj 1 1,457 03-06-2017, 12:01 PM
Last Post: pilino1234

Forum Jump:


Browsing: 1 Guest(s)