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.
 
 
 
 
 
 

71 lines
1.5 KiB

import type { DeviceIconName } from "$lib/components/DeviceIcon.svelte"
import type { ColorFlags, ColorRGB } from "./color"
export default interface Device {
id: string
name: string
icon: DeviceIconName
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?: DeviceIconName
}
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,
});
export function copyState(state?: State | null): State {
return { ...(state || BLANK_STATE) };
}
export type DeviceEditOp = "none" | "assign" | "rename" | "change_icon" | "move_group" | "move_room" | "change_tags" | "change_roles";