Skip to content

Commit

Permalink
add logs for failed sets
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenVdb committed Oct 21, 2024
1 parent 1b53efd commit e2cc7e4
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 47 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"displayName": "Daikin Cloud",
"platformname": "daikincloud",
"name": "homebridge-daikin-cloud",
"version": "2.7.0-beta.2",
"version": "2.7.0-beta.3",
"description": "Integrate with the Daikin Cloud to control your Daikin air conditioning via the cloud",
"license": "Apache-2.0",
"repository": {
Expand Down
132 changes: 86 additions & 46 deletions src/climateControlService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export class ClimateControlService {
try {
await this.accessory.context.device.setData(this.managementPointId, 'onOffMode', state ? DaikinOnOffModes.ON : DaikinOnOffModes.OFF, undefined);
} catch (e) {
this.platform.log.error('Failed to set', e);
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
this.platform.forceUpdateDevices();
}
Expand All @@ -308,7 +308,7 @@ export class ClimateControlService {
try {
await this.accessory.context.device.setData(this.managementPointId, 'temperatureControl', `/operationModes/cooling/setpoints/${this.getSetpoint()}`, temperature);
} catch (e) {
this.platform.log.error('Failed to set', e);
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}

this.platform.forceUpdateDevices();
Expand All @@ -327,7 +327,7 @@ export class ClimateControlService {
await this.accessory.context.device.setData(this.managementPointId, 'fanControl', `/operationModes/${this.getCurrentOperationMode()}/fanSpeed/currentMode`, 'fixed');
await this.accessory.context.device.setData(this.managementPointId, 'fanControl', `/operationModes/${this.getCurrentOperationMode()}/fanSpeed/modes/fixed`, speed);
} catch (e) {
this.platform.log.error('Failed to set', e);
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}

this.platform.forceUpdateDevices();
Expand All @@ -340,11 +340,15 @@ export class ClimateControlService {
}

async handleHeatingThresholdTemperatureSet(value: CharacteristicValue) {
const temperature = Math.round(value as number * 2) / 2;
// const temperature = value as number;
this.platform.log.debug(`[${this.name}] SET HeatingThresholdTemperature, temperature to: ${temperature}`);
await this.accessory.context.device.setData(this.managementPointId, 'temperatureControl', `/operationModes/heating/setpoints/${this.getSetpoint()}`, temperature);
this.platform.forceUpdateDevices();
try {
const temperature = Math.round(value as number * 2) / 2;
// const temperature = value as number;
this.platform.log.debug(`[${this.name}] SET HeatingThresholdTemperature, temperature to: ${temperature}`);
await this.accessory.context.device.setData(this.managementPointId, 'temperatureControl', `/operationModes/heating/setpoints/${this.getSetpoint()}`, temperature);
this.platform.forceUpdateDevices();
} catch (e) {
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
}

async handleTargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
Expand Down Expand Up @@ -381,20 +385,28 @@ export class ClimateControlService {
break;
}

this.platform.log.debug(`[${this.name}] SET TargetHeaterCoolerState, daikinOperationMode to: ${daikinOperationMode}`);
await this.accessory.context.device.setData(this.managementPointId, 'operationMode', daikinOperationMode, undefined);
await this.accessory.context.device.setData(this.managementPointId, 'onOffMode', DaikinOnOffModes.ON, undefined);
this.platform.forceUpdateDevices();
try {
this.platform.log.debug(`[${this.name}] SET TargetHeaterCoolerState, daikinOperationMode to: ${daikinOperationMode}`);
await this.accessory.context.device.setData(this.managementPointId, 'operationMode', daikinOperationMode, undefined);
await this.accessory.context.device.setData(this.managementPointId, 'onOffMode', DaikinOnOffModes.ON, undefined);
this.platform.forceUpdateDevices();
} catch (e) {
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
}

async handleSwingModeSet(value: CharacteristicValue) {
const swingMode = value as number;
const daikinSwingMode = swingMode === 1 ? DaikinFanDirectionHorizontalModes.SWING : DaikinFanDirectionHorizontalModes.STOP;
this.platform.log.debug(`[${this.name}] SET SwingMode, swingmode to: ${swingMode}/${daikinSwingMode}`);
try {
const swingMode = value as number;
const daikinSwingMode = swingMode === 1 ? DaikinFanDirectionHorizontalModes.SWING : DaikinFanDirectionHorizontalModes.STOP;
this.platform.log.debug(`[${this.name}] SET SwingMode, swingmode to: ${swingMode}/${daikinSwingMode}`);

await this.accessory.context.device.setData(this.managementPointId, 'fanControl', `/operationModes/${this.getCurrentOperationMode()}/fanDirection/horizontal/currentMode`, daikinSwingMode);
await this.accessory.context.device.setData(this.managementPointId, 'fanControl', `/operationModes/${this.getCurrentOperationMode()}/fanDirection/vertical/currentMode`, daikinSwingMode);
this.platform.forceUpdateDevices();
await this.accessory.context.device.setData(this.managementPointId, 'fanControl', `/operationModes/${this.getCurrentOperationMode()}/fanDirection/horizontal/currentMode`, daikinSwingMode);
await this.accessory.context.device.setData(this.managementPointId, 'fanControl', `/operationModes/${this.getCurrentOperationMode()}/fanDirection/vertical/currentMode`, daikinSwingMode);
this.platform.forceUpdateDevices();
} catch (e) {
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
}

async handleSwingModeGet(): Promise<CharacteristicValue> {
Expand All @@ -418,10 +430,14 @@ export class ClimateControlService {
}

async handlePowerfulModeSet(value: CharacteristicValue) {
this.platform.log.debug(`[${this.name}] SET PowerfulMode to: ${value}`);
const daikinPowerfulMode = value as boolean ? DaikinPowerfulModes.ON : DaikinPowerfulModes.OFF;
await this.accessory.context.device.setData(this.managementPointId, 'powerfulMode', daikinPowerfulMode, undefined);
this.platform.forceUpdateDevices();
try {
this.platform.log.debug(`[${this.name}] SET PowerfulMode to: ${value}`);
const daikinPowerfulMode = value as boolean ? DaikinPowerfulModes.ON : DaikinPowerfulModes.OFF;
await this.accessory.context.device.setData(this.managementPointId, 'powerfulMode', daikinPowerfulMode, undefined);
this.platform.forceUpdateDevices();
} catch (e) {
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
}

async handleEconoModeGet() {
Expand All @@ -431,10 +447,14 @@ export class ClimateControlService {
}

async handleEconoModeSet(value: CharacteristicValue) {
this.platform.log.debug(`[${this.name}] SET EconoMode to: ${value}`);
const daikinEconoMode = value as boolean ? DaikinEconoModes.ON : DaikinEconoModes.OFF;
await this.accessory.context.device.setData(this.managementPointId, 'econoMode', daikinEconoMode, undefined);
this.platform.forceUpdateDevices();
try {
this.platform.log.debug(`[${this.name}] SET EconoMode to: ${value}`);
const daikinEconoMode = value as boolean ? DaikinEconoModes.ON : DaikinEconoModes.OFF;
await this.accessory.context.device.setData(this.managementPointId, 'econoMode', daikinEconoMode, undefined);
this.platform.forceUpdateDevices();
} catch (e) {
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
}

async handleStreamerModeGet() {
Expand All @@ -444,10 +464,14 @@ export class ClimateControlService {
}

async handleStreamerModeSet(value: CharacteristicValue) {
this.platform.log.debug(`[${this.name}] SET streamerMode to: ${value}`);
const daikinStreamerMode = value as boolean ? DaikinStreamerModes.ON : DaikinStreamerModes.OFF;
await this.accessory.context.device.setData(this.managementPointId, 'streamerMode', daikinStreamerMode, undefined);
this.platform.forceUpdateDevices();
try {
this.platform.log.debug(`[${this.name}] SET streamerMode to: ${value}`);
const daikinStreamerMode = value as boolean ? DaikinStreamerModes.ON : DaikinStreamerModes.OFF;
await this.accessory.context.device.setData(this.managementPointId, 'streamerMode', daikinStreamerMode, undefined);
this.platform.forceUpdateDevices();
} catch (e) {
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
}

async handleOutdoorSilentModeGet() {
Expand All @@ -457,10 +481,14 @@ export class ClimateControlService {
}

async handleOutdoorSilentModeSet(value: CharacteristicValue) {
this.platform.log.debug(`[${this.name}] SET outdoorSilentMode to: ${value}`);
const daikinOutdoorSilentMode = value as boolean ? DaikinOutdoorSilentModes.ON : DaikinOutdoorSilentModes.OFF;
await this.accessory.context.device.setData(this.managementPointId, 'outdoorSilentMode', daikinOutdoorSilentMode, undefined);
this.platform.forceUpdateDevices();
try {
this.platform.log.debug(`[${this.name}] SET outdoorSilentMode to: ${value}`);
const daikinOutdoorSilentMode = value as boolean ? DaikinOutdoorSilentModes.ON : DaikinOutdoorSilentModes.OFF;
await this.accessory.context.device.setData(this.managementPointId, 'outdoorSilentMode', daikinOutdoorSilentMode, undefined);
this.platform.forceUpdateDevices();
} catch (e) {
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
}

async handleIndoorSilentModeGet() {
Expand All @@ -470,10 +498,14 @@ export class ClimateControlService {
}

async handleIndoorSilentModeSet(value: CharacteristicValue) {
this.platform.log.debug(`[${this.name}] SET indoorSilentMode to: ${value}`);
const daikinFanSpeedMode = value as boolean ? DaikinFanSpeedModes.QUIET : DaikinFanSpeedModes.FIXED;
await this.accessory.context.device.setData(this.managementPointId, 'fanControl', `/operationModes/${this.getCurrentOperationMode()}/fanSpeed/currentMode`, daikinFanSpeedMode);
this.platform.forceUpdateDevices();
try {
this.platform.log.debug(`[${this.name}] SET indoorSilentMode to: ${value}`);
const daikinFanSpeedMode = value as boolean ? DaikinFanSpeedModes.QUIET : DaikinFanSpeedModes.FIXED;
await this.accessory.context.device.setData(this.managementPointId, 'fanControl', `/operationModes/${this.getCurrentOperationMode()}/fanSpeed/currentMode`, daikinFanSpeedMode);
this.platform.forceUpdateDevices();
} catch (e) {
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
}

async handleDryOperationModeGet() {
Expand All @@ -484,10 +516,14 @@ export class ClimateControlService {
}

async handleDryOperationModeSet(value: CharacteristicValue) {
this.platform.log.debug(`[${this.name}] SET DryOperationMode to: ${value}`);
const daikinOperationMode = value as boolean ? DaikinOperationModes.DRY : DaikinOperationModes.AUTO;
await this.accessory.context.device.setData(this.managementPointId, 'operationMode', daikinOperationMode, undefined);
this.platform.forceUpdateDevices();
try {
this.platform.log.debug(`[${this.name}] SET DryOperationMode to: ${value}`);
const daikinOperationMode = value as boolean ? DaikinOperationModes.DRY : DaikinOperationModes.AUTO;
await this.accessory.context.device.setData(this.managementPointId, 'operationMode', daikinOperationMode, undefined);
this.platform.forceUpdateDevices();
} catch (e) {
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
}

async handleFanOnlyOperationModeGet() {
Expand All @@ -497,10 +533,14 @@ export class ClimateControlService {
}

async handleFanOnlyOperationModeSet(value: CharacteristicValue) {
this.platform.log.debug(`[${this.name}] SET FanOnlyOperationMode to: ${value}`);
const daikinOperationMode = value as boolean ? DaikinOperationModes.FAN_ONLY : DaikinOperationModes.AUTO;
await this.accessory.context.device.setData(this.managementPointId, 'operationMode', daikinOperationMode, undefined);
this.platform.forceUpdateDevices();
try {
this.platform.log.debug(`[${this.name}] SET FanOnlyOperationMode to: ${value}`);
const daikinOperationMode = value as boolean ? DaikinOperationModes.FAN_ONLY : DaikinOperationModes.AUTO;
await this.accessory.context.device.setData(this.managementPointId, 'operationMode', daikinOperationMode, undefined);
this.platform.forceUpdateDevices();
} catch (e) {
this.platform.log.error('Failed to set', e, this.accessory.context.device.desc);
}
}

getCurrentOperationMode() {
Expand Down

0 comments on commit e2cc7e4

Please sign in to comment.