@@ -24,6 +24,7 @@ export type BatteryStatus = z.infer<typeof battery_status>
24
24
const common_device_error = z . object ( {
25
25
message : z . string ( ) ,
26
26
is_device_error : z . literal ( true ) ,
27
+ created_at : z . string ( ) . datetime ( ) ,
27
28
} )
28
29
29
30
const error_code_description =
@@ -55,6 +56,16 @@ const device_disconnected = common_device_error
55
56
} )
56
57
. describe ( 'Device is disconnected' )
57
58
59
+ const account_disconnected = common_device_error
60
+ . extend ( {
61
+ error_code : z
62
+ . literal ( 'account_disconnected' )
63
+ . describe ( error_code_description ) ,
64
+ is_connected_account_error : z . literal ( true ) ,
65
+ is_device_error : z . literal ( false ) ,
66
+ } )
67
+ . describe ( 'Account is disconnected' )
68
+
58
69
const empty_backup_access_code_pool = common_device_error
59
70
. extend ( {
60
71
error_code : z
@@ -79,11 +90,13 @@ const august_lock_missing_bridge = common_device_error
79
90
} )
80
91
. describe ( 'Lock is not connected to the Seam Bridge.' )
81
92
82
- const salto_site_user_limit_reached = common_device_error
93
+ const salto_ks_subscription_limit_exceeded = common_device_error
83
94
. extend ( {
84
95
error_code : z
85
- . literal ( 'salto_site_user_limit_reached ' )
96
+ . literal ( 'salto_ks_subscription_limit_exceeded ' )
86
97
. describe ( error_code_description ) ,
98
+ is_connected_account_error : z . literal ( true ) ,
99
+ is_device_error : z . literal ( false ) ,
87
100
} )
88
101
. describe ( 'Salto site user limit reached.' )
89
102
@@ -121,14 +134,15 @@ const subscription_required = common_device_error
121
134
122
135
export const device_error = z
123
136
. discriminatedUnion ( 'error_code' , [
137
+ account_disconnected ,
138
+ salto_ks_subscription_limit_exceeded ,
124
139
device_offline ,
125
140
device_removed ,
126
141
hub_disconnected ,
127
142
device_disconnected ,
128
143
empty_backup_access_code_pool ,
129
144
august_lock_not_authorized ,
130
145
august_lock_missing_bridge ,
131
- salto_site_user_limit_reached ,
132
146
ttlock_lock_not_paired_to_gateway ,
133
147
missing_device_credentials ,
134
148
auxiliary_heat_running ,
@@ -138,11 +152,36 @@ export const device_error = z
138
152
139
153
export type DeviceError = z . infer < typeof device_error >
140
154
155
+ const device_error_map = z . object ( {
156
+ device_offline : device_offline . optional ( ) . nullable ( ) ,
157
+ device_removed : device_removed . optional ( ) . nullable ( ) ,
158
+ hub_disconnected : hub_disconnected . optional ( ) . nullable ( ) ,
159
+ device_disconnected : device_disconnected . optional ( ) . nullable ( ) ,
160
+ account_disconnected : account_disconnected . optional ( ) . nullable ( ) ,
161
+ empty_backup_access_code_pool : empty_backup_access_code_pool
162
+ . optional ( )
163
+ . nullable ( ) ,
164
+ august_lock_not_authorized : august_lock_not_authorized . optional ( ) . nullable ( ) ,
165
+ august_lock_missing_bridge : august_lock_missing_bridge . optional ( ) . nullable ( ) ,
166
+ salto_ks_subscription_limit_exceeded : salto_ks_subscription_limit_exceeded
167
+ . optional ( )
168
+ . nullable ( ) ,
169
+ ttlock_lock_not_paired_to_gateway : ttlock_lock_not_paired_to_gateway
170
+ . optional ( )
171
+ . nullable ( ) ,
172
+ missing_device_credentials : missing_device_credentials . optional ( ) . nullable ( ) ,
173
+ auxiliary_heat_running : auxiliary_heat_running . optional ( ) . nullable ( ) ,
174
+ subscription_required : subscription_required . optional ( ) . nullable ( ) ,
175
+ } )
176
+
177
+ export type DeviceErrorMap = z . infer < typeof device_error_map >
178
+
141
179
const warning_code_description =
142
180
'Unique identifier of the type of warning. Enables quick recognition and categorization of the issue.'
143
181
144
182
const common_device_warning = z . object ( {
145
183
message : z . string ( ) ,
184
+ created_at : z . string ( ) . datetime ( ) ,
146
185
} )
147
186
148
187
const partial_backup_access_code_pool = common_device_warning
@@ -297,6 +336,47 @@ const device_warning = z.discriminatedUnion('warning_code', [
297
336
298
337
export type DeviceWarning = z . infer < typeof device_warning >
299
338
339
+ export const device_warning_map = z . object ( {
340
+ partial_backup_access_code_pool : partial_backup_access_code_pool
341
+ . optional ( )
342
+ . nullable ( ) ,
343
+ many_active_backup_codes : many_active_backup_codes . optional ( ) . nullable ( ) ,
344
+ salto_unknown_device_type : salto_unknown_device_type . optional ( ) . nullable ( ) ,
345
+ wyze_device_missing_gateway : wyze_device_missing_gateway
346
+ . optional ( )
347
+ . nullable ( ) ,
348
+ functional_offline_device : functional_offline_device . optional ( ) . nullable ( ) ,
349
+ third_party_integration_detected : third_party_integration_detected
350
+ . optional ( )
351
+ . nullable ( ) ,
352
+ nest_thermostat_in_manual_eco_mode : nest_thermostat_in_manual_eco_mode
353
+ . optional ( )
354
+ . nullable ( ) ,
355
+ ttlock_lock_gateway_unlocking_not_enabled :
356
+ ttlock_lock_gateway_unlocking_not_enabled . optional ( ) . nullable ( ) ,
357
+ ttlock_weak_gateway_signal : ttlock_weak_gateway_signal . optional ( ) . nullable ( ) ,
358
+ temperature_threshold_exceeded : temperature_threshold_exceeded
359
+ . optional ( )
360
+ . nullable ( ) ,
361
+ device_communication_degraded : device_communication_degraded
362
+ . optional ( )
363
+ . nullable ( ) ,
364
+ scheduled_maintenance_window : scheduled_maintenance_window
365
+ . optional ( )
366
+ . nullable ( ) ,
367
+ device_has_flaky_connection : device_has_flaky_connection
368
+ . extend ( {
369
+ _event_id : z . string ( ) . uuid ( ) . optional ( ) ,
370
+ } )
371
+ . optional ( )
372
+ . nullable ( ) ,
373
+ salto_office_mode : salto_office_mode . optional ( ) . nullable ( ) ,
374
+ salto_privacy_mode : salto_privacy_mode . optional ( ) . nullable ( ) ,
375
+ unknown_issue_with_phone : unknown_issue_with_phone . optional ( ) . nullable ( ) ,
376
+ } )
377
+
378
+ export type DeviceWarningMap = z . infer < typeof device_warning_map >
379
+
300
380
export const common_device_properties = z . object ( {
301
381
online : z . boolean ( ) . describe ( 'Indicates whether the device is online.' ) ,
302
382
name : z . string ( ) . describe ( `
@@ -440,6 +520,18 @@ export const common_device_properties = z.object({
440
520
. optional ( ) ,
441
521
} )
442
522
523
+ export const device_and_connected_account_error_options = [
524
+ ...device_error . options ,
525
+ ...connected_account_error . options . filter (
526
+ ( _connected_account_error ) =>
527
+ ! device_error . options . some (
528
+ ( _device_error ) =>
529
+ _device_error . shape . error_code . value ===
530
+ _connected_account_error . shape . error_code . value ,
531
+ ) ,
532
+ ) ,
533
+ ]
534
+
443
535
export const device = z
444
536
. object ( {
445
537
device_id : z . string ( ) . uuid ( ) . describe ( 'Unique identifier for the device.' ) ,
@@ -495,7 +587,14 @@ export const device = z
495
587
. array (
496
588
z . discriminatedUnion ( 'error_code' , [
497
589
...device_error . options ,
498
- ...connected_account_error . options ,
590
+ ...connected_account_error . options . filter (
591
+ ( _connected_account_error ) =>
592
+ ! device_error . options . some (
593
+ ( _device_error ) =>
594
+ _device_error . shape . error_code . value ===
595
+ _connected_account_error . shape . error_code . value ,
596
+ ) ,
597
+ ) ,
499
598
] ) ,
500
599
)
501
600
. describe (
0 commit comments