• 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&without device. One working not the other...
#1
Hi,

(pilight ver. 8.1.2)

I get to work the following device-less rule configuration:

Code:
       "devices": {
               "decoration": {
                       "protocol": [ "nexa_switch" ],
                       "id": [{
                               "id": 7733802,
                               "unit": 0
                       }],
                       "state": "on"
               }
       },
       "rules": {
               "motion-decoration": {
                       "rule": "IF ev1527.state == closed AND ev1527.unitcode == 159637 THEN switch DEVICE decoration TO on",
                       "active": 1
               }
       },

However, I cannot get to work this one with the device configured:


Code:
       "devices": {
               "decoration": {
                       "protocol": [ "nexa_switch" ],
                       "id": [{
                               "id": 7733802,
                               "unit": 0
                       }],
                       "state": "off"
               },
               "motion2": {
                       "protocol": [ "ev1527" ],
                       "id": [{
                               "unitcode": 159637
                       }],
                       "state": "closed"
               }
       },
       "rules": {
               "motion2-decoration": {
                       "rule": "IF motion2.state == closed AND motion2.id.unitcode == 159637 THEN switch DEVICE decoration TO on",
                       "active": 1
               }
       },

I know that first the configuration is more efficient however, I am wondering why the second case does not switch the device "decoration" on.

Any hint please?
 
Reply
#2
Rules triggered by a 433.92 device (the motion sensor) trying to switch on another 433.92 device (the nexa switch) often will fail due to interference. The solution is to put in a short delay.


Code:
IF motion2.state == closed THEN switch DEVICE decoration TO on AFTER '1 SECOND'",

The check for the device id: "AND motion2.id.unitcode == 159637" is redundant, because motion2 is configured with that id, so you can remove that.
 
Reply
#3
I will add an error for that id string because it doesn't do anything. It is currently interpreted as a string 'motion2.id.unitcode'
 
Reply
#4
@Niek & @curlymo thanks for the comments. Some interesting aspects I did not know about however, the problem persists. This is how the "problematic" rule looks now:

Code:
    "rules": {
        "motion2-decoration": {
            "rule": "IF motion2.state == closed THEN switch DEVICE decoration TO on AFTER '5 SECOND'",
            "active": 1
        }
    },

For the sake of having the same rule on both, I added the "AFTER 5 SECOND" to the deviceless rule and so it still works.
 
Reply
#5
I do have a test that's similar to what you are trying to achieve that succeeds:
https://github.com/pilight/pilight/blob/...#L866-L880

And i run a similar setup myself which just works.

Can you check the output of the pilight daemon in debug mode? Do you see the rule getting evaluated?
 
Reply
#6
As suggested in other post, I tried disconnecting the receiver once the motion sensor is over with the transmission without any positive result either.
 
Reply
#7
(07-23-2018, 10:05 PM)curlymo Wrote: I do have a test that's similar to what you are trying to achieve that succeeds:
https://github.com/pilight/pilight/blob/...#L866-L880

And i run a similar setup myself which just works.

Can you check the output of the pilight daemon in debug mode? Do you see the rule getting evaluated?

I put both rules together now:

Code:
    "rules": {
        "motion2-decoration": {
            "rule": "IF motion2.state == closed THEN switch DEVICE decoration TO on AFTER '5 SECOND'",
            "active": 1
        },
        "motion-decoration": {
            "rule": "IF ev1527.state == closed AND ev1527.unitcode == 159637 THEN switch DEVICE decoration TO on AFTER '5 SECOND'",
            "active": 1
        }
    },
 

Here is the dump of the debug. As it can be seen, only rule#2 gets parsed:
Code:
[Jul 23 21:18:08:739362] pilight-daemon: DEBUG: broadcasted: {"message":{"unitcode":159633,"state":"closed"},"origin":"receiver","protocol":"ev1527","uuid":"0000-b8-27-eb-36aef8","repeats":22}
[Jul 23 21:18:08:740226] pilight-daemon: DEBUG: rule #2 motion-decoration was parsed in 0.000185 seconds
[Jul 23 21:18:08:774054] pilight-daemon: DEBUG: possible ev1527 protocol
[Jul 23 21:18:08:774225] pilight-daemon: DEBUG: recevied pulse length of 258
[Jul 23 21:18:08:774342] pilight-daemon: DEBUG: caught minimum # of repeats 23 of ev1527
[Jul 23 21:18:08:774457] pilight-daemon: DEBUG: called ev1527 parseRaw()
[Jul 23 21:18:08:775322] pilight-daemon: DEBUG: socket write succeeded: {"message":{"unitcode":159637,"state":"closed"},"origin":"receiver","protocol":"ev1527","uuid":"0000-b8-27-eb-36aef8","repeats":23}


Here again, the definition of the devices:
Code:
    "devices": {
        "decoration": {
            "protocol": [ "nexa_switch" ],
            "id": [{
                "id": 7733802,
                "unit": 0
            }],
            "state": "on"
        },
        "motion2": {
            "protocol": [ "ev1527" ],
            "id": [{
                "unitcode": 159637
            }],
            "state": "closed"
        }
    },
 
Reply
#8
I now understand what's going on. The ev1527 has only one state which is closed. Therefor, the device never get's updated with a different state. The second rule is based on device value changes and because those never occur, the rules never get triggered. The first rule is how it's actually done.

Try this :
Code:
IF ev1527.state == closed AND ev1527.unitcode == 159637 AND ev1527.repeats = 0 THEN switch DEVICE decoration TO on AFTER '5 SECOND'

This prevents the rule from being triggered all over, because i see the codes being received for about 23 times.
 
Reply
#9
(07-24-2018, 08:04 AM)curlymo Wrote: I now understand what's going on. The ev1527 has only one state which is closed. Therefor, the device never get's updated with a different state. The second rule is based on device value changes and because those never occur, the rules never get triggered. The first rule is how it's actually done.

Try this :
Code:
IF ev1527.state == closed AND ev1527.unitcode == 159637 AND ev1527.repeats = 0 THEN switch DEVICE decoration TO on AFTER '5 SECOND'

This prevents the rule from being triggered all over, because i see the codes being received for about 23 times.

Thank you very much curlymo! Quite many interesting lessons out of this case.

Concerning your suggestion about adding "repeats", you are right! The motion detector I am using sends around 30 repeated messages per detected motion. I guess that also explains the existence of multiple instances of the following message during debugging:  

Code:
[Jul 23 21:18:12:440077] pilight-daemon: DEBUG: lua timer on state #0
[Jul 23 21:18:12:440448] pilight-daemon: ERROR: /usr/local/lib/pilight/actions/switch.lua:148: skipping overridden action switch for device decoration

As I see it, your suggestion would benefit the system from working more efficiently however, the solution would depend on capturing the message #0 which may not occur as of possible interferences.

So avoiding "ev1527.repeats == 0" would not be that elegant but would increase the likelihood of successfully receiving a motion message.
 
Reply
#10
Then change it to:
... repeats < 5
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  sunset rule doesn't work fleisch 3 36 4 hours ago
Last Post: curlymo
  On and Off for one device in one rule Oliver 2 50 10-17-2019, 06:33 PM
Last Post: Oliver
  Can't switch Relay device by rules: Error switch.lua:77 wobbi 6 868 07-31-2018, 06:25 AM
Last Post: curlymo
  rule executed once at start up segalion 3 582 07-12-2018, 05:28 PM
Last Post: curlymo
  Pushover no longer working Alex 6 806 07-09-2018, 06:25 AM
Last Post: curlymo
  Problem with executing bash script via rule/program dYna 1 871 02-15-2018, 09:06 PM
Last Post: dYna
  Rule Sunset works, Sunrise not apartmedia 1 1,019 12-05-2017, 07:09 PM
Last Post: apartmedia
  Always trigger event on any device state Phil 8 2,074 03-22-2017, 07:30 PM
Last Post: Phil
  Problem with a Rule for a One Button Switch martin-dj 1 1,211 03-06-2017, 12:01 PM
Last Post: pilino1234
  Rule executed at wrong time philipp81 1 862 02-25-2017, 10:43 PM
Last Post: curlymo

Forum Jump:


Browsing: 1 Guest(s)