A TypeScript-based framework for building cloud integration servers for Dynamic Controls Home Automation System.
npm install @dynamiccontrols/cloud-integration-serverA TypeScript-based framework for building cloud integration servers for Dynamic Controls Home Automation System.
Create a new class that extends CloudIntegrationServer and implement the abstract methods:
``typescript
import { CloudIntegrationServer, LoggerInterface, CloudIntegrationServerOptions, type Context } from './src/cloudIntegrationServer';
import type { ExecuteRequestPayload, ExecuteResponsePayload, SyncResponsePayload } from './src/types';
class MyIntegrationServer extends CloudIntegrationServer {
constructor(logger: LoggerInterface, options: CloudIntegrationServerOptions) {
super(logger, options);
}
async handleExecute(request: ExecuteRequestPayload, context: Context): Promise
// Implement your EXECUTE logic here
// Handle device executions and optionally report state changes
return { status: 'SUCCESS' };
}
async handleSync(context: Context): Promise
// Implement your SYNC logic here
// Return device information for synchronization
return {
agentUserId: 'user-id',
devices: []
};
}
}
`
`typescript
const logger: LoggerInterface = {
info: (message, meta) => console.log(message, meta),
error: (message, meta) => console.error(message, meta)
};
const options: CloudIntegrationServerOptions = {
port: 3000,
path: '/api/integration',
reportStateUrl: 'https://api.example.com/report-state',
apiKey: 'your-api-key'
};
const server = new MyIntegrationServer(logger, options);
await server.start();
`
#### handleExecute(request, context)
Abstract method to handle EXECUTE requests. Implement device control logic here.
#### handleSync(context)
Abstract method to handle SYNC requests. Return device information for synchronization.
#### reportState(userId, payload)
Report device state changes to the configured report state URL.
The server requires the following configuration options:
- port: Server port numberpath
- : API endpoint pathreportStateUrl
- : URL for reporting state changesapiKey
- : API key for authentication when reporting state changes
`bash`
npm run build
`bash``
npm run build:test
npm test