@adonno I’m a happy user of your tag reader solution and thanks a lot for your work and effort.
I have a problem that I could not resolve or, maybe, I didn’t understand how it works.
Prerequisites
a. Wemos D1 mini
b. PN RFID 532
c. Card & tag, 13.56 MHz
d. master branch pn532_i2c
Use case
I want to use my Huawei Mate 20 Pro as an NFC Tag
What I did
- Open Home Assistant Companion which is logged in at HA instance
- NFC Tag option from Settings
- Write Tag on White Card
- Returning results
- platform: event
event_type: tag_scanned
event_data:
device_id: 93d872ca49dfe4d7
tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
- Fire event button
- Check if ce1685b2-0bdf-4786-bea4-39caa49c4035 is displayed in Tags from configuration
- Make the following automation in automation.yaml
- alias: "Huawei NFC Access"
initial_state: True
mode: single
trigger:
- platform: event
event_type: tag_scanned
event_data:
device_id: 93d872ca49dfe4d7
tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
action:
- service: switch.toggle
entity_id: switch.shelly_1pm
- Reload automation
- Swipe Huawei Phone
Expected results
- The bulb must be switched on
Actual results
- The bulb is not light on and a new entry is created in Tags
- Huawei and White Card still have different identificators
More actions
- Go To events and listen tag_scanned
- Scan Huawei and White Card
–> “device_id”: bf45cac435a56ede5256ea83fed4f9c0
is the same for both.
–> tag id is different than the id created with HA Companion
–> device_id is different than the id created with HA Companion
–
3. Go to automation and at device_id paste bf45cac435a56ede5256ea83fed4f9c0
value
New automation code excluded tag_id
- alias: "Huawei NFC Access Device ID"
initial_state: True
mode: single
trigger:
- platform: event
event_type: tag_scanned
event_data:
device_id: bf45cac435a56ede5256ea83fed4f9c0
# tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
action:
- service: switch.toggle
entity_id: switch.shelly_1pm
- Reload automation
- Swipe White Card --> the bulb is switching ON
- Swipe Huawei --> the bulb is switching ON
- Check Tags from HA
New Tag is created for Huawei
- Swipe Huawei again
New Tag is created for Huawei
Expected results
Huawei and White card should be considered one entity
When I write a new card
device_id: 93d872ca49dfe4d7
tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
must be used in automation in order to make two entities to act as one
–
More Testing
- Go To HA companion and read White Card
–> results
- platform: event
event_type: tag_scanned
event_data:
device_id: 93d872ca49dfe4d7
tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
- Make the following automation
- alias: "Huawei NFC Access"
initial_state: True
mode: single
trigger:
- platform: event
event_type: tag_scanned
event_data:
device_id: 93d872ca49dfe4d7
tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
action:
- service: switch.toggle
entity_id: switch.shelly_1pm
- Fire the event directly from the HA companion / Button Fire Event
–> The bulb is switching ON and OFF
–> Verify-in Tags if ce1685b2-0bdf-4786-bea4-39caa49c4035
was used == yes
- Swipe Huawei in order to obtain the same result
–> a new tag is created
–> the bulb remains switched off
In conclusion
if I used Fire Event button directly from HA companion the phone trigger the action and in TAGS is used the device id which was created, but if I put the same values in the automation I am not able to obtain the same behavior