Page 1 of 1

RFID update values when removing tag

Posted: 26 Mar 2020, 12:33
by sawo
Hi all,

I would like to apologize in advance if this has already been asked several times before.

My current project is to control a water hose with a RFID token.
Current setup:
- Wemos D1 mini (espeasy)
- RDM6300 RFID
- Relais for magnetic valve
- Homematic (Generic HTTP controller)
- iobroker (rules)

The water should turn on when I place the RFID Tag on reader and should turn off when removing it, but the ESPeasy stores the last RFID ID value . see picture "001.jpg"
even when I remove it.
How can I clear the value when RFID token has been removed?

Thanks
sawo

Re: RFID update values when removing tag

Posted: 26 Mar 2020, 15:32
by grovkillen
I would use a timer for it. And clear if after x seconds.

Re: RFID update values when removing tag

Posted: 27 Mar 2020, 08:08
by sawo
hi grovkillen,

thanks for your reply.
Okay I'll give it a try. Never set up a rule in espeasy before :)

thanks
sawo

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 12:53
by sawo
Hi,

so last night I had time to learn about the rules and I have managed to create the rules.

The value will be set to "0" when token is removed.:-)

But now I have the next issue, the rule causes the wemos to reboot after 24 seconds..... and also the load will be by 100%

Could any one check my 2 rules please, to see if I made something wrong?

Rule 1:
On rfid_tag_water#Tag do
timerSet,1,5
endon

On Rules#Timer=1 do
TaskValueSet,1,1,0
SendToHTTP 192.168.1.10,8181,x.exe?Antwort=dom.GetObject("Tag").State(0)
GPIO,4,0
endon


Rule 2: to switch on the relais when token is available
On rfid_tag_water#Tag do
if [rfid_tag_water#Tag]=3364040
GPIO,4,1
endif
endon

thx so far.
sawo

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 13:03
by Ath
On what interval is your rfid reader (device in ESPEasy) set? If that interval is too short, like 1 second, then the load will be (close to) 100%, causing intermittent crashes & reboots.

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 13:21
by sawo
Hi,

attached you´ll find a picture of the device settings.
Nothing to change or setup.

Sawo

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 13:24
by sawo
When I remove the rules and place the rfid token on the reader, it will reboot after 70 seconds.

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 13:34
by TD-er
I do see an error you could not post the data to the selected controller.
So maybe you're running out of memory while trying.

Can you set the queue depth of the active controller to 1 as a test?

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 13:40
by sawo
Hi TD-er,

I have removed it, now it will reboot after 44 seconds.
Maybe I´ll some thing different.

Once the rfid token is placed on the reader it will turn on the valve until I place the token again on the reader.
In this case I will not send so much data.

Could any one help me with this rule or give me a hint what to do?

SAWO

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 17:34
by sawo
So now it tested my new rules:

on water_on do
gpio,4,1
endon

on water_off do
gpio,4,0
endon

on rfid_tag_water#Tag do
timerSet,1,2
if [water_pump#On]=1
event,water_off
else
event,water_on
endif
endon

On Rules#Timer=1 do
TaskValueSet,1,1,0
endon

but when I hold the token on the reader it always switches the relay twince. see attached log file:

I have now idea why.

sawo

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 17:49
by grovkillen
Instead of :

TaskValueSet,1,1,0

Try

TaskValueSetAndRun,1,1,0

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 18:58
by sawo
Hi grovkillen,

sorry that makes no difference.
Even when I remove this part of the rule:
On Rules#Timer=1 do
TaskValueSetAndRun,1,1,-3342336
SendToHTTP 192.168.1.10,8181,x.exe?Antwort=dom.GetObject("Tag").State(0)
endon

it still switches twince or even more often.

Sawo

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 19:18
by grovkillen
Please give me the full rules set, or is it that one above?

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 19:27
by sawo
here you go.

on water_on do
gpio,4,1
endon

on water_off do
gpio,4,0
endon

on rfid_tag_water#Tag do
timerSet,1,2
if [water_pump#On]=1
event,water_off
else
event,water_on
endif
endon


THX

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 19:31
by grovkillen
I would do it like this (without knowing your setup 100%)

Code: Select all

on rfid_tag_water#Tag=3364040 do
timerSet,1,2
Let,1,[water_pump#On]
gpio,4,[VAR#1#!Z]
endon

On Rules#Timer=1 do
TaskValueSet,1,1,0
endon
EDIT: updated rules.

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 19:32
by grovkillen
You can read up on how to format data: https://espeasy.readthedocs.io/en/lates ... Rules.html

In the section "Formatting refered values"

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 19:40
by grovkillen
Or if you want any tag to trigger the rule:

Code: Select all

on rfid_tag_water#Tag>0 do
timerSet,1,2
Let,1,[water_pump#On]
gpio,4,[VAR#1#!Z]
endon

On Rules#Timer=1 do
TaskValueSet,1,1,0
endon
Your rule would trigger when you have set the tag value = 0 which isn't what you wanted.

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 19:50
by sawo
Hi grovkillen,

thanks a lot for helping me.
One question, what does the [VAR1#!Z] stand for, do I need to create a variable or device?
When I copy your rule nothing happends, what do you need to know from my setup?

thx

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 20:09
by grovkillen
I had an error in my rule which I have corrected.

Let,1,[task#value] <---- this sets the first internal variable (16 maximum) to what ever value your pump have.
[VAR#1] is now the same value as [pump#state] (or whatever you called your task and value).
[VAR#1#Z] is making a transformation of the value, but we want this transformation to be inverted and thus:
[VAR#1#!Z]

You can read about it in the page I linked to.

Re: RFID update values when removing tag

Posted: 31 Mar 2020, 23:49
by sawo
Hi grovkillen,

thanks a lot for explaining.
But the issue still exists, I think that the interval of the RDM6300 is set to high.
When I quickly put the tag on and off it only swichtes once, but if I old it on for about a 1/1,5 second it will switch 2 or more times.
Is there a possibility to pause the reading of the RDM6300, by rule, for a few seconds or increase the interval?

attached is the log from around 1 second, holding the tag on the reader.

thx
sawo

Re: RFID update values when removing tag

Posted: 01 Apr 2020, 02:05
by grovkillen
That sounds like a design flaw. Please open a issue on GitHub and refer to this thread

Re: RFID update values when removing tag

Posted: 01 Apr 2020, 09:19
by sawo
@grovkillen
thanks a lot for helping, I have created an issue.

Re: RFID update values when removing tag

Posted: 01 Apr 2020, 09:50
by grovkillen
sawo wrote: 01 Apr 2020, 09:19 @grovkillen
thanks a lot for helping, I have created an issue.
Great! And thank you for reporting this issue.