Skip to content

Commit 55088e3

Browse files
razor-xseambot
andauthored
fix: Use available_hvac_mode_settings over bool props (#655)
* Update types and seam client * fix: Use available_hvac_mode_settings over bool props * ci: Format code --------- Co-authored-by: Seam Bot <devops@getseam.com>
1 parent 72d2435 commit 55088e3

File tree

11 files changed

+37
-84
lines changed

11 files changed

+37
-84
lines changed

.storybook/seed-fake.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,6 @@ export const seedFake = (db) => {
378378
online: true,
379379
is_cooling: false,
380380
is_heating: false,
381-
is_heating_available: true,
382-
is_cooling_available: true,
383381
manufacturer: 'ecobee',
384382
is_fan_running: false,
385383
model: {
@@ -397,8 +395,6 @@ export const seedFake = (db) => {
397395
current_climate_setting: {
398396
hvac_mode_setting: 'heat_cool',
399397
manual_override_allowed: false,
400-
automatic_cooling_enabled: true,
401-
automatic_heating_enabled: true,
402398
cooling_set_point_fahrenheit: 75,
403399
cooling_set_point_celsius: 23.8,
404400
heating_set_point_fahrenheit: 65,
@@ -407,8 +403,6 @@ export const seedFake = (db) => {
407403
default_climate_setting: {
408404
hvac_mode_setting: 'heat_cool',
409405
manual_override_allowed: false,
410-
automatic_cooling_enabled: true,
411-
automatic_heating_enabled: true,
412406
cooling_set_point_fahrenheit: 75,
413407
cooling_set_point_celsius: 23.8,
414408
heating_set_point_fahrenheit: 65,
@@ -464,16 +458,12 @@ export const seedFake = (db) => {
464458
current_climate_setting: {
465459
hvac_mode_setting: 'heat',
466460
manual_override_allowed: false,
467-
automatic_cooling_enabled: false,
468-
automatic_heating_enabled: true,
469461
heating_set_point_celsius: 20,
470462
heating_set_point_fahrenheit: 68,
471463
},
472464
available_hvac_mode_settings: ['off', 'cool', 'heat', 'heat_cool'],
473465
can_enable_automatic_cooling: true,
474466
can_enable_automatic_heating: true,
475-
is_cooling_available: true,
476-
is_heating_available: true,
477467
max_cooling_set_point_celsius: 33.333333333333336,
478468
max_heating_set_point_celsius: 26.11111111111111,
479469
min_cooling_set_point_celsius: 18.333333333333336,
@@ -571,8 +561,6 @@ export const seedFake = (db) => {
571561
schedule_ends_at: '2024-08-01T00:00:00.000Z',
572562
schedule_type: 'time_bound',
573563
manual_override_allowed: true,
574-
automatic_heating_enabled: false,
575-
automatic_cooling_enabled: true,
576564
hvac_mode_setting: 'cool',
577565
cooling_set_point_fahrenheit: 70,
578566
cooling_set_point_celsius: 21,
@@ -587,8 +575,6 @@ export const seedFake = (db) => {
587575
schedule_ends_at: '2024-07-14T00:00:00.000Z',
588576
schedule_type: 'time_bound',
589577
manual_override_allowed: true,
590-
automatic_heating_enabled: true,
591-
automatic_cooling_enabled: true,
592578
hvac_mode_setting: 'heat_cool',
593579
heating_set_point_fahrenheit: 65,
594580
heating_set_point_celsius: 18,
@@ -605,8 +591,6 @@ export const seedFake = (db) => {
605591
schedule_ends_at: '2027-08-14T00:00:00.000Z',
606592
schedule_type: 'time_bound',
607593
manual_override_allowed: true,
608-
automatic_heating_enabled: false,
609-
automatic_cooling_enabled: true,
610594
hvac_mode_setting: 'cool',
611595
cooling_set_point_fahrenheit: 72,
612596
cooling_set_point_celsius: 22.2222,

package-lock.json

Lines changed: 26 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
}
128128
},
129129
"dependencies": {
130-
"@seamapi/http": "^1.0.0",
130+
"@seamapi/http": "^1.2.0",
131131
"@tanstack/react-query": "^5.27.5",
132132
"classnames": "^2.3.2",
133133
"luxon": "^3.3.0",
@@ -144,7 +144,7 @@
144144
"@rxfork/r2wc-react-to-web-component": "^2.4.0",
145145
"@seamapi/fake-devicedb": "^1.6.1",
146146
"@seamapi/fake-seam-connect": "^1.69.1",
147-
"@seamapi/types": "^1.199.0",
147+
"@seamapi/types": "^1.228.0",
148148
"@storybook/addon-designs": "^7.0.1",
149149
"@storybook/addon-essentials": "^7.0.2",
150150
"@storybook/addon-links": "^7.0.2",

src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { NestedClimateSettingScheduleTable } from 'lib/seam/components/ClimateSe
88
import type { NestedSpecificDeviceDetailsProps } from 'lib/seam/components/DeviceDetails/DeviceDetails.js'
99
import { DeviceInfo } from 'lib/seam/components/DeviceDetails/DeviceInfo.js'
1010
import { useClimateSettingSchedules } from 'lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.js'
11-
import { getSupportedThermostatModes } from 'lib/seam/thermostats/temperature-bounds.js'
1211
import type {
1312
HvacModeSetting,
1413
ThermostatDevice,
@@ -252,12 +251,13 @@ function ClimateSettingRow({
252251
const deviceCoolValue =
253252
device.properties.current_climate_setting.cooling_set_point_fahrenheit
254253

255-
const supportedModes = getSupportedThermostatModes(device)
254+
const availableHvacModes = device.properties.available_hvac_mode_settings
256255

257256
const [showSuccess, setShowSuccess] = useState(false)
258257
const [mode, setMode] = useState<HvacModeSetting>(
259-
(supportedModes.includes('heat_cool') ? 'heat_cool' : supportedModes[0]) ??
260-
'off'
258+
(availableHvacModes.includes('heat_cool')
259+
? 'heat_cool'
260+
: availableHvacModes[0]) ?? 'off'
261261
)
262262

263263
const [heatValue, setHeatValue] = useState(
@@ -413,7 +413,7 @@ function ClimateSettingRow({
413413
<ClimateModeMenu
414414
mode={mode}
415415
onChange={setMode}
416-
supportedModes={supportedModes}
416+
supportedModes={availableHvacModes}
417417
/>
418418
</div>
419419
</AccordionRow>

src/lib/seam/thermostats/temperature-bounds.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import type {
2-
HvacModeSetting,
3-
ThermostatDevice,
4-
} from 'lib/seam/thermostats/thermostat-device.js'
1+
import type { HvacModeSetting } from 'lib/seam/thermostats/thermostat-device.js'
52

63
export interface ControlBounds {
74
mode: Exclude<HvacModeSetting, 'off'>
@@ -54,25 +51,3 @@ export const getTemperatureBounds = (
5451
heat: getHeatBounds(controlBounds),
5552
cool: getCoolBounds(controlBounds),
5653
})
57-
58-
export const getSupportedThermostatModes = (
59-
device: ThermostatDevice
60-
): HvacModeSetting[] => {
61-
const allModes: HvacModeSetting[] = ['heat', 'cool', 'heat_cool', 'off']
62-
63-
return allModes.filter((mode) => {
64-
switch (mode) {
65-
case 'cool':
66-
return device.properties.is_cooling_available ?? false
67-
case 'heat':
68-
return device.properties.is_heating_available ?? false
69-
case 'heat_cool':
70-
return (
71-
(device.properties.is_heating_available ?? false) &&
72-
(device.properties.is_cooling_available ?? false)
73-
)
74-
default:
75-
return true
76-
}
77-
})
78-
}

src/lib/seam/thermostats/thermostat-device.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ export type ThermostatDevice = Omit<Device, 'properties'> & {
1010
| 'is_heating'
1111
| 'is_cooling'
1212
| 'is_fan_running'
13-
| 'is_cooling_available'
14-
| 'is_heating_available'
1513
| 'available_hvac_mode_settings'
1614
| 'fan_mode_setting'
1715
| 'current_climate_setting'
@@ -28,8 +26,6 @@ export type HvacModeSetting =
2826

2927
// UPSTREAM: ClimateSetting missing in @seamapi/types.
3028
export interface ClimateSetting {
31-
automatic_heating_enabled?: boolean
32-
automatic_cooling_enabled?: boolean
3329
hvac_mode_setting?: HvacModeSetting
3430
cooling_set_point_celsius?: number
3531
heating_set_point_celsius?: number

src/lib/seam/thermostats/use-cool-thermostat.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ const getUpdatedDevice = (
100100
current_climate_setting: {
101101
...properties.current_climate_setting,
102102
hvac_mode_setting: 'cool',
103-
automatic_heating_enabled: false,
104-
automatic_cooling_enabled: true,
105103
heating_set_point_celsius: undefined,
106104
heating_set_point_fahrenheit: undefined,
107105
cooling_set_point_celsius: getCoolingSetPointCelsius(

src/lib/seam/thermostats/use-heat-cool-thermostat.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ const getUpdatedDevice = (
106106
current_climate_setting: {
107107
...properties.current_climate_setting,
108108
hvac_mode_setting: 'heat_cool',
109-
automatic_heating_enabled: true,
110-
automatic_cooling_enabled: true,
111109
heating_set_point_celsius: getHeatingSetPointCelsius(
112110
variables,
113111
device

src/lib/seam/thermostats/use-heat-thermostat.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ const getUpdatedDevice = (
100100
current_climate_setting: {
101101
...properties.current_climate_setting,
102102
hvac_mode_setting: 'heat',
103-
automatic_heating_enabled: true,
104-
automatic_cooling_enabled: false,
105103
cooling_set_point_celsius: undefined,
106104
cooling_set_point_fahrenheit: undefined,
107105
heating_set_point_celsius: getHeatingSetPointCelsius(

src/lib/seam/thermostats/use-set-thermostat-off.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ const getUpdatedDevice = (device: Device): Device => {
9292
is_heating: false,
9393
current_climate_setting: {
9494
...properties.current_climate_setting,
95-
automatic_cooling_enabled: false,
96-
automatic_heating_enabled: false,
9795
hvac_mode_setting: 'off',
9896
heating_set_point_celsius: undefined,
9997
heating_set_point_fahrenheit: undefined,

0 commit comments

Comments
 (0)