diff --git a/.homeychangelog.json b/.homeychangelog.json index 6db2a4a0..93477928 100644 --- a/.homeychangelog.json +++ b/.homeychangelog.json @@ -466,5 +466,8 @@ }, "3.9.9": { "en": "This release fixes handling inputs on multichannel devices on Homey Cloud. It also fixes various capabilities being out of range on both Homey Pro and Homey Cloud. A there is some better error handling when connecting to Shelly Cloud for Homey Cloud." + }, + "3.9.10": { + "en": "Small bugfixes causing some devices to appear as offline after the latest release." } } diff --git a/.homeycompose/app.json b/.homeycompose/app.json index d9a18701..aaf0be9a 100644 --- a/.homeycompose/app.json +++ b/.homeycompose/app.json @@ -68,7 +68,7 @@ "Shelly radiator" ] }, - "version": "3.9.9", + "version": "3.9.10", "compatibility": ">=5.0.0", "platforms": [ "local", "cloud" ], "author": { diff --git a/app.json b/app.json index 6e744b73..cffe18e6 100644 --- a/app.json +++ b/app.json @@ -69,7 +69,7 @@ "Shelly radiator" ] }, - "version": "3.9.9", + "version": "3.9.10", "compatibility": ">=5.0.0", "platforms": [ "local", diff --git a/drivers/device.js b/drivers/device.js index 3b0c0f79..259958bc 100644 --- a/drivers/device.js +++ b/drivers/device.js @@ -342,9 +342,9 @@ class ShellyDevice extends Homey.Device { /* updating capabilities */ async updateCapabilityValue(capability, value, channel = 0) { try { - if (channel === 0) { + if (Number(channel) === 0) { if (this.hasCapability(capability)) { - if (value != this.getCapabilityValue(capability)) { + if (value !== this.getCapabilityValue(capability) && value !== null) { this.setCapabilityValue(capability, value); } } else { @@ -353,7 +353,13 @@ class ShellyDevice extends Homey.Device { } else { const device_id = this.getStoreValue('main_device') + '-channel-' + channel; const device = this.driver.getDevice({id: device_id }); - device.updateCapabilityValue(capability, value); + if (device.hasCapability(capability)) { + if (value !== device.getCapabilityValue(capability) && value !== null) { + device.setCapabilityValue(capability, value); + } + } else { + device.addCapability(capability); + } } } catch (error) { this.error('Trying to update capability', capability, 'with value', value, 'for device', this.getData().id); @@ -926,13 +932,17 @@ class ShellyDevice extends Homey.Device { // firmware update available? if (result.hasOwnProperty("update")) { - const regex = /(?<=\/v)(.*?)(?=\-)/gm; - const version_data = regex.exec(result.update.old_version); - 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.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)) { diff --git a/package-lock.json b/package-lock.json index 3470f3e1..ad34e278 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cloud.shelly", - "version": "3.9.9", + "version": "3.9.10", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 2242b820..9b0a5757 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cloud.shelly", - "version": "3.9.9", + "version": "3.9.10", "description": "Homey app for controlling Shelly devices", "main": "app.js", "scripts": {