Skip to content

Commit

Permalink
release 0.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz914 committed Feb 10, 2024
1 parent cf609c0 commit d84f640
Show file tree
Hide file tree
Showing 11 changed files with 541 additions and 658 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Important changes v0.4.0 and above!!!
* Main control mode, buttons and presets need to be configured again!!!

## [0.16.0] - (10.02.2024)
## Changes
- removed possibility to set indyvidual refresh time for ATA, ATW, ERV state
- full code refactor for ATA, ATW, ERV
- fixed accesorry publish if units are not configured in MELCloud
- remove sensitive information from debug
- drastically reduce call trace
- config.schema updated
- cleanup

## [0.15.0] - (05.02.2024)
## Changes
- added possibility to set indyvidual refresh time for Account Settings and ATA, ATW, ERV state, [#68](https://github.com/grzegorz914/homebridge-melcloud-control/issues/68)
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
| `user` | Here set the MELCloud username. |
| `passwd` | Here set the MELCloud password. |
| `language` | Here select the MELCloud language. |
| `accountRefreshInterval` | Here set the background MELCLoud account settings refresh time in (sec), default 120s. |
| `ataDisplayMode` | Here select main control mode `Heater/Cooler`, `Thermostat`. |
| `ataTemperatureSensor` | This enable extra temperature sensor for Heater/Cooler control mode to use with automations in HomeKit app. |
| `ataDisableAutoMode` | This will disable `Auto` mode even this mode is supported by device. |
Expand All @@ -185,23 +184,21 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
| `ataButtons.mode` | Here select button mode, VH - Vane Horizontal, VV - Vane Horizontal. |
| `ataButtons.displayType` | Here select display type in HomeKit app, possible `None/Disabled`, `Outlet`, `Switch`, `Motion Sensor`, `Occupancy Sensor`, `Contact Sensor`.|
| `ataButtons.namePrefix` | Here enable/disable the accessory name as a prefix for button/sensor name.|
| `ataRefreshInterval` | Here set the background state refresh time in (sec) for Air Conditioner, default 75s. |
| `atwDisplayMode` | Here select main control mode `Heater/Cooler`, `Thermostat`. |
| `atwTemperatureSensor` | This enable extra temperature sensor for Heater/Cooler control mode to use with automations in HomeKit app. |
| `atwPresets` | This enable display Heat Pump presets in HomeKit app. |
| `atwButtons.name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
| `atwButtons.mode` | Here select button mode. |
| `atwButtons.displayType` | Here select display type in HomeKit app, possible `None/Disabled`, `Outlet`, `Switch`, `Motion Sensor`, `Occupancy Sensor`, `Contact Sensor`.|
| `atwButtons.namePrefix` | Here enable/disable the accessory name as a prefix for button/sensor name.|
| `atwRefreshInterval` | Here set the background state refresh time in (sec) for Heat Pump, default 75s. |
| `ervDisplayMode` | Here select main control mode `Heater/Cooler`, `Thermostat`. |
| `ervTemperatureSensor` | This enable extra temperature sensor for Heater/Cooler control mode to use with automations in HomeKit app. |
| `ervPresets` | This enable display EnergyRecovery Ventilation presets in HomeKit app. |
| `ervButtons.name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
| `ervButtons.mode` | Here select button mode. |
| `ervButtons.displayType` | Here select display type in HomeKit app, possible `None/Disabled`, `Outlet`, `Switch`, `Motion Sensor`, `Occupancy Sensor`, `Contact Sensor`.|
| `ervButtons.namePrefix` | Here enable/disable the accessory name as a prefix for button/sensor name.|
| `ervRefreshInterval` | Here set the background state refresh time in (sec) for Energy Recovery Ventilation, default 75s. |
| `refreshInterval` | Here set the background devices state refresh time in (sec), default 120s. |
| `enableDebugMode` | This enable deep log in homebridge console. |
| `disableLogInfo` | This disable display log values and states on every it change. |
| `disableLogDeviceInfo` | This disable display log device info on plugin start. |
Expand Down
42 changes: 6 additions & 36 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,6 @@
"description": "Here select the language used in MELCloud account.",
"required": true
},
"accountRefreshInterval": {
"title": "Refresh Interval",
"type": "integer",
"default": 120,
"minimum": 90,
"maximum": 300,
"description": "Here set the background state refresh time in (sec) for MELCloud settings.",
"required": true
},
"ataDisplayMode": {
"title": "Control Mode",
"type": "integer",
Expand Down Expand Up @@ -571,15 +562,6 @@
}
}
},
"ataRefreshInterval": {
"title": "Refresh Interval",
"type": "integer",
"default": 75,
"minimum": 60,
"maximum": 900,
"description": "Here set the background state refresh time in (sec) for Air Conditioner.",
"required": true
},
"atwDisplayMode": {
"title": "Control Mode",
"type": "integer",
Expand Down Expand Up @@ -829,15 +811,6 @@
}
}
},
"atwRefreshInterval": {
"title": "Refresh Interval",
"type": "integer",
"default": 70,
"minimum": 60,
"maximum": 900,
"description": "Here set the background state refresh time in (sec) for Heat Pump.",
"required": true
},
"ervDisplayMode": {
"title": "Control Mode",
"type": "integer",
Expand Down Expand Up @@ -1033,13 +1006,13 @@
}
}
},
"ervRefreshInterval": {
"refreshInterval": {
"title": "Refresh Interval",
"type": "integer",
"default": 75,
"minimum": 60,
"maximum": 900,
"description": "Here set the background state refresh time in (sec) for Energy Recovery Ventilation.",
"default": 120,
"minimum": 1,
"maximum": 600,
"description": "Here set the background devices state refresh time in (sec).",
"required": true
},
"disableLogInfo": {
Expand Down Expand Up @@ -1205,7 +1178,6 @@
"accounts[].ataDisableAutoMode",
"accounts[].ataDisableHeatMode",
"accounts[].ataAutoHeatMode",
"accounts[].ataRefreshInterval",
{
"key": "accounts[]",
"type": "section",
Expand Down Expand Up @@ -1235,7 +1207,6 @@
"accounts[].atwDisplayMode",
"accounts[].atwTemperatureSensor",
"accounts[].atwPresets",
"accounts[].atwRefreshInterval",
{
"key": "accounts[]",
"type": "section",
Expand Down Expand Up @@ -1265,7 +1236,6 @@
"accounts[].ervDisplayMode",
"accounts[].ervTemperatureSensor",
"accounts[].ervPresets",
"accounts[].ervRefreshInterval",
{
"key": "accounts[]",
"type": "section",
Expand Down Expand Up @@ -1295,7 +1265,7 @@
"accounts[].enableDebugMode",
"accounts[].disableLogInfo",
"accounts[].disableLogDeviceInfo",
"accounts[].accountRefreshInterval"
"accounts[].refreshInterval"
]
},
{
Expand Down
21 changes: 13 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ class MelCloudPlatform {
const passwd = account.passwd;
const language = account.language;
const enableDebugMode = account.enableDebugMode;
const accountRefreshInterval = account.accountRefreshInterval * 1000 || 90000;
const ataRefreshInterval = account.ataRefreshInterval * 1000 || 75000;
const atwRefreshInterval = account.atwRefreshInterval * 1000 || 75000;
const ervRefreshInterval = account.ervRefreshInterval * 1000 || 75000;
const refreshInterval = account.refreshInterval * 1000 || 120000;

//check mandatory properties
if (!accountName || !user || !passwd || !language) {
Expand All @@ -40,15 +37,23 @@ class MelCloudPlatform {

//debug config
const debug = enableDebugMode ? log(`Account: ${accountName}, did finish launching.`) : false;
const debug1 = enableDebugMode ? log(`Account: ${accountName}, Config: ${JSON.stringify(account, null, 2)}`) : false;

//remove sensitive data
const config = {
...account,
user: 'removed',
passwd: 'removed',
mqttUser: 'removed',
mqttPasswd: 'removed'
};
const debug1 = enableDebugMode ? log(`Account: ${accountName}, Config: ${JSON.stringify(config, null, 2)}`) : false;

//melcloud account
const melCloud = new MelCloud(prefDir, accountName, user, passwd, language, enableDebugMode, accountRefreshInterval);
const melCloud = new MelCloud(prefDir, accountName, user, passwd, language, enableDebugMode, refreshInterval);
melCloud.on('checkDevicesListComplete', (accountInfo, contextKey, buildingId, deviceId, deviceType, deviceName, deviceTypeText) => {

//melcloud devices
const deviceRefreshInterval = [ataRefreshInterval, atwRefreshInterval, 0, ervRefreshInterval][deviceType];
const melCloudDevice = new MelCloudDevice(api, prefDir, account, accountName, melCloud, accountInfo, contextKey, buildingId, deviceId, deviceType, deviceName, deviceTypeText, deviceRefreshInterval)
const melCloudDevice = new MelCloudDevice(api, prefDir, account, accountName, melCloud, accountInfo, contextKey, buildingId, deviceId, deviceType, deviceName, deviceTypeText)
melCloudDevice.on('publishAccessory', (accessory) => {

//publish devices
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": "0.15.4",
"version": "0.16.0",
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
"license": "MIT",
"author": "grzegorz914",
Expand Down
5 changes: 1 addition & 4 deletions sample-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"passwd": "password",
"language": "0",
"ataDisplayMode": 0,
"accountRefreshInterval": 9,
"ataTemperatureSensor": false,
"ataDisableAutoMode": false,
"ataDisableHeatMode": false,
Expand All @@ -38,7 +37,6 @@
"namePrefix": false
}
],
"ataRefreshInterval": 7,
"atwDisplayMode": 0,
"atwTemperatureSensor": false,
"atwPresets": false,
Expand All @@ -50,7 +48,6 @@
"namePrefix": false
}
],
"atwRefreshInterval": 7,
"ervDisplayMode": 0,
"ervTemperatureSensor": false,
"ervPresets": false,
Expand All @@ -62,7 +59,7 @@
"namePrefix": false
}
],
"ervRefreshInterval": 7,
"refreshInterval": 120,
"disableLogInfo": false,
"disableLogDeviceInfo": false,
"enableDebugMode": false,
Expand Down
26 changes: 20 additions & 6 deletions src/melcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,30 @@ class MelCloud extends EventEmitter {
maxContentLength: 100000000,
maxBodyLength: 1000000000,
httpsAgent: new https.Agent({
keepAlive: true,
keepAlive: false,
rejectUnauthorized: false
})
});

this.on('connect', async () => {
try {
const accountData = await axiosInstanceLogin(CONSTANS.ApiUrls.ClientLogin, options);
const debug = enableDebugMode ? this.emit('debug', `MELCloud Info: ${JSON.stringify(accountData.data, null, 2)}`) : false;
const accountInfo = accountData.data.LoginData;
const account = accountData.data;
const accountInfo = account.LoginData;
const contextKey = accountInfo.ContextKey;

//remove sensitive data
const config = {
...account.LoginData,
ContextKey: 'removed',
ClientId: 'removed',
Client: 'removed',
Name: 'removed',
MapLongitude: 'removed',
MapLatitude: 'removed'
};
const debug = enableDebugMode ? this.emit('debug', `MELCloud Info: ${JSON.stringify(config, null, 2)}`) : false;

if (contextKey === undefined || contextKey === null) {
this.emit('message', `context key: ${contextKey}, missing, reconnect in ${refreshIntervalSec}.`)
this.reconnect();
Expand All @@ -64,7 +76,7 @@ class MelCloud extends EventEmitter {
maxBodyLength: 1000000000,
withCredentials: true,
httpsAgent: new https.Agent({
keepAlive: true,
keepAlive: false,
rejectUnauthorized: false
})
});
Expand All @@ -82,7 +94,7 @@ class MelCloud extends EventEmitter {
maxBodyLength: 1000000000,
withCredentials: true,
httpsAgent: new https.Agent({
keepAlive: true,
keepAlive: false,
rejectUnauthorized: false
})
});
Expand Down Expand Up @@ -116,6 +128,7 @@ class MelCloud extends EventEmitter {

//save buildings to the file
await this.saveData(buildingsFile, buildingsList);
const debug = enableDebugMode ? this.emit('debug', `Buildings list saved.`) : false;

//read buildings structure and get the devices
const devices = [];
Expand Down Expand Up @@ -152,6 +165,7 @@ class MelCloud extends EventEmitter {
//save every device info to the file
const deviceInfoFile = `${prefDir}/${accountName}_Device_${deviceId}`;
await this.saveData(deviceInfoFile, deviceInfo);
const debug = enableDebugMode ? this.emit('debug', `Device: ${deviceName} state saved.`) : false;

//prepare device if not in devices array
if (!devicesId.includes(deviceId)) {
Expand All @@ -163,7 +177,7 @@ class MelCloud extends EventEmitter {
this.checkDevicesList();
} catch (error) {
this.emit('error', `check devices list error, ${error}, check again in ${refreshIntervalSec}s.`);
this.checkDevicesList();
this.reconnect();
};
})
this.emit('connect');
Expand Down
Loading

0 comments on commit d84f640

Please sign in to comment.