• 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
Config migration from pilight 7 .0 to 8.1.3 "Rules"
#1
Hey,
I took the saturday to update my home automation with pilight from 7.0 to the recent stable verseion 8.1.3.
There are a lot of differences in the config, and i startet to  write a new config file, compliant to the new version (at least 400 rows of code).
But i can't migrate some Rules due to the new syntax and I don't know how to solve the problem.


eg. old Rule:
Code:
        "time": {
            "protocol": [ "datetime" ],
            "id": [{
                "longitude": 11.572316,
                "latitude": 48.277502
            }],
            "year": 2018,
            "month": 11,
            "day": 17,
            "weekday": 7,
            "hour": 14,
            "minute": 27,
            "second": 18,
            "dst": 0
        },       
       "timeon": {
            "protocol": [ "generic_dimmer" ],
            "id": [{
                "id": 10
            }],
            "state": "on",
            "dimlevel-minimum": 6,
            "dimlevel-maximum": 11,
            "dimlevel": 9
        },
        "timeoff": {
            "protocol": [ "generic_dimmer" ],
            "id": [{
                "id": 11
            }],
            "state": "on",
            "dimlevel-minimum": 18,
            "dimlevel-maximum": 23,
            "dimlevel": 20
        },


"lights_off": {
            "rule": "IF time.hour > (timeon.dimlevel - 1) AND time.hour < timeoff.dimlevel AND timeon.state IS on AND ants.state IS off AND lizards.state IS off AND plants.state IS off THEN switch DEVICE ants AND plants AND lizards TO on",
            "active": 1
        },
I had some dimmers to control the switching time (timeon, timeoff) via the GUI/Webserver. I compared the hour of "time" with the dimmer and switched on/off the lights.

But with the new rules Format:
Code:
"christmass-tree-off": {
   "rule": "IF DATE_FORMAT(currentdatetime, %H%M%S) == 230000 THEN switch DEVICE outsidelight TO on AFTER RANDOM(0, 90) . ' MINUTE' FOR RANDOM(5, 15) . ' MINUTE'",
   "active": 1
 }
this isn't possible any more.

If I just try my old rules, i get an error:

Quote: ^ unexpected symbol, expected a condition                                                                                                                                                                            
[Nov 17 17:47:27:329791] pilight-daemon: INFO: rule #1 lights_off was parsed in 0.015123 seconds                                                                                                                                             
[Nov 17 17:47:27:331346] pilight-daemon: ERROR: failed to read config
 

Is there any solution, to use dimmers for time events?

Thanks and best regards,
Nonaamee
 
Reply
#2
Please post a minimum full config with the rule that errors.
 
Reply
#3
Here it is:
Code:
{
    "devices": {
        "time": {
            "protocol": [ "datetime" ],
            "id": [{
                "longitude": 11.572316,
                "latitude": 48.277502
            }],
            "year": 2018,
            "month": 11,
            "day": 17,
            "weekday": 7,
            "hour": 19,
            "minute": 27,
            "second": 45,
            "dst": 0
        },
        "ants": {
            "protocol": [ "elro_800_switch" ],
            "id": [{
                "systemcode": 19,
                "unitcode": 2
            }],
            "state": "on"
        },
        "plants": {
            "protocol": [ "elro_800_switch" ],
            "id": [{
                "systemcode": 19,
                "unitcode": 1
            }],
            "state": "on"
        },
        "lizards": {
            "protocol": [ "elro_800_switch" ],
            "id": [{
                "systemcode": 19,
                "unitcode": 4
            }],
            "state": "on"
        },
        "timeon": {
            "protocol": [ "generic_dimmer" ],
            "id": [{
                "id": 2
            }],
            "state": "on",
            "dimlevel": 9
        },
        "timeoff": {
            "protocol": [ "generic_dimmer" ],
            "id": [{
                "id": 11
            }],
            "state": "on",
            "dimlevel": 20
        }
    },
    "rules": {
       "lights_off": {
           "rule": "IF time.hour > (timeon.dimlevel - 1) AND time.hour < timeoff.dimlevel AND timeon.state IS on AND ants.state IS off AND lizards.state IS off AND plants.state IS off THEN switch DEVICE ants AND plants AND lizards TO on",
           "active": 1
       }
    },
    "gui": {
        "plants": {
            "name": "Pflanzen",
            "group": [ "Esszimmer" ],
            "media": [ "all" ]
        },
        "ants": {
            "name": "Ameisen Beleuchtung",
            "group": [ "Wohnzimmer" ],
            "media": [ "all" ]
        },
        "lizards": {
            "name": "Echsen Beleuchtung",
            "group": [ "Wohnzimmer" ],
            "media": [ "all" ]
        },
        "timeon": {
            "name": "Beleuchtung an",
            "group": [ "Config" ],
            "media": [ "all" ],
            "dimlevel-minimum": 5,
            "dimlevel-maximum": 11
        },
        "timeoff": {
            "name": "Beleuchtung aus",
            "group": [ "Config" ],
            "media": [ "all" ],
            "dimlevel-minimum": 16,
            "dimlevel-maximum": 23
        }
    },
    "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/webgui",
        "webserver-http-port": 5001,
        "webserver-https-port": 5002,
        "webserver-cache": 1,
        "whitelist": "",
        "gpio-platform": "raspberrypi1b+",
        "ntp-servers": [ "1.de.pool.ntp.org" ],
        "webserver-authentication": [ "XXXX", "XXXXX" ]
    },
    "hardware": {
        "433gpio": {
            "sender": 0,
            "receiver": 1
        }
    },
    "registry": {
        "webserver": {
            "ssl": {
                "certificate": {
                    "secure": 0,
                    "location": "/etc/pilight/pilight.pem"
                }
            }
        },
        "pilight": {
            "firmware": {
                "version": 3,
                "lpf": 80,
                "hpf": 16000
            },
            "version": {
                "current": "8.1.3"
            }
        }
    }
}
Without the rule its running fine, but the rule (which is copied from my previous config) is making some trouble.
 
Reply
#4
Replace all IS with ==
 
Reply
#5
Damn, didn't recognized this change.

Works great! Thanks!
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Fixed] RaspberryPi4 pilight 8.1.5 - Send isn't working DominikB1993 4 50 10-18-2019, 10:25 PM
Last Post: DominikB1993
  Real 433Mhz Remote is disturbed by pilight service henne111 2 158 10-06-2019, 06:18 PM
Last Post: wo_rasp
Tongue (solved) pilight 8.1.5-1-gc0a175e0 Chrashes fleisch 5 584 10-03-2019, 01:15 PM
Last Post: fleisch
  Starting pilight on boot: "cannot bind to the SSDP multicast network" pilino1234 4 347 09-29-2019, 02:08 PM
Last Post: tomk
  pilight for Raspbian Buster (raspberry pi 4) ? starob 29 2,454 07-15-2019, 08:45 PM
Last Post: curlymo
  pilight-receive Filteroption not working Alex 2 569 07-14-2019, 08:35 AM
Last Post: Alex
  pilight usb nano format conversion ettman8 2 452 07-14-2019, 08:32 AM
Last Post: curlymo
  pilight 8.1.4 crashes after some hours Ulrich.Arnold 47 2,696 06-29-2019, 08:58 PM
Last Post: curlymo
  Raspberry PI, gpio-ir-tx and pilight not starting lordslash 5 865 06-11-2019, 05:19 PM
Last Post: curlymo
  pilight fails starting on boot Alex 5 757 06-09-2019, 06:02 PM
Last Post: curlymo

Forum Jump:


Browsing: 1 Guest(s)