
If your Tuya contact sensor appears in Home Assistant as “Contact Sensor (unsupported)”, with product ID a9fn0xcsckjoqpnd, you can enable it with a small local device quirk. I tested this approach successfully with the standard Home Assistant Tuya integration.
The device is unusual because Tuya reports it under category tdq rather than the normal contact-sensor category mcs. Its standard Tuya sharing data is also empty, even though the underlying device reports:
- DP 101:
doorcontact_state, a Boolean open/closed value - DP 102:
battery_state, withlow,middle, orhighvalues
The quirk tells Home Assistant about those data points and treats the device as an mcs contact sensor.
What you need
- Home Assistant 2026.5 or newer
- The official Tuya integration already configured
- The File Editor add-on, Studio Code Server add-on, or another way to edit files under
/config - A Tuya device with product ID
a9fn0xcsckjoqpnd
Confirm the product ID under Settings → Devices & services → Tuya → your contact sensor. You can also select Download diagnostics and look for product_id. Do not publish the full diagnostics file without removing device IDs and other private account information.
Create the custom quirk
Open the Home Assistant File Editor. Its starting directory normally represents /config, even when /config is not displayed in the address bar. It is the directory containing configuration.yaml.
Create a folder named:
tuya_quirks
Inside that folder, create this file:
tdq_a9fn0xcsckjoqpnd.py
The resulting path should be:
/config/tuya_quirks/tdq_a9fn0xcsckjoqpnd.py
Paste the following code into the file:
"""Quirk for Contact Sensor (product_id a9fn0xcsckjoqpnd)."""
from tuya_device_handlers import TUYA_QUIRKS_REGISTRY
from tuya_device_handlers.builder import DeviceQuirk
from tuya_device_handlers.const import DPMode
(
DeviceQuirk()
.applies_to(product_id="a9fn0xcsckjoqpnd")
.override_category("mcs")
.add_dpid_boolean(
dpid=101,
dpcode="doorcontact_state",
dpmode=DPMode.READ,
)
.add_dpid_enum(
dpid=102,
dpcode="battery_state",
dpmode=DPMode.READ,
enum_range=["low", "middle", "high"],
)
.register(TUYA_QUIRKS_REGISTRY)
)
Save the file. Be careful that its name ends in .py, not .py.txt.
Reload Tuya
You do not need to restart the whole Home Assistant server:
- Go to Settings → Devices & services.
- Find Tuya.
- Open its three-dot menu.
- Select Reload.
Return to the contact sensor. It should now expose a door/contact binary sensor and a battery-state sensor instead of appearing unsupported.
Open and close the door or window to verify that the binary sensor changes state. Battery-powered Tuya devices may sleep between reports, so allow the physical sensor to send a fresh event before concluding that it is not working.
Troubleshooting
If the device is still unsupported:
- Confirm that Home Assistant is version 2026.5 or newer.
- Verify the exact folder and filename:
/config/tuya_quirks/tdq_a9fn0xcsckjoqpnd.py. - Confirm that the device product ID is exactly
a9fn0xcsckjoqpnd. - Check Settings → System → Logs for
Loading custom quirk moduleorLoaded custom quirks. - Correct any Python traceback shown in the logs, then reload Tuya again.
- Trigger the physical sensor by opening and closing the door.
To undo the change, delete the quirk file and reload the Tuya integration.
Getting the fix upstream
This product has already been reported in Home Assistant Core issue #159399 and issue #176205. The appropriate permanent fix is a pull request to the Home Assistant Tuya device-handlers repository, rather than a direct device mapping in Home Assistant Core.
The proposed contribution would add:
src/tuya_device_handlers/devices/tdq/tdq_a9fn0xcsckjoqpnd.py- A sanitized device fixture under
tests/fixtures/devices/ - Tests under
tests/devices/tdq/
There is already a useful precedent: tuya-device-handlers PR #154 added support for another tdq contact sensor with the same DP 101/102 layout. The local quirk above follows that implementation.
Once an upstream quirk is merged, released, and included in Home Assistant, the custom file can be removed.
