@seamapi/types 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
+ import { z } from 'zod'
2
+
1
3
  import {
2
4
  access_code_capability_properties,
3
5
  access_code_code_constraint,
@@ -21,10 +23,12 @@ export {
21
23
  }
22
24
 
23
25
  // todo: discriminate based on capability and remove intersection type
24
- export const capability_properties = access_code_capability_properties
25
- .partial()
26
- .merge(lock_capability_properties.partial())
27
- .merge(thermostat_capability_properties.partial())
26
+ export const capability_properties = z.intersection(
27
+ access_code_capability_properties
28
+ .partial()
29
+ .merge(lock_capability_properties.partial()),
30
+ thermostat_capability_properties,
31
+ )
28
32
 
29
33
  export type { AccessCodeConstraint } from './access-code.js'
30
34
  export type { ClimateSetting, HvacModeSetting } from './thermostat.js'
@@ -29,13 +29,15 @@ export const hvac_mode_setting = z.enum(['off', 'heat', 'cool', 'heatcool'])
29
29
 
30
30
  export type HvacModeSetting = z.infer<typeof hvac_mode_setting>
31
31
 
32
- export const thermostat_capability_properties = z.object({
32
+ const base_thermostat_capability_properties = z.object({
33
33
  temperature_fahrenheit: z.number(),
34
34
  temperature_celsius: z.number(),
35
35
  relative_humidity: z.number().min(0).max(1),
36
36
  can_enable_automatic_heating: z.boolean(),
37
37
  can_enable_automatic_cooling: z.boolean(),
38
38
  available_hvac_mode_settings: z.array(hvac_mode_setting),
39
+ is_heating_available: z.literal(false),
40
+ is_cooling_available: z.literal(false),
39
41
  is_heating: z.boolean(),
40
42
  is_cooling: z.boolean(),
41
43
  is_fan_running: z.boolean(),
@@ -53,3 +55,43 @@ export const thermostat_capability_properties = z.object({
53
55
  is_climate_setting_schedule_active: z.boolean(),
54
56
  active_climate_setting_schedule: climate_setting_schedule.optional(),
55
57
  })
58
+
59
+ export const cooling_thermostat_capability_properties =
60
+ base_thermostat_capability_properties.merge(
61
+ z.object({
62
+ min_cooling_set_point_celsius: z.number(),
63
+ min_cooling_set_point_fahrenheit: z.number(),
64
+ max_cooling_set_point_celsius: z.number(),
65
+ max_cooling_set_point_fahrenheit: z.number(),
66
+ is_cooling_available: z.literal(true),
67
+ }),
68
+ )
69
+
70
+ export const heating_thermostat_capability_properties =
71
+ base_thermostat_capability_properties.merge(
72
+ z.object({
73
+ min_heating_set_point_celsius: z.number(),
74
+ min_heating_set_point_fahrenheit: z.number(),
75
+ max_heating_set_point_celsius: z.number(),
76
+ max_heating_set_point_fahrenheit: z.number(),
77
+ is_heating_available: z.literal(true),
78
+ }),
79
+ )
80
+
81
+ export const heating_cooling_thermostat_capability_properties =
82
+ cooling_thermostat_capability_properties
83
+ .merge(heating_thermostat_capability_properties)
84
+ .merge(
85
+ z.object({
86
+ is_cooling_available: z.literal(true),
87
+ is_heating_available: z.literal(true),
88
+ min_heating_cooling_delta_celsius: z.number(),
89
+ min_heating_cooling_delta_fahrenheit: z.number(),
90
+ }),
91
+ )
92
+
93
+ export const thermostat_capability_properties = z.union([
94
+ heating_cooling_thermostat_capability_properties.partial(),
95
+ heating_thermostat_capability_properties.partial(),
96
+ cooling_thermostat_capability_properties.partial(),
97
+ ])
@@ -150,16 +150,6 @@ export const device_metadata = z
150
150
  ecobee_metadata: z.object({
151
151
  ecobee_device_id: z.string(),
152
152
  device_name: z.string(),
153
- min_heating_set_point_fahrenheit: z.number().optional(),
154
- max_heating_set_point_fahrenheit: z.number().optional(),
155
- min_cooling_set_point_fahrenheit: z.number().optional(),
156
- max_cooling_set_point_fahrenheit: z.number().optional(),
157
- min_heating_set_point_celsius: z.number().optional(),
158
- max_heating_set_point_celsius: z.number().optional(),
159
- min_cooling_set_point_celsius: z.number().optional(),
160
- max_cooling_set_point_celsius: z.number().optional(),
161
- min_delta_heat_cool_set_points_fahrenheit: z.number().optional(),
162
- min_delta_heat_cool_set_points_celsius: z.number().optional(),
163
153
  }),
164
154
 
165
155
  hubitat_metadata: z.object({