diff --git a/config.schema.json b/config.schema.json index 26c6beb..140fce5 100644 --- a/config.schema.json +++ b/config.schema.json @@ -236,6 +236,12 @@ } } }, + "idleWatchInterval": { + "type": "integer", + "title": "Idle Poll Interval (minutes)", + "description": "How often to poll Roomba's status when it is idle. Defaults to 15 minutes.", + "required": false + }, "debug": { "type": "boolean", "title": "Debug logging", @@ -316,6 +322,7 @@ "expandable": true, "expanded": false, "items": [ + "idleWatchInterval", "disableDiscovery", "debug" ] diff --git a/docs/functions/default.html b/docs/functions/default.html index fad0b49..5730451 100644 --- a/docs/functions/default.html +++ b/docs/functions/default.html @@ -1,2 +1,2 @@ default | @homebridge-plugins/homebridge-roomba
-

    Function default

    • Parameters

      • api: API

      Returns void

    \ No newline at end of file +

      Function default

      • Parameters

        • api: API

        Returns void

      \ No newline at end of file diff --git a/src/accessory.ts b/src/accessory.ts index da8e00a..894f7c8 100644 --- a/src/accessory.ts +++ b/src/accessory.ts @@ -165,11 +165,9 @@ export default class RoombaAccessory implements AccessoryPlugin { }, }) } - const deviceInfo = device.info ?? undefined - this.log.debug('device info: %s', JSON.stringify(deviceInfo)) this.name = device.name this.model = device.model - this.serialnum = deviceInfo?.mac ?? device.ipaddress + this.serialnum = typeof device.info === 'object' ? device.info.serialNum ?? 'unknown' : device.ipaddress ?? 'unknown' this.blid = device.blid this.robotpwd = device.password this.ipaddress = device.ipaddress ?? device.ip @@ -177,8 +175,7 @@ export default class RoombaAccessory implements AccessoryPlugin { this.cleanBehaviour = device.cleanBehaviour !== undefined ? device.cleanBehaviour : 'everywhere' this.mission = device.mission || { pmap_id: 'local' } this.stopBehaviour = device.stopBehaviour !== undefined ? device.stopBehaviour : 'home' - this.idlePollIntervalMillis = (device.idleWatchInterval * 60_000) || 900_000 - + this.idlePollIntervalMillis = device.idleWatchInterval ? (device.idleWatchInterval * 60_000) : config.idleWatchInterval ? (config.idleWatchInterval * 60_000) : 900_000 const showDockAsContactSensor = device.dockContactSensor === undefined ? true : device.dockContactSensor const showRunningAsContactSensor = device.runningContactSensor const showBinStatusAsContactSensor = device.binContactSensor diff --git a/src/platform.ts b/src/platform.ts index 2a3c665..df67141 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -73,7 +73,7 @@ export default class RoombaPlatform implements DynamicPlatformPlugin { ...device, cleanBehaviour: this.config.cleanBehaviour, stopBehaviour: this.config.stopBehaviour, - idleWatchInterval: this.config.idleWatchInterval, + idleWatchInterval: this.config.idleWatchInterval ?? 900_000, })) } else { this.log.error('No configuration provided for devices.') diff --git a/src/settings.ts b/src/settings.ts index 829776b..2b91ec6 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -15,6 +15,7 @@ export const PLUGIN_NAME = '@homebridge-plugins/homebridge-roomba' export interface RoombaPlatformConfig extends PlatformConfig { devices: DeviceConfig[] disableDiscovery?: boolean + idleWatchInterval?: number debug?: boolean } @@ -32,7 +33,7 @@ export interface DeviceConfig extends Robot { * Idle Poll Interval (minutes). * How often to poll Roomba's status when it is idle. */ - idleWatchInterval: number + idleWatchInterval?: number dockContactSensor?: boolean runningContactSensor?: boolean