Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed using incorrect way of passing override address to accessory #99

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor Author

@Jason-Morcos Jason-Morcos Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to set it on the device record itself, not on the context (must be the same thing accessed by the Kumo-api class)

}

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
Loading