• 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
[8.1.2] variables in rules -> error
#1
Hi,

Can you please explain why this rule does not work any more since upgrade to 8.1.2 nightly?

Rule:
Code:
"Luftheber_ein": {
    "rule": "IF ap2.state == off AND s1.state == off AND vtimeluftheber.state == on AND (DATE_FORMAT(zeit, %H.%M) >= tagnacht.sunrise) AND zeit.second == 0 THEN switch DEVICE ap2 TO on FOR 'vtimeluftheber.dimlevel HOUR'",
    "active": 0
},

This rule let me start the service no more and pilight-daemon shows this:

Error:
Code:
[Sep 14 13:20:22:327173] pilight-daemon: ERROR: rule #3 invalid: device "vtimeluftheber" has no variable "dimlevel HOUR"
[Sep 14 13:20:22:329230] pilight-daemon: INFO: rule #3 Luftheber_ein was parsed in 0.060266 seconds

Device:

Code:
"vtimeluftheber": {
    "protocol": [ "generic_dimmer" ],
    "id": [{
        "id": 100
        }],
        "state": "on",
        "dimlevel": 6
},


GUI:
Code:
"vtimeluftheber": {
        "name": "Luftheberlaufzeit (h)",
        "group": [ "Aquarium" ],
        "media": [ "all" ],
        "dimlevel-minimum": 2,
        "dimlevel-maximum": 8
},
Terrarium:  RPi Model B Rev 2 / pilight 8.1.2 / stretch
Aquarium: RPi Model B Plus Rev 1.2 / pilight 8.0.6 / jessie
 
Reply
#2
You are defining the variable as a fixed string.

You need to do this:

Code:
IF ap2.state == off AND s1.state == off AND vtimeluftheber.state == on AND (DATE_FORMAT(zeit, '%H.%M') >= tagnacht.sunrise) AND zeit.second == 0 THEN switch DEVICE ap2 TO on FOR vtimeluftheber.dimlevel . ' HOUR'

You can see that difference here:
https://manual.pilight.org/eventing/examples/time.html
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Rules wont work bdb 2 665 08-12-2018, 06:25 PM
Last Post: bdb
  Can't switch Relay device by rules: Error switch.lua:77 wobbi 6 776 07-31-2018, 06:25 AM
Last Post: curlymo
  Strange behavior of rules currock 4 770 06-28-2018, 05:57 PM
Last Post: currock
  Error in Actions with 8.1.0 tomk 1 620 05-30-2018, 06:20 AM
Last Post: curlymo
  feature request: switching rules terrar 7 1,135 05-05-2018, 09:23 PM
Last Post: trader23
  variable "label" not allowed in rules Niek 4 2,381 09-30-2017, 06:39 PM
Last Post: curlymo
  Optional Variables can not be used wo_rasp 1 956 08-17-2017, 09:36 PM
Last Post: curlymo
  option "all" not sent in rules muecke 5 1,934 07-01-2016, 11:37 AM
Last Post: Niek
  Rules make pilight freeze koos147 5 1,927 05-04-2016, 08:11 PM
Last Post: curlymo
  ERROR: rule #21 invalid: variable "label" of device "WindMax" cannot be used in even koos147 2 1,723 04-02-2016, 10:24 PM
Last Post: koos147

Forum Jump:


Browsing: 1 Guest(s)