Tips for shortening rules

Moderators: Voyager, BertB, rtenklooster, Stuntteam, Martinus, grovkillen, TD-er

Post Reply
Message
Author
Prutsium
Normal user
Posts: 22
Joined: 29 Mar 2018, 15:39
Location: Germany / Netherlands

Tips for shortening rules

#1 Post by Prutsium » 10 Sep 2018, 18:02

Hello all,

I am looking for some help to be able to shorten the below rule as when i would add all the tags i require i will exceed the character limit from the rules.
This is for a small project with RFID tags to open a door by various users.

The idea is that each tag sends a "Text" string and if the Tag matches it activates the Timer,1,5 so that the relay stays On for 5 seconds and after that the relay is set to off.

What is below is working so thats no issue it's a matter of cleaning up

Code: Select all

On RFID#Tag do
if [RFID#Tag]=1899267376
gpio,13,0
gpio,14,1
publish domoticz/in,{"command": "switchlight", "idx": 125, "switchcmd": "On" }
publish domoticz/in,{"idx":124,"nvalue":0,"svalue":"Card"}
timerSet,1,5

if [RFID#Tag]=2271020827 // Jerome
gpio,13,0
gpio,14,1
publish domoticz/in,{"command": "switchlight", "idx": 125, "switchcmd": "On" }
publish domoticz/in,{"idx":124,"nvalue":0,"svalue":"Tag"}
timerSet,1,5
endif
endon

On Rules#Timer=1 do 
gpio,13,1
gpio,14,0
publish domoticz/in,{"command": "switchlight", "idx": 125, "switchcmd": "Off" }
endon
Thanks for help :)

User avatar
grovkillen
Normal user
Posts: 1897
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Tips for shortening rules

#2 Post by grovkillen » 10 Sep 2018, 18:11

How many tags are we talking about?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Normal user
Posts: 1897
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Tips for shortening rules

#3 Post by grovkillen » 10 Sep 2018, 18:13

If we could use multiple eventvalues we could shorten the rule some. I'd like you to add that as a suggestion on GitHub. Or maybe even better a array variable that we could use in rules! :)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Prutsium
Normal user
Posts: 22
Joined: 29 Mar 2018, 15:39
Location: Germany / Netherlands

Re: Tips for shortening rules

#4 Post by Prutsium » 10 Sep 2018, 18:33

grovkillen wrote:
10 Sep 2018, 18:11
How many tags are we talking about?
In the range of 15-20 tags (As it act as a central door opener)

Prutsium
Normal user
Posts: 22
Joined: 29 Mar 2018, 15:39
Location: Germany / Netherlands

Re: Tips for shortening rules

#5 Post by Prutsium » 10 Sep 2018, 18:36

grovkillen wrote:
10 Sep 2018, 18:13
If we could use multiple eventvalues we could shorten the rule some. I'd like you to add that as a suggestion on GitHub. Or maybe even better a array variable that we could use in rules! :)
Would it be possible within a rule to activate for example Rule2 or a sort of script?

As then i could move the Gpio and send to Domoticz ON to a rule / script and would cleanup the most already a bit.
Since the Bold commands could move out then:
On RFID#Tag do
if [RFID#Tag]=1899267376
gpio,13,0
gpio,14,1
publish domoticz/in,{"command": "switchlight", "idx": 125, "switchcmd": "On" }

publish domoticz/in,{"idx":124,"nvalue":0,"svalue":"Card"}
timerSet,1,5

User avatar
grovkillen
Normal user
Posts: 1897
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Tips for shortening rules

#6 Post by grovkillen » 10 Sep 2018, 18:49

Maybe we could have a rule chunk replacement similar to values... Hmm, I'm thinking out loud now. I need to discuss it with @TD-er
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests