Skip to content

Commit

Permalink
release v2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz914 committed Aug 18, 2024
1 parent 8cf6788 commit c694000
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 34 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- After update to this version the devices need to be added to the Home app again and the old unresponsive remove!!!- This devices will be removed from all automations and scenes!!!

### After update to v2.0.0 RESTFull and MQTT config settings need to be updated

## [2.1.1] - (18.08.2024)

## Changes

- fix correct catch error
- log improvements

## [2.1.0] - (16.08.2024)

## Changes
Expand All @@ -32,8 +41,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Changes

### After update to v2.0.0 RESTFull and MQTT config settings need to be updated

- RestFul and MQTT refactor
- bump dependencies
- cleanup
Expand Down
44 changes: 28 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MelCloudPlatform {

//debug config
const enableDebugMode = account.enableDebugMode || false;
const debug = enableDebugMode ? log(`Account: ${accountName}, did finish launching.`) : false;
const debug = enableDebugMode ? log.info(`Account: ${accountName}, did finish launching.`) : false;

//remove sensitive data
const debugData = {
Expand All @@ -62,7 +62,7 @@ class MelCloudPlatform {
passwd: 'removed'
}
};
const debug1 = enableDebugMode ? log(`Account: ${accountName}, Config: ${JSON.stringify(debugData, null, 2)}`) : false;
const debug1 = enableDebugMode ? log.info(`Account: ${accountName}, Config: ${JSON.stringify(debugData, null, 2)}`) : false;

//set refresh interval
const accountInfoFile = `${prefDir}/${accountName}_Account`;
Expand Down Expand Up @@ -92,16 +92,19 @@ class MelCloudPlatform {

//publish device
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
const debug = enableDebugMode ? log(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`) : false;
log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
})
.on('devInfo', (devInfo) => {
log(devInfo);
log.info(devInfo);
})
.on('message', (message) => {
log(`${deviceTypeText}, ${deviceName}, ${message}`);
log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
})
.on('debug', (debug) => {
log(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
log.info(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
})
.on('warn', (warn) => {
log.warn(`${deviceTypeText}, ${deviceName}, ${warn}`);
})
.on('error', (error) => {
log.error(`${deviceTypeText}, ${deviceName}, ${error}`);
Expand All @@ -118,16 +121,19 @@ class MelCloudPlatform {

//publish device
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
const debug = enableDebugMode ? log(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`) : false;
log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
})
.on('devInfo', (devInfo) => {
log(devInfo);
log.info(devInfo);
})
.on('message', (message) => {
log(`${deviceTypeText}, ${deviceName}, ${message}`);
log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
})
.on('debug', (debug) => {
log(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
log.info(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
})
.on('warn', (warn) => {
log.warn(`${deviceTypeText}, ${deviceName}, ${warn}`);
})
.on('error', (error) => {
log.error(`${deviceTypeText}, ${deviceName}, ${error}`);
Expand All @@ -144,16 +150,19 @@ class MelCloudPlatform {

//publish device
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
const debug = enableDebugMode ? log(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`) : false;
log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
})
.on('devInfo', (devInfo) => {
log(devInfo);
log.info(devInfo);
})
.on('message', (message) => {
log(`${deviceTypeText}, ${deviceName}, ${message}`);
log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
})
.on('debug', (debug) => {
log(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
log.info(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
})
.on('warn', (warn) => {
log.warn(`${deviceTypeText}, ${deviceName}, ${warn}`);
})
.on('error', (error) => {
log.error(`${deviceTypeText}, ${deviceName}, ${error}`);
Expand All @@ -165,10 +174,13 @@ class MelCloudPlatform {
}
})
.on('message', (message) => {
log(`Account ${accountName}, ${message}`);
log.info(`Account ${accountName}, ${message}`);
})
.on('debug', (debug) => {
log(`Account ${accountName}, debug: ${debug}`);
log.info(`Account ${accountName}, debug: ${debug}`);
})
.on('warn', (warn) => {
log.warn(`${deviceTypeText}, ${deviceName}, ${warn}`);
})
.on('error', async (error) => {
log.error(`Account ${accountName}, ${error}, check again in: ${refreshInterval / 1000}s.`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "MELCloud Control",
"name": "homebridge-melcloud-control",
"version": "2.0.3",
"version": "2.1.1",
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
"license": "MIT",
"author": "grzegorz914",
Expand Down
5 changes: 4 additions & 1 deletion src/deviceata.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ class DeviceAta extends EventEmitter {
.on('debug', (debug) => {
this.emit('debug', debug);
})
.on('warn', (warn) => {
this.emit('warn', warn);
})
.on('error', (error) => {
this.emit('error', error);
});
Expand Down Expand Up @@ -1234,7 +1237,7 @@ class DeviceAta extends EventEmitter {

return accessory;
} catch (error) {
this.emit('error', error);
throw new Error(error);
};
};
};
Expand Down
5 changes: 4 additions & 1 deletion src/deviceatw.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,9 @@ class DeviceAtw extends EventEmitter {
.on('debug', (debug) => {
this.emit('debug', debug);
})
.on('warn', (warn) => {
this.emit('warn', warn);
})
.on('error', (error) => {
this.emit('error', error);
});
Expand Down Expand Up @@ -1710,7 +1713,7 @@ class DeviceAtw extends EventEmitter {

return accessory;
} catch (error) {
this.emit('error', error);
throw new Error(error);
};
};
};
Expand Down
5 changes: 4 additions & 1 deletion src/deviceerv.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ class DeviceErv extends EventEmitter {
.on('debug', (debug) => {
this.emit('debug', debug);
})
.on('warn', (warn) => {
this.emit('warn', warn);
})
.on('error', (error) => {
this.emit('error', error);
});
Expand Down Expand Up @@ -1150,7 +1153,7 @@ class DeviceErv extends EventEmitter {

return accessory;
} catch (error) {
this.emit('error', error);
throw new Error(error);
};
};
};
Expand Down
12 changes: 6 additions & 6 deletions src/melcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class MelCloud extends EventEmitter {
const debug1 = this.enableDebugMode ? this.emit('debug', `MELCloud Info: ${JSON.stringify(debugData, null, 2)}`) : false;

if (contextKey === undefined || contextKey === null) {
this.emit('message', `Context key: ${contextKey}, missing.`)
this.emit('warn', `Context key: ${contextKey}, missing.`)
return;
};

Expand Down Expand Up @@ -143,7 +143,7 @@ class MelCloud extends EventEmitter {
const debug1 = this.enableDebugMode ? this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`) : false;

if (!buildingsList) {
this.emit('message', `No building found.`);
this.emit('warn', `No building found.`);
return;
}

Expand All @@ -169,7 +169,7 @@ class MelCloud extends EventEmitter {

const devicesCount = devices.length;
if (devicesCount === 0) {
this.emit('message', `No devices found.`);
this.emit('warn', `No devices found.`);
return;
}
const debug3 = this.enableDebugMode ? this.emit('debug', `Found: ${devicesCount} devices.`) : false;
Expand All @@ -192,7 +192,7 @@ class MelCloud extends EventEmitter {
}
return true;
} catch (error) {
this.emit('error', `Scanning for devices error: ${error}.`);
throw new Error(`Scanning for devices error: ${error}.`);
};
}

Expand All @@ -202,7 +202,7 @@ class MelCloud extends EventEmitter {
const debug3 = this.enableDebugMode ? this.emit('debug', `Data saved to path: ${path}.`) : false;
return true;
} catch (error) {
this.emit('error', `Save data to path: ${path}, error: ${error}`);
throw new Error(`Save data to path: ${path}, error: ${error}`);
}
}

Expand All @@ -216,7 +216,7 @@ class MelCloud extends EventEmitter {
await this.saveData(this.accountInfoFile, accountInfo);
return true;
} catch (error) {
this.emit('error', error);
throw new Error(error);
};
};
};
Expand Down
5 changes: 3 additions & 2 deletions src/melcloudata.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MelCloudAta extends EventEmitter {
const debug1 = debugLog ? this.emit('debug', `Device Info: ${JSON.stringify(deviceData, null, 2)}`) : false;

if (!deviceData) {
this.emit('warn', `Device not data found.`);
return;
}

Expand Down Expand Up @@ -369,7 +370,7 @@ class MelCloudAta extends EventEmitter {
const data = savedData.length > 0 ? JSON.parse(savedData) : false;
return data;
} catch (error) {
this.emit('error', `Read data from path: ${path}, error: ${error}`);
throw new Error(`Read data from path: ${path}, error: ${error}`);
}
}

Expand Down Expand Up @@ -414,7 +415,7 @@ class MelCloudAta extends EventEmitter {
this.emit('deviceState', this.deviceData, deviceState, this.useFahrenheit);
return true;;
} catch (error) {
this.emit('error', error);
throw new Error(error);
};
};
};
Expand Down
5 changes: 3 additions & 2 deletions src/melcloudatw.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MelCloudAtw extends EventEmitter {
const debug1 = debugLog ? this.emit('debug', `Device Info: ${JSON.stringify(deviceData, null, 2)}`) : false;

if (!deviceData) {
this.emit('warn', `Device not data found.`);
return;
}

Expand Down Expand Up @@ -440,7 +441,7 @@ class MelCloudAtw extends EventEmitter {
const data = savedData.length > 0 ? JSON.parse(savedData) : false;
return data;
} catch (error) {
this.emit('error', `Read data from path: ${path}, error: ${error}`);
throw new Error(`Read data from path: ${path}, error: ${error}`);
}
}

Expand All @@ -467,7 +468,7 @@ class MelCloudAtw extends EventEmitter {
this.emit('deviceState', this.deviceData, deviceState, this.useFahrenheit);
return true;
} catch (error) {
this.emit('error', error);
throw new Error(error);
};
};
};
Expand Down
5 changes: 3 additions & 2 deletions src/melclouderv.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MelCloudErv extends EventEmitter {
const debug1 = debugLog ? this.emit('debug', `Device Info: ${JSON.stringify(deviceData, null, 2)}`) : false;

if (!deviceData) {
this.emit('warn', `Device not data found.`);
return;
}

Expand Down Expand Up @@ -357,7 +358,7 @@ class MelCloudErv extends EventEmitter {
const data = savedData.length > 0 ? JSON.parse(savedData) : false;
return data;;
} catch (error) {
this.emit('error', `Read data from path: ${path}, error: ${error}`);
throw new Error(`Read data from path: ${path}, error: ${error}`);
}
}

Expand All @@ -378,7 +379,7 @@ class MelCloudErv extends EventEmitter {
this.emit('deviceState', this.deviceData, deviceState, this.useFahrenheit);
return true;
} catch (error) {
this.emit('error', error);
throw new Error(error);
};
};
};
Expand Down

0 comments on commit c694000

Please sign in to comment.