Skip to content

Fix Linptech ES3 sensor motion clear delay (#1481) #1482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 11, 2025

Conversation

rankjie
Copy link
Contributor

@rankjie rankjie commented Jul 7, 2025

Summary

Fixes the 2-minute delay for Linptech ES3 motion sensors to report motion clear status.

Problem

The Linptech ES3 sensor sends two different frames when motion clears:

  1. An immediate frame with object type 0x484e (occupancy=0)
  2. A delayed frame with explicit motion: 0 (~2 minutes later)

The immediate frame was being ignored because obj484e returned an empty dict for occupancy=0,
causing the motion sensor to remain in "detected" state for ~2 minutes until the second frame
arrived.

Solution

Modified the obj484e handler to return {"motion": 0} specifically for ES3 devices when
occupancy=0, while preserving the original behavior (empty dict) for other devices that rely on
Home Assistant's motion timer.

Changes

  • Added device_type parameter to obj484e function
  • Added 0x484e to the list of object type codes that receive device_type
  • ES3 devices now get immediate motion clear when receiving occupancy=0

Testing

  • Tested with simulated ES3 data frames
  • Verified other devices using 0x484e are unaffected
  • Motion clear now reports immediately instead of after 2 minutes

Fixes #1481

rankjie added 2 commits July 7, 2025 19:08
The ES3 sensor sends two types of frames when motion clears:
1. An immediate data-only frame (currently ignored)
2. A delayed frame with explicit motion: 0 (~2 min later)

This fix treats ES3 data-only frames (with data: True but no motion
or illuminance data) as implicit motion clear events, allowing the
motion sensor to clear immediately instead of waiting 2 minutes.

Fixes custom-components#1481
ES3 sends object type 0x484e with occupancy=0 for immediate motion clear,
but this was being ignored (returning empty dict). Now it returns
{"motion": 0} specifically for ES3 devices to enable immediate motion
clear instead of waiting 2 minutes.

- Modified obj484e to accept device_type parameter
- Added 0x484e to the list of objects that receive device_type
- ES3 now gets motion=0 when occupancy=0, other devices unchanged

Fixes custom-components#1481
@Ernst79
Copy link
Collaborator

Ernst79 commented Jul 7, 2025

Thanks for this PR. Some test seem to fail, these need to be fixed first.

rankjie and others added 3 commits July 7, 2025 22:31
Update test_linptech_ES3_data_only_motion_clear to use actual BLE
advertisement data from a real ES3 device instead of simulated data.
This ensures the test properly validates the motion=0 behavior when
the ES3 sends encrypted frames with occupancy status 0.

- Use real MAC address: A4:C1:38:A4:88:8A
- Use real encryption key from the device
- Use actual BLE packet captured from device logs
- Update expected packet ID to match real data

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Correct the expected RSSI value from -58 to -83 to match the actual
signal strength in the test data.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@rankjie
Copy link
Contributor Author

rankjie commented Jul 7, 2025

Apologies, the test file was created with an inconsistent data set. Could you run the test again with the latest commit?

rankjie added 2 commits July 7, 2025 23:10
Minor formatting fix to remove unnecessary blank line in parse_xiaomi function.
Set default reset_timer to 0 for ES3 devices to prevent motion state
from being incorrectly cleared by the timer. ES3 devices handle motion
clear through their own occupancy status messages.
@Ernst79 Ernst79 merged commit 018cfca into custom-components:master Jul 11, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Linptech ES3 sensor: “data: True” frame without motion/illuminance is ignored → motion-clear delayed ≈ 2 min
2 participants