Help on rules for relay timers

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
_Cyber_
Normal user
Posts: 11
Joined: 20 Oct 2019, 09:46

Help on rules for relay timers

#1 Post by _Cyber_ » 11 Nov 2019, 22:37

Hi,

I am controlling with espeasy a 4-relay LC-Tech module with this plugin: viewtopic.php?f=6&t=3245
two of the 4 modules switch off an on different lamps for "dimming" the light.

I want to disable both of them after 2 hours running time, but independently.

I tried to write (my first - so please be indulgend) rules and it looks like I have a logic error anywhere, but failing in finding it.

the rules:

Code: Select all

//Links heller
on WohnzimmerRelays#Relay1 do
  if [WohnzimmerRelays#Relay1]=1 and [Let#1] <= 0
    timerSet,1,20
    timerSet,7,1
    Let,1,20
  endif
  if [WohnzimmerRelays#Relay1]=0 and [Let#1] <= 0
    timerSet,1,0
    timerSet,7,0
    Let,1,0
  endif
endon
on Rules#Timer=1 do
  if [WohnzimmerRelays#Relay1]=1
    relay,1,0
    Let,1,0
  endif
endon
on Rules#Timer=7 do
  Let,1,[VAR#1]-1
  TimerSet,7,1
endon

//Rechts heller
on WohnzimmerRelays#Relay2 do
  if [WohnzimmerRelays#Relay2]=1 and [Let#2] <= 0
    timerSet,2,20
    timerSet,8,1
    Let,2,20
  endif
  if [WohnzimmerRelays#Relay2]=0 and [Let#2] <= 0
    timerSet,2,0
    timerSet,8,0
    Let,2,0
  endif
endon
on Rules#Timer=2 do
  if [WohnzimmerRelays#Relay2]=1
    relay,2,0
    Let,2,0
  endif
endon
on Rules#Timer=8 do
  Let,2,[VAR#2]-1
  TimerSet,8,1
endon
the effect: it works as long I only switch on one relay. as soon as I switch on the second the already running timer of the other one is restarted (currently at 20 instead of 7200). as soon as a timer switches one of the two relays, the other relay timer is resetted to 20.

Thank you for your time. :-)

BR
Alois


The live-log say's:

Code: Select all


57606808: SerSW : SetSwitch r1:1
57608111: EVENT: Rules#Timer=7
57608131: ACT : Let,1,20.00-1
57608135: Command: let
57608138: ACT : TimerSet,7,1
57608141: Command: timerset
57610111: EVENT: Rules#Timer=7
57610130: ACT : Let,1,19.00-1
57610133: Command: let
57610136: ACT : TimerSet,7,1
57610139: Command: timerset
57612131: ACT : Let,1,20.00-1
57612134: Command: let
57612137: ACT : TimerSet,7,1
57612140: Command: timerset
57612157: EVENT: Rules#Timer=8
57612188: ACT : Let,2,20.00-1
57612191: Command: let
57612194: ACT : TimerSet,8,1
57612197: Command: timerset
57613112: EVENT: Clock#Time=Mon,21:27
57613143: EVENT: Rules#Timer=7
57613161: ACT : Let,1,19.00-1
57613164: Command: let
57613167: ACT : TimerSet,7,1
57613170: Command: timerset
57614111: EVENT: Rules#Timer=8
57614143: ACT : Let,2,19.00-1
57614146: Command: let
57614149: ACT : TimerSet,8,1
57614152: Command: timerset
57615130: ACT : Let,1,18.00-1
57615133: Command: let
57615136: ACT : TimerSet,7,1
57615139: Command: timerset
57615156: EVENT: Rules#Timer=8
57615186: ACT : Let,2,18.00-1
57615190: Command: let
57615193: ACT : TimerSet,8,1
57615195: Command: timerset
57617130: ACT : Let,1,17.00-1
57617133: Command: let
57617136: ACT : TimerSet,7,1
57617139: Command: timerset
57617157: EVENT: Rules#Timer=8
57617188: ACT : Let,2,17.00-1
57617191: Command: let
57617194: ACT : TimerSet,8,1
57617197: Command: timerset
57619130: ACT : Let,1,16.00-1
57619133: Command: let
57619136: ACT : TimerSet,7,1
57619139: Command: timerset
57619156: EVENT: Rules#Timer=8
57619186: ACT : Let,2,16.00-1
57619190: Command: let
57619193: ACT : TimerSet,8,1
57619196: Command: timerset
57621130: ACT : Let,1,15.00-1
57621133: Command: let
57621136: ACT : TimerSet,7,1
57621140: Command: timerset
57621157: EVENT: Rules#Timer=8
57621187: ACT : Let,2,15.00-1
57621191: Command: let
57621194: ACT : TimerSet,8,1
57621197: Command: timerset
57623130: ACT : Let,1,14.00-1
57623133: Command: let
57623136: ACT : TimerSet,7,1
57623139: Command: timerset
57623156: EVENT: Rules#Timer=8
57623186: ACT : Let,2,14.00-1
57623190: Command: let
57623193: ACT : TimerSet,8,1
57623196: Command: timerset
57625130: ACT : Let,1,13.00-1
57625134: Command: let
57625137: ACT : TimerSet,7,1
57625140: Command: timerset
57625157: EVENT: Rules#Timer=8
57625187: ACT : Let,2,13.00-1
57625190: Command: let
57625193: ACT : TimerSet,8,1
57625196: Command: timerset
57627112: EVENT: Rules#Timer=7
57627130: ACT : Let,1,12.00-1
57627133: Command: let
57627136: ACT : TimerSet,7,1
57627139: Command: timerset
57627156: EVENT: Rules#Timer=8
57627212: ACT : Let,2,12.00-1
57627215: Command: let
57627218: ACT : TimerSet,8,1
57627221: Command: timerset
57629132: ACT : Let,1,11.00-1
57629135: Command: let
57629138: ACT : TimerSet,7,1
57629141: Command: timerset
57629158: EVENT: Rules#Timer=8
57629188: ACT : Let,2,11.00-1
57629191: Command: let
57629194: ACT : TimerSet,8,1
57629197: Command: timerset
57631263: ACT : timerSet,8,1
57631266: Command: timerset
57631268: ACT : Let,2,20
57631272: Command: let
57631298: EVENT: WohnzimmerRelays#Relay3=1.00
57631329: SerSW : SetSwitch r1:0
57631331: ACT : Let,1,0
57631333: Command: let
57631666: WD : Uptime 961 ConnectFailures 0 FreeMem 29704
57633111: EVENT: Rules#Timer=8
57633144: ACT : Let,2,20.00-1
57633148: Command: let
57633151: ACT : TimerSet,8,1
57633154: Command: timerset
57635111: EVENT: Rules#Timer=8
57635143: ACT : Let,2,19.00-1
57635147: Command: let
57635150: ACT : TimerSet,8,1
57635153: Command: timerset
57637118: EVENT: Rules#Timer=8
57637151: ACT : Let,2,18.00-1
57637154: Command: let
57637160: ACT : TimerSet,8,1
57637164: Command: timerset
57639111: EVENT: Rules#Timer=8
57639143: ACT : Let,2,17.00-1
57639147: Command: let
57639150: ACT : TimerSet,8,1
57639152: Command: timerset
57641111: EVENT: Rules#Timer=8
57641143: ACT : Let,2,16.00-1
57641146: Command: let
57641150: ACT : TimerSet,8,1
57641153: Command: timerset
57643114: EVENT: Rules#Timer=8
57643146: ACT : Let,2,15.00-1
57643150: Command: let
57643153: ACT : TimerSet,8,1
57643160: Command: timerset
57645111: EVENT: Rules#Timer=8
57645143: ACT : Let,2,14.00-1
57645146: Command: let
57645149: ACT : TimerSet,8,1
57645152: Command: timerset
57647112: EVENT: Rules#Timer=8
57647143: ACT : Let,2,13.00-1
57647146: Command: let
57647150: ACT : TimerSet,8,1
57647153: Command: timerset
57649116: EVENT: Rules#Timer=8
57649148: ACT : Let,2,12.00-1
57649151: Command: let
57649157: ACT : TimerSet,8,1
57649161: Command: timerset
57651111: EVENT: Rules#Timer=8
57651143: ACT : Let,2,11.00-1
57651147: Command: let
57651150: ACT : TimerSet,8,1
57651153: Command: timerset
57652287: Command: timerset
57652290: ACT : timerSet,8,0
57652292: Command: timerset
57652294: ACT : Let,2,0
57652297: Command: let
57652311: EVENT: WohnzimmerRelays#Relay3=1.00
57652341: SerSW : SetSwitch r2:0
57652343: ACT : Let,2,0
57652346: Command: let


_Cyber_
Normal user
Posts: 11
Joined: 20 Oct 2019, 09:46

Re: Help on rules for relay timers

#2 Post by _Cyber_ » 17 Nov 2019, 10:15

anybody? :roll:

User avatar
grovkillen
Core team member
Posts: 3332
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Help on rules for relay timers

#3 Post by grovkillen » 17 Nov 2019, 15:07

Code: Select all

//Links heller
on WohnzimmerRelays#Relay1 do
  if [WohnzimmerRelays#Relay1]=1 and [Let#1] <= 0
    timerSet,1,20
    timerSet,7,1
    Let,1,20
    Let,11,1
  endif
  if [WohnzimmerRelays#Relay1]=0 and [Let#1] <= 0
    timerSet,1,0
    timerSet,7,0
    Let,11,0
  endif
endon
on Rules#Timer=1 do
  if [WohnzimmerRelays#Relay1]=1
    relay,1,0
    Let,11,0
  endif
endon
on Rules#Timer=7 do
 If [VAR#11]=1
  Let,1,[VAR#1]-1
  TimerSet,7,1
 EndIf
endon

//Rechts heller
on WohnzimmerRelays#Relay2 do
  if [WohnzimmerRelays#Relay2]=1 and [Let#2] <= 0
    timerSet,2,20
    timerSet,8,1
    Let,2,20
    Let,12,1
  endif
  if [WohnzimmerRelays#Relay2]=0 and [Let#2] <= 0
    timerSet,2,0
    timerSet,8,0
    Let,12,0
  endif
endon
on Rules#Timer=2 do
  if [WohnzimmerRelays#Relay2]=1
    relay,2,0
    Let,12,0
  endif
endon
on Rules#Timer=8 do
If [VAR#12]=1
  Let,2,[VAR#2]-1
  TimerSet,8,1
  EndIf
endon
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

_Cyber_
Normal user
Posts: 11
Joined: 20 Oct 2019, 09:46

Re: Help on rules for relay timers

#4 Post by _Cyber_ » 11 Dec 2019, 23:09

hi grovkillen,

thanks, but regrettably exact the same issue. on switching first relay 1 and after a few seconds relay 2 I can see in the log the timer of relay 1 beeing resetted to 20 .

Code: Select all

2651339426: ACT : Let,12,0
2651339428: Command: let
2651339441: EVENT: WohnzimmerRelays#Relay3=0.00
2651339470: SerSW : SetSwitch r1:1
2651341111: EVENT: Rules#Timer=7
2651341133: ACT : Let,1,20.00-1
2651341136: Command: let
2651341140: ACT : TimerSet,7,1
2651341143: Command: timerset
2651341666: WD : Uptime 44189 ConnectFailures 0 FreeMem 29704
2651343112: EVENT: Rules#Timer=7
2651343133: ACT : Let,1,19.00-1
2651343136: Command: let
2651343140: ACT : TimerSet,7,1
2651343143: Command: timerset
2651345112: EVENT: Rules#Timer=7
2651345134: ACT : Let,1,18.00-1
2651345137: Command: let
2651345141: ACT : TimerSet,7,1
2651345145: Command: timerset
2651347111: EVENT: Rules#Timer=7
2651347133: ACT : Let,1,17.00-1
2651347136: Command: let
2651347140: ACT : TimerSet,7,1
2651347143: Command: timerset
2651349111: EVENT: Rules#Timer=7
2651349133: ACT : Let,1,16.00-1
2651349137: Command: let
2651349141: ACT : TimerSet,7,1
2651349144: Command: timerset
2651351112: EVENT: Rules#Timer=7
2651351133: ACT : Let,1,15.00-1
2651351136: Command: let
2651351140: ACT : TimerSet,7,1
2651351143: Command: timerset
2651353112: EVENT: Rules#Timer=7
2651353134: ACT : Let,1,14.00-1
2651353137: Command: let
2651353141: ACT : TimerSet,7,1
2651353144: Command: timerset
2651355112: EVENT: Rules#Timer=7
2651355133: ACT : Let,1,13.00-1
2651355136: Command: let
2651355140: ACT : TimerSet,7,1
2651355143: Command: timerset
2651357111: EVENT: Rules#Timer=7
2651357134: ACT : Let,1,12.00-1
2651357137: Command: let
2651357141: ACT : TimerSet,7,1
2651357144: Command: timerset
2651362133: ACT : Let,1,20.00-1
2651362136: Command: let
2651362140: ACT : TimerSet,7,1
2651362144: Command: timerset
2651362163: EVENT: Rules#Timer=8
2651362197: ACT : Let,2,20.00-1
2651362200: Command: let
2651362203: ACT : TimerSet,8,1
2651362206: Command: timerset
2651364134: ACT : Let,1,19.00-1
2651364137: Command: let
2651364141: ACT : TimerSet,7,1
2651364144: Command: timerset
2651364163: EVENT: Rules#Timer=8
2651364197: ACT : Let,2,19.00-1
2651364201: Command: let
2651364204: ACT : TimerSet,8,1
2651364206: Command: timerset
2651366112: EVENT: Rules#Timer=7
2651366133: ACT : Let,1,18.00-1
2651366139: Command: let
2651366146: ACT : TimerSet,7,1
2651366151: Command: timerset
2651366188: EVENT: Rules#Timer=8
2651366229: ACT : Let,2,18.00-1
2651366232: Command: let
2651366235: ACT : TimerSet,8,1
2651366239: Command: timerset
2651368165: ACT : Let,1,17.00-1
2651368168: Command: let
2651368172: ACT : TimerSet,7,1
2651368175: Command: timerset
2651368195: EVENT: Rules#Timer=8
2651368229: ACT : Let,2,17.00-1
2651368232: Command: let
2651368235: ACT : TimerSet,8,1
2651368238: Command: timerset
2651370133: ACT : Let,1,16.00-1
2651370137: Command: let
2651370141: ACT : TimerSet,7,1
2651370144: Command: timerset
2651370163: EVENT: Rules#Timer=8
2651370197: ACT : Let,2,16.00-1
2651370200: Command: let
2651370203: ACT : TimerSet,8,1
2651370206: Command: timerset
2651372133: ACT : Let,1,15.00-1
2651372136: Command: let
2651372140: ACT : TimerSet,7,1
2651372143: Command: timerset
2651372162: EVENT: Rules#Timer=8
2651372197: ACT : Let,2,15.00-1
2651372200: Command: let
2651372203: ACT : TimerSet,8,1
2651372206: Command: timerset
2651374134: ACT : Let,1,14.00-1
2651374137: Command: let
2651374141: ACT : TimerSet,7,1
2651374144: Command: timerset
2651374163: EVENT: Rules#Timer=8
2651374197: ACT : Let,2,14.00-1
2651374200: Command: let
2651374203: ACT : TimerSet,8,1
2651374206: Command: timerset
2651376133: ACT : Let,1,13.00-1
2651376136: Command: let
2651376140: ACT : TimerSet,7,1
2651376143: Command: timerset
2651376162: EVENT: Rules#Timer=8
2651376197: ACT : Let,2,13.00-1
2651376200: Command: let
2651376203: ACT : TimerSet,8,1
2651376206: Command: timerset
2651378134: ACT : Let,1,12.00-1
2651378138: Command: let
2651378142: ACT : TimerSet,7,1
2651378145: Command: timerset
2651378163: EVENT: Rules#Timer=8
2651378198: ACT : Let,2,12.00-1
2651378201: Command: let
2651378204: ACT : TimerSet,8,1
2651378206: Command: timerset
2651380133: ACT : Let,1,11.00-1
2651380137: Command: let
2651380141: ACT : TimerSet,7,1
2651380144: Command: timerset
2651380163: EVENT: Rules#Timer=8
2651380198: ACT : Let,2,11.00-1
2651380201: Command: let
2651380204: ACT : TimerSet,8,1
2651380207: Command: timerset
2651381272: Command: timerset
2651381274: ACT : Let,2,20
2651381277: Command: let
2651381280: ACT : Let,12,1
2651381283: Command: let
2651381310: EVENT: WohnzimmerRelays#Relay3=0.00
2651381341: SerSW : SetSwitch r1:0
2651381343: ACT : Let,11,0
2651381346: Command: let
2651383112: EVENT: Rules#Timer=8
2651383155: ACT : Let,2,20.00-1
2651383158: Command: let
2651383162: ACT : TimerSet,8,1
2651383165: Command: timerset
2651385112: EVENT: Rules#Timer=8
2651385147: ACT : Let,2,19.00-1
2651385151: Command: let
2651385154: ACT : TimerSet,8,1
2651385157: Command: timerset
2651387113: EVENT: Rules#Timer=8
2651387149: ACT : Let,2,18.00-1
2651387152: Command: let
2651387155: ACT : TimerSet,8,1
2651387158: Command: timerset
2651389113: EVENT: Rules#Timer=8
2651389165: ACT : Let,2,17.00-1
2651389168: Command: let
2651389171: ACT : TimerSet,8,1
2651389174: Command: timerset
2651391112: EVENT: Rules#Timer=8
2651391148: ACT : Let,2,16.00-1
2651391151: Command: let
2651391154: ACT : TimerSet,8,1
2651391157: Command: timerset
2651393112: EVENT: Rules#Timer=8
2651393147: ACT : Let,2,15.00-1
2651393150: Command: let
2651393153: ACT : TimerSet,8,1
2651393156: Command: timerset
2651395111: EVENT: Rules#Timer=8
2651395167: ACT : Let,2,14.00-1
2651395170: Command: let
2651395173: ACT : TimerSet,8,1
2651395176: Command: timerset
2651397112: EVENT: Rules#Timer=8
2651397147: ACT : Let,2,13.00-1
2651397150: Command: let
2651397153: ACT : TimerSet,8,1
2651397156: Command: timerset
2651399112: EVENT: Rules#Timer=8
2651399147: ACT : Let,2,12.00-1
2651399150: Command: let
2651399153: ACT : TimerSet,8,1
2651399156: Command: timerset
2651401111: EVENT: Rules#Timer=8
2651402144: ACT : relay,2,0
2651402149: EVENT: WohnzimmerRelays#Relay0=0.00
2651402182: EVENT: WohnzimmerRelays#Relay1=0.00
2651402208: ACT : timerSet,1,0
2651402211: Command: timerset
2651402214: ACT : timerSet,7,0
2651402217: Command: timerset
2651402219: ACT : Let,11,0
2651402222: Command: let
2651402327: Command: timerset
2651402330: ACT : timerSet,8,0
2651402333: Command: timerset
2651402335: ACT : Let,12,0
2651402337: Command: let
2651402351: EVENT: WohnzimmerRelays#Relay3=0.00
2651402384: SerSW : SetSwitch r2:0
2651402386: ACT : Let,12,0
2651402389: Command: let

User avatar
ThomasB
Normal user
Posts: 454
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Help on rules for relay timers

#5 Post by ThomasB » 12 Dec 2019, 03:28

There is an explanation for the problem by enesbcs posted here:
viewtopic.php?p=19650#p19650

TLDR; To summarize, you shouldn't rely on the P165 plugin's Relay states to trigger the rules.

I suggest using the "Generic - Dummy Device" plugin and create two variables that represent the two relays. Write your rules so they use the dummy's states instead of the P165 Relay states.

- Thomas

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests