Skip to content

Commit

Permalink
Release 3.9.11
Browse files Browse the repository at this point in the history
  • Loading branch information
jghaanstra committed Jun 1, 2022
1 parent 24e8ede commit 5ba1025
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 81 deletions.
3 changes: 3 additions & 0 deletions .homeychangelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -469,5 +469,8 @@
},
"3.9.10": {
"en": "Small bugfixes causing some devices to appear as offline after the latest release."
},
"3.9.11": {
"en": "This release fixes two issues. There is a fix for multichannel Plus and Pro devices on Homey Cloud and Homey Pro and a fix for some devices appearing as offline due to an error in status updates 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.9.10",
"version": "3.9.11",
"compatibility": ">=5.0.0",
"platforms": [ "local", "cloud" ],
"author": {
Expand Down
3 changes: 1 addition & 2 deletions .homeycompose/drivers/pair/multi_channel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
16 changes: 14 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,21 +563,33 @@ class ShellyApp extends OAuth2App {
try {
if (this.wss === null) {
this.wss = new WebSocket.Server({ port: 6113 });
this.log('Websocket server for gen2 devices with outbound websockets started');
this.wss.on("connection", (wsserver, req) => {

wsserver.send('{"jsonrpc":"2.0", "id":1, "src":"wsserver", "method":"Shelly.GetStatus"}');
wsserver.send('{"jsonrpc":"2.0", "id":1, "src":"wsserver-getdeviceinfo", "method":"Shelly.GetDeviceInfo"}');

wsserver.on("message", async (data) => {
const result = JSON.parse(data);
if (result.hasOwnProperty('method')) {
if (result.method === 'NotifyFullStatus') {
if (result.method === 'NotifyFullStatus') { // parse full status updates
//TODO: am I getting an inital status update?
console.log(result);
const filteredShelliesWss = this.shellyDevices.filter(shelly => shelly.id.toLowerCase().includes(result.src));
for (const filteredShellyWss of filteredShelliesWss) {
if (result.hasOwnProperty("params")) {
console.log(result.params);
filteredShellyWss.device.parseStatusUpdateGen2(result.params);
}
}
}
} else if (result.dst === 'wsserver-getdeviceinfo') { // parse device info request after each (re)connect
const filteredShelliesWss = this.shellyDevices.filter(shelly => shelly.id.toLowerCase().includes(result.src));
for (const filteredShellyWss of filteredShelliesWss) {
if (result.hasOwnProperty("result")) {
filteredShellyWss.device.setStoreValue('type', result.result.model);
filteredShellyWss.device.setStoreValue('fw_version', result.result.ver);
}
}
}
});
});
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.9.10",
"version": "3.9.11",
"compatibility": ">=5.0.0",
"platforms": [
"local",
Expand Down
68 changes: 37 additions & 31 deletions drivers/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ class ShellyDevice extends Homey.Device {
try {
if (this.getStoreValue('communication') === 'websocket') {

// gen2 devices with no available firmware version
// TODO: replace this after some version with a solution that updates the firmware version from parseStatusUpdateGen2() once supported
if (this.getStoreValue('fw_version') === null ) {
// gen 2 device init for non battery powered devices
if (!this.getStoreValue('battery')) {
const result = await this.util.sendRPCCommand('/rpc/Shelly.GetDeviceInfo', this.getSetting('address'), this.getSetting('password'));
this.setStoreValue('type', result.model);
this.setStoreValue('fw_version', result.ver);
}

Expand Down Expand Up @@ -322,6 +322,19 @@ class ShellyDevice extends Homey.Device {

// gen1 devices
} else {

// gen 1 device init for non battery powered devices
if (!this.getStoreValue('battery')) {
const result = await this.util.sendCommand('/shelly', this.getSetting('address'), this.getSetting('username'), this.getSetting('password'));
this.setStoreValue('type', result.type);
const regex = /(?<=\/v)(.*?)(?=\-)/gm;
const version_data = regex.exec(result.fw);
if (version_data !== null) {
this.setStoreValue('fw_version', version_data[0]);
}
}

// gen 1 polling
if (this.homey.settings.get('general_coap')) { // CoAP is disabled
var polling_frequency = this.homey.settings.get('general_polling_frequency') * 1000 || 5000;
} else { // CoAP is enabled
Expand All @@ -344,7 +357,7 @@ class ShellyDevice extends Homey.Device {
try {
if (Number(channel) === 0) {
if (this.hasCapability(capability)) {
if (value !== this.getCapabilityValue(capability) && value !== null) {
if (value !== this.getCapabilityValue(capability) && value !== null && value !== 'null') {
this.setCapabilityValue(capability, value);
}
} else {
Expand All @@ -371,11 +384,11 @@ class ShellyDevice extends Homey.Device {
async pollDevice() {
try {
if (this.getStoreValue('communication') === 'websocket') {
let result = await this.util.sendRPCCommand('/rpc/Shelly.GetStatus', this.getSetting('address'), this.getSetting('password'));
const result = await this.util.sendRPCCommand('/rpc/Shelly.GetStatus', this.getSetting('address'), this.getSetting('password'));
if (!this.getAvailable()) { this.setAvailable(); }
this.parseStatusUpdateGen2(result);
} else {
let result = await this.util.sendCommand('/status', this.getSetting('address'), this.getSetting('username'), this.getSetting('password'));
const result = await this.util.sendCommand('/status', this.getSetting('address'), this.getSetting('username'), this.getSetting('password'));
if (!this.getAvailable()) { this.setAvailable(); }
this.parseStatusUpdate(result);
}
Expand Down Expand Up @@ -932,19 +945,6 @@ class ShellyDevice extends Homey.Device {
// firmware update available?
if (result.hasOwnProperty("update")) {

if (result.update.hasOwnProperty("old_version")) {
const regex = /(?<=\/v)(.*?)(?=\-)/gm;
const version_data = regex.exec(result.update.old_version);
if (version_data !== null) {
const fw_version = version_data[0];
if (this.getStoreValue('fw_version') === null) {
this.setStoreValue('fw_version', fw_version);
} else if (semver.gt(fw_version, this.getStoreValue('fw_version'))) {
this.setStoreValue('fw_version', fw_version);
}
}
}

if (result.update.has_update === true && (this.getStoreValue('latest_firmware') !== result.update.new_version)) {
this.homey.flow.getTriggerCard('triggerFWUpdate').trigger({"id": this.getData().id, "device": this.getName(), "firmware": result.update.new_version}).catch(error => { this.error(error) });
this.setStoreValue("latest_firmware", result.update.new_version);
Expand Down Expand Up @@ -1076,28 +1076,34 @@ class ShellyDevice extends Homey.Device {
}
}

if (result.hasOwnProperty("input:1") && this.hasCapability('input_2')) {
if (result.hasOwnProperty("input:1")) {
if (result["input:1"].hasOwnProperty("state") && result["input:1"].state !== null) {
this.updateCapabilityValue('input_2', result["input:1"].state, channel);
if (this.hasCapability('input_2') && channel === 0) {
this.updateCapabilityValue('input_2', result["input:1"].state, channel);
} else if (this.hasCapability('input_1') && channel === 1) {
this.updateCapabilityValue('input_1', result["input:1"].state, channel);
}
}
} else if (!this.hasCapability('input_2') && channel !== 0) {
this.updateCapabilityValue('input_1', result["input:1"].state, channel);
}

if (result.hasOwnProperty("input:2") && this.hasCapability('input_3')) {
if (result.hasOwnProperty("input:2")) {
if (result["input:2"].hasOwnProperty("state") && result["input:2"].state !== null) {
this.updateCapabilityValue('input_3', result["input:2"].state, channel);
if (this.hasCapability('input_3') && channel === 0) {
this.updateCapabilityValue('input_3', result["input:2"].state, channel);
} else if (this.hasCapability('input_1') && channel === 2) {
this.updateCapabilityValue('input_1', result["input:2"].state, channel);
}
}
} else if (!this.hasCapability('input_3') && channel !== 0) {
this.updateCapabilityValue('input_1', result["input:2"].state, channel);
}

if (result.hasOwnProperty("input:3") && this.hasCapability('input_4')) {
if (result.hasOwnProperty("input:3")) {
if (result["input:3"].hasOwnProperty("state") && result["input:3"].state !== null) {
this.updateCapabilityValue('input_4', result["input:3"].state, channel);
if (this.hasCapability('input_4') && channel === 0) {
this.updateCapabilityValue('input_4', result["input:3"].state, channel);
} else if (this.hasCapability('input_1') && channel === 3) {
this.updateCapabilityValue('input_1', result["input:3"].state, channel);
}
}
} else if (!this.hasCapability('input_4') && channel !== 0) {
this.updateCapabilityValue('input_1', result["input:3"].state, channel);
}

// ACTION EVENTS (for GEN2 cloud devices only)
Expand Down
23 changes: 7 additions & 16 deletions drivers/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const Homey = require('homey');
const Util = require('../lib/util.js');
const semver = require('semver');

class ShellyDriver extends Homey.Driver {

Expand Down Expand Up @@ -61,15 +60,11 @@ class ShellyDriver extends Homey.Driver {
var result = await this.util.sendCommand('/shelly', discoveryResult.address, '', '');
var auth = result.auth;
var type = result.type;
const regex = /(?<=\/v)(.*?)(?=\-)/gm;
const version_data = regex.exec(result.fw);
var fw_version = version_data[0];
break;
case 'gen2':
var result = await this.util.sendCommand('/rpc/Shelly.GetDeviceInfo', discoveryResult.address, '', '');
var auth = result.auth_en;
var type = result.model;
var fw_version = result.ver;
break;
}

Expand All @@ -92,8 +87,7 @@ class ShellyDriver extends Homey.Driver {
battery: this.config.battery,
sdk: 3,
gen: this.config.gen,
communication: this.config.communication,
fw_version: fw_version
communication: this.config.communication
},
icon: deviceIcon
}
Expand All @@ -114,15 +108,11 @@ class ShellyDriver extends Homey.Driver {
var result = await this.util.sendCommand('/settings', data.address, data.username, data.password);
var id = result.device.hostname;
var type = result.device.type;
const regex = /(?<=\/v)(.*?)(?=\-)/gm;
const version_data = regex.exec(result.fw);
var fw_version = version_data[0];
break;
case 'gen2':
var result = await this.util.sendCommand('/rpc/Shelly.GetDeviceInfo', data.address, '', '');
var id = result.id;
var type = result.model;
var fw_version = result.ver;
break;
}

Expand All @@ -146,8 +136,7 @@ class ShellyDriver extends Homey.Driver {
battery: this.config.battery,
sdk: 3,
gen: this.config.gen,
communication: this.config.communication,
fw_version: fw_version
communication: this.config.communication
}
}
return Promise.resolve(deviceArray);
Expand Down Expand Up @@ -176,9 +165,11 @@ class ShellyDriver extends Homey.Driver {
const unicast = await this.util.setUnicast(deviceArray.settings.address, deviceArray.settings.username, deviceArray.settings.password);
deviceArray.store.unicast = true;
return Promise.resolve({device: deviceArray, config: this.config});
} else if (deviceArray.store.communication === 'websocket' && (semver.gt(deviceArray.store.fw_version, '0.11.0') || deviceArray.store.battery === true)) { // TODO: make this match the new firmware version that supports outbound websockets
const wsserver = await this.util.setWsServer(deviceArray.settings.address, deviceArray.settings.username, deviceArray.settings.password);
deviceArray.store.wsserver = true;
} else if (deviceArray.store.communication === 'websocket') { // TODO: make this match the new firmware version that supports outbound websockets
const result = await this.util.setWsServer(deviceArray.settings.address, deviceArray.settings.password);
if (result === 'OK') {
deviceArray.store.wsserver = true;
}
return Promise.resolve({device: deviceArray, config: this.config});
} else {
return Promise.resolve({device: deviceArray, config: this.config});
Expand Down
3 changes: 1 addition & 2 deletions drivers/shelly-plus-2pm/pair/add_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
3 changes: 1 addition & 2 deletions drivers/shelly-pro-2/pair/add_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
3 changes: 1 addition & 2 deletions drivers/shelly-pro-2pm/pair/add_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
3 changes: 1 addition & 2 deletions drivers/shelly2/pair/add_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
3 changes: 1 addition & 2 deletions drivers/shelly25/pair/add_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
3 changes: 1 addition & 2 deletions drivers/shelly3em/pair/add_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
3 changes: 1 addition & 2 deletions drivers/shelly4pro/pair/add_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
3 changes: 1 addition & 2 deletions drivers/shellyem/pair/add_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
3 changes: 1 addition & 2 deletions drivers/shellyrgbw2white/pair/add_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
3 changes: 1 addition & 2 deletions drivers/shellyuni/pair/add_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
wsserver: result.device.store.wsserver,
sdk: 3,
gen: result.device.store.gen,
communication: result.device.store.communication,
fw_version: result.device.store.fw_version
communication: result.device.store.communication
},
icon: result.device.icon
});
Expand Down
Loading

0 comments on commit 5ba1025

Please sign in to comment.