Refactor sensor data handling for new API and WebSocket format
- Update SensorConsumptionTable to use new sensorStore and websocketStore - Normalize sensor and reading interfaces for consistency - Remove legacy energy data handling and mapping logic - Update API and store types for new backend schema - Fetch sensors on mount in SensorConsumptionTable - Simplify WebSocket data processing and remove legacy code
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
type DataResponse,
|
||||
type SensorType,
|
||||
type SensorStatus,
|
||||
type SensorMetadata,
|
||||
} from './api'
|
||||
|
||||
export const sensorsApi = {
|
||||
@@ -13,8 +14,24 @@ export const sensorsApi = {
|
||||
room?: string
|
||||
sensor_type?: SensorType
|
||||
status?: SensorStatus
|
||||
}): Promise<SensorDevice[]> {
|
||||
return apiClient.get<SensorDevice[]>('/api/v1/sensors/get', params)
|
||||
}): Promise<{
|
||||
sensors: SensorDevice[]
|
||||
count: number
|
||||
filters: {
|
||||
room: string
|
||||
sensor_type: SensorType
|
||||
status: SensorStatus
|
||||
}
|
||||
}> {
|
||||
return apiClient.get<{
|
||||
sensors: SensorDevice[]
|
||||
count: number
|
||||
filters: {
|
||||
room: string
|
||||
sensor_type: SensorType
|
||||
status: SensorStatus
|
||||
}
|
||||
}>('/api/v1/sensors/get', params)
|
||||
},
|
||||
|
||||
async getSensor(sensorId: string): Promise<SensorDevice> {
|
||||
@@ -39,7 +56,7 @@ export const sensorsApi = {
|
||||
|
||||
async updateSensorMetadata(
|
||||
sensorId: string,
|
||||
metadata: Record<string, any>,
|
||||
metadata: SensorMetadata,
|
||||
): Promise<{ message: string }> {
|
||||
return apiClient.put<{ message: string }>(`/api/v1/sensors/${sensorId}/metadata`, metadata)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user