Refactor sensor ID usage and types, add CO2 metrics, update docs
- Standardize on `sensor.sensor_id` throughout components and stores - Add average and max CO2 metrics to sensor store and HomeView - Improve type safety for sensors, actions, and API calls - Update AGENTS.md with repository guidelines - Refine settings store types and utility functions - Add WindowWithAuth interface for auth store access - Minor bug fixes and code cleanup
This commit is contained in:
@@ -131,14 +131,20 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import type { SensorDevice, SensorAction } from '@/services'
|
||||
|
||||
interface ActionParameters {
|
||||
value?: number | string | boolean
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
sensor: any
|
||||
action: any
|
||||
sensor: SensorDevice
|
||||
action: SensorAction
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
execute: [sensorId: string, actionId: string, parameters: any]
|
||||
execute: [sensorId: string, actionId: string, parameters: ActionParameters]
|
||||
close: []
|
||||
}>()
|
||||
|
||||
@@ -182,7 +188,7 @@ const getUnit = () => {
|
||||
const executeAction = async () => {
|
||||
isExecuting.value = true
|
||||
|
||||
const parameters: any = {}
|
||||
const parameters: ActionParameters = {}
|
||||
|
||||
if (props.action.type === 'adjust') {
|
||||
if (hasNumericRange.value) {
|
||||
@@ -195,7 +201,7 @@ const executeAction = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
emit('execute', props.sensor.id, props.action.id, parameters)
|
||||
emit('execute', props.sensor.sensor_id, props.action.id, parameters)
|
||||
} catch (error) {
|
||||
console.error('Failed to execute action:', error)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user