Initial Situation
In our Home Assistant-based setup we do presence detection with device trackers of the mobile Home Assistant app on our mobiles, i.e. our iPhone is our presence locator and Home Assistant (HA) knows if we are at home or not. This is fine for family members, but what to do if we have a longer absence from home and there is some family-external who takes care of the cats?
I didn’t want to have them installing the Home Assistant app on their devices for tracking their location or scanning a NFC tag to indicate, that they are at our home. I was looking from something less intrusive. My idea was to give them a physical key and a RFID tag so that they can unlock the door and once they are in they could check-in by scanning their RFID tag. By that our Home Assistant would know, that someone arrived at home who is authorized to be there and would turn on all required automations, e.g. motion-based lighting.
Since it was quite hard to find information on RFID readers, integrating them with Home Assistant ZHA and using RFID tags practically in Home Assistant, I decided to write down my experience for others and give some instructions so that they can save time.
Hardware
From my time with Z‑Wave on openHAB [1] I still have a RFID scanner from Zipato [2], but I couldn’t get it to work with my Thinka Z‑Wave hub [3]. And if it doesn’t work with Thinka, it doesn’t work with Home Assistant, since I have integrated Thinka in there as an HomeKit device.
So, what to do? I was doing some research on battery-powered RFID-scanners, which integrate with Home Assistant. Actually I was wondering, that I couldn’t find that many. At the end I was looking a bit deeper into the KEPZB-110 Intelligent Keypad from Frient [4]. It is a Zigbee-based battery-powered RFID reader, for which users confirmed to have it successfully integrated into HA.
Integration
I am using Zigbee since the first Philips Hue bridge [5] and I have two of them to manage the majority of our lights at home. But it was quite clear that even if Hue is a Zigbee-based system, it is not the way how to connect an RFID reader. So I was extending my research into Zigbee and Home Assistant and found out that there are two ways to do it, either by Zigbee2MQTT (Z2M, [6]) or by Zigbee Home Assistant (ZHA, [7]). Because I didn’t want to have another component to be setup (MQTT) and because ZHA is natively supported by my Home Assistant Yellow [7], I decided to go for ZHA.
I was a bit concerned to bring up the third Zigbee bridge in our home because I feared interferences. At the end it turned out that all is working fine. I put the three bridges each on their own channel and by that lighting and the RFID reader work fine beside each other.
Preparation
Activation of ZHA on Home Assistant Yellow
ZHA come with Home Assistant Yellow. Activating it is quite easy.
Instructions
- Select Configure in System/Hardware
- Select Switch between Zigbee or Thread firmware and the Zigbee and follow the instructions
Pairing the KEPZB-110 Keypad with ZHA
When ZHA is running in Home Assistant the new integration Zigbee Home Automation should show up. From there it is easy to start pairing.
Instructions
- Select Configure and then Add Device.
- Follow the Frient instructions [9] for setting the device into pairing mode.
Once the device has been included into the Zigbee network, it should be available in Home Assistant.
Testing the Keypad with a Numeric Code
For test the keypad it is required to define a numeric code. Interestingly, this is not being done at the KEPZB-110 device in Home Assistant, but at the level of the Zigbee Home Automation integration.
Instructions for Defining a Master Code
- Open Devices & Services
- Select Zigbee Home Automation
- Click on Configure
- Find the section Alarm Control Panel Options
- Define your Master Code
Instructions for Testing
Once the code has been defined, test it as follows:
- Press Lock on the physical Frient keypad
- Punch your Master code into the keypad followed by the Unlock key.
If successful, the Alarm Control Panel in Home Assistant should switch to Disarmed.
RFID Tags and the ID in RFID
Choosing the Right RFID Tags for KEPZB-110
From my time with the Zipato RFID reader I had three RFID tags. It turned out they don’t work with the Frient keypad. The KEPZB-110 requires a RFID chip based on ISO14443 Type A (MIFARE Classic) [10].
Getting the ID of an RFID Tag
While it is easy to get the keypad into Home Assistant, it seemed to me quite more complicated to get it working with more than one key (master key) or even RFID. I was looking into various Blueprints [12, 13] tried them without success before I finally found a french website [13], which explained how to find out the actual ID of an RFID tag and how to use it in further automations.
Instructions
- Head to Developer tools in Home Assistant
- Select Events, enter “zha_event” into Listen to events and press Start Listening
- Scan the RFID tag (hold close to the middle of the keypad) and press the Unlockbutton
- Look into the captured events. You find the ID of the RFID tag in the argument “code” of the payload
Presence Detection Based on RFID
Defining Persons for RFID Tags
Automations in Home Assistant can be either triggered or conditionally executed based on the presence of persons (people). If RFID tags shall be used to support this functionality it is required to define people and “attach” the RFID tags as Track Deviceto them, so that the presence of the respective person can be determined.
Instructions
- Head to the People section in Home Assistant
- Create a person, e.g. “Green RFID”. Leave the field Track device blank for the time being
Defining Device Trackers for RFID Tags
In former times Device Trackers in Home Assistant were created by the file known_devices.yaml. This is not supported any longer. It took me a while to understand, how these devices are created now.
It is quite easy. They are simply created with an action called Device Trackers: See. As soon as this action is being executed (e.g. in an automation), an entity is being automatically created for the device tracker.
Instructions
Execute the action Device Trackers: See with the attributes DeviceID and Location (either “home” or “not_home”).
Building an Automation for Using RFID for Presence Detection
Once the before-mentioned action has been executed, the device tracker Green_RFID_tracker can be linked to the person Green RFID in the People section of Home Assistant.
The use case for tracking a person at home with an RFID tag is as follows.
Precondition: Nobody at home. Alarm panel of the Frient Keypad is in mode Away
- The person enters the home and scans their RFID tag followed by pressing the Unlock button: Alarm panel switches to Disarmed. The person is being checked-into the Home zone.
- The person leaves and press the Lock button: Alarm panel switches to Away. The person is being checked-out of the Home zone.
Building an automation is quite easy.
Instructions
- When: Add a trigger for zha_event event is fired. Use the before captured ID of the RFID tags as code
- Then Do: Disarm the keypad and perform the action Device tracker: See
An automation for checking out is more or less the opposite of those before. The only difference is, that the RFID tag is not required to be presented. It is sufficient to simply press the Lock button on the keypad.
This behavior can be changed by enforcing the option Code required for arming actions in the Alarm Control Panel Options of the Zigbee Home Automation integration.
References
- [1] https://www.openhab.org
- [2] https://www.zipato.com/product/mini-keypad-rfid
- [3] https://www.thinka.eu/z‑wave
- [4] https://frient.com/products/intelligent-keypad/
- [5] https://www.philips-hue.com/en-us/p/hue-bridge/046677458478
- [6] https://www.zigbee2mqtt.io/guide/usage/integrations/home_assistant.html
- [7] https://www.home-assistant.io/integrations/zha/
- [8] https://www.home-assistant.io/yellow/
- [9] https://frient.com/media/2346/h6500156-intelligent-keypad-installation-manual-v11.pdf
- [10] https://www.amazon.de/dp/B07GL2HTCG?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1
- [11] https://community.home-assistant.io/t/frient-develco-kepzb-110-key-pad/608954/3
- [12] https://community.home-assistant.io/t/alarm-keypad-frient-kepzb-110-for-alarmo-or-other-systems-with-zha/783075
- [13] https://www.auto-domo.fr/installation-keypad-frient-dans-home-assistant/
- [14] https://www.home-assistant.io/integrations/device_tracker/#known_devicesyaml