Skip to content

Commit

Permalink
Merge pull request #75 from ACDR/release/3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ACDR authored Sep 6, 2022
2 parents aadf81a + 5ca16c4 commit a9b1bc5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"license": "UNLICENSED",
"displayName": "Yamaha AVR",
"name": "homebridge-yamaha-avr",
"version": "3.0.0",
"version": "3.0.1",
"description": "homebridge-plugin - Add a Yamaha AVR as a HomeKit Audio Receiver with Power, Input, Volume & Remote Control",
"author": {
"name": "ACDR",
Expand Down Expand Up @@ -47,6 +47,8 @@
"watch": "npm run build && npm link && nodemon",
"build": "rimraf ./dist && tsc",
"prepublishOnly": "npm run lint && npm run build",
"publish:stable": "npm publish --tag stable",
"publish:beta": "npm publish --tag beta",
"lint": "eslint src/**.ts --max-warnings=0",
"lint:fix": "eslint src/**.ts --max-warnings=0 --fix"
},
Expand Down
17 changes: 13 additions & 4 deletions src/accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ export class YamahaAVRAccessory {
private readonly accessory: PlatformAccessory<AccessoryContext>,
private readonly zone: Zone['id'],
) {
this.cacheDirectory =
this.platform.config.cacheDirectory || this.platform.api.user.storagePath() + '/.yamahaAVR/' + this.zone;
this.cacheDirectory = this.platform.config.cacheDirectory
? `${this.platform.config.cacheDirectory}/${this.zone}`.replace('//', '/')
: this.platform.api.user.storagePath() + '/.yamahaAVR/' + this.zone;
this.storageService = new StorageService(this.cacheDirectory);
this.storageService.initSync();

this.platform.log.debug('cache directory', this.cacheDirectory);

// set the AVR accessory information
this.accessory
.getService(this.platform.Service.AccessoryInformation)!
Expand Down Expand Up @@ -160,7 +163,10 @@ export class YamahaAVRAccessory {
// Update input name cache
inputService
.getCharacteristic(this.platform.Characteristic.ConfiguredName)
.onGet((): CharacteristicValue => cachedService?.ConfiguredName || input.text)
.onGet(async (): Promise<CharacteristicValue> => {
const cachedServiceGet = await this.storageService.getItem<CachedServiceData>(input.id);
return cachedServiceGet?.ConfiguredName || input.text;
})
.onSet((name: CharacteristicValue) => {
const currentConfiguredName = inputService.getCharacteristic(
this.platform.Characteristic.ConfiguredName,
Expand All @@ -187,7 +193,10 @@ export class YamahaAVRAccessory {
// Update input visibility cache
inputService
.getCharacteristic(this.platform.Characteristic.TargetVisibilityState)
.onGet((): CharacteristicValue => cachedService?.CurrentVisibilityState || 0)
.onGet(async (): Promise<CharacteristicValue> => {
const cachedServiceGet = await this.storageService.getItem<CachedServiceData>(input.id);
return cachedServiceGet?.CurrentVisibilityState || 0;
})
.onSet((targetVisibilityState: CharacteristicValue) => {
const currentVisbility = inputService.getCharacteristic(
this.platform.Characteristic.CurrentVisibilityState,
Expand Down
9 changes: 1 addition & 8 deletions src/pureDirectAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,7 @@ export class YamahaPureDirectAccessory {
return;
}

this.service.updateCharacteristic(
this.platform.Characteristic.ProgrammableSwitchOutputState,
zoneStatus.pure_direct,
);
}

async getSwitchEvent(): Promise<CharacteristicValue> {
return this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS;
this.service.updateCharacteristic(this.platform.Characteristic.On, zoneStatus.pure_direct);
}

async getState(): Promise<CharacteristicValue> {
Expand Down

0 comments on commit a9b1bc5

Please sign in to comment.