From d35e5c13240ca8402d09a26ce76209c6e92d6797 Mon Sep 17 00:00:00 2001 From: Matt Bateman Date: Thu, 3 Feb 2022 13:56:46 -0800 Subject: [PATCH] Use family instead of type. Works for gates. --- plugins/myq/src/main.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/myq/src/main.ts b/plugins/myq/src/main.ts index 0f00359e0..97afb0c3f 100644 --- a/plugins/myq/src/main.ts +++ b/plugins/myq/src/main.ts @@ -1,12 +1,13 @@ import sdk, { ScryptedDeviceBase, DeviceProvider, Device, ScryptedDeviceType, Entry, Refresh, OnOff, Settings, Setting, EntrySensor, ScryptedInterface, Battery } from '@scrypted/sdk'; const { log } = sdk; -import { myQApi, myQDevice } from '@hjdhjd/myq'; +import { myQApi, myQDevice, myQDeviceInterface } from '@hjdhjd/myq'; import throttle from 'lodash/throttle'; const { deviceManager } = sdk; -function isValidGarageDoor(device_type: string) { - return device_type === 'wifigaragedooropener' || device_type === 'virtualgaragedooropener' || device_type === 'garagedooropener'; +function isValidGarageDoor(device: myQDeviceInterface) { + //return device_type === 'wifigaragedooropener' || device_type === 'virtualgaragedooropener' || device_type === 'garagedooropener'; + return device.device_family === 'garagedoor' } class GarageController extends ScryptedDeviceBase implements DeviceProvider, Settings, Battery { @@ -76,7 +77,7 @@ class GarageController extends ScryptedDeviceBase implements DeviceProvider, Set const devices: Device[] = []; for (const device of this.account.devices) { - if (!isValidGarageDoor(device.device_type)) { + if (!isValidGarageDoor(device)) { console.log('ignoring device', device); continue; } @@ -101,7 +102,7 @@ class GarageController extends ScryptedDeviceBase implements DeviceProvider, Set async updateStates() { for (const device of this.account.devices) { - if (!isValidGarageDoor(device.device_type)) { + if (!isValidGarageDoor(device)) { console.log('ignoring device', device); continue; }