Skip to content

Commit

Permalink
Release 3.11.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jghaanstra committed Aug 31, 2022
1 parent c61ec91 commit 8e29788
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 129 deletions.
3 changes: 3 additions & 0 deletions .homeychangelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -541,5 +541,8 @@
},
"3.11.4": {
"en": "Upcoming breaking change: the next release will remove all old Plus/Pro drivers for both Homey Pro and Cloud. Please migrate to the new unified driver before updating to version 3.12.0 which will be released early september. This release fixes an issue with pairing devices on Homey Pro where it shows already paired devices from the old drivers. It also fixes an issue with the total enery returned capability of the 3EM and adds a triggercard for Total Meter Power for the 3EM."
},
"3.11.5": {
"en": "Upcoming breaking change: the next release will remove all old Plus/Pro drivers for both Homey Pro and Cloud. Please migrate to the new unified driver before updating to version 3.12.0 which will be released early september. This release contains a fix for controlling the RGBW2 White on Homey Pro."
}
}
2 changes: 1 addition & 1 deletion .homeycompose/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"Shelly radiator"
]
},
"version": "3.11.4",
"version": "3.11.5",
"compatibility": ">=8.0.0",
"platforms": [ "local", "cloud" ],
"author": {
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"Shelly radiator"
]
},
"version": "3.11.4",
"version": "3.11.5",
"compatibility": ">=8.0.0",
"platforms": [
"local",
Expand Down
95 changes: 48 additions & 47 deletions drivers/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ class ShellyDevice extends Homey.Device {

// REFRESHING DEVICE CONFIG AND REGISTERING DEVICE TRIGGER CARDS
this.homey.setTimeout(async () => {
if (this.getStoreValue('config') !== null || this.getStoreValue('config') !== undefined) {
const hostname = this.getStoreValue('main_device').substr(0, this.getStoreValue('main_device').lastIndexOf("-") + 1);
let device_config = this.util.getDeviceConfig(hostname);
await this.setStoreValue('config', device_config);

try {
await this.updateDeviceConfig();
for (const trigger of this.getStoreValue('config').triggers) {
this.homey.flow.getDeviceTriggerCard(trigger);
}
} catch (error) {
this.error(error);
}
}, 2000);

Expand Down Expand Up @@ -132,48 +131,6 @@ class ShellyDevice extends Homey.Device {

}

// TODO: REMOVE AFTER SOME RELEASES
/* save the device config under the device store */
if (this.getStoreValue('config') === null || this.getStoreValue('config') === undefined) {
const hostname = this.getStoreValue('main_device').substr(0, this.getStoreValue('main_device').lastIndexOf("-") + 1);
let device_config = this.util.getDeviceConfig(hostname);
if (typeof device_config !== 'undefined') {

/* update gen1 device config if it's a roller shutter */
if (device_config.name === 'Shelly 2' || device_config.name === 'Shelly 2.5') {
const result = await this.util.sendCommand('/settings', this.getSetting('address'), this.getSetting('username'), this.getSetting('password'));
if (result.hasOwnProperty("mode")) {
if (result.mode === "roller") {
device_config = this.util.getDeviceConfig(hostname + 'roller-');
}
}
}

/* update gen2 device config if it's a roller shutter */
if (device_config.name === 'Shelly Plus 2PM' || device_config.name === 'Shelly Pro 2' || device_config.name === 'Shelly Pro 2PM') {
const result = await this.util.sendRPCCommand('/rpc/Shelly.GetDeviceInfo', this.getSetting('address'), this.getSetting('password'));
if (result.hasOwnProperty("profile")) {
if (result.profile === "cover") {
device_config = this.util.getDeviceConfig(hostname + 'roller-');
}
}
}

/* update device config if it's a RGBW2 in white mode */
if (device_config.name === 'Shelly RGBW2 Color') {
const result = await this.util.sendCommand('/settings', this.getSetting('address'), this.getSetting('username'), this.getSetting('password'));
if (result.mode === 'white') {
device_config = this.util.getDeviceConfig(hostname + 'white-');
}
}

this.setStoreValue('config', device_config);
} else {
this.log(this.getData().id + ' has no valid device config to set');
}
}
// END TODO

} catch (error) {
this.error(error);
}
Expand Down Expand Up @@ -1907,6 +1864,50 @@ class ShellyDevice extends Homey.Device {
return this.commandId++
}

async updateDeviceConfig() {
try {
const hostname = this.getStoreValue('main_device').substr(0, this.getStoreValue('main_device').lastIndexOf("-") + 1);
let device_config = this.util.getDeviceConfig(hostname);
if (typeof device_config !== 'undefined') {

/* update gen1 device config if it's a roller shutter */
if (device_config.name === 'Shelly 2' || device_config.name === 'Shelly 2.5') {
const result = await this.util.sendCommand('/settings', this.getSetting('address'), this.getSetting('username'), this.getSetting('password'));
if (result.hasOwnProperty("mode")) {
if (result.mode === "roller") {
device_config = this.util.getDeviceConfig(hostname + 'roller-');
}
}
}

/* update gen2 device config if it's a roller shutter */
if (device_config.name === 'Shelly Plus 2PM' || device_config.name === 'Shelly Pro 2' || device_config.name === 'Shelly Pro 2PM') {
const result = await this.util.sendRPCCommand('/rpc/Shelly.GetDeviceInfo', this.getSetting('address'), this.getSetting('password'));
if (result.hasOwnProperty("profile")) {
if (result.profile === "cover") {
device_config = this.util.getDeviceConfig(hostname + 'roller-');
}
}
}

/* update device config if it's a RGBW2 in white mode */
if (device_config.name === 'Shelly RGBW2 Color') {
const result = await this.util.sendCommand('/settings', this.getSetting('address'), this.getSetting('username'), this.getSetting('password'));
if (result.mode === 'white') {
device_config = this.util.getDeviceConfig(hostname + 'white-');
}
}

this.setStoreValue('config', device_config);
return Promise.resolve(true);
} else {
return Promise.reject(this.getData().id + ' has no valid device config to set');
}
} catch (error) {
return Promise.reject(error);
}
}

}

module.exports = ShellyDevice;
58 changes: 0 additions & 58 deletions drivers/device_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,66 +59,8 @@ class ShellyCloudDevice extends OAuth2Device {
const device_data = await this.oAuth2Client.getCloudDevices(this.getSetting('cloud_server'));
const device_id = this.getSetting('cloud_device_id').toString(16);
if (this.getStoreValue('gen') === 'gen1') {

// TODO: REMOVE AFTER SOME RELEASES
/* save the device config under the device store */
if (this.getStoreValue('config') === null || this.getStoreValue('config') === undefined) {
if (typeof device_data.data.devices_status[device_id] !== 'undefined') {
let device_config = this.util.getDeviceConfig('hostname', device_data.data.devices_status[device_id]._dev_info.code);
if (typeof device_config !== 'undefined') {

/* update gen1 device config if it's a roller shutter */
if (device_config.name === 'Shelly 2' || device_config.name === 'Shelly 2.5') {

// TODO: check if this contains the new mode parameter and use that
if (device_data.data.devices_status[device_id].hasOwnProperty("rollers")) {
device_config = this.util.getDeviceConfig(device_config.hostname + 'roller-');
}
}

/* update device config if it's a RGBW2 in white mode */
if (device_config.name === 'Shelly RGBW2 Color') {
if (device_data.data.devices_status[device_id].hasOwnProperty("mode")) {
if (device_data.data.devices_status[device_id].mode === 'white') {
device_config = this.util.getDeviceConfig(device_config.hostname + 'white-');
}
}
}

this.setStoreValue('config', device_config);
} else {
this.log(this.getData().id + ' has no valid device config to set');
}
}
}
// END TODO

this.parseFullStatusUpdateGen1(device_data.data.devices_status[device_id])
} else if (this.getStoreValue('gen') === 'gen2') {


// TODO: REMOVE AFTER SOME RELEASES
/* save the device config under the device store */
if (this.getStoreValue('config') === null || this.getStoreValue('config') === undefined) {
if ( typeof device_data.data.devices_status[device_id] !== 'undefined') {
let device_config = this.util.getDeviceConfig('hostname', device_data.data.devices_status[device_id]._dev_info.code);
if (typeof device_config !== 'undefined') {

/* update gen2 device config if it's a roller shutter */
if (device_config.name === 'Shelly Plus 2PM' || device_config.name === 'Shelly Pro 2' || device_config.name === 'Shelly Pro 2PM') {
if (device_data.data.devices_status[device_id].hasOwnProperty("cover:0")) {
device_config = this.util.getDeviceConfig(device_config.hostname + 'roller-');
}
}

this.setStoreValue('config', device_config);
} else {
this.log(this.getData().id + ' has no valid device config to set');
}
}
}
// END TODO

this.parseFullStatusUpdateGen2(device_data.data.devices_status[device_id])
}
this.homey.app.websocketCloudListener();
Expand Down
5 changes: 0 additions & 5 deletions drivers/shelly3em/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ class Shelly3EmDevice extends Device {
this.homey.flow.getDeviceTriggerCard('triggerMeterPowerReturned');
this.homey.flow.getDeviceTriggerCard('triggerMeterPowerFactor');

// TODO: REMOVE AFTER SOME RELEASES
if (!this.hasCapability('meter_power.total')) {
this.addCapability('meter_power.total');
}

this.bootSequence();

// CAPABILITY LISTENERS
Expand Down
5 changes: 0 additions & 5 deletions drivers/shelly3em_cloud/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ class Shelly3EmCloudDevice extends Device {
this.homey.flow.getDeviceTriggerCard('triggerMeterPowerReturned');
this.homey.flow.getDeviceTriggerCard('triggerMeterPowerFactor');

// TODO: REMOVE AFTER SOME RELEASES
if (!this.hasCapability('meter_power.total')) {
this.addCapability('meter_power.total');
}

this.setAvailable();

// CAPABILITY LISTENERS
Expand Down
5 changes: 0 additions & 5 deletions drivers/shellyrgbw2white/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ class ShellyRGBW2WhiteDevice extends Device {
this.homey.flow.getDeviceTriggerCard('triggerInput1Off');
this.homey.flow.getDeviceTriggerCard('triggerInput1Changed');

// TODO: REMOVE AFTER SOME RELEASES
if (!this.hasCapability('measure_power.total')) {
this.addCapability('measure_power.total');
}

this.bootSequence();

// CAPABILITY LISTENERS
Expand Down
5 changes: 0 additions & 5 deletions drivers/shellyrgbw2white_cloud/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ class ShellyRGBW2WhiteCloudDevice extends Device {
this.homey.flow.getDeviceTriggerCard('triggerInput1Off');
this.homey.flow.getDeviceTriggerCard('triggerInput1Changed');

// TODO: REMOVE AFTER SOME RELEASES
if (!this.hasCapability('measure_power.total')) {
this.addCapability('measure_power.total');
}

this.setAvailable();

this.bootSequence();
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cloud.shelly",
"version": "3.11.4",
"version": "3.11.5",
"description": "Homey app for controlling Shelly devices",
"main": "app.js",
"scripts": {
Expand Down

0 comments on commit 8e29788

Please sign in to comment.