• 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 triggers twice
#1
Hello pilight forum  Smile

I created a rule that toggles a lamp every time i enable a generic switch.
The rule also sets the generic switch to off everytime it is triggered.

That was working for over 3 month now, but since i made some changes in the config (that have nothing to do with this rule) it's behaving really wierd.
Now if i set the genereic switch to on, the lamp goes on and shortly after off again. It's like the rule gets triggered twice.


The rule:
Code:
IF toggle_table_lamp.state == on THEN
  IF table_lamp.state == on THEN
    switch DEVICE toggle_table_lamp TO off AND switch DEVICE table_lamp TO off
  ELSE IF table_lamp.state == off THEN
    switch DEVICE toggle_table_lamp TO off AND switch DEVICE table_lamp TO on
  END
END

It was working before with the exact same rule.
Thanks.

// Edit
Ok i noticed that the rule is working for 2-3 times if i restart the pilight service. Then if i toggle the generic switch 2-3 times it again stops working and triggers twice.

Using pilight-daemon version v8.1.5 on raspbian buster.
 
Reply
#2
Can you tell me what you're actually trying to achieve?
 
Reply
#3
I want to toggle the lamp using the rest api without knowing the lamps current state. So i can just trigger a rule that does the on/off for me.
 
Reply
#4
And this doesn't work?
Code:
IF toggle_table_lamp.state == on OR toggle_table_lamp.state == off THEN
  toggle DEVICE table_lamp BETWEEN on AND off
END
 
Reply
#5
No, then i have the problem that a rule doesn't trigger twice for the same state.
That means i can't toggle it on and off by enabling the generic switch.
 
Reply
#6
Why?
 
Reply
#7
(12-03-2019, 10:51 PM)curlymo Wrote: Why?

I once had another issue where you said that a rule can't be triggered twice for the same state:
https://forum.pilight.org/showthread.php?tid=3607
 
Reply
#8
Why don't you just call the API twice? One for on and one for off. Either one will trigger the rule.
 
Reply
#9
Yeah that should work, but it also can't be the best solution to send 2 requests.
But i can't think about a better solution, i will just use this one for now.

Thanks.
 
Reply
#10
The best solution IMHO would be able to trigger a specific rule from the API.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Exclude Weekend from a rule PT-Biker 1 399 12-08-2019, 10:22 AM
Last Post: curlymo
  [Solved] On and Off for one device in one rule Oliver 3 442 10-28-2019, 06:55 PM
Last Post: Oliver
  [solved] sunset rule doesn't work fleisch 4 433 10-26-2019, 07:05 AM
Last Post: fleisch
  Rule with&without device. One working not the other... Tamadite 9 1,384 07-24-2018, 08:55 AM
Last Post: curlymo
  rule executed once at start up segalion 3 743 07-12-2018, 05:28 PM
Last Post: curlymo
  Problem with executing bash script via rule/program dYna 1 1,032 02-15-2018, 09:06 PM
Last Post: dYna
  Rule Sunset works, Sunrise not apartmedia 1 1,182 12-05-2017, 07:09 PM
Last Post: apartmedia
  Problem with a Rule for a One Button Switch martin-dj 1 1,343 03-06-2017, 12:01 PM
Last Post: pilino1234
  Rule executed at wrong time philipp81 1 963 02-25-2017, 10:43 PM
Last Post: curlymo
  Rule is executed repeatedly Niek 3 1,606 11-09-2016, 10:22 PM
Last Post: wo_rasp

Forum Jump:


Browsing: 1 Guest(s)