1
1
import { JSONSchema7 } from 'json-schema' ;
2
- import { CustomClusters } from './zcl/definition/tstype'
2
+ import { CustomClusters } from './zcl/definition/tstype' ;
3
3
4
- export type DeviceType = " EndDevice" | " Router" | " Coordinator" ;
4
+ export type DeviceType = ' EndDevice' | ' Router' | ' Coordinator' ;
5
5
export type FriendlyName = string ;
6
6
export type IEEEEAddress = string ;
7
7
8
8
export type OTAState = {
9
- state : " available" | " updating" ;
9
+ state : ' available' | ' updating' ;
10
10
progress : number ;
11
11
remaining : number ;
12
- }
12
+ } ;
13
13
export type RGBColor = {
14
14
r : number ;
15
15
g : number ;
16
16
b : number ;
17
- }
17
+ } ;
18
18
export type HueSaturationColor = {
19
19
hue : number ;
20
20
saturation : number ;
21
- }
21
+ } ;
22
22
23
23
export type XYColor = {
24
24
x : number ;
25
25
y : number ;
26
- }
26
+ } ;
27
27
export type AnyColor = RGBColor | XYColor | HueSaturationColor ;
28
28
export type DeviceState = Record < string , unknown > ;
29
29
export type Cluster = string | number ;
@@ -56,8 +56,8 @@ export interface ClusterDefinition {
56
56
}
57
57
58
58
export interface BridgeDefinitions {
59
- clusters : Readonly < Record < Cluster , Readonly < ClusterDefinition > > > ,
60
- custom_clusters : Readonly < Record < IEEEEAddress , Readonly < CustomClusters > > > ,
59
+ clusters : Readonly < Record < Cluster , Readonly < ClusterDefinition > > > ;
60
+ custom_clusters : Readonly < Record < IEEEEAddress , Readonly < CustomClusters > > > ;
61
61
}
62
62
63
63
export interface Meta {
@@ -85,7 +85,6 @@ export interface AdvancedConfig {
85
85
elapsed : boolean ;
86
86
last_seen : 'disable' | 'ISO_8601' | 'ISO_8601_local' | 'epoch' ;
87
87
legacy_api : boolean ;
88
-
89
88
}
90
89
export interface Z2MConfig {
91
90
homeassistant : boolean ;
@@ -94,25 +93,16 @@ export interface Z2MConfig {
94
93
device_options : DeviceConfig ;
95
94
[ k : string ] : unknown ;
96
95
}
97
- export interface BridgeConfig {
98
- version : string ;
99
- commit : string ;
100
- coordinator : Coordinator ;
101
- network : Network ;
102
- log_level : string ;
103
- permit_join : boolean ;
104
-
105
- }
106
- export type BridgeState = "online" | "offline" ;
96
+ export type BridgeState = 'online' | 'offline' ;
107
97
export interface BridgeInfo {
108
98
config : Z2MConfig ;
109
99
config_schema : JSONSchema7 ;
110
100
permit_join : boolean ;
111
101
permit_join_timeout : number ;
112
102
commit ?: string ;
113
103
version ?: string ;
114
- zigbee_herdsman_converters : { version : string } ,
115
- zigbee_herdsman : { version : string } ,
104
+ zigbee_herdsman_converters : { version : string } ;
105
+ zigbee_herdsman : { version : string } ;
116
106
coordinator ?: {
117
107
meta ?: {
118
108
revision ?: string ;
@@ -124,11 +114,10 @@ export interface BridgeInfo {
124
114
restart_required : boolean ;
125
115
}
126
116
127
- export type PowerSource = "Battery" | "Mains (single phase)" | "DC Source" ;
128
-
129
- export type GenericFeatureType = "numeric" | "binary" | "enum" | "text" | "list" ;
130
- export type CompositeFeatureType = "fan" | "light" | "switch" | "cover" | "lock" | "composite" | "climate" ;
117
+ export type PowerSource = 'Battery' | 'Mains (single phase)' | 'DC Source' ;
131
118
119
+ export type GenericFeatureType = 'numeric' | 'binary' | 'enum' | 'text' | 'list' ;
120
+ export type CompositeFeatureType = 'fan' | 'light' | 'switch' | 'cover' | 'lock' | 'composite' | 'climate' ;
132
121
133
122
export enum FeatureAccessMode {
134
123
NONE ,
@@ -140,30 +129,30 @@ export interface GenericExposedFeature {
140
129
type : GenericFeatureType ;
141
130
name : string ;
142
131
label : string ;
143
- unit ?: " string" ;
132
+ unit ?: ' string' ;
144
133
access : FeatureAccessMode ;
145
134
endpoint ?: Endpoint ;
146
135
property ?: string ;
147
136
description ?: string ;
148
137
}
149
138
150
139
export interface BinaryFeature extends GenericExposedFeature {
151
- type : " binary" ;
140
+ type : ' binary' ;
152
141
value_on : unknown ;
153
142
value_off : unknown ;
154
143
value_toggle ?: unknown ;
155
144
}
156
145
157
146
export interface ListFeature extends GenericExposedFeature {
158
- type : " list" ;
147
+ type : ' list' ;
159
148
// bad design decision
160
- item_type : " number" | GenericOrCompositeFeature ;
149
+ item_type : ' number' | GenericOrCompositeFeature ;
161
150
162
151
length_min ?: number ;
163
152
length_max ?: number ;
164
153
}
165
154
166
- export interface CompositeFeature extends Omit < GenericExposedFeature , " type" > {
155
+ export interface CompositeFeature extends Omit < GenericExposedFeature , ' type' > {
167
156
type : CompositeFeatureType ;
168
157
features : GenericOrCompositeFeature [ ] ;
169
158
}
@@ -176,55 +165,55 @@ export interface NumericFeaturePreset {
176
165
description ?: string ;
177
166
}
178
167
export interface NumericFeature extends GenericExposedFeature {
179
- type : " numeric" ;
168
+ type : ' numeric' ;
180
169
value_min ?: number ;
181
170
value_max ?: number ;
182
171
value_step ?: number ;
183
172
presets ?: NumericFeaturePreset [ ] ;
184
173
}
185
174
186
175
export interface TextualFeature extends GenericExposedFeature {
187
- type : " text" ;
176
+ type : ' text' ;
188
177
}
189
178
190
179
export interface EnumFeature extends GenericExposedFeature {
191
- type : " enum" ;
180
+ type : ' enum' ;
192
181
values : unknown [ ] ;
193
182
}
194
183
195
184
export interface GradientFeature extends GenericExposedFeature {
196
- type : " text" ;
197
- name : " gradient" ;
185
+ type : ' text' ;
186
+ name : ' gradient' ;
198
187
length_min : number ;
199
188
length_max : number ;
200
189
}
201
190
202
191
export interface LightFeature extends CompositeFeature {
203
- type : " light" ;
192
+ type : ' light' ;
204
193
}
205
194
206
195
export interface SwitchFeature extends CompositeFeature {
207
- type : " switch" ;
196
+ type : ' switch' ;
208
197
}
209
198
210
199
export interface CoverFeature extends CompositeFeature {
211
- type : " cover" ;
200
+ type : ' cover' ;
212
201
}
213
202
214
203
export interface LockFeature extends CompositeFeature {
215
- type : " lock" ;
204
+ type : ' lock' ;
216
205
}
217
206
export interface FanFeature extends CompositeFeature {
218
- type : " fan" ;
207
+ type : ' fan' ;
219
208
}
220
209
221
210
export interface ClimateFeature extends CompositeFeature {
222
- type : " climate" ;
211
+ type : ' climate' ;
223
212
}
224
213
225
214
export interface ColorFeature extends CompositeFeature {
226
- type : " composite" ;
227
- name : " color_xy" | " color_hs" ;
215
+ type : ' composite' ;
216
+ name : ' color_xy' | ' color_hs' ;
228
217
features : NumericFeature [ ] ;
229
218
}
230
219
@@ -272,7 +261,7 @@ export type Scene = {
272
261
id : number ;
273
262
name ?: string ;
274
263
endpoint ?: Endpoint ;
275
- }
264
+ } ;
276
265
export interface Group extends WithFriendlyName , WithDescription , WithScenes {
277
266
id : number ;
278
267
members : GroupAddress [ ] ;
@@ -294,42 +283,42 @@ export interface Device extends WithFriendlyName, WithDescription {
294
283
endpoints : Record < Endpoint , EndpointDescription > ;
295
284
}
296
285
297
- export type ObjectType = " device" | " group" ;
286
+ export type ObjectType = ' device' | ' group' ;
298
287
export interface BindRule {
299
288
cluster : Cluster ;
300
289
target : {
301
290
id ?: number ;
302
291
endpoint ?: Endpoint ;
303
292
ieee_address ?: IEEEEAddress ;
304
- type : " endpoint" | " group" ;
293
+ type : ' endpoint' | ' group' ;
305
294
} ;
306
-
307
295
}
308
296
309
297
export interface TouchLinkDevice {
310
298
ieee_address : IEEEEAddress ;
311
299
channel : number ;
312
300
}
313
301
314
- export type LastSeenType = "disable" | "ISO_8601" | "ISO_8601_local" | "epoch" ;
315
-
316
- export type KVP = Record < string , unknown >
302
+ export type LastSeenType = 'disable' | 'ISO_8601' | 'ISO_8601_local' | 'epoch' ;
317
303
304
+ export type KVP = Record < string , unknown > ;
318
305
319
- export type Prev = [ never , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ,
320
- 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , ...0 [ ] ]
306
+ export type Prev = [ never , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , ...0 [ ] ] ;
321
307
322
- export type Join < K , P > = K extends string | number ?
323
- P extends string | number ?
324
- `${K } ${"" extends P ? "" : "." } ${P } `
325
- : never : never ;
326
-
327
-
328
- export type Paths < T , D extends number = 10 > = [ D ] extends [ never ] ? never : T extends object ?
329
- { [ K in keyof T ] -?: K extends string | number ?
330
- `${K } ` | Join < K , Paths < T [ K ] , Prev [ D ] > >
308
+ export type Join < K , P > = K extends string | number
309
+ ? P extends string | number
310
+ ? `${K } ${'' extends P ? '' : '.' } ${P } `
331
311
: never
332
- } [ keyof T ] : ""
333
-
334
- export type Leaves < T , D extends number = 10 > = [ D ] extends [ never ] ? never : T extends object ?
335
- { [ K in keyof T ] -?: Join < K , Leaves < T [ K ] , Prev [ D ] > > } [ keyof T ] : "" ;
312
+ : never ;
313
+
314
+ export type Paths < T , D extends number = 10 > = [ D ] extends [ never ]
315
+ ? never
316
+ : T extends object
317
+ ? { [ K in keyof T ] -?: K extends string | number ? `${K } ` | Join < K , Paths < T [ K ] , Prev [ D ] > > : never } [ keyof T ]
318
+ : '' ;
319
+
320
+ export type Leaves < T , D extends number = 10 > = [ D ] extends [ never ]
321
+ ? never
322
+ : T extends object
323
+ ? { [ K in keyof T ] -?: Join < K , Leaves < T [ K ] , Prev [ D ] > > } [ keyof T ]
324
+ : '' ;
0 commit comments