An object containing configuration parameters for the topic handler.
A decorator function.
@kosTopicHandler({
topic: 'temperature/update',
websocket: true
})
handleTemperature(payload: TemperatureData) { }
@kosTopicHandler({
topic: 'rapid/updates',
websocket: true,
debounce: 1000 // Wait 1 second after last event
})
handleRapidUpdates(payload: UpdateData) { }
@kosTopicHandler({
topic: 'log/entry',
websocket: true,
buffer: { time: 5000, maxSize: 100 }
})
handleLogBatch(entries: LogEntry[]) { }
@kosTopicHandler({
topic: '/config/system/*',
websocket: true,
wildcardName: 'configPath'
})
handleConfigUpdate(payload: ConfigData, raw: ApiCallbackWithWildcard<any>) {
// raw.wildcardCapture.configPath = "network/timeout" (everything after "/config/system/")
}
const DEVICE_ID = createPropKey<DeviceModel>('deviceId');
@kosTopicHandler({
topic: `/devices/${DEVICE_ID}/sensors/*`,
websocket: true,
wildcardName: 'sensorPath'
})
handleSensorEvent(payload: SensorData, raw: ApiCallbackWithWildcard<any>) {
// raw.wildcardCapture.sensorPath = "temperature/reading" (everything after device-specific prefix)
}
Decorator for defining a Kos topic handler function within a Kos Data Model class.