This project provides a MacroDroid-based integration to sync Leapmotor vehicle data to Home Assistant. Since Leapmotor doesn't provide an official API, this solution uses screen scraping via MacroDroid on Android to extract vehicle information and push it to Home Assistant via the REST API.
The integration consists of three main components:
- MacroDroid Macro - Runs on your Android device to scrape the Leapmotor app and send data to Home Assistant
- Home Assistant Sensors - Template sensors that extract attributes from the main sensor
- Home Assistant Dashboard - A pre-configured Lovelace dashboard to display vehicle information
The integration tracks the following vehicle data:
- Vehicle state (parked, driving, etc.)
- Battery percentage
- Lock state (locked/unlocked)
- Remaining range (km)
- Interior temperature
- Exterior temperature
- Android Device with MacroDroid installed
- Leapmotor App installed and logged in on the same Android device
- Home Assistant instance (local or cloud accessible)
- Custom Layout Card (HACS)
- Mushroom Cards (HACS)
- Mini Graph Card (HACS)
- card-mod (HACS)
Add the contents of sensor.yaml to your Home Assistant configuration.
Option A: If using configuration.yaml directly:
# Add to configuration.yaml
template: !include sensor.yamlThen place sensor.yaml in your Home Assistant config directory.
Option B: If you already have template sensors:
Copy the sensor definitions from sensor.yaml and merge them into your existing template configuration.
- In Home Assistant, click your profile (bottom left)
- Scroll to "Long-Lived Access Tokens"
- Click "Create Token"
- Name it "MacroDroid Leapmotor"
- Copy the token and save it securely (you'll need it for MacroDroid setup)
After adding the sensor configuration, restart Home Assistant to load the new sensors.
- Download
Leapmotor_to_HomeAssistant.macroto your Android device - Open MacroDroid
- Tap the menu (three dots) → "Import"
- Select the downloaded
.macrofile
After importing, you need to configure three local variables:
-
Tap the macro to edit it
-
Tap "Variables" (at the bottom)
-
Configure the following local variables:
-
ha_url(Secure): Your Home Assistant URL- Examples:
- Local:
http://homeassistant.local:8123 - Nabu Casa:
https://abcdefgh.ui.nabu.casa - Custom domain:
https://home.yourdomain.com
- Local:
⚠️ Do not include trailing slash
- Examples:
-
ha_token(Secure): The Long-Lived Access Token from Step 1.2 -
ha_sensor_name(not secure): The sensor entity ID suffix- Default:
leapmotor_c10_1 - This creates:
sensor.leapmotor_c10_1 - Change if you have multiple vehicles or prefer a different name
- Default:
-
-
Make sure your device is unlocked and the Leapmotor app is logged in
-
In MacroDroid, tap the macro
-
Tap "Test Actions" (not "Test Macro")
-
Observe the macro running:
- It will open the Leapmotor app
- Wait for the home screen to load
- Navigate to the energy/battery details
- Scrape the data
- Send it to Home Assistant
- Return to your previous app
-
Check Home Assistant Developer Tools → States to verify
sensor.leapmotor_c10_1was created
- In Home Assistant, go to your dashboard
- Click the three dots → "Edit Dashboard"
- Click "Add View"
- Switch to "YAML mode"
- Paste the contents of
dashboard.yaml - Save
If you changed ha_sensor_name in Step 2.2, you'll need to update the dashboard:
- Replace all instances of
sensor.leapmotor_c10_1with your custom sensor name - Replace all instances of derived sensors accordingly:
sensor.leapmotor_c10_battery_1sensor.leapmotor_c10_range_1sensor.leapmotor_c10_car_temperature_1sensor.leapmotor_c10_air_temperature_1sensor.leapmotor_c10_lock_state_1
Trigger:
- Screen turns off (to avoid interrupting active use)
Constraints:
- Device is unlocked
- Macro hasn't run in the last 30 minutes
Actions:
- Saves the current foreground app
- Launches the Leapmotor app
- Waits for the "energy" screen to load (loops up to 20 times)
- Reads screen contents and extracts:
- Air temperature
- Car temperature
- Lock state
- Remaining range
- Car state
- Clicks on the battery indicator to view battery percentage
- Waits for battery screen to load (loops up to 20 times)
- Extracts battery percentage
- Constructs JSON payload with all data
- Sends POST request to Home Assistant REST API
- Kills the Leapmotor app
- Returns to the original app
Leapmotor App (Android)
↓ (screen scraping)
MacroDroid Macro
↓ (HTTP POST)
Home Assistant REST API
↓ (creates/updates)
sensor.leapmotor_c10_1
↓ (attributes extracted)
Template Sensors (battery, range, temps, lock state)
↓ (displayed on)
Lovelace Dashboard
The main sensor (sensor.leapmotor_c10_1) stores data in this format:
{
"state": "parked",
"attributes": {
"battery_percent": 85,
"air_temp": 12,
"car_temp": 18,
"lock_state": "locked",
"remaining_range": 340,
"friendly_name": "Leapmotor C10",
"icon": "mdi:car-electric"
}
}- Check that the device is unlocked when the screen turns off
- Verify the "Last Run Time" constraint (30 minutes) hasn't blocked it
- Check MacroDroid logs: Menu → Log → Macro Log
- Verify
ha_urlis correct and accessible from your Android device - Test by opening the URL in a browser on the same device
- Check that the access token is valid in Home Assistant
- Ensure Home Assistant is not behind a firewall blocking your device
- Check that the macro has run at least once successfully
- Verify sensor names in
sensor.yamlmatch the main sensor ID - Check Home Assistant logs for template errors
- Ensure the main sensor exists: Developer Tools → States
- The Leapmotor app may have updated its UI elements
- Check the macro logs to see where it fails
- You may need to update the UI element IDs in the macro
- Ensure the Leapmotor app is logged in and working
- Install all required HACS integrations (see Prerequisites)
- Clear browser cache
- Check browser console for errors
The macro runs when:
- Screen turns off
- Device is unlocked
- At least 30 minutes have passed since last run
To change the frequency:
- Edit the macro
- Find "Constraint: Last Run Time"
- Adjust the time period
If you want to track additional data from the Leapmotor app:
- Edit the macro
- Add screen scraping actions for the new data points
- Update the JSON payload in the "Set Variable: ha_request_body" action
- Add corresponding template sensors in
sensor.yaml - Update the dashboard to display the new sensors
The dashboard uses card-mod for styling. Adjust:
- Card widths (default: 162px)
- Colors (in
icon_colortemplates) - Thresholds (battery warnings, range warnings, etc.)
The macro handles sensitive information:
- Home Assistant access token - Stored securely in MacroDroid
- Home Assistant URL - Stored securely in MacroDroid
Important:
- Both are marked as "secure" variables in MacroDroid
- They are encrypted in the MacroDroid database
- The exported
.macrofile contains empty placeholders only - Never share your configured macro file publicly
- Regenerate your access token if compromised
- Use HTTPS for your Home Assistant URL when possible
- Consider using Nabu Casa for secure remote access
- If using local HTTP, ensure your WiFi network is secure
- The access token grants full API access - treat it like a password
- Requires Android device with MacroDroid
- Only updates when device screen turns off
- Requires Leapmotor app to be installed and logged in
- Screen scraping is fragile and may break with app updates
- No real-time updates (updates every 30+ minutes)
- Device must be unlocked for macro to run
- Cannot control vehicle functions (read-only integration)
Potential enhancements:
- Support for multiple Leapmotor vehicles
- More frequent updates (with battery optimization)
- Additional data points (odometer, tire pressure, etc.)
- Notifications for low battery or unlock events
- Historical data tracking and charts
- Created for Leapmotor C10 owners who want Home Assistant integration
- Uses MacroDroid for Android automation
- Dashboard built with Mushroom Cards and Mini Graph Card
This project is provided as-is for personal use. Leapmotor is a trademark of their respective owners. This is an unofficial integration and is not affiliated with or endorsed by Leapmotor.
If you encounter issues:
- Check the Troubleshooting section above
- Review MacroDroid logs
- Check Home Assistant logs
- Verify all prerequisites are installed
- Initial release
- Support for Leapmotor C10
- Basic vehicle data tracking
- Home Assistant sensors and dashboard