-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaces.ts
More file actions
64 lines (53 loc) · 1.81 KB
/
Copy pathinterfaces.ts
File metadata and controls
64 lines (53 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import type { DateTime } from 'luxon'
import type { IBaseDeviceModel, IDeviceModel } from '../models/index.ts'
import type { Attributes, PostAttributes } from '../types.ts'
import {
type DerogationMode,
type Mode,
type TemperatureCompensation,
Product,
} from '../enums.ts'
export interface IDeviceFacade extends IBaseDeviceModel {
readonly isOn: boolean
readonly mode: Mode
readonly onSync: () => Promise<void>
readonly setValues: (data: PostAttributes) => Promise<Partial<Attributes>>
readonly values: () => Promise<Attributes>
}
export interface IDeviceGlowFacade extends IDeviceV2Facade {
readonly comfortTemperature: number
readonly currentTemperature: number
readonly ecoTemperature: number
readonly temperatureCompensation: TemperatureCompensation
}
export interface IDeviceProFacade extends IDeviceGlowFacade {
readonly currentHumidity: number
readonly currentMode: Mode
readonly isDetectingOpenWindow: boolean
readonly isPresence: boolean
}
export interface IDeviceV2Facade extends IDeviceFacade {
readonly derogationEndDate: DateTime | null
readonly derogationEndString: string | null
readonly derogationMode: DerogationMode
readonly derogationTime: number
readonly isLocked: boolean
readonly isTimer: boolean
}
export interface IFacadeManager {
readonly get: (instance?: IDeviceModel) => IDeviceFacade | null
}
export type IDeviceFacadeAny =
| IDeviceFacade
| IDeviceGlowFacade
| IDeviceProFacade
| IDeviceV2Facade
export const supportsV2 = (
device: IDeviceFacadeAny,
): device is IDeviceV2Facade => device.product >= Product.v2
export const supportsGlow = (
device: IDeviceFacadeAny,
): device is IDeviceGlowFacade => device.product >= Product.glow
export const supportsPro = (
device: IDeviceFacadeAny,
): device is IDeviceProFacade => device.product >= Product.pro