Skip to content

Commit 1f7b1af

Browse files
razor-xseambot
andauthored
Prefer null checks for capability flags (#715)
* Prefer null checks for capability flags * ci: Format code --------- Co-authored-by: Seam Bot <[email protected]>
1 parent e0872ea commit 1f7b1af

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/lib/seam/locks/lock-device.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ export type LockDevice = Omit<Device, 'properties'> & {
77

88
export const isLockDevice = (device: Device): device is LockDevice => {
99
return (
10-
'locked' in device.properties ||
11-
'can_remotely_lock' in device ||
12-
'can_remotely_unlock' in device ||
13-
'can_program_online_access_codes' in device ||
14-
'can_program_offline_access_codes' in device ||
15-
device.properties.online_access_codes_enabled === true ||
16-
device.properties.offline_access_codes_enabled === true
10+
device.properties.locked != null ||
11+
device.can_remotely_lock != null ||
12+
device.can_remotely_unlock != null ||
13+
device.can_program_online_access_codes != null ||
14+
device.can_program_offline_access_codes != null ||
15+
device.properties.online_access_codes_enabled != null ||
16+
device.properties.offline_access_codes_enabled != null
1717
)
1818
}

src/lib/seam/noise-sensors/noise-sensor-device.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ export type NoiseSensorDevice = Omit<Device, 'properties'> & {
77

88
export const isNoiseSensorDevice = (
99
device: Device
10-
): device is NoiseSensorDevice => 'noise_level_decibels' in device.properties
10+
): device is NoiseSensorDevice => device.properties.noise_level_decibels != null

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface ClimateSetting {
3737
export const isThermostatDevice = (
3838
device: Device
3939
): device is ThermostatDevice =>
40-
'available_climate_presets' in device.properties
40+
device.properties.available_climate_presets != null
4141

4242
export type ThermostatClimatePreset =
4343
ThermostatDevice['properties']['available_climate_presets'][number]

0 commit comments

Comments
 (0)