diff --git a/modules/ScheduledScene/index.js b/modules/ScheduledScene/index.js index f4b275faf..e33cf82d7 100644 --- a/modules/ScheduledScene/index.js +++ b/modules/ScheduledScene/index.js @@ -1,7 +1,7 @@ /*** ScheduledScene Z-Way HA module ******************************************* -Version: 2.2.1 -(c) Z-Wave.Me, 2017 +Version: 2.2.2 +(c) Z-Wave.Me, 2018 ----------------------------------------------------------------------------- Author: Serguei Poltorak , Niels Roche , Yurkin Vitaliy Author: Hans-Christian Göckeritz @@ -32,15 +32,50 @@ ScheduledScene.prototype.init = function (config) { var self = this; + /**** TRANSFORM OLD CONFIG FROM 2.1.2 TO 2.2.1 VERSION ****/ + var needToSaveConfig = false; + + if (self.config.switches) { + self.config.devices.switches = self.config.switches; + delete self.config.switches; + needToSaveConfig = true; + } + if (self.config.dimmers) { + self.config.devices.dimmers = self.config.dimmers; + delete self.config.dimmers; + needToSaveConfig = true; + } + if (self.config.thermostats) { + self.config.devices.thermostats = self.config.thermostats; + delete self.config.thermostats; + needToSaveConfig = true; + } + if (self.config.scenes) { + self.config.devices.scenes = self.config.scenes; + delete self.config.scenes; + needToSaveConfig = true; + } + if (self.config.locks) { + self.config.devices.locks = self.config.locks; + delete self.config.locks; + needToSaveConfig = true; + } + if (self.config.time) { + self.config.times = []; + self.config.times.push(self.config.time); + delete self.config.time; + needToSaveConfig = true; + } + if (needToSaveConfig) { + self.saveConfig(); + } + /***********************************************************/ + this.runScene = function() { var switchesArray; if (_.isArray(self.config.devices.switches)) { switchesArray = self.config.devices.switches; } - // compatibility configuration to version 2.2 - if (_.isArray(self.config.switches)) { - switchesArray = self.config.switches; - } if (switchesArray) { switchesArray.forEach(function(devState) { @@ -57,10 +92,6 @@ ScheduledScene.prototype.init = function (config) { if (_.isArray(self.config.devices.thermostats)) { thermostatsArray = self.config.devices.thermostats; } - // compatibility configuration to version 2.2 - if (_.isArray(self.config.thermostats)) { - thermostatsArray = self.config.thermostats; - } if (thermostatsArray) { thermostatsArray.forEach(function(devState) { @@ -77,10 +108,6 @@ ScheduledScene.prototype.init = function (config) { if (_.isArray(self.config.devices.dimmers)) { dimmersArray = self.config.devices.dimmers; } - // compatibility configuration to version 2.2 - if (_.isArray(self.config.dimmers)) { - dimmersArray = self.config.dimmers; - } if (dimmersArray) { dimmersArray.forEach(function(devState) { @@ -97,10 +124,6 @@ ScheduledScene.prototype.init = function (config) { if (_.isArray(self.config.devices.locks)) { locksArray = self.config.devices.locks; } - // compatibility configuration to version 2.2 - if (_.isArray(self.config.locks)) { - locksArray = self.config.locks; - } if (locksArray) { locksArray.forEach(function(devState) { @@ -117,10 +140,6 @@ ScheduledScene.prototype.init = function (config) { if (_.isArray(self.config.devices.scenes)) { scenesArray = self.config.devices.scenes; } - // compatibility configuration to version 2.2 - if (_.isArray(self.config.scenes)) { - scenesArray = self.config.scenes; - } if (scenesArray) { scenesArray.forEach(function(scene) { @@ -154,16 +173,6 @@ ScheduledScene.prototype.init = function (config) { }); }); } - // compatibility configuration to version 2.2 - else { - self.controller.emit("cron.addTask", "scheduledScene.run."+self.id, { - minute: parseInt(self.config.time.split(":")[1], 10), - hour: parseInt(self.config.time.split(":")[0], 10), - weekDay: wd, - day: null, - month: null - }); - } }); }; diff --git a/modules/ScheduledScene/module.json b/modules/ScheduledScene/module.json index 3f4850d49..ae51ebd15 100644 --- a/modules/ScheduledScene/module.json +++ b/modules/ScheduledScene/module.json @@ -5,7 +5,7 @@ "homepage": "http://razberry.z-wave.me", "icon": "icon.png", "moduleName":"ScheduledScene", - "version": "2.2.1", + "version": "2.2.2", "maturity": "stable", "repository": { "type": "git",