This document explains how the Home Assistant functionality was converted from a built-in feature to a standalone AndrOBD plugin.
The Home Assistant integration was initially added as a built-in feature in AndrOBD. After review, it was decided to convert it to a plugin for several reasons:
- Modularity: Plugins keep the core app lean and allow users to install only features they need
- Maintainability: Separate codebase makes updates and bug fixes easier
- Community Sharing: Plugins can be shared independently and updated on their own schedule
- Consistency: Aligns with existing integrations like MQTT, GPS, and Sensor providers which are all plugins
AndrOBD plugins follow a specific architecture defined by the AndrOBD plugin framework:
-
Plugin Service: Main service that extends
com.fr3ts0n.androbd.plugin.Plugin- Implements
ConfigurationHandlerfor settings - Implements
ActionHandlerfor manual actions - Implements
DataReceiverto receive OBD data from AndrOBD
- Implements
-
PluginReceiver: Broadcast receiver that responds to plugin discovery
- Extends
PluginInfoBroadcastReceiver - Provides plugin metadata to AndrOBD
- Extends
-
SettingsActivity: Configuration UI for the plugin
- Uses Android PreferenceFragment
- Allows users to configure plugin behavior
-
AndroidManifest: Declares plugin components and permissions
- Service and receiver must be properly declared
- Required permissions (Internet, Network State, WiFi State)
The following components were removed from the main AndrOBD app:
- HomeAssistantService.java: Core service class for Home Assistant integration
- MainActivity integration:
- Service initialization in onCreate()
- Service cleanup in onDestroy()
- Data forwarding in onDataUpdate()
- Settings change handling
- Settings UI:
- Home Assistant PreferenceScreen from settings.xml
- All Home Assistant-related strings and arrays
- Documentation: HOME_ASSISTANT.md moved to plugin README
The plugin includes these new/adapted components:
-
HomeAssistantPlugin.java: Adapted from HomeAssistantService
- Now extends Plugin base class
- Implements plugin interfaces
- Manages data buffering and transmission
- Handles network connectivity checks
-
PluginReceiver.java: New component for plugin discovery
- Responds to AndrOBD's plugin identification broadcast
-
SettingsActivity.java: New configuration UI
- Preference-based settings interface
- Dynamic data item selection
- Real-time settings updates
-
Resources: Complete resource definitions
- Strings for all UI elements
- Preference XML layouts
- Styles and themes
- Before: MainActivity directly called
homeAssistantService.updateData() - After: Plugin implements
DataReceiver.onDataUpdate()callback
- Before: Settings integrated in main app's PreferenceScreen
- After: Separate SettingsActivity with its own PreferenceScreen
- Before: Tied to MainActivity lifecycle
- After: Independent service with its own lifecycle
- Before: All OBD data automatically sent
- After: Users can select specific data items to publish
- AndrOBD plugin framework (as a Git submodule or local project)
- Android SDK with build tools
- Gradle build system
-
Ensure the plugin framework is available:
# If part of AndrOBD-Plugin repository git submodule init git submodule update -
Build the plugin:
cd HomeAssistantPlugin ../gradlew assembleDebug # or assembleRelease
-
Install on device:
adb install -r build/outputs/apk/debug/HomeAssistantPlugin-debug.apk
-
Manual Testing:
- Install both AndrOBD and the Home Assistant plugin
- Enable the plugin in AndrOBD settings
- Configure Home Assistant URL and credentials
- Connect to vehicle and verify data transmission
- Test both real-time and SSID-triggered modes
-
Home Assistant Verification:
- Set up a webhook in Home Assistant
- Monitor webhook triggers
- Verify JSON payload structure
- Create sensors from received data
-
Network Scenarios:
- Test with WiFi connectivity
- Test with mobile data
- Test SSID-triggered mode with correct/incorrect WiFi
- Test connection failures and retries
- Version Numbering: Follow semantic versioning (MAJOR.MINOR.PATCH)
- Build Release APK: Use
assembleReleasetask - Sign APK: Use Android signing configuration
- Create GitHub Release: Tag and publish release with APK
- Documentation: Update README with release notes
- GitHub Releases: Direct APK downloads
- F-Droid: Submit to F-Droid repository (like MQTT plugin)
- Google Play: Optional, for wider distribution
- AndrOBD Plugin List: Add to README.md in main AndrOBD repo
public abstract class Plugin extends Service {
public abstract PluginInfo getPluginInfo();
}// For plugins that have configuration UI
public interface ConfigurationHandler {
void performConfigure();
}
// For plugins that perform actions
public interface ActionHandler {
void performAction();
}
// For plugins that receive data from AndrOBD
public interface DataReceiver {
void onDataListUpdate(String[] dataItems);
void onDataUpdate(String key, String value);
}public class PluginInfo {
public PluginInfo(String name,
Class<?> serviceClass,
String description,
String copyright,
String license,
String url)
}Possible improvements for the Home Assistant plugin:
- Auto-discovery: Automatically discover Home Assistant on local network
- SSL Certificate Validation: Add option for custom CA certificates
- Batch Optimization: Group multiple updates into single request
- Retry Logic: Implement exponential backoff for failed transmissions
- Status Display: Show connection status in plugin UI
- Data Filtering: More advanced filtering options (by value, rate of change)
- Custom Topics: Allow custom Home Assistant entity naming
- AndrOBD Plugin Framework
- AndrOBD Plugin Development
- MQTT Plugin Example
- Home Assistant Webhook Documentation
- AndrOBD Wiki
For questions or issues:
- AndrOBD Telegram: https://t.me/joinchat/G60ltQv5CCEQ94BZ5yWQbg
- AndrOBD Matrix: https://matrix.to/#/#AndrOBD:matrix.org
- GitHub Issues: https://github.com/ian-morgan99/AndrOBD-HomeAssistantPlugin/issues