️ Ultimate Guide: Solution for Nuki Auto Unlock on HyperOS (Xiaomi) with MacroDroid (UPDATED)
If you have a Xiaomi phone running HyperOS, you have likely experienced the main problem with Nuki Auto Unlock: the system's aggressive energy and memory management kills background processes and throttles the Bluetooth antenna when the screen is off, causing automatic unlocking to fail systematically at your front door.UPDATE NOTE (Latest Revisions)
Extensive stress-testing on HyperOS has revealed that background processes are aggressively killed during Deep Sleep, ignoring regular battery exemptions. This guide and template have been updated with the "Zero-Interruption Defibrillator" Architecture:
- Wi-Fi Disconnect Trigger: The macro uses your home Wi-Fi disconnection to silently wake up the GPS and Nuki before you reach the outer geofence, guaranteeing the "Departure" state is recorded.
- Smart Screen-State Trap: If you leave your house actively using your phone (screen on), the macro pauses indefinitely so it doesn't interrupt your usage. The moment you put the phone in your pocket (screen off), it instantly executes the background wake-up actions.
- ️ Hardware GPS Timing: A precise 2-second delay has been added after forcing location updates to allow the Android OS exactly enough time to write new satellite coordinates to RAM before launching Nuki.
This guide compiles the exact system-level configuration and a fully optimized MacroDroid macro structure to bulletproof its operation.
Essential Prerequisite Settings in HyperOS
To prevent the system from sabotaging the automation, apply these changes:Nuki & MacroDroid App Settings
- Auto-start: Enabled.
- Battery saver: Set to No restrictions.
- Multitasking (CRITICAL): Long-press the Nuki and MacroDroid apps in recent apps and lock them with the padlock so the OS script doesn't clear them from RAM.
- PERSISTENT NOTIFICATIONS (CRITICAL): You MUST enable permanent background notifications for both Nuki and MacroDroid in the system settings. The persistent icons visible in your status bar are strictly mandatory for HyperOS to register them as active Foreground Services. Without this, the system will kill GPS and Bluetooth access entirely.
️ Developer Options
- Wi-Fi scan throttling: Disabled (allows scanning networks with the screen off).
- Background process limit: Set to Standard limit.
- Suspend execution of cached apps: Disabled.
- Disable secondary process restrictions: Enabled.
Network and Battery Settings
- Wi-Fi Assistant / Switch to mobile data automatically: Disabled.
- Use mobile data to accelerate Wi-Fi: Disabled.
- Keep mobile data turned on (even with Wi-Fi): Disabled.
- Clear cache when device is locked: Set to Never.
Macro Triggers
- Geofence (Enter): [Geofence_Close] (e.g., 50m radius)
- Geofence (Exit): [Geofence_Far] (e.g., 150m radius)
- Geofence (Enter): [Geofence_Intermediate] (e.g., 100m radius inner)
- Wifi Connected: [Your_Home_SSID]
- Wifi Disconnected: [Your_Home_SSID]
- Bluetooth Disconnected: [Your_Car_Bluetooth_Name]
Actions Structure and Logic
If: Trigger fired: Wifi Connected: [Your_Home_SSID]Wait 15 seconds
Turn Screen On
Disable Trigger [This macro]: Geofence Enter: [Geofence_Close]
Disable Trigger [This macro]: Geofence Enter: [Geofence_Intermediate]
Disable Trigger [This macro]: Geofence Exit: [Geofence_Far]
Cancel Macro Actions [This macro]
Else If: Trigger fired: Wifi Disconnected: [Your_Home_SSID]
Enable Trigger [This macro]: Geofence Enter: [Geofence_Close]
Enable Trigger [This macro]: Geofence Enter: [Geofence_Intermediate]
Enable Trigger [This macro]: Geofence Exit: [Geofence_Far]
Else If: Trigger fired: Geofence Exit: [Geofence_Far]
Force Location Update
Wait 2 seconds
Launch Application: Nuki (io.nuki)
Wait 5 seconds
Launch Home Screen
Set Variable: Aprox. Activa = False
Cancel Macro Actions [This macro]
Else If: Trigger fired: Geofence Enter: [Geofence_Close] OR Bluetooth Disconnected: [Your_Car_Bluetooth_Name] [AND Aprox. Activa = True]
Repeat 120 times
Wifi SSID Scan ➔ wifis
Wait 9 seconds 60 ms
Set Variable: texto redes = {vjson=wifis}
If: texto redes contains [Your_Home_SSID]|[Other...] (Regex Enabled)
Turn Screen On
End If
End Loop
Else If: Trigger fired: Geofence Enter: [Geofence_Intermediate]
Set Variable: Aprox. Activa = Verdadero
End If
Attachments
Last edited: