Skip to content

Commit

Permalink
Update curtain.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Sep 11, 2024
1 parent a0a4a86 commit 51e077c
Showing 1 changed file with 15 additions and 29 deletions.
44 changes: 15 additions & 29 deletions src/device/curtain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { hostname } from 'node:os'
* import { SwitchBotBLEModel, SwitchBotBLEModelName } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
*/
import { SwitchBotBLEModel, SwitchBotBLEModelName } from 'node-switchbot'
import { debounceTime, interval, skipWhile, Subject, take, tap } from 'rxjs'
import { debounceTime, generate, interval, skipWhile, Subject, take, tap } from 'rxjs'

Check failure on line 21 in src/device/curtain.ts

View workflow job for this annotation

GitHub Actions / lint / ESLint

'generate' is defined but never used

import { deviceBase } from './device.js'

Expand Down Expand Up @@ -191,20 +191,13 @@ export class Curtain extends deviceBase {
}
} else {
accessory.context.OpenModeSwitch = accessory.context.OpenModeSwitch ?? {}
if (this.OpenModeSwitch?.Service) {
this.debugLog('Restoring Open Mode Switch Service')
this.OpenModeSwitch = {
Name: `${accessory.displayName} Silent Open Mode`,
Service: this.accessory.getService(this.OpenModeSwitch.Name) as Service,
On: accessory.context.OpenModeSwitch.On ?? false,
}
} else {
this.debugLog('Adding Open Mode Switch Service')
this.OpenModeSwitch = {
Name: `${accessory.displayName} Silent Open Mode`,
Service: accessory.addService(this.hap.Service.Switch, this.OpenModeSwitch?.Name, this.OpenModeSwitch?.Name) as Service,
On: accessory.context.OpenModeSwitch.On ?? false,
}
this.debugLog('Adding Open Mode Switch Service')
const name = `${accessory.displayName} Silent Open Mode`
const uuid = this.api.hap.uuid.generate(name)
this.OpenModeSwitch = {
Name: name,
Service: accessory.getService(name) ?? accessory.addService(this.hap.Service.Switch, name, uuid) as Service,
On: accessory.context.OpenModeSwitch.On ?? false,
}
accessory.context.OpenModeSwitch = this.OpenModeSwitch as object

Expand All @@ -226,20 +219,13 @@ export class Curtain extends deviceBase {
}
} else {
accessory.context.CloseModeSwitch = accessory.context.CloseModeSwitch ?? {}
if (this.CloseModeSwitch?.Service) {
this.debugLog('Restoring Close Mode Switch Service')
this.CloseModeSwitch = {
Name: `${accessory.displayName} Silent Close Mode`,
Service: this.accessory.getService(this.CloseModeSwitch.Name) as Service,
On: accessory.context.CloseModeSwitch.On ?? false,
}
} else {
this.debugLog('Adding Close Mode Switch Service')
this.CloseModeSwitch = {
Name: `${accessory.displayName} Silent Close Mode`,
Service: accessory.addService(this.hap.Service.Switch, this.CloseModeSwitch?.Name, this.CloseModeSwitch?.Name) as Service,
On: accessory.context.CloseModeSwitch.On ?? false,
}
this.debugLog('Adding Close Mode Switch Service')
const name = `${accessory.displayName} Silent Close Mode`
const uuid = this.api.hap.uuid.generate(name)
this.CloseModeSwitch = {
Name: name,
Service: this.accessory.getService(name) ?? accessory.addService(this.hap.Service.Switch, name, uuid) as Service,
On: accessory.context.CloseModeSwitch.On ?? false,
}
accessory.context.CloseModeSwitch = this.CloseModeSwitch as object

Expand Down

0 comments on commit 51e077c

Please sign in to comment.