• 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
  ERROR: failed to read config. stack: 2 Stefan 6 229 02-03-2020, 09:37 PM
Last Post: curlymo
  raspberry pi 4 config.json Stefan 2 195 02-02-2020, 09:59 AM
Last Post: Stefan
  pilight cpu usage possibly associated with noticeable sluggishness? hepcat72 4 172 01-28-2020, 08:02 PM
Last Post: hepcat72
  apt.pilight.org stable Release' is not signed. thomasol 2 281 01-23-2020, 11:34 PM
Last Post: thomasol
  pilight and SIGNALduino cc1101 Caleus 0 166 01-19-2020, 09:13 AM
Last Post: Caleus
  filter stopped working after update to pilight 8.1.5 zlin50 19 672 01-03-2020, 02:15 PM
Last Post: curlymo
Question [Solved] Openweathermap with pilight 7.0-40 doesn't work Seebueb 2 188 01-01-2020, 06:45 PM
Last Post: Seebueb
  [Solved] Strange receive problem with 433Mhz Receiver and pilight 8.1.5 vanillaice30 15 832 12-18-2019, 11:09 AM
Last Post: vanillaice30
  pilight error after update to 8.1.5 on Odroid C2 WitchDoctor 3 392 11-29-2019, 09:56 PM
Last Post: curlymo
  pilight crashing randomly PatiB 7 645 11-16-2019, 10:50 PM
Last Post: curlymo

Forum Jump:


Browsing: 1 Guest(s)