You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.2 KiB
62 lines
1.2 KiB
import type { IconName } from "$lib/components/DeviceIcon.svelte"
|
|
import type { ColorFlags, ColorRGB } from "./color"
|
|
|
|
export default interface Device {
|
|
id: string
|
|
name: string
|
|
hwMetadata: HardwareMetadata | null
|
|
hwState: HardwareState | null
|
|
desiredColorRgb: ColorRGB | null
|
|
activeColorRgb: ColorRGB | null
|
|
desiredState: State,
|
|
aliases: string[],
|
|
assignment: string,
|
|
sensors: Sensors
|
|
}
|
|
|
|
export interface Sensors {
|
|
lastMotion?: number
|
|
temperature?: number
|
|
}
|
|
|
|
export interface HardwareState {
|
|
id: string
|
|
internalName: string
|
|
supportFlags: SupportFlags
|
|
colorFlags: ColorFlags
|
|
buttons: string[] | null
|
|
state: State
|
|
batteryPercentage: number
|
|
unreachable: boolean
|
|
}
|
|
|
|
export interface HardwareMetadata {
|
|
firmwareVersion?: string
|
|
icon?: IconName
|
|
}
|
|
|
|
export interface State {
|
|
power: boolean | null
|
|
temperature: number | null
|
|
intensity: number | null
|
|
color: string | null
|
|
}
|
|
|
|
export enum SupportFlags {
|
|
Power = 1 << 0,
|
|
Intensity = 1 << 1,
|
|
Color = 1 << 2,
|
|
Temperature = 1 << 3,
|
|
SensorButtons = 1 << 4,
|
|
SensorTemperature = 1 << 5,
|
|
SensorLightLevel = 1 << 6,
|
|
SensorPresence = 1 << 7,
|
|
}
|
|
|
|
|
|
export const BLANK_STATE: State = (Object.seal||(v=>v))({
|
|
power: null,
|
|
temperature: null,
|
|
intensity: null,
|
|
color: null,
|
|
});
|