Page 1 of 1

PN532 and Home Assistant

Posted: 23 Oct 2018, 06:21
by mufidsyed
Hi,

I have a nodemcu running the Release mega-20181022 stable version along with a PN532. I am able to read the tags. I have also integrated the same into my home assistant.

While setting up automation i found that home assistant does not realize the same tag being read multiple times. In order to avoid the same is there anyway i can use rules to reset the readings of the PN532 after 3 seconds of every read. i.e. once the card is detected, after 3 seconds, the value should be something other than what was read.

Thank you

Re: PN532 and Home Assistant

Posted: 23 Oct 2018, 06:30
by grovkillen
Are the tag numbers integers or is there letters inside them? If they are numbers only (=integers) then you can store them inside the newly added internal variables (1...16) or use traditional dummy devices.

Re: PN532 and Home Assistant

Posted: 23 Oct 2018, 06:42
by mufidsyed
tag numbers are all intergers. sorry this is very new to me. can you tell me where can i find the internal variable or traditional dummy devices

Re: PN532 and Home Assistant

Posted: 23 Oct 2018, 06:48
by grovkillen
If you look in the wiki regarding rules you get a good start. After that you can come here and I'll help you out.

Re: PN532 and Home Assistant

Posted: 23 Oct 2018, 06:49
by grovkillen

Re: PN532 and Home Assistant

Posted: 23 Oct 2018, 09:40
by mufidsyed
so going through the rules this is what i came up with. the rfid is connected to i2c whichi would be GPIO-4 for SDA and GPIO-5 for SCL

On Rules#Timer=1 do
if[esp004#tag]>0
gpio,4,%value%
else
gpio,4,000000000
endif
timerSet,1,3
endon

is this correct

Re: PN532 and Home Assistant

Posted: 23 Oct 2018, 10:24
by grovkillen
No you need to create either a dummy device or use the newly added system variables. So either you do it like this:

Old way with dummy devices (I place them on task number 12 in this example, naming them Dummy#CurrentTag and Dummy#ZeroTag), if your esp004#tag device is on task number 1 and value number 1 this would then hopefully work.

Code: Select all

'
On System#Boot Do
 taskValueSet,12,2,123456789
EndOn

On esp004#tag Do
 taskValueSet,12,1,[esp004#tag] //Setting dummy vaue 1 to the tag code
 TimerSet,1,3
EndOn

On Rules#Timer=1 Do
 If [esp004#tag] = [Dummy#CurrentTag] //If the tag code is still the same after 3 seconds clear it
   taskValueSet,1,1,[Dummy#ZeroTag]
  EndIf
EndOn
New way would be to use this:

Code: Select all

On System#Boot Do
 Let,1,123456789
EndOn

On esp004#tag Do
 Let,2,[esp004#tag]
 TimerSet,1,3
EndOn

On Rules#Timer=1 Do
 If [esp004#tag] = %v2%
   taskValueSet,1,1,%v1%
  EndIf
EndOn
I'm typing this out of my head so please get back here if something is not working as you was hoping.

Re: PN532 and Home Assistant

Posted: 24 Oct 2018, 09:17
by Domosapiens
New way would be to use this:

Code: Select all

Let,1,123456789
Let statement?

Can you enlighten us about this new way?

Re: PN532 and Home Assistant

Posted: 24 Oct 2018, 12:17
by grovkillen
It's only a couple of days old. I will add more info about it but in short:

Let,<value number 1...16>,<float>

Example

Let,1,10
Let,2,20
Publish,Answer/%v1%+%v2,(%v1%+%v2%)

This would render in this being published

Topic
Answer/10+20

Message
30

Re: PN532 and Home Assistant

Posted: 24 Oct 2018, 22:52
by Domosapiens
Ohhh great :idea: