Skip to content

Commit

Permalink
Merge pull request #99 from Jason-Morcos/fix/Preserve-override-addres…
Browse files Browse the repository at this point in the history
…s-between-API-refreshes

Fixed using incorrect way of passing override address to accessory
  • Loading branch information
fjs21 authored Nov 6, 2023
2 parents e748ef4 + e96880a commit a28e876
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/kumo-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ export class KumoApi {
headers: {'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'},
body: post_data,
}, 2000, 'Time out on local IP connection.');
}, 2000, 'Time out on local IP connection to ' + address + '.');
// check response from server
if (response.status >= 200 && response.status <= 299) {
data = await response.json();
Expand Down
16 changes: 8 additions & 8 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ export class KumoHomebridgePlatform implements DynamicPlatformPlugin {
const overrideAddress = this.optionGetOverrideAddress(device);
if (overrideAddress !== null) {
this.log.info('Override address found for device - using IP %s instead of %s for direct access', overrideAddress, existingAccessory.context.zoneTable.address);
existingAccessory.context.overrideAddress = overrideAddress;
device.overrideAddress = overrideAddress;
}

this.log.debug(device.zoneTable);

if (this.config.directAccess) {
existingAccessory.context.device = await this.kumo.queryDevice_Direct(device.serial);
if(existingAccessory.context.device === null) {
this.log.error('Failed to connect to device IP (%s) at %s', device.serial, existingAccessory.context.overrideAddress ?? existingAccessory.context.zoneTable.address);
this.log.error('Failed to connect to device IP (%s) at %s', device.serial, device.overrideAddress ?? existingAccessory.context.zoneTable.address);
existingAccessory.context.device = await this.kumo.queryDevice(device.serial);
this.config.directAccess = false;
this.log.info('Disabling directAccess to Kumo devices');
Expand Down Expand Up @@ -307,9 +307,9 @@ export class KumoHomebridgePlatform implements DynamicPlatformPlugin {

// We've explicitly set an address for this device.
for (const configOption of this.config.options) {
if(configOption.startsWith('Address.' + (device.serial) + '=')) {
return configOption.split('=')[1];
}
if(configOption.startsWith('Address.' + (device.serial) + '=')) {
return configOption.split('=')[1];
}
}

// If we don't have a zoneTable label, we're done here.
Expand All @@ -319,9 +319,9 @@ export class KumoHomebridgePlatform implements DynamicPlatformPlugin {

// We've explicitly set an address for the zoneTable label this device is attached to.
for (const configOption of this.config.options) {
if(configOption.startsWith('Address.' + (device.label) + '=')) {
return configOption.split('=')[1];
}
if(configOption.startsWith('Address.' + (device.label) + '=')) {
return configOption.split('=')[1];
}
}

// Nothing special to do - return default.
Expand Down

0 comments on commit a28e876

Please sign in to comment.