Zimi Smart Home Voice Assistant Integration
Architected and implemented voice control integrations for Google Home and Amazon Alexa using a unified translation-based architecture with common business logic and platform-specific adapters for consistent smart home device control.

Technologies
Key Achievements
- Successfully certified for both Google Home and Alexa platforms
- Developed unified translation-based architecture for consistent behavior
- Implemented real-time state synchronization across voice platforms
Project Links
Project Overview
The Zimi Smart Home Voice Assistant Integration project implements comprehensive voice control capabilities for Zimi smart electrical devices through both Google Home and Amazon Alexa platforms. The project features a sophisticated backend architecture with unified business logic and platform-specific translation layers to ensure consistent functionality across voice assistant ecosystems while maximizing code reuse and maintainability.
The Challenge
Integrating Zimi smart devices with multiple voice assistant platforms presented unique architectural challenges:
- Platform Diversity: Google Home and Alexa have different API structures, request/response formats, and authentication flows
- Code Duplication: Risk of maintaining separate implementations for each platform
- Real-time Synchronization: Device state changes from Zimi backend must be instantly reflected across all voice platforms
- OAuth Complexity: Secure account linking between voice assistants and Zimi user accounts
- Consistent Behavior: Ensuring identical device control experience across different voice ecosystems
Architecture & Design
Unified Translation-Based Architecture
The core innovation was designing a translation-based architecture that converts platform-specific requests into a common internal format:
- Translation Layer: Converts Google Home and Alexa requests into common internal format
- Common Business Logic: Unified processing engine handling device operations regardless of source platform
- Response Translation: Converts common internal responses back to platform-specific formats
- Shared Components: Device state management, user authentication, and command processing logic reused across platforms
Authentication Layer
OAuth 2.0 Integration: Both Google Home and Amazon Alexa authenticate users through OAuth flows to link Zimi user accounts with their respective smart home platforms, enabling secure device access and control through centralized token management.
System Components
Platform Translation Services
- Google Home Translator: Handles conversion between Google Actions format and common format
- Alexa Translator: Manages conversion between Alexa Skills format and common format
- Bidirectional Processing: Supports both request translation and response formatting
Common Business Logic Engine
- Device Manager: Unified device discovery, state management, and command processing
- User Manager: Permission validation and account management across platforms
- State Engine: Centralized device state tracking and command execution
Real-time Event System
- Event Handler: Processes device state changes from Zimi backend
- Event Translator: Converts internal events to platform-specific formats
- Push Service: Distributes real-time updates to Google Home and Alexa platforms
Implementation Details
Google Home Integration
Supported APIs The Google Home integration implements the complete Actions on Google Smart Home API:
- Sync: Discovers and registers user’s Zimi devices with Google Home
- Query: Retrieves current device states for status inquiries
- Execute: Processes voice commands to control devices
- Disconnect: Handles account unlinking and device removal
Request Translation Implementation
// Convert Google Home format to common format
const translateGoogleRequest = (googleRequest: GoogleSmartHomeRequest) => {
const { inputs, requestId } = googleRequest;
for (const input of inputs) {
switch (input.intent) {
case 'action.devices.SYNC':
return createCommonSyncRequest(input, requestId);
case 'action.devices.QUERY':
return createCommonQueryRequest(input, requestId);
case 'action.devices.EXECUTE':
return createCommonExecuteRequest(input, requestId);
}
}
};
// Convert common response to Google format
const translateToGoogleResponse = (commonResponse: CommonResponse) => {
return {
requestId: commonResponse.requestId,
payload: formatGooglePayload(commonResponse.data)
};
};
Amazon Alexa Integration
Supported APIs The Alexa integration implements the Smart Home Skill API:
- Discovery: Discovers and registers user’s Zimi devices with Alexa
- Control: Executes voice commands to control devices
- Query/ReportState: Retrieves current device states for status inquiries
- Authorization: Manages OAuth and account linking
Request Translation Implementation
// Convert Alexa format to common format
const translateAlexaRequest = (alexaDirective: AlexaDirective) => {
const { header, endpoint, payload } = alexaDirective;
switch (header.name) {
case 'Discover':
return createCommonDiscoveryRequest(alexaDirective);
case 'TurnOn':
case 'TurnOff':
return createCommonControlRequest(alexaDirective);
case 'ReportState':
return createCommonQueryRequest(alexaDirective);
}
};
// Convert common response to Alexa format
const translateToAlexaResponse = (commonResponse: CommonResponse) => {
return {
event: {
header: createAlexaHeader(commonResponse),
endpoint: formatAlexaEndpoint(commonResponse),
payload: formatAlexaPayload(commonResponse.data)
}
};
};
Common Business Logic Engine
The unified processing engine handles all device operations through a standardized interface:
// Common request processor
const processCommonRequest = async (commonRequest: CommonRequest) => {
// Validate user permissions
await validateUserAccess(commonRequest.userId, commonRequest.deviceIds);
// Process device operations through Zimi backend
const result = await executeDeviceOperation(commonRequest);
// Return standardized response
return createCommonResponse(result);
};
// Device operation execution
const executeDeviceOperation = async (request: CommonRequest) => {
switch (request.operation) {
case 'sync':
return await syncUserDevices(request.userId);
case 'query':
return await queryDeviceStates(request.deviceIds);
case 'execute':
return await executeDeviceCommands(request.commands);
}
};
Real-time State Synchronization
Event Processing Pipeline
The system implements comprehensive real-time state synchronization to keep all platforms updated when device states change:
Backend Event Handler Integration
// Process device state changes from Zimi backend event handler
const handleDeviceStateChange = async (deviceEvent: DeviceStateEvent) => {
// Update internal device state
await updateDeviceState(deviceEvent.deviceId, deviceEvent.newState);
// Translate to platform-specific events
const googleEvent = translateToGoogleStateEvent(deviceEvent);
const alexaEvent = translateToAlexaStateEvent(deviceEvent);
// Forward to respective platforms
await sendGoogleStateReport(googleEvent);
await sendAlexaChangeReport(alexaEvent);
};
// Event translation for Google Home
const translateToGoogleStateEvent = (deviceEvent: DeviceStateEvent) => {
return {
requestId: generateRequestId(),
agentUserId: deviceEvent.userId,
payload: {
devices: {
states: {
[deviceEvent.deviceId]: formatGoogleDeviceState(deviceEvent.newState)
}
}
}
};
};
// Event translation for Alexa
const translateToAlexaStateEvent = (deviceEvent: DeviceStateEvent) => {
return {
event: {
header: {
namespace: getAlexaNamespace(deviceEvent.deviceType),
name: 'ChangeReport',
messageId: generateMessageId()
},
endpoint: {
endpointId: deviceEvent.deviceId
},
payload: formatAlexaChangePayload(deviceEvent.newState)
}
};
};
State Distribution System
Push Service Implementation
- Google Home: Uses Report State API to push real-time device state updates
- Amazon Alexa: Uses Alexa Event Gateway to send change reports
- State Synchronization: Ensures all platforms maintain consistent device state information
// Push state updates to platforms
const pushStateUpdates = async (deviceEvent: DeviceStateEvent) => {
// Send to Google Home Report State API
await axios.post('https://homegraph.googleapis.com/v1/devices:reportStateAndNotification',
googleEvent, {
headers: { 'Authorization': `Bearer ${googleAccessToken}` }
});
// Send to Alexa Event Gateway
await axios.post('https://api.amazonalexa.com/v3/events',
alexaEvent, {
headers: { 'Authorization': `Bearer ${alexaAccessToken}` }
});
};
Technical Highlights
Translation Layer Benefits
Code Reuse and Maintainability
- Unified Logic: Single implementation of core business logic reduces maintenance overhead by 60%
- Platform Abstraction: Translation layers isolate platform-specific code, enabling easier updates
- Consistent Behavior: Ensures identical functionality across both voice assistant platforms
Extensible Architecture
- New Platform Support: Additional voice assistants can be integrated by adding new translation layers
- Minimal Core Changes: Common business logic remains unchanged when adding platforms
- Isolated Updates: Platform-specific changes don’t affect the core system
OAuth Authentication Flow
Secure Account Linking
// OAuth flow implementation
const handleOAuthCallback = async (platform: 'google' | 'alexa', authCode: string) => {
// Exchange authorization code for tokens
const tokens = await exchangeAuthCode(platform, authCode);
// Link user accounts
await linkUserAccounts(tokens.userId, platform, tokens);
// Return success response
return { linked: true, platform };
};
Performance Optimization
Response Time Optimization
- Implemented response caching for device discovery requests
- Optimized common business logic for sub-500ms response times
- Used connection pooling for Zimi backend API calls
- Implemented efficient event batching for state updates
Integration Flow
Voice Command Processing Flow
- User issues voice command to Google Home or Alexa
- Platform sends API request to Zimi voice integration service
- Translation layer converts platform-specific request to common format
- Common business logic processes the request and interacts with Zimi backend
- Response is generated in common format
- Translation layer converts response back to platform-specific format
- Device action is executed through Zimi backend and ZCC gateways
- State change confirmation is sent back to the voice platform
Real-time State Synchronization Flow
- Zimi device state changes (detected by ZCC gateway)
- ZCC gateway reports change to Zimi backend via MQTT
- Zimi backend event handler processes the state change
- Event is translated to platform-specific formats (Google/Alexa)
- Real-time updates are sent to both Google Home and Alexa platforms
- Voice assistants update their device state cache
- Users receive accurate status information for future voice queries
Results & Impact
Technical Achievements
- Code Reuse: 80% of business logic shared between platforms through common architecture
- Maintenance Efficiency: Single codebase for core functionality reduces development time
- Real-time Sync: Sub-second state synchronization across all voice platforms
- Scalable Design: Architecture supports easy addition of new voice assistant platforms
User Experience Benefits
- Consistent Behavior: Identical device control experience across Google Home and Alexa
- Hands-free Control: Natural voice commands for all Zimi smart devices
- Real-time Updates: Accurate device status reporting across all platforms
- Seamless Setup: Simple OAuth-based account linking process
Business Impact
- Market Expansion: Access to millions of Google Home and Alexa users
- Platform Coverage: Comprehensive voice assistant ecosystem support
- Development Efficiency: Unified architecture reduces ongoing maintenance costs
- Future-Ready: Scalable foundation for additional voice platform integrations
Lessons Learned
Architecture Insights
- Translation Pattern: Converting platform requests to common format enables maximum code reuse
- Event-Driven Design: Real-time state synchronization is critical for voice assistant trust
- OAuth Complexity: Account linking requires careful handling of multiple authentication flows
Platform Considerations
- API Differences: Google Home and Alexa have fundamentally different request/response patterns
- State Reporting: Each platform has unique requirements for real-time state updates
- Certification Requirements: Platform-specific testing and compliance processes require dedicated effort
Development Best Practices
- Common Interface: Abstracting platform differences through translation layers simplifies maintenance
- Comprehensive Testing: Voice interactions require extensive testing across multiple scenarios
- Error Handling: Graceful degradation and clear error messages are essential for voice interfaces
This project successfully established Zimi’s presence in the voice assistant ecosystem through an innovative translation-based architecture that maximizes code reuse while providing platform-specific optimizations for Google Home and Amazon Alexa integration.