PN532 and Home Assistant

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mufidsyed
Normal user
Posts: 8
Joined: 30 Sep 2018, 10:37

PN532 and Home Assistant

#1 Post by mufidsyed » 23 Oct 2018, 06:21

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

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

Re: PN532 and Home Assistant

#2 Post by grovkillen » 23 Oct 2018, 06:30

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.
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:

mufidsyed
Normal user
Posts: 8
Joined: 30 Sep 2018, 10:37

Re: PN532 and Home Assistant

#3 Post by mufidsyed » 23 Oct 2018, 06:42

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

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

Re: PN532 and Home Assistant

#4 Post by grovkillen » 23 Oct 2018, 06:48

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.
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:

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

Re: PN532 and Home Assistant

#5 Post by grovkillen » 23 Oct 2018, 06:49

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:

mufidsyed
Normal user
Posts: 8
Joined: 30 Sep 2018, 10:37

Re: PN532 and Home Assistant

#6 Post by mufidsyed » 23 Oct 2018, 09:40

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

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

Re: PN532 and Home Assistant

#7 Post by grovkillen » 23 Oct 2018, 10:24

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.
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:

Domosapiens
Normal user
Posts: 286
Joined: 06 Nov 2016, 13:45

Re: PN532 and Home Assistant

#8 Post by Domosapiens » 24 Oct 2018, 09:17

New way would be to use this:

Code: Select all

Let,1,123456789
Let statement?

Can you enlighten us about this new way?
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

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

Re: PN532 and Home Assistant

#9 Post by grovkillen » 24 Oct 2018, 12:17

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
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:

Domosapiens
Normal user
Posts: 286
Joined: 06 Nov 2016, 13:45

Re: PN532 and Home Assistant

#10 Post by Domosapiens » 24 Oct 2018, 22:52

Ohhh great :idea:
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests