From 4ab7ecb7117f7f47f3dfe36e2be79cb5208ab7c5 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 6 Sep 2023 12:53:17 +0200 Subject: [PATCH 001/118] Update package.json changed request into axios --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 57cd3fc..1682d70 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "Siri" ], "dependencies": { - "request": ">=2.88.2", + "axios": ">=1.5.0", "fakegato-history": "NebzHB/fakegato-history#master" }, "devDependencies": { From 1f3f3ecb002c91c6954af41792679c37301f314a Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 6 Sep 2023 12:53:35 +0200 Subject: [PATCH 002/118] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1682d70..6b53743 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", - "version": "v1.6.1", - "cust_serial": "0007", + "version": "v1.6.2", + "cust_serial": "0001", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 634d48794c990ae98078418d84fd979f6317c8d3 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:50:56 +0200 Subject: [PATCH 003/118] Update jeedom-api.js replace request by axios --- lib/jeedom-api.js | 290 ++++++++++++++++++++++------------------------ 1 file changed, 136 insertions(+), 154 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 1b6a32f..f07f7c6 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -15,8 +15,7 @@ */ /* jshint esversion: 6,node: true */ 'use strict'; - -var request = require('request'); +const axios = require('axios'); var DEV_DEBUG; function JeedomClient(url, apikey, Plateform, myPlugin) { @@ -32,36 +31,33 @@ function JeedomClient(url, apikey, Plateform, myPlugin) { JeedomClient.prototype.getModel = function() { var that = this; - - return new Promise(function(resolve, reject) { - var url = that.url; - var request_id = Math.floor(Math.random() * 1000); - request.post(url, { - json : true, - gzip : true, - form : { - request : '{"jsonrpc":"2.0","id":"'+request_id+'","method":"sync_homebridge","params":{"plugin":"'+that.myPlugin+'","apikey":"' + that.apikey + '","session":true,"sess_id":"'+ that.sess_id +'"}}', - }, - }, function(err, response, json) { - // that.log(JSON.stringify(response).replace('\n','')); - if (!err && response.statusCode == 200) { - if(!json) {reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(response));} - if(!json.result && json.error) { - reject(json.error); - } else { - if(json.sess_id !== undefined) { - that.sess_id = json.sess_id; - } else { - that.sess_id = ""; - } - that._cachedModel=json.result; - resolve(that._cachedModel); - } - + var url = that.url; + var request_id = Math.floor(Math.random() * 1000); + + return axios.post(url, + { + jsonrpc:"2.0", + id:request_id, + method:"sync_homebridge", + params:{ + plugin:that.myPlugin, + apikey:that.apikey, + session:true, + sess_id:that.sess_id + } + }).then(result => { + if(!result.data) {throw new Error("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data.result && result.data.error) { + throw new Error(result.data.error.message); + } else { + if(result.data.sess_id !== undefined) { + that.sess_id = result.data.sess_id; } else { - reject(err); + that.sess_id = ""; } - }); + that._cachedModel=result.data.result; + return that._cachedModel; + } }); }; @@ -80,32 +76,39 @@ JeedomClient.prototype.getDevicePropertiesFromCache = function(ID) { JeedomClient.prototype.getDeviceProperties = function(ID) { var that = this; - var p = new Promise(function(resolve, reject) { - var url = that.url; - var request_id = Math.floor(Math.random() * 1000); - request.post(url, { - json : true, - form : { - request : '{"jsonrpc":"2.0","id":"'+request_id+'","method":"getEql","params":{"plugin":"'+that.myPlugin+'","apikey":"' + that.apikey + '","id":"' + ID + '","session":true,"sess_id":"'+ that.sess_id +'"}}', - }, - }, function(err, response, json) { - if (!err && response.statusCode == 200) { - if(!json.result && json.error) { - reject(json.error); - } else { - if(json.sess_id !== undefined) { - that.sess_id = json.sess_id; - } else { - that.sess_id = ""; - } - resolve(json.result); - } + var url = that.url; + var request_id = Math.floor(Math.random() * 1000); + + return axios.post(url, + { + jsonrpc:"2.0", + id:request_id, + method:"getEql", + params:{ + plugin:that.myPlugin, + apikey:that.apikey, + id:ID, + session:true, + sess_id:that.sess_id + } + }).then(result => { + if(!result.data) {throw new Error("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data.result && result.data.error) { + throw new Error(result.data.error.message); + } else { + if(result.data.sess_id !== undefined) { + that.sess_id = result.data.sess_id; } else { - reject(err); + that.sess_id = ""; } - }); + if(result.data.result != 'ok') { + return result.data.result; + } else { + throw new Error("EqLogic "+ID+" n'existe pas ou pas envoyé à homebridge"); + } + } }); - return p; + }; JeedomClient.prototype.getDeviceCmdFromCache = function(ID) { @@ -135,36 +138,6 @@ JeedomClient.prototype.getScenarioPropertiesFromCache = function(ID) { return null; }; -JeedomClient.prototype.getScenarioProperties = function(ID) { - var that = this; - var p = new Promise(function(resolve, reject) { - var url = that.url; - var request_id = Math.floor(Math.random() * 1000); - request.post(url, { - json : true, - form : { - request : '{"jsonrpc":"2.0","id":"'+request_id+'","method":"scenario::byId","params":{"apikey":"' + that.apikey + '","id":"' + ID + '","session":true,"sess_id":"'+ that.sess_id +'"}}', - }, - }, function(err, response, json) { - if (!err && response.statusCode == 200) { - if(!json.result && json.error) { - reject(json.error); - } else { - if(json.sess_id !== undefined) { - that.sess_id = json.sess_id; - } else { - that.sess_id = ""; - } - resolve(json.result); - } - } else { - reject(err); - } - }); - }); - return p; -}; - JeedomClient.prototype.updateModelScenario = function(ID,state) { var that = this; for (var s in that._cachedModel.scenarios) { @@ -1521,102 +1494,111 @@ JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { var that = this; - var options = ',"options":{}'; + var options = {}; + var url = that.url; + var request_id = Math.floor(Math.random() * 1000); // console.log('params : ' + param); if (param != null) { if (action == 'setRGB') { - options = ',"options":{"color":"' + param + '"}'; + options = {color:param}; } else if (action == 'GBtoggleSelect') { - options = ',"options":{"select":"' + param + '"}'; + options = {select:param}; } else if (!isNaN(parseInt(param))) { - options = ',"options":{"slider":' + parseInt(param) + '}'; + options = {slider:parseInt(param)}; } } - return new Promise(function(resolve, reject) { - var url = that.url; - var request_id = Math.floor(Math.random() * 1000); - request.post(url, { - json : true, - form : { - request : '{"jsonrpc":"2.0","id":"'+request_id+'","method":"cmd::execCmd","params":{"apikey":"' + that.apikey + '","id":"' + ID + '"' + options + ',"session":true,"sess_id":"'+ that.sess_id +'"}}', - }, - }, function(err, response, json) { - if (!err && (response.statusCode == 200 || response.statusCode == 202)){ - if(!json.result && json.error) { - reject(json.error); - } else { - if(json.sess_id !== undefined) { - that.sess_id = json.sess_id; - } else { - that.sess_id = ""; - } - resolve(json.result); - } + return axios.post(url, + { + jsonrpc:"2.0", + id:request_id, + method:"cmd::execCmd", + params:{ + apikey:that.apikey, + id:ID, + options:options, + session:true, + sess_id:that.sess_id + } + }).then(result => { + if(!result.data) {throw new Error("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data.result && result.data.error) { + throw new Error(result.data.error.message); + } else { + if(result.data.sess_id !== undefined) { + that.sess_id = result.data.sess_id; } else { - reject(err); + that.sess_id = ""; } - }); + return result.data.result; + } }); }; JeedomClient.prototype.executeScenarioAction = function(ID, action) { var that = this; + var url = that.url; + var request_id = Math.floor(Math.random() * 1000); - return new Promise(function(resolve, reject) { - var url = that.url; - var request_id = Math.floor(Math.random() * 1000); - request.post(url, { - json : true, - form : { - request : '{"jsonrpc":"2.0","id":"'+request_id+'","method":"scenario::changeState","params":{"apikey":"' + that.apikey + '","id":"' + ID + '","state":"' + action + '","session":true,"sess_id":"'+ that.sess_id +'"}}', - }, - }, function(err, response, json) { - if (!err && (response.statusCode == 200 || response.statusCode == 202)) { - if(!json.result && json.error) { - reject(json.error); - } else { - if(json.sess_id !== undefined) { - that.sess_id = json.sess_id; - } else { - that.sess_id = ""; - } - resolve(json.result); - } + return axios.post(url, + { + jsonrpc:"2.0", + id:request_id, + method:"scenario::changeState", + params:{ + apikey:that.apikey, + id:ID, + state:action, + session:true, + sess_id:that.sess_id + } + }).then(result => { + if(!result.data) {throw new Error("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data.result && result.data.error) { + throw new Error(result.data.error.message); + } else { + if(result.data.sess_id !== undefined) { + that.sess_id = result.data.sess_id; } else { - reject(err); + that.sess_id = ""; } - }); + return result.data.result; + } }); }; JeedomClient.prototype.refreshStates = function() { var that = this; - return new Promise(function(resolve, reject) { - var url = that.url; - var request_id = Math.floor(Math.random() * 1000); - request.post(url, { - timeout : 70000, - json : true, - form : { - request : '{"jsonrpc":"2.0","id":"'+request_id+'","method":"event::changes","params":{"apikey":"' + that.apikey + '","longPolling":"30","datetime" : "' + that.Plateform.lastPoll + '","filter":"homebridge","session":true,"sess_id":"'+ that.sess_id +'"}}', - }, - }, function(err, response, json) { - if (!err && response.statusCode == 200) { - if(!json.result && json.error) { - reject(json.error); - } else { - if(json.sess_id !== undefined) { - that.sess_id = json.sess_id; - } else { - that.sess_id = ""; - } - resolve(json.result); - } + var url = that.url; + var request_id = Math.floor(Math.random() * 1000); + + return axios.post(url, + { + jsonrpc:"2.0", + id:request_id, + method:"event::changes", + params:{ + apikey:that.apikey, + longPolling:"30", + datetime:that.Plateform.lastPoll, + filter:"homebridge", + session:true, + sess_id:that.sess_id + } + },{ + timeout: 70000 + }).then(result => { + if(!result.data) {throw new Error("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data.result && result.data.error) { + throw new Error(result.data.error.message); + } else { + if(result.data.sess_id !== undefined) { + that.sess_id = result.data.sess_id; } else { - reject(err); + that.sess_id = ""; } - }); + return result.data.result; + } }); }; From 3e65b87a246663f077636ca4391c0b6f0932a3c9 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:51:33 +0200 Subject: [PATCH 004/118] Update index.js add catch error --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 5973cc7..51d1fca 100755 --- a/index.js +++ b/index.js @@ -5607,6 +5607,8 @@ JeedomPlatform.prototype.startPollingUpdate = function() { that.log('debug',"Changing Enable in",update.option.eqLogic_id,'from',cacheState.isEnable,'to',eqLogic.isEnable); that.jeedomClient.updateModelEq(update.option.eqLogic_id,eqLogic); } + }).catch(e => { + that.log('error','Erreur :',e); }); that.log('debug','[Reçu Type non géré]',update.name+' contenu: '+JSON.stringify(update).replace("\n","")); } else if(DEV_DEBUG) { From 99ad17ccb47344dcbae530393adce5eebc4d60ea Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Thu, 7 Sep 2023 07:42:03 +0200 Subject: [PATCH 005/118] Update jeedom-api.js replace throw new Error by return Promise.reject( --- lib/jeedom-api.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index f07f7c6..152ffd0 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -46,9 +46,9 @@ JeedomClient.prototype.getModel = function() { sess_id:that.sess_id } }).then(result => { - if(!result.data) {throw new Error("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { - throw new Error(result.data.error.message); + return Promise.reject(result.data.error.message); } else { if(result.data.sess_id !== undefined) { that.sess_id = result.data.sess_id; @@ -92,9 +92,9 @@ JeedomClient.prototype.getDeviceProperties = function(ID) { sess_id:that.sess_id } }).then(result => { - if(!result.data) {throw new Error("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { - throw new Error(result.data.error.message); + return Promise.reject(result.data.error.message); } else { if(result.data.sess_id !== undefined) { that.sess_id = result.data.sess_id; @@ -104,7 +104,7 @@ JeedomClient.prototype.getDeviceProperties = function(ID) { if(result.data.result != 'ok') { return result.data.result; } else { - throw new Error("EqLogic "+ID+" n'existe pas ou pas envoyé à homebridge"); + return Promise.reject("EqLogic "+ID+" n'existe pas ou pas envoyé à homebridge"); } } }); @@ -1521,9 +1521,9 @@ JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { sess_id:that.sess_id } }).then(result => { - if(!result.data) {throw new Error("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { - throw new Error(result.data.error.message); + return Promise.reject(result.data.error.message); } else { if(result.data.sess_id !== undefined) { that.sess_id = result.data.sess_id; @@ -1553,9 +1553,9 @@ JeedomClient.prototype.executeScenarioAction = function(ID, action) { sess_id:that.sess_id } }).then(result => { - if(!result.data) {throw new Error("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { - throw new Error(result.data.error.message); + return Promise.reject(result.data.error.message); } else { if(result.data.sess_id !== undefined) { that.sess_id = result.data.sess_id; @@ -1588,9 +1588,9 @@ JeedomClient.prototype.refreshStates = function() { },{ timeout: 70000 }).then(result => { - if(!result.data) {throw new Error("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { - throw new Error(result.data.error.message); + return Promise.reject(result.data.error.message); } else { if(result.data.sess_id !== undefined) { that.sess_id = result.data.sess_id; From 1e1256b3974a6d9a47476703ff321bf3d43cf082 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Thu, 7 Sep 2023 08:08:28 +0200 Subject: [PATCH 006/118] Update jeedom-api.js --- lib/jeedom-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 152ffd0..ffb26d0 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -1579,7 +1579,7 @@ JeedomClient.prototype.refreshStates = function() { method:"event::changes", params:{ apikey:that.apikey, - longPolling:"30", + longPolling:30, datetime:that.Plateform.lastPoll, filter:"homebridge", session:true, From cdac163d4eb60c3019cde3287e4a82dd7ca02f80 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 10:35:34 +0000 Subject: [PATCH 007/118] Update eslint requirement from ^8.52.0 to ^8.53.0 (#187) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d5cd8fa..e1572a5 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "devDependencies": { "@babel/core": ">=7.23.2", "@babel/eslint-parser": "^7.22.15", - "eslint": "^8.52.0" + "eslint": "^8.53.0" }, "author": "Nebz ", "license": "GPL-2.0", From 6e1d02f211acce74a5f66b482e46714a0f0db227 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:53:13 +0100 Subject: [PATCH 008/118] Add lux fakegato + remove for thermostat HC (no service) --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 28d1f01..9c2f0ce 100755 --- a/index.js +++ b/index.js @@ -1890,14 +1890,14 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.eqID = eqLogic.id; Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - /* if(that.fakegato && !eqLogic.hasLogging) { + if(that.fakegato && !eqLogic.hasLogging) { // HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.loggingService = {type:"custom", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; - } */ + } HBservices.push(HBservice); HBservice = null; } @@ -3840,7 +3840,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i time: Math.round(new Date().valueOf() / 1000), temp: returnValue, }); - } else if (cmd.generic_type == 'THERMOSTAT_TEMPERATURE' || cmd.generic_type == 'THERMOSTAT_HC_TEMPERATURE') { + } else if (cmd.generic_type == 'THERMOSTAT_TEMPERATURE') { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), currentTemp: returnValue, From b9c409ce8153a2037a89eeecf4fd278d4687ba72 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:00:35 +0100 Subject: [PATCH 009/118] fix addEntry for lux --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 9c2f0ce..03f43a3 100755 --- a/index.js +++ b/index.js @@ -3816,12 +3816,12 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i for (const cmd of cmdList) { if (cmd.generic_type == 'BRIGHTNESS' && cmd.id == service.cmd_id) { returnValue = cmd.currentValue; - /* if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), lux: returnValue, }); - } */ + } break; } } From f44878e6c4a9d478fd40d4295bfad7a0c2d44c1d Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 20 Nov 2023 08:04:35 +0100 Subject: [PATCH 010/118] add mode manual = auto thermostat --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 03f43a3..baaf8af 100755 --- a/index.js +++ b/index.js @@ -4392,6 +4392,8 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i case 'ninguna': // ES case 'ohne': // DE case 'nemhum': // PT + case 'manuel': // Plugin Boiler + case 'manual': // Plugin Boiler returnValue = Characteristic.TargetHeatingCoolingState.AUTO; break; } From f6e57233b24763737a8cc1db7bcd867de7c87cac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 14:21:39 +0000 Subject: [PATCH 011/118] Update @babel/core requirement from >=7.23.2 to >=7.23.7 (#195) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e1572a5..71f08c6 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "fakegato-history": "NebzHB/fakegato-history#master" }, "devDependencies": { - "@babel/core": ">=7.23.2", + "@babel/core": ">=7.23.7", "@babel/eslint-parser": "^7.22.15", "eslint": "^8.53.0" }, From 0fa5a557303c71692f1ab3a8b6699023fa41cd28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 14:21:54 +0000 Subject: [PATCH 012/118] Update eslint requirement from ^8.53.0 to ^8.56.0 (#194) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 71f08c6..490a329 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "devDependencies": { "@babel/core": ">=7.23.7", "@babel/eslint-parser": "^7.22.15", - "eslint": "^8.53.0" + "eslint": "^8.56.0" }, "author": "Nebz ", "license": "GPL-2.0", From ea333e08d5902fbc75977cc0b5dcc8f46add138e Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:27:13 +0100 Subject: [PATCH 013/118] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e51ae78..75c15d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [16.x, 17.x, 18.x, 20.x] + node-version: [18.x, 20.x, 21.x, 22.x] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} From 1e5fe609fa3f14454e6651c21256b8fab02d437c Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:27:34 +0100 Subject: [PATCH 014/118] Update build.yml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 75c15d4..ac63ceb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: Build on: push: - branches: [ beta ] + branches: [ beta, alpha ] pull_request: - branches: [ beta ] + branches: [ beta, alpha ] jobs: build: From 8367fffa62e3a0c69e7a9b6796bbcb38fafea6f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 14:27:57 +0000 Subject: [PATCH 015/118] Update @babel/eslint-parser requirement from ^7.22.15 to ^7.23.3 (#188) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 490a329..e47ed58 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "devDependencies": { "@babel/core": ">=7.23.7", - "@babel/eslint-parser": "^7.22.15", + "@babel/eslint-parser": "^7.23.3", "eslint": "^8.56.0" }, "author": "Nebz ", From 25b07a19efc1ffcfb759d652156dae5d76d3318a Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:28:56 +0100 Subject: [PATCH 016/118] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac63ceb..b7f858f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [18.x, 20.x, 21.x, 22.x] + node-version: [18.x, 20.x, 21.x] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} From aabbab93ab936f59ece0dda7e62958e1952c46e7 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:30:50 +0100 Subject: [PATCH 017/118] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 51d1fca..f2fa22a 100755 --- a/index.js +++ b/index.js @@ -5607,7 +5607,7 @@ JeedomPlatform.prototype.startPollingUpdate = function() { that.log('debug',"Changing Enable in",update.option.eqLogic_id,'from',cacheState.isEnable,'to',eqLogic.isEnable); that.jeedomClient.updateModelEq(update.option.eqLogic_id,eqLogic); } - }).catch(e => { + }).catch((e) => { that.log('error','Erreur :',e); }); that.log('debug','[Reçu Type non géré]',update.name+' contenu: '+JSON.stringify(update).replace("\n","")); From 5759a22c0b90b3f022f8038b37c474109577a021 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:32:15 +0100 Subject: [PATCH 018/118] Update jeedom-api.js --- lib/jeedom-api.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index ffb26d0..ac8838a 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -43,9 +43,9 @@ JeedomClient.prototype.getModel = function() { plugin:that.myPlugin, apikey:that.apikey, session:true, - sess_id:that.sess_id - } - }).then(result => { + sess_id:that.sess_id, + }, + }).then((result) => { if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { return Promise.reject(result.data.error.message); @@ -89,9 +89,9 @@ JeedomClient.prototype.getDeviceProperties = function(ID) { apikey:that.apikey, id:ID, session:true, - sess_id:that.sess_id - } - }).then(result => { + sess_id:that.sess_id, + }, + }).then((result) => { if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { return Promise.reject(result.data.error.message); @@ -1518,9 +1518,9 @@ JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { id:ID, options:options, session:true, - sess_id:that.sess_id - } - }).then(result => { + sess_id:that.sess_id, + }, + }).then((result) => { if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { return Promise.reject(result.data.error.message); From 77db78434f034c8266f6dfee4128674c6a7fff53 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:36:39 +0100 Subject: [PATCH 019/118] Update jeedom-api.js --- lib/jeedom-api.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index ac8838a..db64cf8 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -1550,9 +1550,9 @@ JeedomClient.prototype.executeScenarioAction = function(ID, action) { id:ID, state:action, session:true, - sess_id:that.sess_id - } - }).then(result => { + sess_id:that.sess_id, + }, + }).then((result) => { if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { return Promise.reject(result.data.error.message); @@ -1583,11 +1583,11 @@ JeedomClient.prototype.refreshStates = function() { datetime:that.Plateform.lastPoll, filter:"homebridge", session:true, - sess_id:that.sess_id - } + sess_id:that.sess_id, + }, },{ - timeout: 70000 - }).then(result => { + timeout: 70000, + }).then((result) => { if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { return Promise.reject(result.data.error.message); From 48eb7e42f6fe2a871d565967a6c30aaf6093bc0f Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 5 Jan 2024 08:43:09 +0100 Subject: [PATCH 020/118] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e47ed58..d8084d3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.6.1", - "cust_serial": "0009", + "cust_serial": "0010", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, @@ -25,7 +25,7 @@ "Siri" ], "dependencies": { - "request": ">=2.88.2", + "axios": ">=1.5.0", "fakegato-history": "NebzHB/fakegato-history#master" }, "devDependencies": { From bd14205f210281a2829f13c21403257a346f4ad5 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 5 Jan 2024 08:43:49 +0100 Subject: [PATCH 021/118] Update package.json --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 6b53743..d8084d3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", - "version": "v1.6.2", - "cust_serial": "0001", + "version": "v1.6.1", + "cust_serial": "0010", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, @@ -29,9 +29,9 @@ "fakegato-history": "NebzHB/fakegato-history#master" }, "devDependencies": { - "@babel/core": ">=7.22.15", - "@babel/eslint-parser": "^7.22.15", - "eslint": "^8.48.0" + "@babel/core": ">=7.23.7", + "@babel/eslint-parser": "^7.23.3", + "eslint": "^8.56.0" }, "author": "Nebz ", "license": "GPL-2.0", From bdc6ad1b6cc598c664afba2ec4abd88a300d2a22 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 5 Jan 2024 09:01:01 +0100 Subject: [PATCH 022/118] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d8084d3..cafa177 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", - "version": "v1.6.1", - "cust_serial": "0010", + "version": "v1.7.0", + "cust_serial": "0001", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 9010806dba6e51c3a483ebbc7dcb0256407e6368 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 5 Jan 2024 18:32:42 +0100 Subject: [PATCH 023/118] Fix slider .5 --- lib/jeedom-api.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index db64cf8..dfdcfd3 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -1503,8 +1503,10 @@ JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { options = {color:param}; } else if (action == 'GBtoggleSelect') { options = {select:param}; - } else if (!isNaN(parseInt(param))) { + } else if (!isNaN(parseInt(param)) && parseInt(param) == param) { options = {slider:parseInt(param)}; + } else if (!isNaN(parseFloat(param)) && parseFloat(param) == param) { + options = {slider:parseFloat(param)}; } } From 7b792442e99166f242d4a7da68bd67163dcafa18 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 5 Jan 2024 18:34:24 +0100 Subject: [PATCH 024/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cafa177..2969d42 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0001", + "cust_serial": "0002", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 3d575fc543f81869a05be2330b6e07c28332192c Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 8 Jan 2024 13:17:34 +0100 Subject: [PATCH 025/118] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 89bd726..1c1c0f2 100755 --- a/index.js +++ b/index.js @@ -138,7 +138,7 @@ JeedomPlatform.prototype.addAccessories = function() { }); } else { that.log('error','Pièce > '+model.objects); - throw new Error('Rooms list empty or invalid'); + throw new Error('Liste des pièces vide ou invalide, vérifiez que vous avez bien coché au moins une pièce à envoyer à homebridge !'); } that.log('Enumération des scénarios Jeedom...'); From 3960b34ac591ebb80e5ae5ec37218a52d84a7c93 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 8 Jan 2024 13:18:12 +0100 Subject: [PATCH 026/118] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 1c1c0f2..68c4f29 100755 --- a/index.js +++ b/index.js @@ -138,7 +138,7 @@ JeedomPlatform.prototype.addAccessories = function() { }); } else { that.log('error','Pièce > '+model.objects); - throw new Error('Liste des pièces vide ou invalide, vérifiez que vous avez bien coché au moins une pièce à envoyer à homebridge !'); + throw new Error("Liste des pièces vide ou invalide, vérifiez que vous avez bien coché au moins une pièce à envoyer à homebridge !"); } that.log('Enumération des scénarios Jeedom...'); From 4a14dc48d0f9d113affa8675237056bfaff0dc47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:03:26 +0000 Subject: [PATCH 027/118] Update axios requirement from >=1.5.0 to >=1.6.5 (#198) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2969d42..db1d6e2 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "Siri" ], "dependencies": { - "axios": ">=1.5.0", + "axios": ">=1.6.5", "fakegato-history": "NebzHB/fakegato-history#master" }, "devDependencies": { From 37aa32c6d370be0505020499cebb4816c59b0479 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:03:57 +0100 Subject: [PATCH 028/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index db1d6e2..7b30488 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0002", + "cust_serial": "0003", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 14f44db111dd1a0220cd2eef54df2630a2af2f7b Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:16:07 +0100 Subject: [PATCH 029/118] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 68c4f29..c70ba6c 100755 --- a/index.js +++ b/index.js @@ -337,7 +337,7 @@ JeedomPlatform.prototype.JeedomDevices2HomeKitAccessories = function(devices) { that.log('error','!!! ERREUR DETECTÉE, ON QUITTE HOMEBRIDGE !!!'); process.exit(1); } - const endLog = '--== Homebridge est démarré et a intégré '+countA+' accessoire'+ (countA>1 ? 's' : '') +' ! (Si vous avez un Warning Avahi, ne pas en tenir compte) ==--'; + const endLog = '--== Homebridge est démarré et a intégré '+countA+' accessoire'+ (countA>1 ? 's' : '') +' ! ==--'; that.log(endLog); if(countA >= 150) {that.log('error','!!! ATTENTION !!! Vous avez '+countA+' accessoires + Jeedom et HomeKit en supporte 150 max au total !!');} else if(countA >= 140) {that.log('warn','!! Avertissement, vous avez '+countA+' accessoires + Jeedom et HomeKit en supporte 150 max au total !!');} From 810c6ee22336519764004e52d9f02282125273c6 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:07:10 +0100 Subject: [PATCH 030/118] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index c70ba6c..e71b853 100755 --- a/index.js +++ b/index.js @@ -5623,7 +5623,7 @@ JeedomPlatform.prototype.startPollingUpdate = function() { } }).then(function(){ that.pollingUpdateRunning = false; - that.pollingID = setTimeout(function(){ /* that.log('debug','==RESTART POLLING=='); */that.startPollingUpdate(); }, that.pollerPeriod * 1000); + that.pollingID = setImmediate(() => that.startPollingUpdate()); }).catch(function(err) { that.log('error','Erreur de récupération des évènements de mise à jour: ', err); if(err && err.stack) { console.error(err.stack); } From 5df616f9a2afd646faa8350d5c8b4ec71c848397 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:18:06 +0100 Subject: [PATCH 031/118] no session anymore + simplify --- lib/jeedom-api.js | 221 +++++++++++++++++++--------------------------- 1 file changed, 90 insertions(+), 131 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index dfdcfd3..10fbbe9 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -25,36 +25,27 @@ function JeedomClient(url, apikey, Plateform, myPlugin) { this.Plateform = Plateform; this.log = this.Plateform.log; this.myPlugin = myPlugin || "mobile"; - this.sess_id = ""; DEV_DEBUG = Plateform.DEV_DEBUG || false; } JeedomClient.prototype.getModel = function() { var that = this; var url = that.url; - var request_id = Math.floor(Math.random() * 1000); return axios.post(url, { jsonrpc:"2.0", - id:request_id, + id:(Math.floor(Math.random() * 1000)), method:"sync_homebridge", params:{ plugin:that.myPlugin, apikey:that.apikey, - session:true, - sess_id:that.sess_id, }, }).then((result) => { if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { return Promise.reject(result.data.error.message); } else { - if(result.data.sess_id !== undefined) { - that.sess_id = result.data.sess_id; - } else { - that.sess_id = ""; - } that._cachedModel=result.data.result; return that._cachedModel; } @@ -77,30 +68,22 @@ JeedomClient.prototype.getDevicePropertiesFromCache = function(ID) { JeedomClient.prototype.getDeviceProperties = function(ID) { var that = this; var url = that.url; - var request_id = Math.floor(Math.random() * 1000); return axios.post(url, { jsonrpc:"2.0", - id:request_id, + id:(Math.floor(Math.random() * 1000)), method:"getEql", params:{ plugin:that.myPlugin, apikey:that.apikey, id:ID, - session:true, - sess_id:that.sess_id, }, }).then((result) => { if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { return Promise.reject(result.data.error.message); } else { - if(result.data.sess_id !== undefined) { - that.sess_id = result.data.sess_id; - } else { - that.sess_id = ""; - } if(result.data.result != 'ok') { return result.data.result; } else { @@ -211,6 +194,94 @@ JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { return false; }; +JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { + var that = this; + var options = {}; + var url = that.url; + // console.log('params : ' + param); + if (param != null) { + if (action == 'setRGB') { + options = {color:param}; + } else if (action == 'GBtoggleSelect') { + options = {select:param}; + } else if (!isNaN(parseInt(param)) && parseInt(param) == param) { + options = {slider:parseInt(param)}; + } else if (!isNaN(parseFloat(param)) && parseFloat(param) == param) { + options = {slider:parseFloat(param)}; + } + } + + return axios.post(url, + { + jsonrpc:"2.0", + id:(Math.floor(Math.random() * 1000)), + method:"cmd::execCmd", + params:{ + apikey:that.apikey, + id:ID, + options:options, + }, + }).then((result) => { + if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data.result && result.data.error) { + return Promise.reject(result.data.error.message); + } else { + return result.data.result; + } + }); +}; + +JeedomClient.prototype.executeScenarioAction = function(ID, action) { + var that = this; + var url = that.url; + + return axios.post(url, + { + jsonrpc:"2.0", + id:(Math.floor(Math.random() * 1000)), + method:"scenario::changeState", + params:{ + apikey:that.apikey, + id:ID, + state:action, + }, + }).then((result) => { + if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data.result && result.data.error) { + return Promise.reject(result.data.error.message); + } else { + return result.data.result; + } + }); +}; + +JeedomClient.prototype.refreshStates = function() { + var that = this; + var url = that.url; + + return axios.post(url, + { + jsonrpc:"2.0", + id:(Math.floor(Math.random() * 1000)), + method:"event::changes", + params:{ + apikey:that.apikey, + longPolling:30, + datetime:that.Plateform.lastPoll, + filter:"homebridge", + }, + },{ + timeout: 70000, + }).then((result) => { + if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data.result && result.data.error) { + return Promise.reject(result.data.error.message); + } else { + return result.data.result; + } + }); +}; + JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { var result_cmd = {}; result_cmd = EqLogic; @@ -1492,118 +1563,6 @@ JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { return result_cmd; }; -JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { - var that = this; - var options = {}; - var url = that.url; - var request_id = Math.floor(Math.random() * 1000); - // console.log('params : ' + param); - if (param != null) { - if (action == 'setRGB') { - options = {color:param}; - } else if (action == 'GBtoggleSelect') { - options = {select:param}; - } else if (!isNaN(parseInt(param)) && parseInt(param) == param) { - options = {slider:parseInt(param)}; - } else if (!isNaN(parseFloat(param)) && parseFloat(param) == param) { - options = {slider:parseFloat(param)}; - } - } - - return axios.post(url, - { - jsonrpc:"2.0", - id:request_id, - method:"cmd::execCmd", - params:{ - apikey:that.apikey, - id:ID, - options:options, - session:true, - sess_id:that.sess_id, - }, - }).then((result) => { - if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} - if(!result.data.result && result.data.error) { - return Promise.reject(result.data.error.message); - } else { - if(result.data.sess_id !== undefined) { - that.sess_id = result.data.sess_id; - } else { - that.sess_id = ""; - } - return result.data.result; - } - }); -}; - -JeedomClient.prototype.executeScenarioAction = function(ID, action) { - var that = this; - var url = that.url; - var request_id = Math.floor(Math.random() * 1000); - - return axios.post(url, - { - jsonrpc:"2.0", - id:request_id, - method:"scenario::changeState", - params:{ - apikey:that.apikey, - id:ID, - state:action, - session:true, - sess_id:that.sess_id, - }, - }).then((result) => { - if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} - if(!result.data.result && result.data.error) { - return Promise.reject(result.data.error.message); - } else { - if(result.data.sess_id !== undefined) { - that.sess_id = result.data.sess_id; - } else { - that.sess_id = ""; - } - return result.data.result; - } - }); -}; - -JeedomClient.prototype.refreshStates = function() { - var that = this; - var url = that.url; - var request_id = Math.floor(Math.random() * 1000); - - return axios.post(url, - { - jsonrpc:"2.0", - id:request_id, - method:"event::changes", - params:{ - apikey:that.apikey, - longPolling:30, - datetime:that.Plateform.lastPoll, - filter:"homebridge", - session:true, - sess_id:that.sess_id, - }, - },{ - timeout: 70000, - }).then((result) => { - if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} - if(!result.data.result && result.data.error) { - return Promise.reject(result.data.error.message); - } else { - if(result.data.sess_id !== undefined) { - that.sess_id = result.data.sess_id; - } else { - that.sess_id = ""; - } - return result.data.result; - } - }); -}; - function isset() { var a = arguments, l = a.length, i = 0; From c37879e4f08a6035e8eeb1216553bb9fe38bd457 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:20:58 +0100 Subject: [PATCH 032/118] Update jeedom-api.js --- lib/jeedom-api.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 10fbbe9..4db21c5 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -83,12 +83,10 @@ JeedomClient.prototype.getDeviceProperties = function(ID) { if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { return Promise.reject(result.data.error.message); + } else if(result.data.result != 'ok') { + return result.data.result; } else { - if(result.data.result != 'ok') { - return result.data.result; - } else { - return Promise.reject("EqLogic "+ID+" n'existe pas ou pas envoyé à homebridge"); - } + return Promise.reject("EqLogic "+ID+" n'existe pas ou pas envoyé à homebridge"); } }); From 692d5a740b2fcc67b81f44f0c2abd06328015de9 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:22:13 +0100 Subject: [PATCH 033/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7b30488..3c9479c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0003", + "cust_serial": "0004", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 6fb237cfd6fe918ccd373adf58db619c365f3121 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sat, 20 Jan 2024 10:04:19 +0100 Subject: [PATCH 034/118] Update jeedom-api.js --- lib/jeedom-api.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 4db21c5..e870e79 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -949,6 +949,15 @@ JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { } result_cmd.services.flap[i].stop = cmds[i]; break; + case 'FLAP_MOVING' : + if (!result_cmd.services.flap) { + result_cmd.services.flap = []; + } + if (!result_cmd.services.flap[i]) { + result_cmd.services.flap[i] = {}; + } + result_cmd.services.flap[i].moving = cmds[i]; + break; case 'FLAP_HOR_TILT_STATE' : if (!result_cmd.services.flap) { result_cmd.services.flap = []; From 7adf50f4bfef773d62f4ff9678c32c0dca5ce512 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sat, 20 Jan 2024 10:16:11 +0100 Subject: [PATCH 035/118] Update index.js --- index.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e71b853..3fb12c3 100755 --- a/index.js +++ b/index.js @@ -511,6 +511,9 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.eqLogic=eqLogic; Serv.actions={}; Serv.infos={}; + if(cmd.moving) { + Serv.infos.moving=cmd.moving; + } if(cmd.stateClosing) { Serv.infos.state=cmd.stateClosing; if(Serv.infos.state.subType == 'binary') { @@ -4579,7 +4582,30 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } break; case Characteristic.PositionState.UUID : - returnValue = Characteristic.PositionState.STOPPED; + if(moving in service.infos) { + for (const cmd of cmdList) { + if (cmd.generic_type == 'FLAP_MOVING' || cmd.generic_type == 'WINDOW_MOVING') { + switch(parseInt(cmd.currentValue)) { + case 0 : + returnValue=Characteristic.PositionState.DECREASING; + break; + case 1 : + returnValue=Characteristic.PositionState.INCREASING; + break; + case 2 : + returnValue=Characteristic.PositionState.STOPPED; + break; + default : + returnValue=Characteristic.PositionState.STOPPED; + break; + } + that.log('debug','---------update PositionState:',returnValue); + break; + } + } + } else { + returnValue = Characteristic.PositionState.STOPPED; + } break; case Characteristic.CurrentHorizontalTiltAngle.UUID : case Characteristic.TargetHorizontalTiltAngle.UUID : From 03ff16c604e8c22d70620334c3d83b8896db8397 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sat, 20 Jan 2024 10:17:03 +0100 Subject: [PATCH 036/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3c9479c..44e51f1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0004", + "cust_serial": "0005", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 0a28971bafc194974fa54eec344e2f26d09fadb5 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sat, 20 Jan 2024 10:18:14 +0100 Subject: [PATCH 037/118] Update jeedom-api.js --- lib/jeedom-api.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index e870e79..380e8b4 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -1031,6 +1031,15 @@ JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { } result_cmd.services.windowMoto[i].slider = cmds[i]; break; + case 'WINDOW_MOVING' : + if (!result_cmd.services.windowMoto) { + result_cmd.services.windowMoto = []; + } + if (!result_cmd.services.windowMoto[i]) { + result_cmd.services.windowMoto[i] = {}; + } + result_cmd.services.windowMoto[i].moving = cmds[i]; + break; /** ************* THERMOSTAT ***********************/ case 'THERMOSTAT_STATE' : if (!result_cmd.services.thermostat) { From f33f6a24c21f17aac5fd5c852c0a9217f860b387 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sat, 20 Jan 2024 10:19:23 +0100 Subject: [PATCH 038/118] Update index.js --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 3fb12c3..7db7df2 100755 --- a/index.js +++ b/index.js @@ -739,7 +739,9 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.state=cmd.state; - + if(cmd.moving) { + Serv.infos.moving=cmd.moving; + } eqServicesCopy.windowMoto.forEach(function(cmd2) { if (cmd2.up) { Serv.actions.up = cmd2.up; From a7488b7b1abb6bd4392ff050038fd33cf61cc2aa Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sat, 20 Jan 2024 10:24:11 +0100 Subject: [PATCH 039/118] Update codeql.yml --- .github/workflows/codeql.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2b81922..a5d67de 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -28,7 +28,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -39,7 +39,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl From 1bcc38c2963b56751e5d68de2f3e244c80caf9f7 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sat, 20 Jan 2024 10:26:16 +0100 Subject: [PATCH 040/118] Update index.js --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7db7df2..72a2def 100755 --- a/index.js +++ b/index.js @@ -511,6 +511,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.eqLogic=eqLogic; Serv.actions={}; Serv.infos={}; + Serv.infos.moving=null; if(cmd.moving) { Serv.infos.moving=cmd.moving; } @@ -739,6 +740,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.state=cmd.state; + Serv.infos.moving=null; if(cmd.moving) { Serv.infos.moving=cmd.moving; } @@ -4584,7 +4586,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } break; case Characteristic.PositionState.UUID : - if(moving in service.infos) { + if(moving in service.infos && service.infos.moving !== null) { for (const cmd of cmdList) { if (cmd.generic_type == 'FLAP_MOVING' || cmd.generic_type == 'WINDOW_MOVING') { switch(parseInt(cmd.currentValue)) { From 2d5cb6b097954eb21ea8b0360e3dea7c9f01823c Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sat, 20 Jan 2024 10:29:03 +0100 Subject: [PATCH 041/118] Update codeql.yml --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a5d67de..fbdb01f 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,4 +53,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 From 1da84c3f94544f300b780f56b2594118f368d211 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sat, 20 Jan 2024 10:30:17 +0100 Subject: [PATCH 042/118] Update index.js --- index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/index.js b/index.js index 72a2def..1f54884 100755 --- a/index.js +++ b/index.js @@ -511,7 +511,6 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.eqLogic=eqLogic; Serv.actions={}; Serv.infos={}; - Serv.infos.moving=null; if(cmd.moving) { Serv.infos.moving=cmd.moving; } @@ -740,7 +739,6 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.state=cmd.state; - Serv.infos.moving=null; if(cmd.moving) { Serv.infos.moving=cmd.moving; } @@ -4586,7 +4584,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } break; case Characteristic.PositionState.UUID : - if(moving in service.infos && service.infos.moving !== null) { + if('moving' in service.infos && service.infos.moving !== null) { for (const cmd of cmdList) { if (cmd.generic_type == 'FLAP_MOVING' || cmd.generic_type == 'WINDOW_MOVING') { switch(parseInt(cmd.currentValue)) { From 11a62e8d7a4097f4feb6086063c832916be54340 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 22 Jan 2024 14:51:47 +0100 Subject: [PATCH 043/118] Add Express --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 44e51f1..1c37c48 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ ], "dependencies": { "axios": ">=1.6.5", + "express": "^4.18.2", "fakegato-history": "NebzHB/fakegato-history#master" }, "devDependencies": { From 30516c7cc3b41e7a259750d5d631605c689c344e Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:32:11 +0100 Subject: [PATCH 044/118] New config receiving --- index.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/index.js b/index.js index 1f54884..31aca68 100755 --- a/index.js +++ b/index.js @@ -20,6 +20,8 @@ let Access, Accessory, Service, Characteristic, AdaptiveLightingController, UUID const fs = require('fs'); const inherits = require('util').inherits; const myLogger = require('./lib/myLogger').myLogger; +const express = require('express'); + const debug = {}; debug.DEBUG = 100; debug.INFO = 200; @@ -88,6 +90,15 @@ function JeedomPlatform(logger, config, api) { } else { this.log('info',"Adresse Jeedom bien configurée :"+config.url); } + + this.app = express(); + this.app.get('/config', this.ConfigCMD.bind(this)); + this.app.use((err, req, res, _next) => { + res.type('json'); + console.log('error',err); + res.json({'result':'ko','msg':err}); + }); + this.DEV_DEBUG = DEV_DEBUG; // for passing by this.jeedomClient = require('./lib/jeedom-api').createClient(config.url, config.apikey, this, config.myPlugin); this.rooms = {}; @@ -108,6 +119,11 @@ function JeedomPlatform(logger, config, api) { if (api) { this.api = api; this.api.on('didFinishLaunching',function(){ + /** Listen **/ + this.server = this.app.listen(0, '0.0.0.0', () => { + this.log('info',"On écoute les messages sur le port "+this.server.address().port); + this.jeedomClient.daemonIsReady(this.server.address().port); + }); this.addAccessories(); }.bind(this)); } @@ -118,6 +134,42 @@ function JeedomPlatform(logger, config, api) { } } +JeedomPlatform.prototype.ConfigCMD = function(req, res) { + res.type('json'); + res.status(202); + + this.log('info','Recu une configuration de jeedom :'+JSON.stringify(req.query)); + + if ('setting' in req.query === false) { + const error="Pour faire une config, le démon a besoin de son nom"; + this.log('error',error); + res.json({'result':'ko','msg':error}); + return; + } + if ('value' in req.query === false) { + const error="Pour faire une config, le démon a besoin d'une valeur a configurer"; + this.log('error',error); + res.json({'result':'ko','msg':error}); + return; + } + + switch(req.query.setting) { + case 'sendLoglevel': + this.debugLevel = req.query.value; + this.log.changeLevel(this.debugLevel); + break; + default: { + const error = "Configuration inexistante"; + this.log('error','ERROR CONFIG: ' + req.query.setting + ' : '+error); + res.json({'result':'ko','msg':error}); + return; + } + } + this.log('conf',"Configuration de : "+req.query.setting+" effectuée avec la valeur : "+((typeof req.query.value == "object")?JSON.stringify(req.query.value):req.query.value)); + res.json({'result':'ok','value':req.query.value}); +}; + + // -- addAccessories // -- Desc : Accessories creation, we get a full model from jeedom and put it in local cache // -- Return : nothing From 58a9b785fa1c28e6986c70a38f7aabfd7e97d8e9 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:33:33 +0100 Subject: [PATCH 045/118] add changeLevel function, conf level and lowercase level --- lib/myLogger.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/myLogger.js b/lib/myLogger.js index 5e3aa78..6a7e9ea 100644 --- a/lib/myLogger.js +++ b/lib/myLogger.js @@ -41,11 +41,12 @@ var loggerCache = {}; function myLogger(debugLevel,logger,creationLogPath) { this.logger = logger; this.debugLevel= debugLevel; - this.allowedLevel = ['debug','info','warn','error']; + this.allowedLevel = ['debug','info','warn','error','conf']; this.creationLogPath = creationLogPath; this.creationPassed = false; fs.writeFileSync(this.creationLogPath+startLog, '['+(new Date().toISOString())+"] ---Début du log de création---\n"); this.log = function(level, msg) { + level=level.toLowerCase(); msg = util.format.apply(util, Array.prototype.slice.call(arguments, 1)); if(msg) { @@ -75,6 +76,9 @@ function myLogger(debugLevel,logger,creationLogPath) { this.logger(msg); msg=null; }; + this.changeLevel = (newDebugLevel) => { + this.debugLevel=newDebugLevel; + }; } myLogger.createMyLogger = function(debugLevel,logger,creationLogPath) { @@ -84,6 +88,7 @@ myLogger.createMyLogger = function(debugLevel,logger,creationLogPath) { var ml = new myLogger(debugLevel,logger,creationLogPath); var log = ml.log.bind(ml); log.log = ml.log; + log.changeLevel = ml.changeLevel.bind(ml); loggerCache[debugLevel] = log; } return loggerCache[debugLevel]; From b112197ef15293740f2506520f6d2ee8df434be0 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:34:07 +0100 Subject: [PATCH 046/118] daemonIsReady --- lib/jeedom-api.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 380e8b4..7de41bb 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -92,6 +92,33 @@ JeedomClient.prototype.getDeviceProperties = function(ID) { }; +JeedomClient.prototype.daemonIsReady = function(port) { + var that = this; + var url = that.url; + + return axios.post(url, + { + jsonrpc:"2.0", + id:(Math.floor(Math.random() * 1000)), + method:"daemonIsReady", + params:{ + plugin:that.myPlugin, + apikey:that.apikey, + port:port, + }, + }).then((result) => { + if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} + if(!result.data.result && result.data.error) { + return Promise.reject(result.data.error.message); + } else if(result.data.result == true) { + return result.data.result; + } else { + return Promise.reject("Jeedom n'a pas compris l'envoi du port"); + } + }); + +}; + JeedomClient.prototype.getDeviceCmdFromCache = function(ID) { var that = this; var clist = []; From 97ee08e7d633e725d9048e37ed61883f44a1d293 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:34:39 +0100 Subject: [PATCH 047/118] add express --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1c37c48..c0f3dfd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0005", + "cust_serial": "0006", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, @@ -26,7 +26,7 @@ ], "dependencies": { "axios": ">=1.6.5", - "express": "^4.18.2", + "express": "^4.18.2", "fakegato-history": "NebzHB/fakegato-history#master" }, "devDependencies": { From acf4a7de4596a4e8e358e69d41830a46bff95c31 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 09:49:38 +0100 Subject: [PATCH 048/118] Update index.js --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 31aca68..361e657 100755 --- a/index.js +++ b/index.js @@ -120,7 +120,9 @@ function JeedomPlatform(logger, config, api) { this.api = api; this.api.on('didFinishLaunching',function(){ /** Listen **/ - this.server = this.app.listen(0, '0.0.0.0', () => { + let port=0; + if(fs.existsSync('/homebridge/')) { port=8582; } // if docker, use the port next to homebridge-config-ui + this.server = this.app.listen(port, '0.0.0.0', () => { this.log('info',"On écoute les messages sur le port "+this.server.address().port); this.jeedomClient.daemonIsReady(this.server.address().port); }); From 3d45a1a23234408d59181edf1bebd07aa5f8a0e4 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 09:53:51 +0100 Subject: [PATCH 049/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c0f3dfd..f28a0e6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0006", + "cust_serial": "0007", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From b3400224b842b93f17cc0f5e5aff304d7b529435 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:47:44 +0100 Subject: [PATCH 050/118] Update jeedom-api.js --- lib/jeedom-api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 7de41bb..dc11a27 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -242,6 +242,7 @@ JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { id:(Math.floor(Math.random() * 1000)), method:"cmd::execCmd", params:{ + plugin:that.myPlugin, apikey:that.apikey, id:ID, options:options, @@ -266,6 +267,7 @@ JeedomClient.prototype.executeScenarioAction = function(ID, action) { id:(Math.floor(Math.random() * 1000)), method:"scenario::changeState", params:{ + plugin:that.myPlugin, apikey:that.apikey, id:ID, state:action, @@ -290,6 +292,7 @@ JeedomClient.prototype.refreshStates = function() { id:(Math.floor(Math.random() * 1000)), method:"event::changes", params:{ + plugin:that.myPlugin, apikey:that.apikey, longPolling:30, datetime:that.Plateform.lastPoll, From 07ab4fbaff5d7cf18aa466e13f9682a092e6a898 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:55:22 +0100 Subject: [PATCH 051/118] Revert "Update jeedom-api.js" This reverts commit b3400224b842b93f17cc0f5e5aff304d7b529435. --- lib/jeedom-api.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index dc11a27..7de41bb 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -242,7 +242,6 @@ JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { id:(Math.floor(Math.random() * 1000)), method:"cmd::execCmd", params:{ - plugin:that.myPlugin, apikey:that.apikey, id:ID, options:options, @@ -267,7 +266,6 @@ JeedomClient.prototype.executeScenarioAction = function(ID, action) { id:(Math.floor(Math.random() * 1000)), method:"scenario::changeState", params:{ - plugin:that.myPlugin, apikey:that.apikey, id:ID, state:action, @@ -292,7 +290,6 @@ JeedomClient.prototype.refreshStates = function() { id:(Math.floor(Math.random() * 1000)), method:"event::changes", params:{ - plugin:that.myPlugin, apikey:that.apikey, longPolling:30, datetime:that.Plateform.lastPoll, From 583159354b4d67ceb1ec6f43916e85beed3b527e Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:59:00 +0100 Subject: [PATCH 052/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f28a0e6..23d7512 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0007", + "cust_serial": "0008", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From f0e9caae5e8852a69549245c3add7eeeb2896246 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:33:10 +0100 Subject: [PATCH 053/118] Update package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 23d7512..c64f486 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,9 @@ "Siri" ], "dependencies": { + "async": "^3.2.5", "axios": ">=1.6.5", - "express": "^4.18.2", + "express": "^4.18.2", "fakegato-history": "NebzHB/fakegato-history#master" }, "devDependencies": { From abc540b40af6c8d63c80c88ac8e85ea7098ccf11 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:43:46 +0100 Subject: [PATCH 054/118] Queues pour cmd et scenarios --- lib/jeedom-api.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 7de41bb..c1a4e5b 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -16,6 +16,7 @@ /* jshint esversion: 6,node: true */ 'use strict'; const axios = require('axios'); +const async = require('async'); var DEV_DEBUG; function JeedomClient(url, apikey, Plateform, myPlugin) { @@ -26,6 +27,17 @@ function JeedomClient(url, apikey, Plateform, myPlugin) { this.log = this.Plateform.log; this.myPlugin = myPlugin || "mobile"; DEV_DEBUG = Plateform.DEV_DEBUG || false; + this.queue = async.queue((task, callback) => { + if(task.type==='cmd') { + this._executeDeviceAction(task.ID, task.action, task.param) + .then(result => callback(null, result)) + .catch(err => callback(err, null)); + } else if(task.type==='scenario') { + this._executeScenarioAction(task.ID, task.action) + .then(result => callback(null, result)) + .catch(err => callback(err, null)); + } + }, 1); } JeedomClient.prototype.getModel = function() { @@ -220,6 +232,15 @@ JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { }; JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { + return new Promise((resolve, reject) => { + this.queue.push({ID, action, param, type:'cmd'}, (err, result) => { + if (err) reject(err); + else resolve(result); + }); + }); +}; + +JeedomClient.prototype._executeDeviceAction = function(ID, action, param) { var that = this; var options = {}; var url = that.url; @@ -257,6 +278,15 @@ JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { }; JeedomClient.prototype.executeScenarioAction = function(ID, action) { + return new Promise((resolve, reject) => { + this.queue.push({ID, action, type:'scenario'}, (err, result) => { + if (err) reject(err); + else resolve(result); + }); + }); +}; + +JeedomClient.prototype._executeScenarioAction = function(ID, action) { var that = this; var url = that.url; From 586b2a9d8eb9672f40c6a3b4bb776c5aaa48951b Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:45:28 +0100 Subject: [PATCH 055/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c64f486..0275870 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0008", + "cust_serial": "0009", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 88cd069bc07d5b6b5b9f06c03a7070288122f82c Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:12:15 +0100 Subject: [PATCH 056/118] Update jeedom-api.js --- lib/jeedom-api.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index c1a4e5b..bb1dd26 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -18,6 +18,7 @@ const axios = require('axios'); const async = require('async'); var DEV_DEBUG; +var USE_QUEUES=true; function JeedomClient(url, apikey, Plateform, myPlugin) { this.apikey = apikey; @@ -30,12 +31,12 @@ function JeedomClient(url, apikey, Plateform, myPlugin) { this.queue = async.queue((task, callback) => { if(task.type==='cmd') { this._executeDeviceAction(task.ID, task.action, task.param) - .then(result => callback(null, result)) - .catch(err => callback(err, null)); + .then(result => callback(null, result)) + .catch(err => callback(err, null)); } else if(task.type==='scenario') { this._executeScenarioAction(task.ID, task.action) - .then(result => callback(null, result)) - .catch(err => callback(err, null)); + .then(result => callback(null, result)) + .catch(err => callback(err, null)); } }, 1); } @@ -232,12 +233,13 @@ JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { }; JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { - return new Promise((resolve, reject) => { - this.queue.push({ID, action, param, type:'cmd'}, (err, result) => { - if (err) reject(err); - else resolve(result); - }); - }); + if(!USE_QUEUES) return this._executeDeviceAction(ID, action, param); + return new Promise((resolve, reject) => { + this.queue.push({ID, action, param, type:'cmd'}, (err, result) => { + if (err) reject(err); + else resolve(result); + }); + }); }; JeedomClient.prototype._executeDeviceAction = function(ID, action, param) { @@ -278,12 +280,13 @@ JeedomClient.prototype._executeDeviceAction = function(ID, action, param) { }; JeedomClient.prototype.executeScenarioAction = function(ID, action) { - return new Promise((resolve, reject) => { - this.queue.push({ID, action, type:'scenario'}, (err, result) => { - if (err) reject(err); - else resolve(result); - }); - }); + if(!USE_QUEUES) return this._executeScenarioAction(ID, action); + return new Promise((resolve, reject) => { + this.queue.push({ID, action, type:'scenario'}, (err, result) => { + if (err) reject(err); + else resolve(result); + }); + }); }; JeedomClient.prototype._executeScenarioAction = function(ID, action) { From cd841ee4fed84c8b4a9c652e2a9086c1a94c91e7 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:20:32 +0100 Subject: [PATCH 057/118] Update jeedom-api.js --- lib/jeedom-api.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index bb1dd26..1e4a9c5 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -18,7 +18,7 @@ const axios = require('axios'); const async = require('async'); var DEV_DEBUG; -var USE_QUEUES=true; +const USE_QUEUES=1; function JeedomClient(url, apikey, Plateform, myPlugin) { this.apikey = apikey; @@ -38,7 +38,7 @@ function JeedomClient(url, apikey, Plateform, myPlugin) { .then(result => callback(null, result)) .catch(err => callback(err, null)); } - }, 1); + }, ((USE_QUEUES===0)?1:USE_QUEUES)); } JeedomClient.prototype.getModel = function() { @@ -233,11 +233,11 @@ JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { }; JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { - if(!USE_QUEUES) return this._executeDeviceAction(ID, action, param); + if(USE_QUEUES === 0) { return this._executeDeviceAction(ID, action, param); } return new Promise((resolve, reject) => { this.queue.push({ID, action, param, type:'cmd'}, (err, result) => { - if (err) reject(err); - else resolve(result); + if (err) { reject(err); } + else { resolve(result); } }); }); }; @@ -280,11 +280,11 @@ JeedomClient.prototype._executeDeviceAction = function(ID, action, param) { }; JeedomClient.prototype.executeScenarioAction = function(ID, action) { - if(!USE_QUEUES) return this._executeScenarioAction(ID, action); + if(USE_QUEUES === 0) { return this._executeScenarioAction(ID, action); } return new Promise((resolve, reject) => { this.queue.push({ID, action, type:'scenario'}, (err, result) => { - if (err) reject(err); - else resolve(result); + if (err) { reject(err); } + else { resolve(result); } }); }); }; From efb84a8ed2f490198f21fb44ae598f6e92b6accd Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:32:15 +0100 Subject: [PATCH 058/118] Update jeedom-api.js --- lib/jeedom-api.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 1e4a9c5..34c48a8 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -31,12 +31,12 @@ function JeedomClient(url, apikey, Plateform, myPlugin) { this.queue = async.queue((task, callback) => { if(task.type==='cmd') { this._executeDeviceAction(task.ID, task.action, task.param) - .then(result => callback(null, result)) - .catch(err => callback(err, null)); + .then((result) => callback(null, result)) + .catch((err) => callback(err, null)); } else if(task.type==='scenario') { this._executeScenarioAction(task.ID, task.action) - .then(result => callback(null, result)) - .catch(err => callback(err, null)); + .then((result) => callback(null, result)) + .catch((err) => callback(err, null)); } }, ((USE_QUEUES===0)?1:USE_QUEUES)); } From 0c2482df88bb908f7e96cf3cf112491401965c58 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:34:47 +0100 Subject: [PATCH 059/118] Update jeedom-api.js --- lib/jeedom-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 34c48a8..25b82bf 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -18,7 +18,7 @@ const axios = require('axios'); const async = require('async'); var DEV_DEBUG; -const USE_QUEUES=1; +const USE_QUEUES=1; // 0 = NO, or 1 or 2 etc for the concurrent tasks function JeedomClient(url, apikey, Plateform, myPlugin) { this.apikey = apikey; From fc3286be43d19f3c1234f71179cbf5b7b82d4fe0 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 26 Jan 2024 17:29:30 +0100 Subject: [PATCH 060/118] Update jeedom-api.js --- lib/jeedom-api.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 25b82bf..d3b3812 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -18,7 +18,7 @@ const axios = require('axios'); const async = require('async'); var DEV_DEBUG; -const USE_QUEUES=1; // 0 = NO, or 1 or 2 etc for the concurrent tasks +var USE_QUEUES; function JeedomClient(url, apikey, Plateform, myPlugin) { this.apikey = apikey; @@ -28,6 +28,7 @@ function JeedomClient(url, apikey, Plateform, myPlugin) { this.log = this.Plateform.log; this.myPlugin = myPlugin || "mobile"; DEV_DEBUG = Plateform.DEV_DEBUG || false; + USE_QUEUES = Plateform.USE_QUEUES || 1; // 0 = NO, or 1 or 2 etc for the concurrent tasks this.queue = async.queue((task, callback) => { if(task.type==='cmd') { this._executeDeviceAction(task.ID, task.action, task.param) @@ -41,6 +42,11 @@ function JeedomClient(url, apikey, Plateform, myPlugin) { }, ((USE_QUEUES===0)?1:USE_QUEUES)); } +JeedomClient.prototype.changeQueueSys = function(newVal = 1) { + USE_QUEUES = newVal; + this.queue.concurrency = ((USE_QUEUES===0)?1:USE_QUEUES); +} + JeedomClient.prototype.getModel = function() { var that = this; var url = that.url; From 2536bb6139c2afad74176f1e7f00658d3ebfb69d Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 26 Jan 2024 17:29:48 +0100 Subject: [PATCH 061/118] Update index.js --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index 361e657..a5b57a0 100755 --- a/index.js +++ b/index.js @@ -100,6 +100,7 @@ function JeedomPlatform(logger, config, api) { }); this.DEV_DEBUG = DEV_DEBUG; // for passing by + this.USE_QUEUES = config.USE_QUEUES || 1; // 0 = NO, or 1 or 2 etc for the concurrent tasks this.jeedomClient = require('./lib/jeedom-api').createClient(config.url, config.apikey, this, config.myPlugin); this.rooms = {}; this.updateSubscriptions = []; @@ -160,6 +161,10 @@ JeedomPlatform.prototype.ConfigCMD = function(req, res) { this.debugLevel = req.query.value; this.log.changeLevel(this.debugLevel); break; + case 'changeUSE_QUEUES': + this.USE_QUEUES=parseInt(req.query.value); + this.jeedomClient.changeQueueSys(this.USE_QUEUES); + break; default: { const error = "Configuration inexistante"; this.log('error','ERROR CONFIG: ' + req.query.setting + ' : '+error); From 3dfba28ba52b44415032882e482d852fbf8edcf6 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 26 Jan 2024 17:29:58 +0100 Subject: [PATCH 062/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0275870..7cec2be 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0009", + "cust_serial": "0010", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From a42c2d248a46aab1ee10e2ef1f946e4ca1ff1ca4 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 26 Jan 2024 17:31:58 +0100 Subject: [PATCH 063/118] Update jeedom-api.js --- lib/jeedom-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index d3b3812..ebb441f 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -45,7 +45,7 @@ function JeedomClient(url, apikey, Plateform, myPlugin) { JeedomClient.prototype.changeQueueSys = function(newVal = 1) { USE_QUEUES = newVal; this.queue.concurrency = ((USE_QUEUES===0)?1:USE_QUEUES); -} +}; JeedomClient.prototype.getModel = function() { var that = this; From 49038bce29f343dc252ace516dee4a8fb0a97df3 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 09:58:44 +0100 Subject: [PATCH 064/118] Update index.js --- index.js | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index a5b57a0..ad24369 100755 --- a/index.js +++ b/index.js @@ -3141,7 +3141,7 @@ JeedomPlatform.prototype.bindCharacteristicEvents = function(characteristic, ser readOnly = false; } } - this.subscribeUpdate(service, characteristic); + this.updateSubscriptions.push({ service, characteristic }); if (!readOnly) { characteristic.on('set', function(value, callback, context) { if (context !== 'fromJeedom' && context !== 'fromSetValue') { // from Homekit @@ -5640,29 +5640,6 @@ JeedomPlatform.prototype.command = function(action, value, service) { } }; -// -- subscribeUpdate -// -- Desc : Populate the subscriptions to the characteristic. if the value is changed, the characteristic will be updated -// -- Params -- -// -- service : service containing the characteristic to subscribe to -// -- characteristic : characteristic to subscribe to -// -- Return : nothing -JeedomPlatform.prototype.subscribeUpdate = function(service, characteristic) { - try{ - if (characteristic.UUID == Characteristic.PositionState.UUID) { - return; - } - this.updateSubscriptions.push({ - 'service' : service, - 'characteristic' : characteristic, - }); - } - catch(e){ - this.log('error','Erreur de la fonction subscribeUpdate :',e); - console.error(e.stack); - hasError=true; - } -}; - // -- startPollingUpdate // -- Desc : Get the last status from Jeedom and act on it (update model and subscribers) // -- Params -- @@ -5720,7 +5697,7 @@ JeedomPlatform.prototype.startPollingUpdate = function() { }; // -- updateSubscribers -// -- Desc : update subcribers populated by the subscribeUpdate method +// -- Desc : update subcribers in updateSubscriptions array // -- Params -- // -- update : the update received from Jeedom // -- Return : nothing From c26940fec465f655876ef1e10c09d55fdd8ae0c5 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 09:59:03 +0100 Subject: [PATCH 065/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7cec2be..4f57e86 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0010", + "cust_serial": "0011", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 450d4fca0a567336dcb5da3e40f016bf1b36a7be Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 10:43:10 +0100 Subject: [PATCH 066/118] Update index.js --- index.js | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index ad24369..b026bc2 100755 --- a/index.js +++ b/index.js @@ -119,7 +119,7 @@ function JeedomPlatform(logger, config, api) { } if (api) { this.api = api; - this.api.on('didFinishLaunching',function(){ + this.api.on('didFinishLaunching',() => { /** Listen **/ let port=0; if(fs.existsSync('/homebridge/')) { port=8582; } // if docker, use the port next to homebridge-config-ui @@ -128,7 +128,7 @@ function JeedomPlatform(logger, config, api) { this.jeedomClient.daemonIsReady(this.server.address().port); }); this.addAccessories(); - }.bind(this)); + }); } } catch (e) { @@ -3045,10 +3045,10 @@ JeedomPlatform.prototype.addAccessory = function(jeedomAccessory) { this.log('│ OK : Mise à jour de l\'accessoire (' + jeedomAccessory.name + ')'); this.api.updatePlatformAccessories([HBAccessory]); } - HBAccessory.on('identify', function(paired, callback) { + HBAccessory.on('identify', (paired, callback) => { this.log(HBAccessory.displayName, "->Identifié!!!"); if(typeof callback === 'function') {callback();} - }.bind(this)); + }); HBAccessory.reviewed = true; } catch(e){ @@ -3066,15 +3066,13 @@ JeedomPlatform.prototype.addAccessory = function(jeedomAccessory) { // -- UUID : UUID to find // -- silence : flag for logging or not // -- Return : nothing -JeedomPlatform.prototype.existingAccessory = function(UUID,silence) { +JeedomPlatform.prototype.existingAccessory = function(UUID,silence=false) { try{ - silence = silence || false; - for (const a in this.accessories) { - if (this.accessories.hasOwnProperty(a)) { - if (this.accessories[a].UUID == UUID) { - if(!silence) {this.log('debug',' Accessoire déjà existant dans le cache Homebridge');} - return this.accessories[a]; - } + for (const key of Object.keys(this.accessories)) { + const accessory = this.accessories[key]; + if (accessory.UUID == UUID) { + if(!silence) {this.log('debug',' Accessoire déjà existant dans le cache Homebridge');} + return accessory; } } if(!silence) {this.log('debug',' Accessoire non existant dans le cache Homebridge');} @@ -3135,15 +3133,9 @@ JeedomPlatform.prototype.configureAccessory = function(accessory) { // -- Return : nothing JeedomPlatform.prototype.bindCharacteristicEvents = function(characteristic, service) { try{ - var readOnly = true; - for (var i = 0; i < characteristic.props.perms.length; i++) { - if (characteristic.props.perms[i] == 'pw') { - readOnly = false; - } - } this.updateSubscriptions.push({ service, characteristic }); - if (!readOnly) { - characteristic.on('set', function(value, callback, context) { + if (characteristic.props.perms.includes('pw')) { + characteristic.on('set', (value, callback, context) => { if (context !== 'fromJeedom' && context !== 'fromSetValue') { // from Homekit this.log('info','[Commande d\'Homekit]','Nom:'+characteristic.displayName+'('+characteristic.UUID+'):'+characteristic.value+'->'+value,'\t\t\t\t\t|||characteristic:'+JSON.stringify(characteristic)); this.setAccessoryValue(value,characteristic,service); @@ -3151,9 +3143,9 @@ JeedomPlatform.prototype.bindCharacteristicEvents = function(characteristic, ser this.log('info','[Commande de Jeedom]','Nom:'+characteristic.displayName+'('+characteristic.UUID+'):'+value,'\t\t\t\t\t|||context:'+JSON.stringify(context),'characteristic:'+JSON.stringify(characteristic)); } callback(); - }.bind(this)); + }); } - characteristic.on('get', function(callback) { + characteristic.on('get', (callback) => { let returnValue = this.getAccessoryValue(characteristic, service); if(returnValue !== undefined && returnValue !== 'no_response') { returnValue = sanitizeValue(returnValue,characteristic); @@ -3164,12 +3156,12 @@ JeedomPlatform.prototype.bindCharacteristicEvents = function(characteristic, ser } else { callback(); } - }.bind(this)); + }); if (this.fakegato) { - characteristic.on('change', function(_callback) { + characteristic.on('change', (_callback) => { this.changeAccessoryValue(characteristic, service); - }.bind(this)); + }); } } catch(e){ From 9ac786ae18a4eea92eab3dfb0eeec1ec972d85be Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 10:59:41 +0100 Subject: [PATCH 067/118] Update index.js --- index.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index b026bc2..82b68ed 100755 --- a/index.js +++ b/index.js @@ -2937,14 +2937,12 @@ JeedomPlatform.prototype.createAccessory = function(HBservices, eqLogic) { // -- jeedomAccessory : JeedomBridgedAccessory to delete // -- silence : flag for logging or not // -- Return : nothing -JeedomPlatform.prototype.delAccessory = function(jeedomAccessory,silence) { - var existingAccessory; +JeedomPlatform.prototype.delAccessory = function(jeedomAccessory,silence=false) { + let existingAccessory; try{ - silence = silence || false; if (!jeedomAccessory) { return; } - if(!silence) {this.log('debug',' Vérification d\'existance de l\'accessoire dans le cache Homebridge...');} existingAccessory = this.existingAccessory(jeedomAccessory.UUID,silence); if(existingAccessory) @@ -2973,15 +2971,12 @@ JeedomPlatform.prototype.delAccessory = function(jeedomAccessory,silence) { // -- jeedomAccessory : JeedomBridgedAccessory to add // -- Return : nothing JeedomPlatform.prototype.addAccessory = function(jeedomAccessory) { - var HBAccessory,numberOpened,lastAct; try{ - if (!jeedomAccessory) { - return; - } + if (!jeedomAccessory) {return;} let isNewAccessory = false; const services2Add = jeedomAccessory.services_add; - this.log('debug',' Vérification d\'existance de l\'accessoire dans le cache Homebridge...'); - HBAccessory = this.existingAccessory(jeedomAccessory.UUID); + this.log('debug'," Vérification d'existance de l'accessoire dans le cache Homebridge..."); + var HBAccessory = this.existingAccessory(jeedomAccessory.UUID); if (!HBAccessory) { this.log('│ Nouvel accessoire (' + jeedomAccessory.name + ')'); isNewAccessory = true; @@ -2989,6 +2984,7 @@ JeedomPlatform.prototype.addAccessory = function(jeedomAccessory) { jeedomAccessory.initAccessory(HBAccessory); this.accessories[jeedomAccessory.UUID] = HBAccessory; } + let numberOpened,lastAct; if(this.fakegato) { numberOpened = HBAccessory.context && HBAccessory.context.eqLogic && HBAccessory.context.eqLogic.numberOpened || 0; lastAct = HBAccessory.context && HBAccessory.context.eqLogic && HBAccessory.context.eqLogic.lastAct || 0; @@ -3069,10 +3065,9 @@ JeedomPlatform.prototype.addAccessory = function(jeedomAccessory) { JeedomPlatform.prototype.existingAccessory = function(UUID,silence=false) { try{ for (const key of Object.keys(this.accessories)) { - const accessory = this.accessories[key]; - if (accessory.UUID == UUID) { + if (this.accessories[key].UUID == UUID) { if(!silence) {this.log('debug',' Accessoire déjà existant dans le cache Homebridge');} - return accessory; + return this.accessories[key]; } } if(!silence) {this.log('debug',' Accessoire non existant dans le cache Homebridge');} @@ -3133,7 +3128,7 @@ JeedomPlatform.prototype.configureAccessory = function(accessory) { // -- Return : nothing JeedomPlatform.prototype.bindCharacteristicEvents = function(characteristic, service) { try{ - this.updateSubscriptions.push({ service, characteristic }); + this.updateSubscriptions.push({service, characteristic}); if (characteristic.props.perms.includes('pw')) { characteristic.on('set', (value, callback, context) => { if (context !== 'fromJeedom' && context !== 'fromSetValue') { // from Homekit From 1b7a571ddd6587eb0764af67949b6d627edf1baf Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 11:01:53 +0100 Subject: [PATCH 068/118] Update index.js --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 82b68ed..a570020 100755 --- a/index.js +++ b/index.js @@ -2971,12 +2971,13 @@ JeedomPlatform.prototype.delAccessory = function(jeedomAccessory,silence=false) // -- jeedomAccessory : JeedomBridgedAccessory to add // -- Return : nothing JeedomPlatform.prototype.addAccessory = function(jeedomAccessory) { + let HBAccessory; try{ if (!jeedomAccessory) {return;} let isNewAccessory = false; const services2Add = jeedomAccessory.services_add; this.log('debug'," Vérification d'existance de l'accessoire dans le cache Homebridge..."); - var HBAccessory = this.existingAccessory(jeedomAccessory.UUID); + HBAccessory = this.existingAccessory(jeedomAccessory.UUID); if (!HBAccessory) { this.log('│ Nouvel accessoire (' + jeedomAccessory.name + ')'); isNewAccessory = true; From a4127cf4240027d82570a5aae77dec30983ce9a7 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:17:04 +0100 Subject: [PATCH 069/118] Update index.js --- index.js | 54 +++++++++++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/index.js b/index.js index a570020..06cd46d 100755 --- a/index.js +++ b/index.js @@ -6364,9 +6364,9 @@ JeedomBridgedAccessory.prototype.initAccessory = function(newAccessory) { // -- services : services to be added // -- Return : nothing JeedomBridgedAccessory.prototype.addServices = function(newAccessory,services,cachedValues) { - var service; + let service; try { - var cachedValue, characteristic; + let cachedValue, characteristic; for (var s = 0; s < services.length; s++) { service = services[s]; @@ -6412,24 +6412,23 @@ JeedomBridgedAccessory.prototype.addServices = function(newAccessory,services,ca // -- accessory : accessory to delete the services from // -- Return : nothing JeedomBridgedAccessory.prototype.delServices = function(accessory) { - var service; + let service; try { - const serviceList=[]; - const cachedValues=[]; - for(var t=0; t< accessory.services.length;t++) { - if(accessory.services[t].UUID != Service.AccessoryInformation.UUID && - accessory.services[t].UUID != Service.BridgingState.UUID) { - serviceList.push(accessory.services[t]); - } - } - for(service of serviceList){ // dont work in one loop or with temp object :( - this.log('debug',' Suppression service :'+service.displayName+' subtype:'+service.subtype+' UUID:'+service.UUID); - for (const c of service.characteristics) { - this.log('debug',' Caractéristique :'+c.displayName+' valeur cache:'+c.value); - cachedValues[service.subtype+c.displayName]=c.value; - } + const cachedValues = []; + const serviceList = accessory.services.filter((svc) => + svc.UUID !== Service.AccessoryInformation.UUID && + svc.UUID !== Service.BridgingState.UUID + ); + + serviceList.forEach((svc) => { + service=svc; + this.log('debug', ' Suppression service :' + service.displayName + ' subtype:' + service.subtype + ' UUID:' + service.UUID); + service.characteristics.forEach((c) => { + this.log('debug', ' Caractéristique :' + c.displayName + ' valeur cache:' + c.value); + cachedValues[service.subtype + c.displayName] = c.value; + }); accessory.removeService(service); - } + }); return cachedValues; } catch(e){ @@ -6473,7 +6472,7 @@ function hexToB(h) { // -- h : html color string // -- Return : numeric value of html color function cutHex(h) { - return (h.charAt(0) == '#') ? h.substring(1, 7) : h; + return h.charAt(0) === '#' ? h.substring(1, 7) : h; } // -- rgbToHex @@ -6493,12 +6492,7 @@ function rgbToHex(R, G, B) { // -- n : number // -- Return : hex value function toHex(n) { - n = parseInt(n, 10); - if (isNaN(n)) { - return '00'; - } - n = Math.max(0, Math.min(n, 255)); - return '0123456789ABCDEF'.charAt((n - n % 16) / 16) + '0123456789ABCDEF'.charAt(n % 16); + return parseInt(n,10).toString(16).padStart(2, '0'); } // -- HSVtoRGB @@ -6612,12 +6606,6 @@ function RGBtoHSV(r, g, b) { // -- Params -- // -- id : id to find // -- Return : Object found -function findMyID(obj,id) { - for(const o in obj) { - // if( obj.hasOwnProperty( o ) && obj[o] && obj[o].id && parseInt(obj[o].id) && parseInt(id) && parseInt(obj[o].id)==parseInt(id)) { - if( obj.hasOwnProperty( o ) && obj[o] && obj[o].id && obj[o].id==id) { - return obj[o]; - } - } - return -1; +function findMyID(obj, id) { + return Object.values(obj).find(item => item && item.id == id) || -1; } From d55a586f59cd34c15101f0fb5678189cf9cecae0 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:20:12 +0100 Subject: [PATCH 070/118] Update index.js --- index.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 06cd46d..2ca97c6 100755 --- a/index.js +++ b/index.js @@ -6415,12 +6415,11 @@ JeedomBridgedAccessory.prototype.delServices = function(accessory) { let service; try { const cachedValues = []; - const serviceList = accessory.services.filter((svc) => - svc.UUID !== Service.AccessoryInformation.UUID && - svc.UUID !== Service.BridgingState.UUID - ); + const serviceList = accessory.services.filter((svc) => + svc.UUID !== Service.AccessoryInformation.UUID && svc.UUID !== Service.BridgingState.UUID + ); - serviceList.forEach((svc) => { + serviceList.forEach((svc) => { service=svc; this.log('debug', ' Suppression service :' + service.displayName + ' subtype:' + service.subtype + ' UUID:' + service.UUID); service.characteristics.forEach((c) => { @@ -6428,7 +6427,7 @@ JeedomBridgedAccessory.prototype.delServices = function(accessory) { cachedValues[service.subtype + c.displayName] = c.value; }); accessory.removeService(service); - }); + }); return cachedValues; } catch(e){ @@ -6607,5 +6606,5 @@ function RGBtoHSV(r, g, b) { // -- id : id to find // -- Return : Object found function findMyID(obj, id) { - return Object.values(obj).find(item => item && item.id == id) || -1; + return Object.values(obj).find((item) => item && item.id == id) || -1; } From 5360412078957be481ebe3efc27843ea952f77e4 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:21:51 +0100 Subject: [PATCH 071/118] Update index.js --- index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/index.js b/index.js index 2ca97c6..13130bc 100755 --- a/index.js +++ b/index.js @@ -6415,9 +6415,7 @@ JeedomBridgedAccessory.prototype.delServices = function(accessory) { let service; try { const cachedValues = []; - const serviceList = accessory.services.filter((svc) => - svc.UUID !== Service.AccessoryInformation.UUID && svc.UUID !== Service.BridgingState.UUID - ); + const serviceList = accessory.services.filter((svc) => svc.UUID !== Service.AccessoryInformation.UUID && svc.UUID !== Service.BridgingState.UUID); serviceList.forEach((svc) => { service=svc; From 985c79e5e8edee27fd51ea61e55ba4154f4ae1fb Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:23:25 +0100 Subject: [PATCH 072/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f57e86..e4fc1fd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0011", + "cust_serial": "0012", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From f93b9df8bf4295c3addc123087efabebb59293a8 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:30:10 +0100 Subject: [PATCH 073/118] Update index.js --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 13130bc..ce89511 100755 --- a/index.js +++ b/index.js @@ -6604,5 +6604,12 @@ function RGBtoHSV(r, g, b) { // -- id : id to find // -- Return : Object found function findMyID(obj, id) { - return Object.values(obj).find((item) => item && item.id == id) || -1; + //return Object.values(obj).find((item) => item && item.id == id) || -1; + for(const o in obj) { + // if( obj.hasOwnProperty( o ) && obj[o] && obj[o].id && parseInt(obj[o].id) && parseInt(id) && parseInt(obj[o].id)==parseInt(id)) { + if( obj.hasOwnProperty( o ) && obj[o] && obj[o].id && obj[o].id==id) { + return obj[o]; + } + } + return -1; } From dcc60ebd7ab2578f5d2aa0dbb29ee2e4fa2d301b Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:30:21 +0100 Subject: [PATCH 074/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e4fc1fd..f36d3d8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0012", + "cust_serial": "0013", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 55f4a89d939cbfef4ad842317b20f1a41052af49 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:46:40 +0100 Subject: [PATCH 075/118] Update index.js --- index.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index ce89511..4537577 100755 --- a/index.js +++ b/index.js @@ -6604,12 +6604,6 @@ function RGBtoHSV(r, g, b) { // -- id : id to find // -- Return : Object found function findMyID(obj, id) { - //return Object.values(obj).find((item) => item && item.id == id) || -1; - for(const o in obj) { - // if( obj.hasOwnProperty( o ) && obj[o] && obj[o].id && parseInt(obj[o].id) && parseInt(id) && parseInt(obj[o].id)==parseInt(id)) { - if( obj.hasOwnProperty( o ) && obj[o] && obj[o].id && obj[o].id==id) { - return obj[o]; - } - } - return -1; + if (!obj) return -1; + return Object.values(obj).find((item) => item && item.id == id) || -1; } From 64de579fffa4ce8db89a8ccf4d33650de4bc7d15 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:46:51 +0100 Subject: [PATCH 076/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f36d3d8..acbdea5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0013", + "cust_serial": "0014", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 57ea66fe4f49fe330e03d6007806d9fa8a322a3b Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:48:41 +0100 Subject: [PATCH 077/118] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 4537577..5c3071c 100755 --- a/index.js +++ b/index.js @@ -6604,6 +6604,6 @@ function RGBtoHSV(r, g, b) { // -- id : id to find // -- Return : Object found function findMyID(obj, id) { - if (!obj) return -1; + if (!obj) {return -1;} return Object.values(obj).find((item) => item && item.id == id) || -1; } From 1e5ecb91f23104613c749a3381af36973da94b61 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 16:30:50 +0100 Subject: [PATCH 078/118] Update index.js --- index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 5c3071c..0ff3972 100755 --- a/index.js +++ b/index.js @@ -570,9 +570,6 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.eqLogic=eqLogic; Serv.actions={}; Serv.infos={}; - if(cmd.moving) { - Serv.infos.moving=cmd.moving; - } if(cmd.stateClosing) { Serv.infos.state=cmd.stateClosing; if(Serv.infos.state.subType == 'binary') { @@ -612,6 +609,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.HorTiltState = cmd2.HorTiltState; } else if (cmd2.VerTiltState) { Serv.infos.VerTiltState = cmd2.VerTiltState; + } else if(cmd.moving) { + Serv.infos.moving=cmd2.moving; } }); if(Serv.actions.up && !Serv.actions.down) {that.log('warn','Pas de type générique "Action/Volet Bouton Descendre"');} @@ -798,9 +797,6 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.state=cmd.state; - if(cmd.moving) { - Serv.infos.moving=cmd.moving; - } eqServicesCopy.windowMoto.forEach(function(cmd2) { if (cmd2.up) { Serv.actions.up = cmd2.up; @@ -808,6 +804,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions.down = cmd2.down; } else if (cmd2.slider) { Serv.actions.slider = cmd2.slider; + } else if(cmd.moving) { + Serv.infos.moving=cmd2.moving; } }); Serv.maxValue = 100; // if not set in Jeedom it's 100 From e9d4cbf6f35ec196afdc6c5586f1a063e71026f8 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 16:31:01 +0100 Subject: [PATCH 079/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index acbdea5..b6f866e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0014", + "cust_serial": "0015", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 748946660e437d92d701b6a2badb0ef0e7f09339 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 16:33:16 +0100 Subject: [PATCH 080/118] Update index.js --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0ff3972..89e2f17 100755 --- a/index.js +++ b/index.js @@ -609,7 +609,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.HorTiltState = cmd2.HorTiltState; } else if (cmd2.VerTiltState) { Serv.infos.VerTiltState = cmd2.VerTiltState; - } else if(cmd.moving) { + } else if(cmd2.moving) { Serv.infos.moving=cmd2.moving; } }); @@ -804,7 +804,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions.down = cmd2.down; } else if (cmd2.slider) { Serv.actions.slider = cmd2.slider; - } else if(cmd.moving) { + } else if(cmd2.moving) { Serv.infos.moving=cmd2.moving; } }); From 9e7a5d3a1eaa8a787f866d12a683e40b716786e1 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 28 Jan 2024 17:38:06 +0100 Subject: [PATCH 081/118] Update index.js --- index.js | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index 89e2f17..20d345c 100755 --- a/index.js +++ b/index.js @@ -570,6 +570,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.eqLogic=eqLogic; Serv.actions={}; Serv.infos={}; + if(cmd.stateClosing) { Serv.infos.state=cmd.stateClosing; if(Serv.infos.state.subType == 'binary') { @@ -797,6 +798,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.state=cmd.state; + eqServicesCopy.windowMoto.forEach(function(cmd2) { if (cmd2.up) { Serv.actions.up = cmd2.up; @@ -5650,8 +5652,9 @@ JeedomPlatform.prototype.startPollingUpdate = function() { update.option.state != undefined && update.option.scenario_id) { - that.jeedomClient.updateModelScenario(update.option.scenario_id,update.option.state); // Update cachedModel - that.updateSubscribers(update);// Update subscribers + if(that.jeedomClient.updateModelScenario(update.option.scenario_id,update.option.state)){ // Update cachedModel + that.updateSubscribers(update);// Update subscribers + } } else if(DEV_DEBUG && update.name == 'eqLogic::update' && update.option.eqLogic_id) { @@ -5689,45 +5692,41 @@ JeedomPlatform.prototype.startPollingUpdate = function() { // -- Return : nothing JeedomPlatform.prototype.updateSubscribers = function(update) { const that = this; - var subCharact,subService,updateID; + const updateID = update.option.scenario_id || update.option.cmd_id; for (let i = 0; i < that.updateSubscriptions.length; i++) { - subCharact = that.updateSubscriptions[i].characteristic; - subService = that.updateSubscriptions[i].service; - - if(update.option.scenario_id) { - updateID = update.option.scenario_id; - } else if(update.option.cmd_id) { - updateID = update.option.cmd_id; - } + const { characteristic: subCharact, service: subService } = that.updateSubscriptions[i]; // that.log('debug',"update :",updateID,JSON.stringify(subService.infos),JSON.stringify(subService.statusArr),subCharact.UUID); const infoFound = findMyID(subService.infos,updateID); const statusFound = findMyID(subService.statusArr,updateID); - if(infoFound != -1 || statusFound != -1) { - let returnValue = that.getAccessoryValue(subCharact, subService, ((infoFound!=-1)?infoFound:statusFound)); - if(returnValue !== undefined && returnValue !== 'no_response') { + if(infoFound !== -1 || statusFound !== -1) { + let returnValue = that.getAccessoryValue(subCharact, subService, (infoFound !== -1?infoFound:statusFound)); + + if (returnValue === 'no_response') { + subCharact.updateValue(new Error('no_response'), undefined, 'fromJeedom'); + } else if(returnValue !== undefined) { returnValue = sanitizeValue(returnValue,subCharact); - if(infoFound != -1 && infoFound.generic_type=="LIGHT_STATE") { // if it's a LIGHT_STATE + const logMessage = 'Cause de modif: "' + (infoFound && infoFound.name ? infoFound.name + '" (' + updateID + ')' : '') + (statusFound && statusFound.name ? statusFound.name + '" (' + updateID + ')' : '') + ' Envoi valeur:' + returnValue + ' dans ' + subCharact.displayName; + if(infoFound !== -1 && infoFound.generic_type=="LIGHT_STATE") { // if it's a LIGHT_STATE if(!that.settingLight) { // and it's not currently being modified - that.log('info','[Commande envoyée à HomeKit]','Cause de modif: "'+((infoFound && infoFound.name)?infoFound.name+'" ('+updateID+')':'')+((statusFound && statusFound.name)?statusFound.name+'" ('+updateID+')':''),"Envoi valeur:",returnValue,'dans',subCharact.displayName); + that.log('info','[Commande envoyée à HomeKit]',logMessage); subCharact.updateValue(returnValue, undefined, 'fromJeedom'); - } else if(DEV_DEBUG) {that.log('debug','//Commande NON envoyée à HomeKit','Cause de modif: "'+((infoFound && infoFound.name)?infoFound.name+'" ('+updateID+')':'')+((statusFound && statusFound.name)?statusFound.name+'" ('+updateID+')':''),"Envoi valeur:",returnValue,'dans',subCharact.displayName);} - } else if(infoFound != -1 && (infoFound.generic_type=="FAN_STATE" || infoFound.generic_type=="FAN_SPEED_STATE")) { // if it's a FAN_STATE + } else if(DEV_DEBUG) {that.log('debug','//Commande NON envoyée à HomeKit',logMessage);} + } else if(infoFound !== -1 && (infoFound.generic_type=="FAN_STATE" || infoFound.generic_type=="FAN_SPEED_STATE")) { // if it's a FAN_STATE if(!that.settingFan) { // and it's not currently being modified - that.log('info','[Commande envoyée à HomeKit]','Cause de modif: "'+((infoFound && infoFound.name)?infoFound.name+'" ('+updateID+')':'')+((statusFound && statusFound.name)?statusFound.name+'" ('+updateID+')':''),"Envoi valeur:",returnValue,'dans',subCharact.displayName); + that.log('info','[Commande envoyée à HomeKit]',logMessage); subCharact.updateValue(returnValue, undefined, 'fromJeedom'); - } else if(DEV_DEBUG) {that.log('debug','//Commande NON envoyée à HomeKit','Cause de modif: "'+((infoFound && infoFound.name)?infoFound.name+'" ('+updateID+')':'')+((statusFound && statusFound.name)?statusFound.name+'" ('+updateID+')':''),"Envoi valeur:",returnValue,'dans',subCharact.displayName);} + } else if(DEV_DEBUG) {that.log('debug','//Commande NON envoyée à HomeKit',logMessage);} } else { - that.log('info','[Commande envoyée à HomeKit]','Cause de modif: "'+((infoFound && infoFound.name)?infoFound.name+'" ('+updateID+')':'')+((statusFound && statusFound.name)?statusFound.name+'" ('+updateID+')':''),"Envoi valeur:",returnValue,'dans',subCharact.displayName); + that.log('info','[Commande envoyée à HomeKit]',logMessage); subCharact.updateValue(returnValue, undefined, 'fromJeedom'); } - } else if (returnValue === 'no_response') { - subCharact.updateValue(new Error('no_response'), undefined, 'fromJeedom'); - } else { return; } + } else {return;} } } }; + // -- updateJeedomColorFromHomeKit // -- Desc : convert HSV value (Homebridge) to html value (Jeedom) // -- Params -- From 2e1ca73554f671698b410c813355f774bb5cf1e6 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:50:05 +0100 Subject: [PATCH 082/118] Update jeedom-api.js --- lib/jeedom-api.js | 1150 +++++++-------------------------------------- 1 file changed, 158 insertions(+), 992 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index ebb441f..f31c6c4 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with Jeedom. If not, see . */ -/* jshint esversion: 6,node: true */ +/* jshint esversion: 11,node: true */ 'use strict'; const axios = require('axios'); const async = require('async'); @@ -346,499 +346,198 @@ JeedomClient.prototype.refreshStates = function() { }); }; +function initServ(result_cmd, serviceType, property, value, isPush = false) { + result_cmd.services[serviceType] ??= []; + const service = {}; + if (isPush) { + service[property] ??= []; + service[property].push(value); + } else { + service[property] = value; + } + result_cmd.services[serviceType].push(service); +} + JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { - var result_cmd = {}; - result_cmd = EqLogic; - result_cmd.services = {}; - result_cmd.numSwitches=0; - result_cmd.numDetector=0; - for (var i in cmds) { - if (isset(cmds[i].generic_type)) { - if (cmds[i].generic_type) { - switch(cmds[i].generic_type) { + const result_cmd = {...EqLogic, services: {}, numSwitches: 0, numDetector: 0}; + + cmds.forEach((cmd) => { + if (cmd.generic_type !== null) { + switch(cmd.generic_type) { case 'SHOCK' : case 'RAIN_CURRENT' : case 'RAIN_TOTAL' : case 'WIND_SPEED' : case 'WIND_DIRECTION' : case 'GENERIC_INFO': - if (!result_cmd.services.generic) { - result_cmd.services.generic = []; - } - if (!result_cmd.services.generic[i]) { - result_cmd.services.generic[i] = {}; - } - result_cmd.services.generic[i].state = cmds[i]; + initServ(result_cmd,'generic','state',cmd); break; /** *************** MODE ***********************/ case 'MODE_STATE' : - if (!result_cmd.services.mode) { - result_cmd.services.mode = []; - } - if (!result_cmd.services.mode[i]) { - result_cmd.services.mode[i] = {}; - } - result_cmd.services.mode[i].state = cmds[i]; + initServ(result_cmd,'mode','state',cmd); break; case 'MODE_SET_STATE' : - if(cmds[i].logicalId=="returnPreviousMode") { - if (!result_cmd.services.mode) { - result_cmd.services.mode = []; - } - if (!result_cmd.services.mode[i]) { - result_cmd.services.mode[i] = {}; - } - result_cmd.services.mode[i].set_state_previous = cmds[i]; + if(cmd.logicalId=="returnPreviousMode") { + initServ(result_cmd,'mode','set_state_previous',cmd); } else { - if (!result_cmd.services.mode) { - result_cmd.services.mode = []; - } - if (!result_cmd.services.mode[i]) { - result_cmd.services.mode[i] = {}; - } - if (!result_cmd.services.mode[i].set_state) { - result_cmd.services.mode[i].set_state = []; - } - result_cmd.services.mode[i].set_state.push(cmds[i]); + initServ(result_cmd,'mode','set_state',cmd,true); } break; /** *************** LIGHT ***********************/ case 'LIGHT_STATE' : - if (!result_cmd.services.light) { - result_cmd.services.light = []; - } - if (!result_cmd.services.light[i]) { - result_cmd.services.light[i] = {}; - } - result_cmd.services.light[i].state = cmds[i]; + initServ(result_cmd,'light','state',cmd); break; case 'LIGHT_BRIGHTNESS' : - if (!result_cmd.services.light) { - result_cmd.services.light = []; - } - if (!result_cmd.services.light[i]) { - result_cmd.services.light[i] = {}; - } - result_cmd.services.light[i].brightness = cmds[i]; + initServ(result_cmd,'light','brightness',cmd); break; case 'LIGHT_STATE_BOOL' : - if (!result_cmd.services.light) { - result_cmd.services.light = []; - } - if (!result_cmd.services.light[i]) { - result_cmd.services.light[i] = {}; - } - result_cmd.services.light[i].state_bool = cmds[i]; + initServ(result_cmd,'light','state_bool',cmd); break; case 'LIGHT_ON' : - if (!result_cmd.services.light) { - result_cmd.services.light = []; - } - if (!result_cmd.services.light[i]) { - result_cmd.services.light[i] = {}; - } - result_cmd.services.light[i].on = cmds[i]; + initServ(result_cmd,'light','on',cmd); break; case 'LIGHT_OFF' : - if (!result_cmd.services.light) { - result_cmd.services.light = []; - } - if (!result_cmd.services.light[i]) { - result_cmd.services.light[i] = {}; - } - result_cmd.services.light[i].off = cmds[i]; + initServ(result_cmd,'light','off',cmd); break; case 'LIGHT_SLIDER' : - if (!result_cmd.services.light) { - result_cmd.services.light = []; - } - if (!result_cmd.services.light[i]) { - result_cmd.services.light[i] = {}; - } - result_cmd.services.light[i].slider = cmds[i]; + initServ(result_cmd,'light','slider',cmd); break; case 'LIGHT_COLOR' : - if (!result_cmd.services.light) { - result_cmd.services.light = []; - } - if (!result_cmd.services.light[i]) { - result_cmd.services.light[i] = {}; - } - result_cmd.services.light[i].color = cmds[i]; + initServ(result_cmd,'light','color',cmd); break; case 'LIGHT_COLOR_TEMP' : - if (!result_cmd.services.light) { - result_cmd.services.light = []; - } - if (!result_cmd.services.light[i]) { - result_cmd.services.light[i] = {}; - } - result_cmd.services.light[i].color_temp = cmds[i]; + initServ(result_cmd,'light','color_temp',cmd); break; case 'LIGHT_SET_COLOR' : - if (!result_cmd.services.light) { - result_cmd.services.light = []; - } - if (!result_cmd.services.light[i]) { - result_cmd.services.light[i] = {}; - } - result_cmd.services.light[i].setcolor = cmds[i]; + initServ(result_cmd,'light','setcolor',cmd); break; case 'LIGHT_SET_COLOR_TEMP' : - if (!result_cmd.services.light) { - result_cmd.services.light = []; - } - if (!result_cmd.services.light[i]) { - result_cmd.services.light[i] = {}; - } - result_cmd.services.light[i].setcolor_temp = cmds[i]; + initServ(result_cmd,'light','setcolor_temp',cmd); break; /** *************** WEATHER ***********************/ case 'WEATHER_TEMPERATURE' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].temperature = cmds[i]; + initServ(result_cmd,'weather','temperature',cmd); break; case 'WEATHER_HUMIDITY' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].humidity = cmds[i]; + initServ(result_cmd,'weather','humidity',cmd); break; case 'WEATHER_PRESSURE' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].pressure = cmds[i]; + initServ(result_cmd,'weather','pressure',cmd); break; case 'WEATHER_WIND_SPEED' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].wind_speed = cmds[i]; + initServ(result_cmd,'weather','wind_speed',cmd); break; case 'WEATHER_WIND_DIRECTION' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].wind_direction = cmds[i]; + initServ(result_cmd,'weather','wind_direction',cmd); break; case 'WEATHER_CONDITION' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].condition = cmds[i]; + initServ(result_cmd,'weather','condition',cmd); break; case 'WEATHER_UVINDEX' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].UVIndex = cmds[i]; + initServ(result_cmd,'weather','UVIndex',cmd); break; case 'WEATHER_VISIBILITY' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].visibility = cmds[i]; + initServ(result_cmd,'weather','visibility',cmd); break; case 'WEATHER_RAIN' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].rain = cmds[i]; + initServ(result_cmd,'weather','rain',cmd); break; case 'WEATHER_SNOW' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].snow = cmds[i]; + initServ(result_cmd,'weather','snow',cmd); break; case 'WEATHER_TEMPERATURE_MIN' : - if (!result_cmd.services.weather) { - result_cmd.services.weather = []; - } - if (!result_cmd.services.weather[i]) { - result_cmd.services.weather[i] = {}; - } - result_cmd.services.weather[i].temperature_min = cmds[i]; + initServ(result_cmd,'weather','temperature_min',cmd); break; /** *************** SIREN ***********************/ case 'SIREN_STATE' : - if (!result_cmd.services.siren) { - result_cmd.services.siren = []; - } - if (!result_cmd.services.siren[i]) { - result_cmd.services.siren[i] = {}; - } - result_cmd.services.siren[i].state = cmds[i]; + initServ(result_cmd,'siren','state',cmd); break; /* case 'SIREN_ON' : - if (!result_cmd.services.siren) { - result_cmd.services.siren = []; - } - if (!result_cmd.services.siren[i]) { - result_cmd.services.siren[i] = {}; - } - result_cmd.services.siren[i].on = cmds[i]; + initServ(result_cmd,'siren','on',cmd); break; case 'SIREN_OFF' : - if (!result_cmd.services.siren) { - result_cmd.services.siren = []; - } - if (!result_cmd.services.siren[i]) { - result_cmd.services.siren[i] = {}; - } - result_cmd.services.siren[i].off = cmds[i]; + initServ(result_cmd,'siren','off',cmd); break; */ /** *************** ENERGY ***********************/ case 'ENERGY_STATE' : - if (!result_cmd.services.energy) { - result_cmd.services.energy = []; - } - if (!result_cmd.services.energy[i]) { - result_cmd.services.energy[i] = {}; - } - result_cmd.services.energy[i].state = cmds[i]; + initServ(result_cmd,'energy','state',cmd); break; case 'ENERGY_ON' : - if (!result_cmd.services.energy) { - result_cmd.services.energy = []; - } - if (!result_cmd.services.energy[i]) { - result_cmd.services.energy[i] = {}; - } - result_cmd.services.energy[i].on = cmds[i]; + initServ(result_cmd,'energy','on',cmd); break; case 'ENERGY_OFF' : - if (!result_cmd.services.energy) { - result_cmd.services.energy = []; - } - if (!result_cmd.services.energy[i]) { - result_cmd.services.energy[i] = {}; - } - result_cmd.services.energy[i].off = cmds[i]; + initServ(result_cmd,'energy','off',cmd); break; case 'ENERGY_INUSE' : - if (!result_cmd.services.energy) { - result_cmd.services.energy = []; - } - if (!result_cmd.services.energy[i]) { - result_cmd.services.energy[i] = {}; - } - result_cmd.services.energy[i].inuse = cmds[i]; + initServ(result_cmd,'energy','inuse',cmd); break; /** *************** VALVES ***********************/ case 'FAUCET_STATE' : - if (!result_cmd.services.faucet) { - result_cmd.services.faucet = []; - } - if (!result_cmd.services.faucet[i]) { - result_cmd.services.faucet[i] = {}; - } - result_cmd.services.faucet[i].state = cmds[i]; + initServ(result_cmd,'faucet','state',cmd); break; case 'FAUCET_ON' : - if (!result_cmd.services.faucet) { - result_cmd.services.faucet = []; - } - if (!result_cmd.services.faucet[i]) { - result_cmd.services.faucet[i] = {}; - } - result_cmd.services.faucet[i].on = cmds[i]; + initServ(result_cmd,'faucet','on',cmd); break; case 'FAUCET_OFF' : - if (!result_cmd.services.faucet) { - result_cmd.services.faucet = []; - } - if (!result_cmd.services.faucet[i]) { - result_cmd.services.faucet[i] = {}; - } - result_cmd.services.faucet[i].off = cmds[i]; + initServ(result_cmd,'faucet','off',cmd); break; case 'IRRIG_STATE' : - if (!result_cmd.services.irrigation) { - result_cmd.services.irrigation = []; - } - if (!result_cmd.services.irrigation[i]) { - result_cmd.services.irrigation[i] = {}; - } - result_cmd.services.irrigation[i].state = cmds[i]; + initServ(result_cmd,'irrigation','state',cmd); break; case 'IRRIG_ON' : - if (!result_cmd.services.irrigation) { - result_cmd.services.irrigation = []; - } - if (!result_cmd.services.irrigation[i]) { - result_cmd.services.irrigation[i] = {}; - } - result_cmd.services.irrigation[i].on = cmds[i]; + initServ(result_cmd,'irrigation','on',cmd); break; case 'IRRIG_OFF' : - if (!result_cmd.services.irrigation) { - result_cmd.services.irrigation = []; - } - if (!result_cmd.services.irrigation[i]) { - result_cmd.services.irrigation[i] = {}; - } - result_cmd.services.irrigation[i].off = cmds[i]; + initServ(result_cmd,'irrigation','off',cmd); break; case 'VALVE_STATE' : - if (!result_cmd.services.valve) { - result_cmd.services.valve = []; - } - if (!result_cmd.services.valve[i]) { - result_cmd.services.valve[i] = {}; - } - result_cmd.services.valve[i].state = cmds[i]; + initServ(result_cmd,'valve','state',cmd); break; case 'VALVE_ON' : - if (!result_cmd.services.valve) { - result_cmd.services.valve = []; - } - if (!result_cmd.services.valve[i]) { - result_cmd.services.valve[i] = {}; - } - result_cmd.services.valve[i].on = cmds[i]; + initServ(result_cmd,'valve','on',cmd); break; case 'VALVE_OFF' : - if (!result_cmd.services.valve) { - result_cmd.services.valve = []; - } - if (!result_cmd.services.valve[i]) { - result_cmd.services.valve[i] = {}; - } - result_cmd.services.valve[i].off = cmds[i]; + initServ(result_cmd,'valve','off',cmd); break; case 'VALVE_SET_DURATION' : - if (!result_cmd.services.valve) { - result_cmd.services.valve = []; - } - if (!result_cmd.services.valve[i]) { - result_cmd.services.valve[i] = {}; - } - result_cmd.services.valve[i].setDuration = cmds[i]; + initServ(result_cmd,'valve','setDuration',cmd); break; case 'VALVE_REMAINING_DURATION' : - if (!result_cmd.services.valve) { - result_cmd.services.valve = []; - } - if (!result_cmd.services.valve[i]) { - result_cmd.services.valve[i] = {}; - } - result_cmd.services.valve[i].remainingDuration = cmds[i]; + initServ(result_cmd,'valve','remainingDuration',cmd); break; /** *************** FAN ***********************/ case 'FAN_STATE' : case 'FAN_SPEED_STATE' : - if (!result_cmd.services.fan) { - result_cmd.services.fan = []; - } - if (!result_cmd.services.fan[i]) { - result_cmd.services.fan[i] = {}; - } - result_cmd.services.fan[i].state = cmds[i]; + initServ(result_cmd,'fan','state',cmd); break; case 'FAN_ON' : - if (!result_cmd.services.fan) { - result_cmd.services.fan = []; - } - if (!result_cmd.services.fan[i]) { - result_cmd.services.fan[i] = {}; - } - result_cmd.services.fan[i].on = cmds[i]; + initServ(result_cmd,'fan','on',cmd); break; case 'FAN_OFF' : - if (!result_cmd.services.fan) { - result_cmd.services.fan = []; - } - if (!result_cmd.services.fan[i]) { - result_cmd.services.fan[i] = {}; - } - result_cmd.services.fan[i].off = cmds[i]; + initServ(result_cmd,'fan','off',cmd); break; case 'FAN_SLIDER' : case 'FAN_SPEED' : - if (!result_cmd.services.fan) { - result_cmd.services.fan = []; - } - if (!result_cmd.services.fan[i]) { - result_cmd.services.fan[i] = {}; - } - result_cmd.services.fan[i].slider = cmds[i]; + initServ(result_cmd,'fan','slider',cmd); break; /** *************** SWITCH ***********************/ case 'SWITCH_STATE' : case 'CAMERA_RECORD_STATE' : - if (!result_cmd.services.Switch) { - result_cmd.services.Switch = []; - } - if (!result_cmd.services.Switch[i]) { - result_cmd.services.Switch[i] = {}; - } - result_cmd.services.Switch[i].state = cmds[i]; + initServ(result_cmd,'Switch','state',cmd); result_cmd.numSwitches++; break; case 'SWITCH_ON' : case 'CAMERA_RECORD' : - if (!result_cmd.services.Switch) { - result_cmd.services.Switch = []; - } - if (!result_cmd.services.Switch[i]) { - result_cmd.services.Switch[i] = {}; - } - result_cmd.services.Switch[i].on = cmds[i]; + initServ(result_cmd,'Switch','on',cmd); break; case 'SWITCH_OFF' : case 'CAMERA_STOP' : - if (!result_cmd.services.Switch) { - result_cmd.services.Switch = []; - } - if (!result_cmd.services.Switch[i]) { - result_cmd.services.Switch[i] = {}; - } - result_cmd.services.Switch[i].off = cmds[i]; + initServ(result_cmd,'Switch','off',cmd); break; /** *************** SWITCH ***********************/ case 'GENERIC_ACTION' : - if(cmds[i].subType=="other") { - if (!result_cmd.services.Push) { - result_cmd.services.Push = []; - } - if (!result_cmd.services.Push[i]) { - result_cmd.services.Push[i] = {}; - } - result_cmd.services.Push[i].Push = cmds[i]; + if(cmd.subType=="other") { + initServ(result_cmd,'Push','Push',cmd); } break; case 'PUSH_BUTTON' : @@ -849,818 +548,285 @@ JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { case 'CAMERA_ZOOM' : case 'CAMERA_DEZOOM' : case 'CAMERA_PRESET' : - if (!result_cmd.services.Push) { - result_cmd.services.Push = []; - } - if (!result_cmd.services.Push[i]) { - result_cmd.services.Push[i] = {}; - } - result_cmd.services.Push[i].Push = cmds[i]; + initServ(result_cmd,'Push','Push',cmd); break; /** *************** BARRIER/GARAGE**************/ case "BARRIER_STATE" : case "GARAGE_STATE" : - if (!result_cmd.services.GarageDoor) { - result_cmd.services.GarageDoor = []; - } - if (!result_cmd.services.GarageDoor[i]) { - result_cmd.services.GarageDoor[i] = {}; - } - result_cmd.services.GarageDoor[i].state = cmds[i]; + initServ(result_cmd,'GarageDoor','state',cmd); break; case "GB_OPEN" : // should not be used - if (!result_cmd.services.GarageDoor) { - result_cmd.services.GarageDoor = []; - } - if (!result_cmd.services.GarageDoor[i]) { - result_cmd.services.GarageDoor[i] = {}; - } - result_cmd.services.GarageDoor[i].on = cmds[i]; + initServ(result_cmd,'GarageDoor','on',cmd); break; case "GB_CLOSE" : // should not be used - if (!result_cmd.services.GarageDoor) { - result_cmd.services.GarageDoor = []; - } - if (!result_cmd.services.GarageDoor[i]) { - result_cmd.services.GarageDoor[i] = {}; - } - result_cmd.services.GarageDoor[i].off = cmds[i]; + initServ(result_cmd,'GarageDoor','off',cmd); break; case "GB_TOGGLE" : - if (!result_cmd.services.GarageDoor) { - result_cmd.services.GarageDoor = []; - } - if (!result_cmd.services.GarageDoor[i]) { - result_cmd.services.GarageDoor[i] = {}; - } - result_cmd.services.GarageDoor[i].toggle = cmds[i]; + initServ(result_cmd,'GarageDoor','toggle',cmd); break; /** *************** LOCK ***********************/ case 'LOCK_STATE' : - if (!result_cmd.services.lock) { - result_cmd.services.lock = []; - } - if (!result_cmd.services.lock[i]) { - result_cmd.services.lock[i] = {}; - } - result_cmd.services.lock[i].state = cmds[i]; + initServ(result_cmd,'lock','state',cmd); break; case 'LOCK_OPEN' : - if (!result_cmd.services.lock) { - result_cmd.services.lock = []; - } - if (!result_cmd.services.lock[i]) { - result_cmd.services.lock[i] = {}; - } - result_cmd.services.lock[i].on = cmds[i]; + initServ(result_cmd,'lock','on',cmd); break; case 'LOCK_CLOSE' : - if (!result_cmd.services.lock) { - result_cmd.services.lock = []; - } - if (!result_cmd.services.lock[i]) { - result_cmd.services.lock[i] = {}; - } - result_cmd.services.lock[i].off = cmds[i]; + initServ(result_cmd,'lock','off',cmd); break; /** *************** StatelessSwitch ******************/ case 'SWITCH_STATELESS_ALLINONE' : - if (!result_cmd.services.StatelessSwitch) { - result_cmd.services.StatelessSwitch = []; - } - if (!result_cmd.services.StatelessSwitch[i]) { - result_cmd.services.StatelessSwitch[i] = {}; - } - result_cmd.services.StatelessSwitch[i].eventType = cmds[i]; + initServ(result_cmd,'StatelessSwitch','eventType',cmd); break; case 'SWITCH_STATELESS_SINGLE' : - if (!result_cmd.services.StatelessSwitchMono) { - result_cmd.services.StatelessSwitchMono = []; - } - if (!result_cmd.services.StatelessSwitchMono[i]) { - result_cmd.services.StatelessSwitchMono[i] = {}; - } - result_cmd.services.StatelessSwitchMono[i].Single = cmds[i]; + initServ(result_cmd,'StatelessSwitchMono','Single',cmd); break; case 'SWITCH_STATELESS_DOUBLE' : - if (!result_cmd.services.StatelessSwitchMono) { - result_cmd.services.StatelessSwitchMono = []; - } - if (!result_cmd.services.StatelessSwitchMono[i]) { - result_cmd.services.StatelessSwitchMono[i] = {}; - } - result_cmd.services.StatelessSwitchMono[i].Double = cmds[i]; + initServ(result_cmd,'StatelessSwitchMono','Double',cmd); break; case 'SWITCH_STATELESS_LONG' : - if (!result_cmd.services.StatelessSwitchMono) { - result_cmd.services.StatelessSwitchMono = []; - } - if (!result_cmd.services.StatelessSwitchMono[i]) { - result_cmd.services.StatelessSwitchMono[i] = {}; - } - result_cmd.services.StatelessSwitchMono[i].Long = cmds[i]; + initServ(result_cmd,'StatelessSwitchMono','Long',cmd); break; /** *************** FLAP ***********************/ case 'FLAP_STATE' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].state = cmds[i]; + initServ(result_cmd,'flap','state',cmd); break; case 'FLAP_STATE_CLOSING' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].stateClosing = cmds[i]; + initServ(result_cmd,'flap','stateClosing',cmd); break; case 'FLAP_UP' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].up = cmds[i]; + initServ(result_cmd,'flap','up',cmd); break; case 'FLAP_DOWN' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].down = cmds[i]; + initServ(result_cmd,'flap','down',cmd); break; case 'FLAP_SLIDER' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].slider = cmds[i]; + initServ(result_cmd,'flap','slider',cmd); break; case 'FLAP_STOP' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].stop = cmds[i]; + initServ(result_cmd,'flap','stop',cmd); break; case 'FLAP_MOVING' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].moving = cmds[i]; + initServ(result_cmd,'flap','moving',cmd); break; case 'FLAP_HOR_TILT_STATE' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].HorTiltState = cmds[i]; + initServ(result_cmd,'flap','HorTiltState',cmd); break; case 'FLAP_HOR_TILT_SLIDER' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].HorTiltSlider = cmds[i]; + initServ(result_cmd,'flap','HorTiltSlider',cmd); break; case 'FLAP_VER_TILT_STATE' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].VerTiltState = cmds[i]; + initServ(result_cmd,'flap','VerTiltState',cmd); break; case 'FLAP_VER_TILT_SLIDER' : - if (!result_cmd.services.flap) { - result_cmd.services.flap = []; - } - if (!result_cmd.services.flap[i]) { - result_cmd.services.flap[i] = {}; - } - result_cmd.services.flap[i].VerTiltSlider = cmds[i]; + initServ(result_cmd,'flap','VerTiltSlider',cmd); break; /** *************** WINDOW ***********************/ case 'WINDOW_STATE' : - if (!result_cmd.services.windowMoto) { - result_cmd.services.windowMoto = []; - } - if (!result_cmd.services.windowMoto[i]) { - result_cmd.services.windowMoto[i] = {}; - } - result_cmd.services.windowMoto[i].state = cmds[i]; + initServ(result_cmd,'windowMoto','state',cmd); break; case 'WINDOW_UP' : - if (!result_cmd.services.windowMoto) { - result_cmd.services.windowMoto = []; - } - if (!result_cmd.services.windowMoto[i]) { - result_cmd.services.windowMoto[i] = {}; - } - result_cmd.services.windowMoto[i].up = cmds[i]; + initServ(result_cmd,'windowMoto','up',cmd); break; case 'WINDOW_DOWN' : - if (!result_cmd.services.windowMoto) { - result_cmd.services.windowMoto = []; - } - if (!result_cmd.services.windowMoto[i]) { - result_cmd.services.windowMoto[i] = {}; - } - result_cmd.services.windowMoto[i].down = cmds[i]; + initServ(result_cmd,'windowMoto','down',cmd); break; case 'WINDOW_SLIDER' : - if (!result_cmd.services.windowMoto) { - result_cmd.services.windowMoto = []; - } - if (!result_cmd.services.windowMoto[i]) { - result_cmd.services.windowMoto[i] = {}; - } - result_cmd.services.windowMoto[i].slider = cmds[i]; + initServ(result_cmd,'windowMoto','slider',cmd); break; case 'WINDOW_MOVING' : - if (!result_cmd.services.windowMoto) { - result_cmd.services.windowMoto = []; - } - if (!result_cmd.services.windowMoto[i]) { - result_cmd.services.windowMoto[i] = {}; - } - result_cmd.services.windowMoto[i].moving = cmds[i]; + initServ(result_cmd,'windowMoto','moving',cmd); break; /** ************* THERMOSTAT ***********************/ case 'THERMOSTAT_STATE' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].state = cmds[i]; + initServ(result_cmd,'thermostat','state',cmd); break; case 'THERMOSTAT_STATE_NAME' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].state_name = cmds[i]; + initServ(result_cmd,'thermostat','state_name',cmd); break; case 'THERMOSTAT_TEMPERATURE' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].temperature = cmds[i]; + initServ(result_cmd,'thermostat','temperature',cmd); break; case 'THERMOSTAT_SET_SETPOINT' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].set_setpoint = cmds[i]; + initServ(result_cmd,'thermostat','set_setpoint',cmd); break; case 'THERMOSTAT_SETPOINT' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].setpoint = cmds[i]; + initServ(result_cmd,'thermostat','setpoint',cmd); break; case 'THERMOSTAT_SET_MODE' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].set_mode = cmds[i]; + initServ(result_cmd,'thermostat','set_mode',cmd); break; case 'THERMOSTAT_MODE' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].mode = cmds[i]; + initServ(result_cmd,'thermostat','mode',cmd); break; case 'THERMOSTAT_LOCK' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].lock = cmds[i]; + initServ(result_cmd,'thermostat','lock',cmd); break; case 'THERMOSTAT_SET_LOCK' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].set_lock = cmds[i]; + initServ(result_cmd,'thermostat','set_lock',cmd); break; case 'THERMOSTAT_SET_UNLOCK' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].set_unlock = cmds[i]; + initServ(result_cmd,'thermostat','set_unlock',cmd); break; case 'THERMOSTAT_TEMPERATURE_OUTDOOR' : - if (!result_cmd.services.thermostat) { - result_cmd.services.thermostat = []; - } - if (!result_cmd.services.thermostat[i]) { - result_cmd.services.thermostat[i] = {}; - } - result_cmd.services.thermostat[i].temperature_outdoor = cmds[i]; + initServ(result_cmd,'thermostat','temperature_outdoor',cmd); break; /** ************* THERMOSTAT_HC ***********************/ case 'THERMOSTAT_HC_STATE' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].state = cmds[i]; + initServ(result_cmd,'thermostatHC','state',cmd); break; case 'THERMOSTAT_HC_STATE_NAME' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].state_name = cmds[i]; + initServ(result_cmd,'thermostatHC','state_name',cmd); break; case 'THERMOSTAT_HC_TEMPERATURE' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].temperature = cmds[i]; + initServ(result_cmd,'thermostatHC','temperature',cmd); break; case 'THERMOSTAT_HC_SET_SETPOINT_H' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].set_setpointH = cmds[i]; + initServ(result_cmd,'thermostatHC','set_setpointH',cmd); break; case 'THERMOSTAT_HC_SET_SETPOINT_C' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].set_setpointC = cmds[i]; + initServ(result_cmd,'thermostatHC','set_setpointC',cmd); break; case 'THERMOSTAT_HC_SETPOINT_H' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].setpointH = cmds[i]; + initServ(result_cmd,'thermostatHC','setpointH',cmd); break; case 'THERMOSTAT_HC_SETPOINT_C' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].setpointC = cmds[i]; + initServ(result_cmd,'thermostatHC','setpointC',cmd); break; case 'THERMOSTAT_HC_SET_MODE' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].set_mode = cmds[i]; + initServ(result_cmd,'thermostatHC','set_mode',cmd); break; case 'THERMOSTAT_HC_MODE' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].mode = cmds[i]; + initServ(result_cmd,'thermostatHC','mode',cmd); break; case 'THERMOSTAT_HC_LOCK' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].lock = cmds[i]; + initServ(result_cmd,'thermostatHC','lock',cmd); break; case 'THERMOSTAT_HC_SET_LOCK' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].set_lock = cmds[i]; + initServ(result_cmd,'thermostatHC','set_lock',cmd); break; case 'THERMOSTAT_HC_SET_UNLOCK' : - if (!result_cmd.services.thermostatHC) { - result_cmd.services.thermostatHC = []; - } - if (!result_cmd.services.thermostatHC[i]) { - result_cmd.services.thermostatHC[i] = {}; - } - result_cmd.services.thermostatHC[i].set_unlock = cmds[i]; + initServ(result_cmd,'thermostatHC','set_unlock',cmd); break; /** ************* ALARME ***********************/ case 'ALARM_STATE' : - if (!result_cmd.services.alarm) { - result_cmd.services.alarm = []; - } - if (!result_cmd.services.alarm[i]) { - result_cmd.services.alarm[i] = {}; - } - result_cmd.services.alarm[i].state = cmds[i]; + initServ(result_cmd,'alarm','state',cmd); break; case 'ALARM_MODE' : - if (!result_cmd.services.alarm) { - result_cmd.services.alarm = []; - } - if (!result_cmd.services.alarm[i]) { - result_cmd.services.alarm[i] = {}; - } - result_cmd.services.alarm[i].mode = cmds[i]; + initServ(result_cmd,'alarm','mode',cmd); break; case 'ALARM_ENABLE_STATE' : - if (!result_cmd.services.alarm) { - result_cmd.services.alarm = []; - } - if (!result_cmd.services.alarm[i]) { - result_cmd.services.alarm[i] = {}; - } - result_cmd.services.alarm[i].enable_state = cmds[i]; + initServ(result_cmd,'alarm','enable_state',cmd); break; case 'ALARM_ARMED' : - if (!result_cmd.services.alarm) { - result_cmd.services.alarm = []; - } - if (!result_cmd.services.alarm[i]) { - result_cmd.services.alarm[i] = {}; - } - result_cmd.services.alarm[i].armed = cmds[i]; + initServ(result_cmd,'alarm','armed',cmd); break; case 'ALARM_RELEASED' : - if (!result_cmd.services.alarm) { - result_cmd.services.alarm = []; - } - if (!result_cmd.services.alarm[i]) { - result_cmd.services.alarm[i] = {}; - } - result_cmd.services.alarm[i].released = cmds[i]; + initServ(result_cmd,'alarm','released',cmd); break; case 'ALARM_SET_MODE' : - if (!result_cmd.services.alarm) { - result_cmd.services.alarm = []; - } - if (!result_cmd.services.alarm[i]) { - result_cmd.services.alarm[i] = {}; - } - result_cmd.services.alarm[i].set_mode = cmds[i]; + initServ(result_cmd,'alarm','set_mode',cmd); break; /** *************** GENERIC ***********************/ case 'AIRQUALITY_INDEX' : - if (!result_cmd.services.AirQuality) { - result_cmd.services.AirQuality = []; - } - if (!result_cmd.services.AirQuality[i]) { - result_cmd.services.AirQuality[i] = {}; - } - result_cmd.services.AirQuality[i].Index = cmds[i]; + initServ(result_cmd,'AirQuality','Index',cmd); break; case 'AIRQUALITY_PM25' : - if (!result_cmd.services.AirQuality) { - result_cmd.services.AirQuality = []; - } - if (!result_cmd.services.AirQuality[i]) { - result_cmd.services.AirQuality[i] = {}; - } - result_cmd.services.AirQuality[i].PM25 = cmds[i]; + initServ(result_cmd,'AirQuality','PM25',cmd); break; case 'AIRQUALITY_CUSTOM' : - if (!result_cmd.services.AirQualityCustom) { - result_cmd.services.AirQualityCustom = []; - } - if (!result_cmd.services.AirQualityCustom[i]) { - result_cmd.services.AirQualityCustom[i] = {}; - } - result_cmd.services.AirQualityCustom[i].Index = cmds[i]; + initServ(result_cmd,'AirQualityCustom','Index',cmd); break; case 'NOISE' : - if (!result_cmd.services.Noise) { - result_cmd.services.Noise = []; - } - if (!result_cmd.services.Noise[i]) { - result_cmd.services.Noise[i] = {}; - } - result_cmd.services.Noise[i].Noise = cmds[i]; + initServ(result_cmd,'Noise','Noise',cmd); break; case 'CO2' : - if (!result_cmd.services.CO2) { - result_cmd.services.CO2 = []; - } - if (!result_cmd.services.CO2[i]) { - result_cmd.services.CO2[i] = {}; - } - result_cmd.services.CO2[i].CO2 = cmds[i]; + initServ(result_cmd,'CO2','CO2',cmd); break; case 'CO' : - if (!result_cmd.services.CO) { - result_cmd.services.CO = []; - } - if (!result_cmd.services.CO[i]) { - result_cmd.services.CO[i] = {}; - } - result_cmd.services.CO[i].CO = cmds[i]; + initServ(result_cmd,'CO','CO',cmd); break; case 'OPENING_WINDOW' : case 'OPENING' : - if (!result_cmd.services.opening) { - result_cmd.services.opening = []; - } - if (!result_cmd.services.opening[i]) { - result_cmd.services.opening[i] = {}; - } - result_cmd.services.opening[i].opening = cmds[i]; + initServ(result_cmd,'opening','opening',cmd); break; case 'BATTERY' : - if (!result_cmd.services.battery) { - result_cmd.services.battery = []; - } - if (!result_cmd.services.battery[i]) { - result_cmd.services.battery[i] = {}; - } - result_cmd.services.battery[i].battery = cmds[i]; + initServ(result_cmd,'battery','battery',cmd); break; case 'BATTERY_CHARGING' : // not existing yet - if (!result_cmd.services.battery) { - result_cmd.services.battery = []; - } - if (!result_cmd.services.battery[i]) { - result_cmd.services.battery[i] = {}; - } - result_cmd.services.battery[i].batteryCharging = cmds[i]; + initServ(result_cmd,'battery','batteryCharging',cmd); break; case 'DEFECT' : - if (!result_cmd.services.defect) { - result_cmd.services.defect = []; - } - if (!result_cmd.services.defect[i]) { - result_cmd.services.defect[i] = {}; - } - result_cmd.services.defect[i].defect = cmds[i]; + initServ(result_cmd,'defect','defect',cmd); break; case 'PRESENCE' : - if (!result_cmd.services.presence) { - result_cmd.services.presence = []; - } - if (!result_cmd.services.presence[i]) { - result_cmd.services.presence[i] = {}; - } - result_cmd.services.presence[i].presence = cmds[i]; + initServ(result_cmd,'presence','presence',cmd); result_cmd.numDetector++; break; case 'OCCUPANCY' : - if (!result_cmd.services.occupancy) { - result_cmd.services.occupancy = []; - } - if (!result_cmd.services.occupancy[i]) { - result_cmd.services.occupancy[i] = {}; - } - result_cmd.services.occupancy[i].occupancy = cmds[i]; + initServ(result_cmd,'occupancy','occupancy',cmd); result_cmd.numDetector++; break; case 'TEMPERATURE' : - if (!result_cmd.services.temperature) { - result_cmd.services.temperature = []; - } - if (!result_cmd.services.temperature[i]) { - result_cmd.services.temperature[i] = {}; - } - result_cmd.services.temperature[i].temperature = cmds[i]; + initServ(result_cmd,'temperature','temperature',cmd); break; case 'BRIGHTNESS' : - if (!result_cmd.services.brightness) { - result_cmd.services.brightness = []; - } - if (!result_cmd.services.brightness[i]) { - result_cmd.services.brightness[i] = {}; - } - result_cmd.services.brightness[i].brightness = cmds[i]; + initServ(result_cmd,'brightness','brightness',cmd); break; case 'SMOKE' : - if (!result_cmd.services.smoke) { - result_cmd.services.smoke = []; - } - if (!result_cmd.services.smoke[i]) { - result_cmd.services.smoke[i] = {}; - } - result_cmd.services.smoke[i].smoke = cmds[i]; + initServ(result_cmd,'smoke','smoke',cmd); break; case 'UV' : // via custom - if (!result_cmd.services.uv) { - result_cmd.services.uv = []; - } - if (!result_cmd.services.uv[i]) { - result_cmd.services.uv[i] = {}; - } - result_cmd.services.uv[i].uv = cmds[i]; + initServ(result_cmd,'uv','uv',cmd); break; case 'HUMIDITY' : - if (!result_cmd.services.humidity) { - result_cmd.services.humidity = []; - } - if (!result_cmd.services.humidity[i]) { - result_cmd.services.humidity[i] = {}; - } - result_cmd.services.humidity[i].humidity = cmds[i]; + initServ(result_cmd,'humidity','humidity',cmd); break; case 'SABOTAGE' : - if (!result_cmd.services.sabotage) { - result_cmd.services.sabotage = []; - } - if (!result_cmd.services.sabotage[i]) { - result_cmd.services.sabotage[i] = {}; - } - result_cmd.services.sabotage[i].sabotage = cmds[i]; + initServ(result_cmd,'sabotage','sabotage',cmd); break; case 'FLOOD' : case 'WATER_LEAK' : - if (!result_cmd.services.flood) { - result_cmd.services.flood = []; - } - if (!result_cmd.services.flood[i]) { - result_cmd.services.flood[i] = {}; - } - result_cmd.services.flood[i].flood = cmds[i]; + initServ(result_cmd,'flood','flood',cmd); break; case 'POWER' : // via custom - if (!result_cmd.services.power) { - result_cmd.services.power = []; - } - if (!result_cmd.services.power[i]) { - result_cmd.services.power[i] = {}; - } - result_cmd.services.power[i].power = cmds[i]; + initServ(result_cmd,'power','power',cmd); break; case 'CONSUMPTION' : // via custom - if (!result_cmd.services.consumption) { - result_cmd.services.consumption = []; - } - if (!result_cmd.services.consumption[i]) { - result_cmd.services.consumption[i] = {}; - } - result_cmd.services.consumption[i].consumption = cmds[i]; + initServ(result_cmd,'consumption','consumption',cmd); break; case 'ACTIVE' : - if (!result_cmd.services.status_active) { - result_cmd.services.status_active = []; - } - if (!result_cmd.services.status_active[i]) { - result_cmd.services.status_active[i] = {}; - } - result_cmd.services.status_active[i].status_active = cmds[i]; + initServ(result_cmd,'status_active','status_active',cmd); break; case 'SPEAKER_VOLUME' : case 'VOLUME' : - if (!result_cmd.services.speaker) { - result_cmd.services.speaker = []; - } - if (!result_cmd.services.speaker[i]) { - result_cmd.services.speaker[i] = {}; - } - result_cmd.services.speaker[i].volume = cmds[i]; + initServ(result_cmd,'speaker','volume',cmd); break; case 'SPEAKER_SET_VOLUME' : case 'SET_VOLUME' : - if (!result_cmd.services.speaker) { - result_cmd.services.speaker = []; - } - if (!result_cmd.services.speaker[i]) { - result_cmd.services.speaker[i] = {}; - } - result_cmd.services.speaker[i].set_volume = cmds[i]; + initServ(result_cmd,'speaker','set_volume',cmd); break; case 'SPEAKER_MUTE' : - if (!result_cmd.services.speaker) { - result_cmd.services.speaker = []; - } - if (!result_cmd.services.speaker[i]) { - result_cmd.services.speaker[i] = {}; - } - result_cmd.services.speaker[i].mute = cmds[i]; + initServ(result_cmd,'speaker','mute',cmd); break; case 'SPEAKER_MUTE_TOGGLE' : - if (!result_cmd.services.speaker) { - result_cmd.services.speaker = []; - } - if (!result_cmd.services.speaker[i]) { - result_cmd.services.speaker[i] = {}; - } - result_cmd.services.speaker[i].mute_toggle = cmds[i]; + initServ(result_cmd,'speaker','mute_toggle',cmd); break; case 'SPEAKER_MUTE_ON' : - if (!result_cmd.services.speaker) { - result_cmd.services.speaker = []; - } - if (!result_cmd.services.speaker[i]) { - result_cmd.services.speaker[i] = {}; - } - result_cmd.services.speaker[i].mute_on = cmds[i]; + initServ(result_cmd,'speaker','mute_on',cmd); break; case 'SPEAKER_MUTE_OFF' : - if (!result_cmd.services.speaker) { - result_cmd.services.speaker = []; - } - if (!result_cmd.services.speaker[i]) { - result_cmd.services.speaker[i] = {}; - } - result_cmd.services.speaker[i].mute_off = cmds[i]; + initServ(result_cmd,'speaker','mute_off',cmd); break; case 'PRESSURE' : - if (!result_cmd.services.pressure) { - result_cmd.services.pressure = []; - } - if (!result_cmd.services.pressure[i]) { - result_cmd.services.pressure[i] = {}; - } - result_cmd.services.pressure[i].pressure = cmds[i]; + initServ(result_cmd,'pressure','pressure',cmd); break; - } } } - } + }); return result_cmd; }; -function isset() { - var a = arguments, l = a.length, i = 0; - - if (l === 0) { - throw new Error('Empty isset'); - } - - while (i !== l) { - if (!a[i]) { - return false; - } - i++; - } - return true; -} - module.exports.createClient = function(url, apikey, Plateform,myPlugin) { return new JeedomClient(url, apikey, Plateform,myPlugin); }; From 4370d687a3202ed432f396c39057eebc839ce3f9 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:51:32 +0100 Subject: [PATCH 083/118] Update index.js --- index.js | 54 ++++++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) diff --git a/index.js b/index.js index 20d345c..e807601 100755 --- a/index.js +++ b/index.js @@ -323,17 +323,11 @@ JeedomPlatform.prototype.JeedomDevices2HomeKitAccessories = function(devices) { try{ const that = this; if (devices) { - devices.sort(function compare(a, b) { + devices.sort((a, b) => { // reorder by room name asc and name asc - const aC = that.rooms[a.object_id]+a.name; - const bC = that.rooms[b.object_id]+b.name; - if (aC > bC) { - return 1; - } - if (aC < bC) { - return -1; - } - return 0; + const aC = that.rooms[a.object_id] + a.name; + const bC = that.rooms[b.object_id] + b.name; + return aC.localeCompare(bC); }); devices.map(function(device) { @@ -3495,18 +3489,15 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser } }; -JeedomPlatform.prototype.findAccessoryByService = function(service) { - for (const acc in this.accessories) { - if (this.accessories.hasOwnProperty(acc)) { - for(const ser in this.accessories[acc].services) { - if (this.accessories[acc].services.hasOwnProperty(ser)) { - if(this.accessories[acc].services[ser].cmd_id && this.accessories[acc].services[ser].cmd_id.toString() == service.cmd_id.toString()) { - return this.accessories[acc]; - } - } - } - } - } +JeedomPlatform.prototype.findAccessoryByService = function(serviceToFind) { + const targetCmdId = serviceToFind.cmd_id.toString(); + for (const accessory of Object.values(this.accessories)) { + for (const service of Object.values(accessory.services)) { + if (service.cmd_id && service.cmd_id.toString() === targetCmdId) { + return accessory; + } + } + } }; JeedomPlatform.prototype.changeAccessoryValue = function(characteristic, service) { @@ -5694,7 +5685,7 @@ JeedomPlatform.prototype.updateSubscribers = function(update) { const that = this; const updateID = update.option.scenario_id || update.option.cmd_id; for (let i = 0; i < that.updateSubscriptions.length; i++) { - const { characteristic: subCharact, service: subService } = that.updateSubscriptions[i]; + const {characteristic: subCharact, service: subService} = that.updateSubscriptions[i]; // that.log('debug',"update :",updateID,JSON.stringify(subService.infos),JSON.stringify(subService.statusArr),subCharact.UUID); const infoFound = findMyID(subService.infos,updateID); @@ -5784,31 +5775,14 @@ JeedomPlatform.prototype.updateHomeKitColorFromJeedom = function(color, service) // -- service : service to set color to // -- Return : nothing JeedomPlatform.prototype.syncColorCharacteristics = function(rgb, service) { - /* switch (--service.countColorCharacteristics) { - case -1: - service.countColorCharacteristics = 2; */ const that = this; clearTimeout(service.timeoutIdColorCharacteristics); service.timeoutIdColorCharacteristics = setTimeout(function() { - // if (service.countColorCharacteristics < 2) - // return; const rgbColor = rgbToHex(rgb.r, rgb.g, rgb.b); if (DEV_DEBUG) {that.log('debug',"---------setRGB : ",rgbColor);} that.command('setRGB', rgbColor, service); - // service.countColorCharacteristics = 0; - // service.timeoutIdColorCharacteristics = 0; }, 500); - /* break; - case 0: - var rgbColor = rgbToHex(rgb.r, rgb.g, rgb.b); - this.command('setRGB', rgbColor, service); - service.countColorCharacteristics = 0; - service.timeoutIdColorCharacteristics = 0; - break; - default: - break; - } */ }; // -- RegisterCustomCharacteristics From 9d134aa94e97dee447527738945fbb17af583ae5 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:53:03 +0100 Subject: [PATCH 084/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b6f866e..5fa51de 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0015", + "cust_serial": "0016", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 30fe50c80b74bf2816d1a646d3daaa7dd472bc8b Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:33:49 +0100 Subject: [PATCH 085/118] Update index.js --- index.js | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/index.js b/index.js index e807601..f38eb82 100755 --- a/index.js +++ b/index.js @@ -604,8 +604,6 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.HorTiltState = cmd2.HorTiltState; } else if (cmd2.VerTiltState) { Serv.infos.VerTiltState = cmd2.VerTiltState; - } else if(cmd2.moving) { - Serv.infos.moving=cmd2.moving; } }); if(Serv.actions.up && !Serv.actions.down) {that.log('warn','Pas de type générique "Action/Volet Bouton Descendre"');} @@ -800,8 +798,6 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions.down = cmd2.down; } else if (cmd2.slider) { Serv.actions.slider = cmd2.slider; - } else if(cmd2.moving) { - Serv.infos.moving=cmd2.moving; } }); Serv.maxValue = 100; // if not set in Jeedom it's 100 @@ -3123,7 +3119,7 @@ JeedomPlatform.prototype.configureAccessory = function(accessory) { // -- Return : nothing JeedomPlatform.prototype.bindCharacteristicEvents = function(characteristic, service) { try{ - this.updateSubscriptions.push({service, characteristic}); + if (characteristic.UUID != Characteristic.PositionState.UUID) {this.updateSubscriptions.push({service, characteristic});} if (characteristic.props.perms.includes('pw')) { characteristic.on('set', (value, callback, context) => { if (context !== 'fromJeedom' && context !== 'fromSetValue') { // from Homekit @@ -4622,30 +4618,8 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } break; case Characteristic.PositionState.UUID : - if('moving' in service.infos && service.infos.moving !== null) { - for (const cmd of cmdList) { - if (cmd.generic_type == 'FLAP_MOVING' || cmd.generic_type == 'WINDOW_MOVING') { - switch(parseInt(cmd.currentValue)) { - case 0 : - returnValue=Characteristic.PositionState.DECREASING; - break; - case 1 : - returnValue=Characteristic.PositionState.INCREASING; - break; - case 2 : - returnValue=Characteristic.PositionState.STOPPED; - break; - default : - returnValue=Characteristic.PositionState.STOPPED; - break; - } - that.log('debug','---------update PositionState:',returnValue); - break; - } - } - } else { - returnValue = Characteristic.PositionState.STOPPED; - } + returnValue = Characteristic.PositionState.STOPPED; + break; case Characteristic.CurrentHorizontalTiltAngle.UUID : case Characteristic.TargetHorizontalTiltAngle.UUID : From c29b5cfe6cff9ab0fee6a6760c44ab28f644f10c Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:34:09 +0100 Subject: [PATCH 086/118] Update jeedom-api.js --- lib/jeedom-api.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index f31c6c4..ea21d50 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -606,9 +606,6 @@ JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { case 'FLAP_STOP' : initServ(result_cmd,'flap','stop',cmd); break; - case 'FLAP_MOVING' : - initServ(result_cmd,'flap','moving',cmd); - break; case 'FLAP_HOR_TILT_STATE' : initServ(result_cmd,'flap','HorTiltState',cmd); break; @@ -634,9 +631,6 @@ JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { case 'WINDOW_SLIDER' : initServ(result_cmd,'windowMoto','slider',cmd); break; - case 'WINDOW_MOVING' : - initServ(result_cmd,'windowMoto','moving',cmd); - break; /** ************* THERMOSTAT ***********************/ case 'THERMOSTAT_STATE' : initServ(result_cmd,'thermostat','state',cmd); From e2cf3391870600932b42cdc16057b610463a65dc Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:49:56 +0100 Subject: [PATCH 087/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5fa51de..f327790 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0016", + "cust_serial": "0017", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 6dd3ad02b0b7f67d8464f3bbd1fbd4f512c07110 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:51:13 +0100 Subject: [PATCH 088/118] Update jeedom-api.js --- lib/jeedom-api.js | 704 ++++++++++++++++------------------------------ 1 file changed, 235 insertions(+), 469 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index ea21d50..402cb7e 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -207,8 +207,8 @@ JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { var cmd = that._cachedModel.cmds[c]; if(cmd.id == ID && cmd.type=='info') { eq = that.getDevicePropertiesFromCache(cmd.eqLogic_id); - if(!internal) { that.log('info','[Maj reçue de Jeedom] commande:'+ID+' value:'+value); } - else { that.log('info','[Maj interne] commande:'+ID+' value:'+value); } + if(!internal) {that.log('info','[Maj reçue de Jeedom] commande:'+ID+' value:'+value);} + else {that.log('info','[Maj interne] commande:'+ID+' value:'+value);} that.log('info','[[Modification Cache Jeedom: '+eq.name+'>'+cmd.name+'('+cmd.generic_type+') de '+cmd.currentValue+' vers '+value+' dans ' + JSON.stringify(cmd).replace('\n','')); if(cmd.generic_type == 'ALARM_STATE') { if(cmd.currentValue != value) { @@ -239,11 +239,11 @@ JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { }; JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { - if(USE_QUEUES === 0) { return this._executeDeviceAction(ID, action, param); } + if(USE_QUEUES === 0) {return this._executeDeviceAction(ID, action, param);} return new Promise((resolve, reject) => { this.queue.push({ID, action, param, type:'cmd'}, (err, result) => { - if (err) { reject(err); } - else { resolve(result); } + if (err) {reject(err);} + else {resolve(result);} }); }); }; @@ -286,11 +286,11 @@ JeedomClient.prototype._executeDeviceAction = function(ID, action, param) { }; JeedomClient.prototype.executeScenarioAction = function(ID, action) { - if(USE_QUEUES === 0) { return this._executeScenarioAction(ID, action); } + if(USE_QUEUES === 0) {return this._executeScenarioAction(ID, action);} return new Promise((resolve, reject) => { this.queue.push({ID, action, type:'scenario'}, (err, result) => { - if (err) { reject(err); } - else { resolve(result); } + if (err) {reject(err);} + else {resolve(result);} }); }); }; @@ -346,481 +346,247 @@ JeedomClient.prototype.refreshStates = function() { }); }; -function initServ(result_cmd, serviceType, property, value, isPush = false) { - result_cmd.services[serviceType] ??= []; +function initServ(result_cmd, value, serviceType, property, isPush = false) { + result_cmd.services[serviceType] ??= []; const service = {}; - if (isPush) { - service[property] ??= []; - service[property].push(value); - } else { - service[property] = value; - } + if (isPush) { + service[property] ??= []; + service[property].push(value); + } else { + service[property] = value; + } result_cmd.services[serviceType].push(service); } JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { const result_cmd = {...EqLogic, services: {}, numSwitches: 0, numDetector: 0}; - cmds.forEach((cmd) => { if (cmd.generic_type !== null) { - switch(cmd.generic_type) { - case 'SHOCK' : - case 'RAIN_CURRENT' : - case 'RAIN_TOTAL' : - case 'WIND_SPEED' : - case 'WIND_DIRECTION' : - case 'GENERIC_INFO': - initServ(result_cmd,'generic','state',cmd); - break; - /** *************** MODE ***********************/ - case 'MODE_STATE' : - initServ(result_cmd,'mode','state',cmd); - break; - case 'MODE_SET_STATE' : - if(cmd.logicalId=="returnPreviousMode") { - initServ(result_cmd,'mode','set_state_previous',cmd); - } else { - initServ(result_cmd,'mode','set_state',cmd,true); - } - break; - /** *************** LIGHT ***********************/ - case 'LIGHT_STATE' : - initServ(result_cmd,'light','state',cmd); - break; - case 'LIGHT_BRIGHTNESS' : - initServ(result_cmd,'light','brightness',cmd); - break; - case 'LIGHT_STATE_BOOL' : - initServ(result_cmd,'light','state_bool',cmd); - break; - case 'LIGHT_ON' : - initServ(result_cmd,'light','on',cmd); - break; - case 'LIGHT_OFF' : - initServ(result_cmd,'light','off',cmd); - break; - case 'LIGHT_SLIDER' : - initServ(result_cmd,'light','slider',cmd); - break; - case 'LIGHT_COLOR' : - initServ(result_cmd,'light','color',cmd); - break; - case 'LIGHT_COLOR_TEMP' : - initServ(result_cmd,'light','color_temp',cmd); - break; - case 'LIGHT_SET_COLOR' : - initServ(result_cmd,'light','setcolor',cmd); - break; - case 'LIGHT_SET_COLOR_TEMP' : - initServ(result_cmd,'light','setcolor_temp',cmd); - break; - /** *************** WEATHER ***********************/ - case 'WEATHER_TEMPERATURE' : - initServ(result_cmd,'weather','temperature',cmd); - break; - case 'WEATHER_HUMIDITY' : - initServ(result_cmd,'weather','humidity',cmd); - break; - case 'WEATHER_PRESSURE' : - initServ(result_cmd,'weather','pressure',cmd); - break; - case 'WEATHER_WIND_SPEED' : - initServ(result_cmd,'weather','wind_speed',cmd); - break; - case 'WEATHER_WIND_DIRECTION' : - initServ(result_cmd,'weather','wind_direction',cmd); - break; - case 'WEATHER_CONDITION' : - initServ(result_cmd,'weather','condition',cmd); - break; - case 'WEATHER_UVINDEX' : - initServ(result_cmd,'weather','UVIndex',cmd); - break; - case 'WEATHER_VISIBILITY' : - initServ(result_cmd,'weather','visibility',cmd); - break; - case 'WEATHER_RAIN' : - initServ(result_cmd,'weather','rain',cmd); - break; - case 'WEATHER_SNOW' : - initServ(result_cmd,'weather','snow',cmd); - break; - case 'WEATHER_TEMPERATURE_MIN' : - initServ(result_cmd,'weather','temperature_min',cmd); - break; - /** *************** SIREN ***********************/ - case 'SIREN_STATE' : - initServ(result_cmd,'siren','state',cmd); - break; - /* case 'SIREN_ON' : - initServ(result_cmd,'siren','on',cmd); - break; - case 'SIREN_OFF' : - initServ(result_cmd,'siren','off',cmd); - break; */ - /** *************** ENERGY ***********************/ - case 'ENERGY_STATE' : - initServ(result_cmd,'energy','state',cmd); - break; - case 'ENERGY_ON' : - initServ(result_cmd,'energy','on',cmd); - break; - case 'ENERGY_OFF' : - initServ(result_cmd,'energy','off',cmd); - break; - case 'ENERGY_INUSE' : - initServ(result_cmd,'energy','inuse',cmd); - break; - /** *************** VALVES ***********************/ - case 'FAUCET_STATE' : - initServ(result_cmd,'faucet','state',cmd); - break; - case 'FAUCET_ON' : - initServ(result_cmd,'faucet','on',cmd); - break; - case 'FAUCET_OFF' : - initServ(result_cmd,'faucet','off',cmd); - break; - case 'IRRIG_STATE' : - initServ(result_cmd,'irrigation','state',cmd); - break; - case 'IRRIG_ON' : - initServ(result_cmd,'irrigation','on',cmd); - break; - case 'IRRIG_OFF' : - initServ(result_cmd,'irrigation','off',cmd); - break; - case 'VALVE_STATE' : - initServ(result_cmd,'valve','state',cmd); - break; - case 'VALVE_ON' : - initServ(result_cmd,'valve','on',cmd); - break; - case 'VALVE_OFF' : - initServ(result_cmd,'valve','off',cmd); - break; - case 'VALVE_SET_DURATION' : - initServ(result_cmd,'valve','setDuration',cmd); - break; - case 'VALVE_REMAINING_DURATION' : - initServ(result_cmd,'valve','remainingDuration',cmd); - break; - /** *************** FAN ***********************/ - case 'FAN_STATE' : - case 'FAN_SPEED_STATE' : - initServ(result_cmd,'fan','state',cmd); - break; - case 'FAN_ON' : - initServ(result_cmd,'fan','on',cmd); - break; - case 'FAN_OFF' : - initServ(result_cmd,'fan','off',cmd); - break; - case 'FAN_SLIDER' : - case 'FAN_SPEED' : - initServ(result_cmd,'fan','slider',cmd); - break; - /** *************** SWITCH ***********************/ - case 'SWITCH_STATE' : - case 'CAMERA_RECORD_STATE' : - initServ(result_cmd,'Switch','state',cmd); - result_cmd.numSwitches++; - break; - case 'SWITCH_ON' : - case 'CAMERA_RECORD' : - initServ(result_cmd,'Switch','on',cmd); - break; - case 'SWITCH_OFF' : - case 'CAMERA_STOP' : - initServ(result_cmd,'Switch','off',cmd); - break; - /** *************** SWITCH ***********************/ - case 'GENERIC_ACTION' : - if(cmd.subType=="other") { - initServ(result_cmd,'Push','Push',cmd); - } - break; - case 'PUSH_BUTTON' : - case 'CAMERA_UP' : - case 'CAMERA_DOWN' : - case 'CAMERA_LEFT' : - case 'CAMERA_RIGHT' : - case 'CAMERA_ZOOM' : - case 'CAMERA_DEZOOM' : - case 'CAMERA_PRESET' : - initServ(result_cmd,'Push','Push',cmd); - break; - /** *************** BARRIER/GARAGE**************/ - case "BARRIER_STATE" : - case "GARAGE_STATE" : - initServ(result_cmd,'GarageDoor','state',cmd); - break; - case "GB_OPEN" : // should not be used - initServ(result_cmd,'GarageDoor','on',cmd); - break; - case "GB_CLOSE" : // should not be used - initServ(result_cmd,'GarageDoor','off',cmd); - break; - case "GB_TOGGLE" : - initServ(result_cmd,'GarageDoor','toggle',cmd); - break; - /** *************** LOCK ***********************/ - case 'LOCK_STATE' : - initServ(result_cmd,'lock','state',cmd); - break; - case 'LOCK_OPEN' : - initServ(result_cmd,'lock','on',cmd); - break; - case 'LOCK_CLOSE' : - initServ(result_cmd,'lock','off',cmd); - break; - /** *************** StatelessSwitch ******************/ - case 'SWITCH_STATELESS_ALLINONE' : - initServ(result_cmd,'StatelessSwitch','eventType',cmd); - break; - case 'SWITCH_STATELESS_SINGLE' : - initServ(result_cmd,'StatelessSwitchMono','Single',cmd); - break; - case 'SWITCH_STATELESS_DOUBLE' : - initServ(result_cmd,'StatelessSwitchMono','Double',cmd); - break; - case 'SWITCH_STATELESS_LONG' : - initServ(result_cmd,'StatelessSwitchMono','Long',cmd); - break; - /** *************** FLAP ***********************/ - case 'FLAP_STATE' : - initServ(result_cmd,'flap','state',cmd); - break; - case 'FLAP_STATE_CLOSING' : - initServ(result_cmd,'flap','stateClosing',cmd); - break; - case 'FLAP_UP' : - initServ(result_cmd,'flap','up',cmd); - break; - case 'FLAP_DOWN' : - initServ(result_cmd,'flap','down',cmd); - break; - case 'FLAP_SLIDER' : - initServ(result_cmd,'flap','slider',cmd); - break; - case 'FLAP_STOP' : - initServ(result_cmd,'flap','stop',cmd); - break; - case 'FLAP_HOR_TILT_STATE' : - initServ(result_cmd,'flap','HorTiltState',cmd); - break; - case 'FLAP_HOR_TILT_SLIDER' : - initServ(result_cmd,'flap','HorTiltSlider',cmd); - break; - case 'FLAP_VER_TILT_STATE' : - initServ(result_cmd,'flap','VerTiltState',cmd); - break; - case 'FLAP_VER_TILT_SLIDER' : - initServ(result_cmd,'flap','VerTiltSlider',cmd); - break; - /** *************** WINDOW ***********************/ - case 'WINDOW_STATE' : - initServ(result_cmd,'windowMoto','state',cmd); - break; - case 'WINDOW_UP' : - initServ(result_cmd,'windowMoto','up',cmd); - break; - case 'WINDOW_DOWN' : - initServ(result_cmd,'windowMoto','down',cmd); - break; - case 'WINDOW_SLIDER' : - initServ(result_cmd,'windowMoto','slider',cmd); - break; - /** ************* THERMOSTAT ***********************/ - case 'THERMOSTAT_STATE' : - initServ(result_cmd,'thermostat','state',cmd); - break; - case 'THERMOSTAT_STATE_NAME' : - initServ(result_cmd,'thermostat','state_name',cmd); - break; - case 'THERMOSTAT_TEMPERATURE' : - initServ(result_cmd,'thermostat','temperature',cmd); - break; - case 'THERMOSTAT_SET_SETPOINT' : - initServ(result_cmd,'thermostat','set_setpoint',cmd); - break; - case 'THERMOSTAT_SETPOINT' : - initServ(result_cmd,'thermostat','setpoint',cmd); - break; - case 'THERMOSTAT_SET_MODE' : - initServ(result_cmd,'thermostat','set_mode',cmd); - break; - case 'THERMOSTAT_MODE' : - initServ(result_cmd,'thermostat','mode',cmd); - break; - case 'THERMOSTAT_LOCK' : - initServ(result_cmd,'thermostat','lock',cmd); - break; - case 'THERMOSTAT_SET_LOCK' : - initServ(result_cmd,'thermostat','set_lock',cmd); - break; - case 'THERMOSTAT_SET_UNLOCK' : - initServ(result_cmd,'thermostat','set_unlock',cmd); - break; - case 'THERMOSTAT_TEMPERATURE_OUTDOOR' : - initServ(result_cmd,'thermostat','temperature_outdoor',cmd); - break; - /** ************* THERMOSTAT_HC ***********************/ - case 'THERMOSTAT_HC_STATE' : - initServ(result_cmd,'thermostatHC','state',cmd); - break; - case 'THERMOSTAT_HC_STATE_NAME' : - initServ(result_cmd,'thermostatHC','state_name',cmd); - break; - case 'THERMOSTAT_HC_TEMPERATURE' : - initServ(result_cmd,'thermostatHC','temperature',cmd); - break; - case 'THERMOSTAT_HC_SET_SETPOINT_H' : - initServ(result_cmd,'thermostatHC','set_setpointH',cmd); - break; - case 'THERMOSTAT_HC_SET_SETPOINT_C' : - initServ(result_cmd,'thermostatHC','set_setpointC',cmd); - break; - case 'THERMOSTAT_HC_SETPOINT_H' : - initServ(result_cmd,'thermostatHC','setpointH',cmd); - break; - case 'THERMOSTAT_HC_SETPOINT_C' : - initServ(result_cmd,'thermostatHC','setpointC',cmd); - break; - case 'THERMOSTAT_HC_SET_MODE' : - initServ(result_cmd,'thermostatHC','set_mode',cmd); - break; - case 'THERMOSTAT_HC_MODE' : - initServ(result_cmd,'thermostatHC','mode',cmd); - break; - case 'THERMOSTAT_HC_LOCK' : - initServ(result_cmd,'thermostatHC','lock',cmd); - break; - case 'THERMOSTAT_HC_SET_LOCK' : - initServ(result_cmd,'thermostatHC','set_lock',cmd); - break; - case 'THERMOSTAT_HC_SET_UNLOCK' : - initServ(result_cmd,'thermostatHC','set_unlock',cmd); - break; - /** ************* ALARME ***********************/ - case 'ALARM_STATE' : - initServ(result_cmd,'alarm','state',cmd); - break; - case 'ALARM_MODE' : - initServ(result_cmd,'alarm','mode',cmd); - break; - case 'ALARM_ENABLE_STATE' : - initServ(result_cmd,'alarm','enable_state',cmd); - break; - case 'ALARM_ARMED' : - initServ(result_cmd,'alarm','armed',cmd); - break; - case 'ALARM_RELEASED' : - initServ(result_cmd,'alarm','released',cmd); - break; - case 'ALARM_SET_MODE' : - initServ(result_cmd,'alarm','set_mode',cmd); - break; - /** *************** GENERIC ***********************/ - case 'AIRQUALITY_INDEX' : - initServ(result_cmd,'AirQuality','Index',cmd); - break; - case 'AIRQUALITY_PM25' : - initServ(result_cmd,'AirQuality','PM25',cmd); - break; - case 'AIRQUALITY_CUSTOM' : - initServ(result_cmd,'AirQualityCustom','Index',cmd); - break; - case 'NOISE' : - initServ(result_cmd,'Noise','Noise',cmd); - break; - case 'CO2' : - initServ(result_cmd,'CO2','CO2',cmd); - break; - case 'CO' : - initServ(result_cmd,'CO','CO',cmd); - break; - case 'OPENING_WINDOW' : - case 'OPENING' : - initServ(result_cmd,'opening','opening',cmd); - break; - case 'BATTERY' : - initServ(result_cmd,'battery','battery',cmd); - break; - case 'BATTERY_CHARGING' : // not existing yet - initServ(result_cmd,'battery','batteryCharging',cmd); - break; - case 'DEFECT' : - initServ(result_cmd,'defect','defect',cmd); - break; - case 'PRESENCE' : - initServ(result_cmd,'presence','presence',cmd); - result_cmd.numDetector++; - break; - case 'OCCUPANCY' : - initServ(result_cmd,'occupancy','occupancy',cmd); - result_cmd.numDetector++; - break; - case 'TEMPERATURE' : - initServ(result_cmd,'temperature','temperature',cmd); - break; - case 'BRIGHTNESS' : - initServ(result_cmd,'brightness','brightness',cmd); - break; - case 'SMOKE' : - initServ(result_cmd,'smoke','smoke',cmd); - break; - case 'UV' : // via custom - initServ(result_cmd,'uv','uv',cmd); - break; - case 'HUMIDITY' : - initServ(result_cmd,'humidity','humidity',cmd); - break; - case 'SABOTAGE' : - initServ(result_cmd,'sabotage','sabotage',cmd); - break; - case 'FLOOD' : - case 'WATER_LEAK' : - initServ(result_cmd,'flood','flood',cmd); - break; - case 'POWER' : // via custom - initServ(result_cmd,'power','power',cmd); - break; - case 'CONSUMPTION' : // via custom - initServ(result_cmd,'consumption','consumption',cmd); - break; - case 'ACTIVE' : - initServ(result_cmd,'status_active','status_active',cmd); - break; - case 'SPEAKER_VOLUME' : - case 'VOLUME' : - initServ(result_cmd,'speaker','volume',cmd); - break; - case 'SPEAKER_SET_VOLUME' : - case 'SET_VOLUME' : - initServ(result_cmd,'speaker','set_volume',cmd); - break; - case 'SPEAKER_MUTE' : - initServ(result_cmd,'speaker','mute',cmd); - break; - case 'SPEAKER_MUTE_TOGGLE' : - initServ(result_cmd,'speaker','mute_toggle',cmd); - break; - case 'SPEAKER_MUTE_ON' : - initServ(result_cmd,'speaker','mute_on',cmd); - break; - case 'SPEAKER_MUTE_OFF' : - initServ(result_cmd,'speaker','mute_off',cmd); - break; - case 'PRESSURE' : - initServ(result_cmd,'pressure','pressure',cmd); - break; + + if(cmd.generic_type === 'MODE_SET_STATE') { + if(cmd.logicalId === "returnPreviousMode") { + initServ(result_cmd,cmd,'mode','set_state_previous'); + } else { + initServ(result_cmd,cmd,'mode','set_state',true); + } + return; + } else if(cmd.generic_type === 'GENERIC_ACTION') { + if(cmd.subType=="other") { + initServ(result_cmd,cmd,'Push','Push'); + } + return; + } + + const serviceInfo = genTypesMapping[cmd.generic_type]; + if(!serviceInfo) {return;} + initServ(result_cmd, cmd, serviceInfo.serviceType, serviceInfo.property, serviceInfo.isPush || false); + + if(cmd.generic_type === 'PRESENCE') { + result_cmd.numDetector++; + } else if(cmd.generic_type === 'OCCUPANCY') { + result_cmd.numDetector++; + } else if(cmd.generic_type === 'SWITCH_STATE' || cmd.generic_type === 'CAMERA_RECORD_STATE') { + result_cmd.numSwitches++; } } }); return result_cmd; }; +const genTypesMapping = { + // *************** MODE *********************** + 'MODE_STATE': {serviceType: 'mode', property: 'state'}, + + // *************** LIGHT *********************** + 'LIGHT_STATE': {serviceType: 'light', property: 'state'}, + 'LIGHT_BRIGHTNESS': {serviceType: 'light', property: 'brightness'}, + 'LIGHT_STATE_BOOL': {serviceType: 'light', property: 'state_bool'}, + 'LIGHT_ON': {serviceType: 'light', property: 'on'}, + 'LIGHT_OFF': {serviceType: 'light', property: 'off'}, + 'LIGHT_SLIDER': {serviceType: 'light', property: 'slider'}, + 'LIGHT_COLOR': {serviceType: 'light', property: 'color'}, + 'LIGHT_COLOR_TEMP': {serviceType: 'light', property: 'color_temp'}, + 'LIGHT_SET_COLOR': {serviceType: 'light', property: 'setcolor'}, + 'LIGHT_SET_COLOR_TEMP': {serviceType: 'light', property: 'setcolor_temp'}, + + // *************** WEATHER *********************** + 'WEATHER_TEMPERATURE': {serviceType: 'weather', property: 'temperature'}, + 'WEATHER_HUMIDITY': {serviceType: 'weather', property: 'humidity'}, + 'WEATHER_PRESSURE': {serviceType: 'weather', property: 'pressure'}, + 'WEATHER_WIND_SPEED': {serviceType: 'weather', property: 'wind_speed'}, + 'WEATHER_WIND_DIRECTION': {serviceType: 'weather', property: 'wind_direction'}, + 'WEATHER_CONDITION': {serviceType: 'weather', property: 'condition'}, + 'WEATHER_UVINDEX': {serviceType: 'weather', property: 'UVIndex'}, + 'WEATHER_VISIBILITY': {serviceType: 'weather', property: 'visibility'}, + 'WEATHER_RAIN': {serviceType: 'weather', property: 'rain'}, + 'WEATHER_SNOW': {serviceType: 'weather', property: 'snow'}, + 'WEATHER_TEMPERATURE_MIN': {serviceType: 'weather', property: 'temperature_min'}, + + // *************** SIREN *********************** + 'SIREN_STATE': {serviceType: 'siren', property: 'state'}, + // 'SIREN_ON': {serviceType: 'siren', property: 'on'}, + // 'SIREN_OFF': {serviceType: 'siren', property: 'off'}, + + // *************** ENERGY *********************** + 'ENERGY_STATE': {serviceType: 'energy', property: 'state'}, + 'ENERGY_ON': {serviceType: 'energy', property: 'on'}, + 'ENERGY_OFF': {serviceType: 'energy', property: 'off'}, + 'ENERGY_INUSE': {serviceType: 'energy', property: 'inuse'}, + + // *************** VALVES *********************** + 'FAUCET_STATE': {serviceType: 'faucet', property: 'state'}, + 'FAUCET_ON': {serviceType: 'faucet', property: 'on'}, + 'FAUCET_OFF': {serviceType: 'faucet', property: 'off'}, + 'IRRIG_STATE': {serviceType: 'irrigation', property: 'state'}, + 'IRRIG_ON': {serviceType: 'irrigation', property: 'on'}, + 'IRRIG_OFF': {serviceType: 'irrigation', property: 'off'}, + 'VALVE_STATE': {serviceType: 'valve', property: 'state'}, + 'VALVE_ON': {serviceType: 'valve', property: 'on'}, + 'VALVE_OFF': {serviceType: 'valve', property: 'off'}, + 'VALVE_SET_DURATION': {serviceType: 'valve', property: 'setDuration'}, + 'VALVE_REMAINING_DURATION': {serviceType: 'valve', property: 'remainingDuration'}, + + // *************** FAN *********************** + 'FAN_STATE': {serviceType: 'fan', property: 'state'}, + 'FAN_SPEED_STATE': {serviceType: 'fan', property: 'state'}, + 'FAN_ON': {serviceType: 'fan', property: 'on'}, + 'FAN_OFF': {serviceType: 'fan', property: 'off'}, + 'FAN_SLIDER': {serviceType: 'fan', property: 'slider'}, + 'FAN_SPEED': {serviceType: 'fan', property: 'slider'}, + + // *************** SWITCH *********************** + 'SWITCH_STATE': {serviceType: 'Switch', property: 'state'}, + 'SWITCH_ON': {serviceType: 'Switch', property: 'on'}, + 'SWITCH_OFF': {serviceType: 'Switch', property: 'off'}, + 'CAMERA_RECORD_STATE': {serviceType: 'Switch', property: 'state'}, + 'CAMERA_RECORD': {serviceType: 'Switch', property: 'on'}, + 'CAMERA_STOP': {serviceType: 'Switch', property: 'off'}, + + // *************** PUSH *********************** + 'PUSH_BUTTON': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_UP': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_DOWN': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_LEFT': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_RIGHT': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_ZOOM': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_DEZOOM':{serviceType: 'Push', property: 'Push'}, + 'CAMERA_PRESET':{serviceType: 'Push', property: 'Push'}, + + // *************** BARRIER/GARAGE************** + 'BARRIER_STATE': {serviceType: 'GarageDoor', property: 'state'}, + 'GARAGE_STATE': {serviceType: 'GarageDoor', property: 'state'}, + 'GB_OPEN': {serviceType: 'GarageDoor', property: 'on'}, // should not be used + 'GB_CLOSE': {serviceType: 'GarageDoor', property: 'off'}, // should not be used + 'GB_TOGGLE': {serviceType: 'GarageDoor', property: 'toggle'}, + + // *************** LOCK *********************** + 'LOCK_STATE': {serviceType: 'lock', property: 'state'}, + 'LOCK_OPEN': {serviceType: 'lock', property: 'on'}, + 'LOCK_CLOSE': {serviceType: 'lock', property: 'off'}, + + // *************** StatelessSwitch ****************** + 'SWITCH_STATELESS_ALLINONE':{serviceType: 'StatelessSwitch', property: 'eventType'}, + 'SWITCH_STATELESS_SINGLE': {serviceType: 'StatelessSwitchMono', property: 'Single'}, + 'SWITCH_STATELESS_DOUBLE': {serviceType: 'StatelessSwitchMono', property: 'Double'}, + 'SWITCH_STATELESS_LONG': {serviceType: 'StatelessSwitchMono', property: 'Long'}, + + // *************** FLAP *********************** + 'FLAP_STATE': {serviceType: 'flap', property: 'state'}, + 'FLAP_STATE_CLOSING': {serviceType: 'flap', property: 'stateClosing'}, + 'FLAP_UP': {serviceType: 'flap', property: 'up'}, + 'FLAP_DOWN': {serviceType: 'flap', property: 'down'}, + 'FLAP_SLIDER': {serviceType: 'flap', property: 'slider'}, + 'FLAP_STOP': {serviceType: 'flap', property: 'stop'}, + 'FLAP_HOR_TILT_STATE': {serviceType: 'flap', property: 'HorTiltState'}, + 'FLAP_HOR_TILT_SLIDER': {serviceType: 'flap', property: 'HorTiltSlider'}, + 'FLAP_VER_TILT_STATE': {serviceType: 'flap', property: 'VerTiltState'}, + 'FLAP_VER_TILT_SLIDER': {serviceType: 'flap', property: 'VerTiltSlider'}, + + // *************** WINDOW *********************** + 'WINDOW_STATE': {serviceType: 'windowMoto', property: 'state'}, + 'WINDOW_UP': {serviceType: 'windowMoto', property: 'up'}, + 'WINDOW_DOWN': {serviceType: 'windowMoto', property: 'down'}, + 'WINDOW_SLIDER':{serviceType: 'windowMoto', property: 'slider'}, + + // ************* THERMOSTAT *********************** + 'THERMOSTAT_STATE': {serviceType: 'thermostat', property: 'state'}, + 'THERMOSTAT_STATE_NAME': {serviceType: 'thermostat', property: 'state_name'}, + 'THERMOSTAT_TEMPERATURE': {serviceType: 'thermostat', property: 'temperature'}, + 'THERMOSTAT_SET_SETPOINT': {serviceType: 'thermostat', property: 'set_setpoint'}, + 'THERMOSTAT_SETPOINT': {serviceType: 'thermostat', property: 'setpoint'}, + 'THERMOSTAT_SET_MODE': {serviceType: 'thermostat', property: 'set_mode'}, + 'THERMOSTAT_MODE': {serviceType: 'thermostat', property: 'mode'}, + 'THERMOSTAT_LOCK': {serviceType: 'thermostat', property: 'lock'}, + 'THERMOSTAT_SET_LOCK': {serviceType: 'thermostat', property: 'set_lock'}, + 'THERMOSTAT_SET_UNLOCK': {serviceType: 'thermostat', property: 'set_unlock'}, + 'THERMOSTAT_TEMPERATURE_OUTDOOR': {serviceType: 'thermostat', property: 'temperature_outdoor'}, + + // ************* THERMOSTAT_HC *********************** + 'THERMOSTAT_HC_STATE': {serviceType: 'thermostatHC', property: 'state'}, + 'THERMOSTAT_HC_STATE_NAME': {serviceType: 'thermostatHC', property: 'state_name'}, + 'THERMOSTAT_HC_TEMPERATURE': {serviceType: 'thermostatHC', property: 'temperature'}, + 'THERMOSTAT_HC_SET_SETPOINT_H': {serviceType: 'thermostatHC', property: 'set_setpointH'}, + 'THERMOSTAT_HC_SET_SETPOINT_C': {serviceType: 'thermostatHC', property: 'set_setpointC'}, + 'THERMOSTAT_HC_SETPOINT_H': {serviceType: 'thermostatHC', property: 'setpointH'}, + 'THERMOSTAT_HC_SETPOINT_C': {serviceType: 'thermostatHC', property: 'setpointC'}, + 'THERMOSTAT_HC_SET_MODE': {serviceType: 'thermostatHC', property: 'set_mode'}, + 'THERMOSTAT_HC_MODE': {serviceType: 'thermostatHC', property: 'mode'}, + 'THERMOSTAT_HC_LOCK': {serviceType: 'thermostatHC', property: 'lock'}, + 'THERMOSTAT_HC_SET_LOCK': {serviceType: 'thermostatHC', property: 'set_lock'}, + 'THERMOSTAT_HC_SET_UNLOCK': {serviceType: 'thermostatHC', property: 'set_unlock'}, + + // ************* ALARME *********************** + 'ALARM_STATE': {serviceType: 'alarm', property: 'state'}, + 'ALARM_MODE': {serviceType: 'alarm', property: 'mode'}, + 'ALARM_ENABLE_STATE': {serviceType: 'alarm', property: 'enable_state'}, + 'ALARM_ARMED': {serviceType: 'alarm', property: 'armed'}, + 'ALARM_RELEASED': {serviceType: 'alarm', property: 'released'}, + 'ALARM_SET_MODE': {serviceType: 'alarm', property: 'set_mode'}, + + // ************* SPEAKER *********************** + 'SPEAKER_VOLUME': {serviceType: 'speaker', property: 'volume'}, + 'VOLUME': {serviceType: 'speaker', property: 'volume'}, + 'SPEAKER_SET_VOLUME': {serviceType: 'speaker', property: 'set_volume'}, + 'SET_VOLUME': {serviceType: 'speaker', property: 'set_volume'}, + 'SPEAKER_MUTE': {serviceType: 'speaker', property: 'mute'}, + 'SPEAKER_MUTE_TOGGLE': {serviceType: 'speaker', property: 'mute_toggle'}, + 'SPEAKER_MUTE_ON': {serviceType: 'speaker', property: 'mute_on'}, + 'SPEAKER_MUTE_OFF': {serviceType: 'speaker', property: 'mute_off'}, + + // *************** GENERIC *********************** + 'AIRQUALITY_INDEX': {serviceType: 'AirQuality', property: 'Index'}, + 'AIRQUALITY_PM25': {serviceType: 'AirQuality', property: 'PM25'}, + 'AIRQUALITY_CUSTOM':{serviceType: 'AirQualityCustom', property: 'Index'}, + 'NOISE': {serviceType: 'Noise', property: 'Noise'}, + 'CO2': {serviceType: 'CO2', property: 'CO2'}, + 'CO': {serviceType: 'CO', property: 'CO'}, + 'OPENING_WINDOW': {serviceType: 'opening', property: 'opening'}, + 'OPENING': {serviceType: 'opening', property: 'opening'}, + 'BATTERY': {serviceType: 'battery', property: 'battery'}, + 'BATTERY_CHARGING': {serviceType: 'battery', property: 'batteryCharging'}, // not existing yet + 'DEFECT': {serviceType: 'defect', property: 'defect'}, + 'PRESENCE': {serviceType: 'presence', property: 'presence'}, + 'OCCUPANCY': {serviceType: 'occupancy', property: 'occupancy'}, + 'TEMPERATURE': {serviceType: 'temperature', property: 'temperature'}, + 'BRIGHTNESS': {serviceType: 'brightness', property: 'brightness'}, + 'SMOKE': {serviceType: 'smoke', property: 'smoke'}, + 'UV': {serviceType: 'uv', property: 'uv'}, // via custom + 'HUMIDITY': {serviceType: 'humidity', property: 'humidity'}, + 'SABOTAGE': {serviceType: 'sabotage', property: 'sabotage'}, + 'FLOOD': {serviceType: 'flood', property: 'flood'}, + 'WATER_LEAK': {serviceType: 'flood', property: 'flood'}, + 'POWER': {serviceType: 'power', property: 'power'}, // via custom + 'CONSUMPTION': {serviceType: 'consumption', property: 'consumption'}, // via custom + 'ACTIVE': {serviceType: 'status_active', property: 'status_active'}, + 'PRESSURE': {serviceType: 'pressure', property: 'pressure'}, + 'SHOCK': {serviceType: 'generic', property: 'state'}, + 'RAIN_CURRENT': {serviceType: 'generic', property: 'state'}, + 'RAIN_TOTAL': {serviceType: 'generic', property: 'state'}, + 'WIND_SPEED': {serviceType: 'generic', property: 'state'}, + 'WIND_DIRECTION': {serviceType: 'generic', property: 'state'}, + 'GENERIC_INFO': {serviceType: 'generic', property: 'state'}, +}; + module.exports.createClient = function(url, apikey, Plateform,myPlugin) { return new JeedomClient(url, apikey, Plateform,myPlugin); }; From af2c8a77059ef19cf439b4a0f79eb7447943fdcf Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:58:17 +0100 Subject: [PATCH 089/118] Update jeedom-api.js --- lib/jeedom-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 402cb7e..a32b09d 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -395,7 +395,7 @@ JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { const genTypesMapping = { // *************** MODE *********************** - 'MODE_STATE': {serviceType: 'mode', property: 'state'}, + 'MODE_STATE': {serviceType: 'mode', property: 'state'}, // *************** LIGHT *********************** 'LIGHT_STATE': {serviceType: 'light', property: 'state'}, From ec890b4e8e76a2ec952480dd985df8c644dcb6ea Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:01:56 +0100 Subject: [PATCH 090/118] Update jeedom-api.js --- lib/jeedom-api.js | 148 +++++++++++++++++++++++----------------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index a32b09d..c38c19c 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -395,18 +395,18 @@ JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { const genTypesMapping = { // *************** MODE *********************** - 'MODE_STATE': {serviceType: 'mode', property: 'state'}, + 'MODE_STATE': {serviceType: 'mode', property: 'state'}, // *************** LIGHT *********************** - 'LIGHT_STATE': {serviceType: 'light', property: 'state'}, + 'LIGHT_STATE': {serviceType: 'light', property: 'state'}, 'LIGHT_BRIGHTNESS': {serviceType: 'light', property: 'brightness'}, 'LIGHT_STATE_BOOL': {serviceType: 'light', property: 'state_bool'}, - 'LIGHT_ON': {serviceType: 'light', property: 'on'}, - 'LIGHT_OFF': {serviceType: 'light', property: 'off'}, - 'LIGHT_SLIDER': {serviceType: 'light', property: 'slider'}, - 'LIGHT_COLOR': {serviceType: 'light', property: 'color'}, + 'LIGHT_ON': {serviceType: 'light', property: 'on'}, + 'LIGHT_OFF': {serviceType: 'light', property: 'off'}, + 'LIGHT_SLIDER': {serviceType: 'light', property: 'slider'}, + 'LIGHT_COLOR': {serviceType: 'light', property: 'color'}, 'LIGHT_COLOR_TEMP': {serviceType: 'light', property: 'color_temp'}, - 'LIGHT_SET_COLOR': {serviceType: 'light', property: 'setcolor'}, + 'LIGHT_SET_COLOR': {serviceType: 'light', property: 'setcolor'}, 'LIGHT_SET_COLOR_TEMP': {serviceType: 'light', property: 'setcolor_temp'}, // *************** WEATHER *********************** @@ -416,10 +416,10 @@ const genTypesMapping = { 'WEATHER_WIND_SPEED': {serviceType: 'weather', property: 'wind_speed'}, 'WEATHER_WIND_DIRECTION': {serviceType: 'weather', property: 'wind_direction'}, 'WEATHER_CONDITION': {serviceType: 'weather', property: 'condition'}, - 'WEATHER_UVINDEX': {serviceType: 'weather', property: 'UVIndex'}, + 'WEATHER_UVINDEX': {serviceType: 'weather', property: 'UVIndex'}, 'WEATHER_VISIBILITY': {serviceType: 'weather', property: 'visibility'}, - 'WEATHER_RAIN': {serviceType: 'weather', property: 'rain'}, - 'WEATHER_SNOW': {serviceType: 'weather', property: 'snow'}, + 'WEATHER_RAIN': {serviceType: 'weather', property: 'rain'}, + 'WEATHER_SNOW': {serviceType: 'weather', property: 'snow'}, 'WEATHER_TEMPERATURE_MIN': {serviceType: 'weather', property: 'temperature_min'}, // *************** SIREN *********************** @@ -434,33 +434,33 @@ const genTypesMapping = { 'ENERGY_INUSE': {serviceType: 'energy', property: 'inuse'}, // *************** VALVES *********************** - 'FAUCET_STATE': {serviceType: 'faucet', property: 'state'}, - 'FAUCET_ON': {serviceType: 'faucet', property: 'on'}, - 'FAUCET_OFF': {serviceType: 'faucet', property: 'off'}, - 'IRRIG_STATE': {serviceType: 'irrigation', property: 'state'}, - 'IRRIG_ON': {serviceType: 'irrigation', property: 'on'}, - 'IRRIG_OFF': {serviceType: 'irrigation', property: 'off'}, - 'VALVE_STATE': {serviceType: 'valve', property: 'state'}, - 'VALVE_ON': {serviceType: 'valve', property: 'on'}, - 'VALVE_OFF': {serviceType: 'valve', property: 'off'}, + 'FAUCET_STATE': {serviceType: 'faucet', property: 'state'}, + 'FAUCET_ON': {serviceType: 'faucet', property: 'on'}, + 'FAUCET_OFF': {serviceType: 'faucet', property: 'off'}, + 'IRRIG_STATE': {serviceType: 'irrigation', property: 'state'}, + 'IRRIG_ON': {serviceType: 'irrigation', property: 'on'}, + 'IRRIG_OFF': {serviceType: 'irrigation', property: 'off'}, + 'VALVE_STATE': {serviceType: 'valve', property: 'state'}, + 'VALVE_ON': {serviceType: 'valve', property: 'on'}, + 'VALVE_OFF': {serviceType: 'valve', property: 'off'}, 'VALVE_SET_DURATION': {serviceType: 'valve', property: 'setDuration'}, - 'VALVE_REMAINING_DURATION': {serviceType: 'valve', property: 'remainingDuration'}, + 'VALVE_REMAINING_DURATION': {serviceType: 'valve', property: 'remainingDuration'}, // *************** FAN *********************** 'FAN_STATE': {serviceType: 'fan', property: 'state'}, 'FAN_SPEED_STATE': {serviceType: 'fan', property: 'state'}, - 'FAN_ON': {serviceType: 'fan', property: 'on'}, - 'FAN_OFF': {serviceType: 'fan', property: 'off'}, + 'FAN_ON': {serviceType: 'fan', property: 'on'}, + 'FAN_OFF': {serviceType: 'fan', property: 'off'}, 'FAN_SLIDER': {serviceType: 'fan', property: 'slider'}, 'FAN_SPEED': {serviceType: 'fan', property: 'slider'}, // *************** SWITCH *********************** - 'SWITCH_STATE': {serviceType: 'Switch', property: 'state'}, - 'SWITCH_ON': {serviceType: 'Switch', property: 'on'}, - 'SWITCH_OFF': {serviceType: 'Switch', property: 'off'}, + 'SWITCH_STATE': {serviceType: 'Switch', property: 'state'}, + 'SWITCH_ON': {serviceType: 'Switch', property: 'on'}, + 'SWITCH_OFF': {serviceType: 'Switch', property: 'off'}, 'CAMERA_RECORD_STATE': {serviceType: 'Switch', property: 'state'}, - 'CAMERA_RECORD': {serviceType: 'Switch', property: 'on'}, - 'CAMERA_STOP': {serviceType: 'Switch', property: 'off'}, + 'CAMERA_RECORD': {serviceType: 'Switch', property: 'on'}, + 'CAMERA_STOP': {serviceType: 'Switch', property: 'off'}, // *************** PUSH *********************** 'PUSH_BUTTON': {serviceType: 'Push', property: 'Push'}, @@ -475,7 +475,7 @@ const genTypesMapping = { // *************** BARRIER/GARAGE************** 'BARRIER_STATE': {serviceType: 'GarageDoor', property: 'state'}, 'GARAGE_STATE': {serviceType: 'GarageDoor', property: 'state'}, - 'GB_OPEN': {serviceType: 'GarageDoor', property: 'on'}, // should not be used + 'GB_OPEN': {serviceType: 'GarageDoor', property: 'on'}, // should not be used 'GB_CLOSE': {serviceType: 'GarageDoor', property: 'off'}, // should not be used 'GB_TOGGLE': {serviceType: 'GarageDoor', property: 'toggle'}, @@ -485,18 +485,18 @@ const genTypesMapping = { 'LOCK_CLOSE': {serviceType: 'lock', property: 'off'}, // *************** StatelessSwitch ****************** - 'SWITCH_STATELESS_ALLINONE':{serviceType: 'StatelessSwitch', property: 'eventType'}, + 'SWITCH_STATELESS_ALLINONE': {serviceType: 'StatelessSwitch', property: 'eventType'}, 'SWITCH_STATELESS_SINGLE': {serviceType: 'StatelessSwitchMono', property: 'Single'}, 'SWITCH_STATELESS_DOUBLE': {serviceType: 'StatelessSwitchMono', property: 'Double'}, 'SWITCH_STATELESS_LONG': {serviceType: 'StatelessSwitchMono', property: 'Long'}, // *************** FLAP *********************** - 'FLAP_STATE': {serviceType: 'flap', property: 'state'}, + 'FLAP_STATE': {serviceType: 'flap', property: 'state'}, 'FLAP_STATE_CLOSING': {serviceType: 'flap', property: 'stateClosing'}, - 'FLAP_UP': {serviceType: 'flap', property: 'up'}, - 'FLAP_DOWN': {serviceType: 'flap', property: 'down'}, - 'FLAP_SLIDER': {serviceType: 'flap', property: 'slider'}, - 'FLAP_STOP': {serviceType: 'flap', property: 'stop'}, + 'FLAP_UP': {serviceType: 'flap', property: 'up'}, + 'FLAP_DOWN': {serviceType: 'flap', property: 'down'}, + 'FLAP_SLIDER': {serviceType: 'flap', property: 'slider'}, + 'FLAP_STOP': {serviceType: 'flap', property: 'stop'}, 'FLAP_HOR_TILT_STATE': {serviceType: 'flap', property: 'HorTiltState'}, 'FLAP_HOR_TILT_SLIDER': {serviceType: 'flap', property: 'HorTiltSlider'}, 'FLAP_VER_TILT_STATE': {serviceType: 'flap', property: 'VerTiltState'}, @@ -509,77 +509,77 @@ const genTypesMapping = { 'WINDOW_SLIDER':{serviceType: 'windowMoto', property: 'slider'}, // ************* THERMOSTAT *********************** - 'THERMOSTAT_STATE': {serviceType: 'thermostat', property: 'state'}, - 'THERMOSTAT_STATE_NAME': {serviceType: 'thermostat', property: 'state_name'}, - 'THERMOSTAT_TEMPERATURE': {serviceType: 'thermostat', property: 'temperature'}, - 'THERMOSTAT_SET_SETPOINT': {serviceType: 'thermostat', property: 'set_setpoint'}, - 'THERMOSTAT_SETPOINT': {serviceType: 'thermostat', property: 'setpoint'}, - 'THERMOSTAT_SET_MODE': {serviceType: 'thermostat', property: 'set_mode'}, - 'THERMOSTAT_MODE': {serviceType: 'thermostat', property: 'mode'}, - 'THERMOSTAT_LOCK': {serviceType: 'thermostat', property: 'lock'}, - 'THERMOSTAT_SET_LOCK': {serviceType: 'thermostat', property: 'set_lock'}, - 'THERMOSTAT_SET_UNLOCK': {serviceType: 'thermostat', property: 'set_unlock'}, + 'THERMOSTAT_STATE': {serviceType: 'thermostat', property: 'state'}, + 'THERMOSTAT_STATE_NAME': {serviceType: 'thermostat', property: 'state_name'}, + 'THERMOSTAT_TEMPERATURE': {serviceType: 'thermostat', property: 'temperature'}, + 'THERMOSTAT_SET_SETPOINT': {serviceType: 'thermostat', property: 'set_setpoint'}, + 'THERMOSTAT_SETPOINT': {serviceType: 'thermostat', property: 'setpoint'}, + 'THERMOSTAT_SET_MODE': {serviceType: 'thermostat', property: 'set_mode'}, + 'THERMOSTAT_MODE': {serviceType: 'thermostat', property: 'mode'}, + 'THERMOSTAT_LOCK': {serviceType: 'thermostat', property: 'lock'}, + 'THERMOSTAT_SET_LOCK': {serviceType: 'thermostat', property: 'set_lock'}, + 'THERMOSTAT_SET_UNLOCK': {serviceType: 'thermostat', property: 'set_unlock'}, 'THERMOSTAT_TEMPERATURE_OUTDOOR': {serviceType: 'thermostat', property: 'temperature_outdoor'}, // ************* THERMOSTAT_HC *********************** - 'THERMOSTAT_HC_STATE': {serviceType: 'thermostatHC', property: 'state'}, + 'THERMOSTAT_HC_STATE': {serviceType: 'thermostatHC', property: 'state'}, 'THERMOSTAT_HC_STATE_NAME': {serviceType: 'thermostatHC', property: 'state_name'}, 'THERMOSTAT_HC_TEMPERATURE': {serviceType: 'thermostatHC', property: 'temperature'}, 'THERMOSTAT_HC_SET_SETPOINT_H': {serviceType: 'thermostatHC', property: 'set_setpointH'}, 'THERMOSTAT_HC_SET_SETPOINT_C': {serviceType: 'thermostatHC', property: 'set_setpointC'}, 'THERMOSTAT_HC_SETPOINT_H': {serviceType: 'thermostatHC', property: 'setpointH'}, 'THERMOSTAT_HC_SETPOINT_C': {serviceType: 'thermostatHC', property: 'setpointC'}, - 'THERMOSTAT_HC_SET_MODE': {serviceType: 'thermostatHC', property: 'set_mode'}, - 'THERMOSTAT_HC_MODE': {serviceType: 'thermostatHC', property: 'mode'}, - 'THERMOSTAT_HC_LOCK': {serviceType: 'thermostatHC', property: 'lock'}, - 'THERMOSTAT_HC_SET_LOCK': {serviceType: 'thermostatHC', property: 'set_lock'}, + 'THERMOSTAT_HC_SET_MODE': {serviceType: 'thermostatHC', property: 'set_mode'}, + 'THERMOSTAT_HC_MODE': {serviceType: 'thermostatHC', property: 'mode'}, + 'THERMOSTAT_HC_LOCK': {serviceType: 'thermostatHC', property: 'lock'}, + 'THERMOSTAT_HC_SET_LOCK': {serviceType: 'thermostatHC', property: 'set_lock'}, 'THERMOSTAT_HC_SET_UNLOCK': {serviceType: 'thermostatHC', property: 'set_unlock'}, // ************* ALARME *********************** - 'ALARM_STATE': {serviceType: 'alarm', property: 'state'}, - 'ALARM_MODE': {serviceType: 'alarm', property: 'mode'}, + 'ALARM_STATE': {serviceType: 'alarm', property: 'state'}, + 'ALARM_MODE': {serviceType: 'alarm', property: 'mode'}, 'ALARM_ENABLE_STATE': {serviceType: 'alarm', property: 'enable_state'}, - 'ALARM_ARMED': {serviceType: 'alarm', property: 'armed'}, - 'ALARM_RELEASED': {serviceType: 'alarm', property: 'released'}, - 'ALARM_SET_MODE': {serviceType: 'alarm', property: 'set_mode'}, + 'ALARM_ARMED': {serviceType: 'alarm', property: 'armed'}, + 'ALARM_RELEASED': {serviceType: 'alarm', property: 'released'}, + 'ALARM_SET_MODE': {serviceType: 'alarm', property: 'set_mode'}, // ************* SPEAKER *********************** - 'SPEAKER_VOLUME': {serviceType: 'speaker', property: 'volume'}, - 'VOLUME': {serviceType: 'speaker', property: 'volume'}, + 'SPEAKER_VOLUME': {serviceType: 'speaker', property: 'volume'}, + 'VOLUME': {serviceType: 'speaker', property: 'volume'}, 'SPEAKER_SET_VOLUME': {serviceType: 'speaker', property: 'set_volume'}, - 'SET_VOLUME': {serviceType: 'speaker', property: 'set_volume'}, - 'SPEAKER_MUTE': {serviceType: 'speaker', property: 'mute'}, + 'SET_VOLUME': {serviceType: 'speaker', property: 'set_volume'}, + 'SPEAKER_MUTE': {serviceType: 'speaker', property: 'mute'}, 'SPEAKER_MUTE_TOGGLE': {serviceType: 'speaker', property: 'mute_toggle'}, - 'SPEAKER_MUTE_ON': {serviceType: 'speaker', property: 'mute_on'}, + 'SPEAKER_MUTE_ON': {serviceType: 'speaker', property: 'mute_on'}, 'SPEAKER_MUTE_OFF': {serviceType: 'speaker', property: 'mute_off'}, // *************** GENERIC *********************** - 'AIRQUALITY_INDEX': {serviceType: 'AirQuality', property: 'Index'}, + 'AIRQUALITY_INDEX': {serviceType: 'AirQuality', property: 'Index'}, 'AIRQUALITY_PM25': {serviceType: 'AirQuality', property: 'PM25'}, - 'AIRQUALITY_CUSTOM':{serviceType: 'AirQualityCustom', property: 'Index'}, - 'NOISE': {serviceType: 'Noise', property: 'Noise'}, - 'CO2': {serviceType: 'CO2', property: 'CO2'}, - 'CO': {serviceType: 'CO', property: 'CO'}, + 'AIRQUALITY_CUSTOM': {serviceType: 'AirQualityCustom', property: 'Index'}, + 'NOISE': {serviceType: 'Noise', property: 'Noise'}, + 'CO2': {serviceType: 'CO2', property: 'CO2'}, + 'CO': {serviceType: 'CO', property: 'CO'}, 'OPENING_WINDOW': {serviceType: 'opening', property: 'opening'}, - 'OPENING': {serviceType: 'opening', property: 'opening'}, - 'BATTERY': {serviceType: 'battery', property: 'battery'}, - 'BATTERY_CHARGING': {serviceType: 'battery', property: 'batteryCharging'}, // not existing yet - 'DEFECT': {serviceType: 'defect', property: 'defect'}, + 'OPENING': {serviceType: 'opening', property: 'opening'}, + 'BATTERY': {serviceType: 'battery', property: 'battery'}, + 'BATTERY_CHARGING': {serviceType: 'battery', property: 'batteryCharging'}, // not existing yet + 'DEFECT': {serviceType: 'defect', property: 'defect'}, 'PRESENCE': {serviceType: 'presence', property: 'presence'}, 'OCCUPANCY': {serviceType: 'occupancy', property: 'occupancy'}, 'TEMPERATURE': {serviceType: 'temperature', property: 'temperature'}, 'BRIGHTNESS': {serviceType: 'brightness', property: 'brightness'}, - 'SMOKE': {serviceType: 'smoke', property: 'smoke'}, - 'UV': {serviceType: 'uv', property: 'uv'}, // via custom + 'SMOKE': {serviceType: 'smoke', property: 'smoke'}, + 'UV': {serviceType: 'uv', property: 'uv'}, // via custom 'HUMIDITY': {serviceType: 'humidity', property: 'humidity'}, 'SABOTAGE': {serviceType: 'sabotage', property: 'sabotage'}, - 'FLOOD': {serviceType: 'flood', property: 'flood'}, + 'FLOOD': {serviceType: 'flood', property: 'flood'}, 'WATER_LEAK': {serviceType: 'flood', property: 'flood'}, - 'POWER': {serviceType: 'power', property: 'power'}, // via custom + 'POWER': {serviceType: 'power', property: 'power'}, // via custom 'CONSUMPTION': {serviceType: 'consumption', property: 'consumption'}, // via custom - 'ACTIVE': {serviceType: 'status_active', property: 'status_active'}, + 'ACTIVE': {serviceType: 'status_active', property: 'status_active'}, 'PRESSURE': {serviceType: 'pressure', property: 'pressure'}, - 'SHOCK': {serviceType: 'generic', property: 'state'}, + 'SHOCK': {serviceType: 'generic', property: 'state'}, 'RAIN_CURRENT': {serviceType: 'generic', property: 'state'}, 'RAIN_TOTAL': {serviceType: 'generic', property: 'state'}, 'WIND_SPEED': {serviceType: 'generic', property: 'state'}, From 93ac79224cde13303580181edc1fef1d21cc77fd Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:27:27 +0100 Subject: [PATCH 091/118] Update jeedom-api.js --- lib/jeedom-api.js | 150 +++++++++++++++++----------------------------- 1 file changed, 55 insertions(+), 95 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index c38c19c..de65fb5 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -48,54 +48,44 @@ JeedomClient.prototype.changeQueueSys = function(newVal = 1) { }; JeedomClient.prototype.getModel = function() { - var that = this; - var url = that.url; - - return axios.post(url, + return axios.post(this.url, { jsonrpc:"2.0", id:(Math.floor(Math.random() * 1000)), method:"sync_homebridge", params:{ - plugin:that.myPlugin, - apikey:that.apikey, + plugin:this.myPlugin, + apikey:this.apikey, }, }).then((result) => { if(!result.data) {return Promise.reject("JSON reçu de Jeedom invalide, vérifiez le log API de Jeedom, reçu :"+JSON.stringify(result));} if(!result.data.result && result.data.error) { return Promise.reject(result.data.error.message); } else { - that._cachedModel=result.data.result; - return that._cachedModel; + this._cachedModel=result.data.result; + return this._cachedModel; } }); }; JeedomClient.prototype.getDevicePropertiesFromCache = function(ID) { - var that = this; - for (var e in that._cachedModel.eqLogics) { - if (that._cachedModel.eqLogics.hasOwnProperty(e)) { - var eqLogic = that._cachedModel.eqLogics[e]; - if(eqLogic.id == ID) { - return eqLogic; - } + for (let e in this._cachedModel.eqLogics) { + if(this._cachedModel.eqLogics[e].id == ID) { + return this._cachedModel.eqLogics[e]; } } return null; }; JeedomClient.prototype.getDeviceProperties = function(ID) { - var that = this; - var url = that.url; - - return axios.post(url, + return axios.post(this.url, { jsonrpc:"2.0", id:(Math.floor(Math.random() * 1000)), method:"getEql", params:{ - plugin:that.myPlugin, - apikey:that.apikey, + plugin:this.myPlugin, + apikey:this.apikey, id:ID, }, }).then((result) => { @@ -112,17 +102,14 @@ JeedomClient.prototype.getDeviceProperties = function(ID) { }; JeedomClient.prototype.daemonIsReady = function(port) { - var that = this; - var url = that.url; - - return axios.post(url, + return axios.post(this.url, { jsonrpc:"2.0", id:(Math.floor(Math.random() * 1000)), method:"daemonIsReady", params:{ - plugin:that.myPlugin, - apikey:that.apikey, + plugin:this.myPlugin, + apikey:this.apikey, port:port, }, }).then((result) => { @@ -139,77 +126,59 @@ JeedomClient.prototype.daemonIsReady = function(port) { }; JeedomClient.prototype.getDeviceCmdFromCache = function(ID) { - var that = this; - var clist = []; - for (var c in that._cachedModel.cmds) { - if (that._cachedModel.cmds.hasOwnProperty(c)) { - var cmd = that._cachedModel.cmds[c]; - if(cmd.eqLogic_id == ID) { - clist.push(cmd); - } - } + const clist = []; + for (let c in this._cachedModel.cmds) { + if (this._cachedModel.cmds[c].eqLogic_id == ID) { + clist.push(this._cachedModel.cmds[c]); + } } return clist; }; JeedomClient.prototype.getScenarioPropertiesFromCache = function(ID) { - var that = this; - for (var s in that._cachedModel.scenarios) { - if (that._cachedModel.scenarios.hasOwnProperty(s)) { - var scenario = that._cachedModel.scenarios[s]; - if(scenario.id == ID) { - return scenario; - } + for (let s in this._cachedModel.scenarios) { + if(this._cachedModel.scenarios[s].id == ID) { + return this._cachedModel.scenarios[s]; } } return null; }; JeedomClient.prototype.updateModelScenario = function(ID,state) { - var that = this; - for (var s in that._cachedModel.scenarios) { - if (that._cachedModel.scenarios.hasOwnProperty(s)) { - var scenario_cached = that._cachedModel.scenarios[s]; - if(scenario_cached.id == ID) { - that.log('debug','[[Modification Cache Jeedom scenarios: '+scenario_cached.name+'> State de '+scenario_cached.state+' vers '+state+' dans ' + JSON.stringify(scenario_cached).replace('\n','')); - that._cachedModel.scenarios[s].state=state; - return that._cachedModel.scenarios[s]; - } - } + for (let s in this._cachedModel.scenarios) { + if(this._cachedModel.scenarios[s].id == ID) { + this.log('debug','[[Modification Cache Jeedom scenarios: '+this._cachedModel.scenarios[s].name+'> State de '+this._cachedModel.scenarios[s].state+' vers '+state+' dans ' + JSON.stringify(this._cachedModel.scenarios[s]).replace('\n','')); + this._cachedModel.scenarios[s].state=state; + return this._cachedModel.scenarios[s]; + } } - that.log('debug','Scénario pas trouvée dans le cache jeedom (Nouveau Scénario, redémarrez le démon Homebridge pour prendre en compte): '+ID); + this.log('debug','Scénario pas trouvée dans le cache jeedom (Nouveau Scénario, redémarrez le démon Homebridge pour prendre en compte): '+ID); return null; }; JeedomClient.prototype.updateModelEq = function(ID,eqLogic) { - var that = this; - for (var e in that._cachedModel.eqLogics) { - if (that._cachedModel.eqLogics.hasOwnProperty(e)) { - var eqLogic_cached = that._cachedModel.eqLogics[e]; - if(eqLogic_cached.id == ID) { - that.log('info','[[Modification Cache Jeedom eqLogic: '+eqLogic_cached.name+'>'+eqLogic.name+' Enable de '+eqLogic_cached.isEnable+' vers '+eqLogic.isEnable+' dans ' + JSON.stringify(eqLogic).replace('\n','')); - that._cachedModel.eqLogics[e].isEnable=eqLogic.isEnable; - return eqLogic; - } - } + for (let e in this._cachedModel.eqLogics) { + if(this._cachedModel.eqLogics[e].id == ID) { + this.log('info','[[Modification Cache Jeedom eqLogic: '+this._cachedModel.eqLogics[e].name+'>'+eqLogic.name+' Enable de '+this._cachedModel.eqLogics[e].isEnable+' vers '+eqLogic.isEnable+' dans ' + JSON.stringify(eqLogic).replace('\n','')); + this._cachedModel.eqLogics[e].isEnable=eqLogic.isEnable; + return eqLogic; + } } if(DEV_DEBUG) { - that.log('debug','Eqlogic pas trouvée dans le cache jeedom (non visible ou pas envoyé à homebridge): '+ID); + this.log('debug','Eqlogic pas trouvée dans le cache jeedom (non visible ou pas envoyé à homebridge): '+ID); } return null; }; JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { - var that = this; - var eq; - for (var c in that._cachedModel.cmds) { - if (that._cachedModel.cmds.hasOwnProperty(c)) { - var cmd = that._cachedModel.cmds[c]; + for (let c in this._cachedModel.cmds) { + let cmd = this._cachedModel.cmds[c]; + let eq; if(cmd.id == ID && cmd.type=='info') { - eq = that.getDevicePropertiesFromCache(cmd.eqLogic_id); - if(!internal) {that.log('info','[Maj reçue de Jeedom] commande:'+ID+' value:'+value);} - else {that.log('info','[Maj interne] commande:'+ID+' value:'+value);} - that.log('info','[[Modification Cache Jeedom: '+eq.name+'>'+cmd.name+'('+cmd.generic_type+') de '+cmd.currentValue+' vers '+value+' dans ' + JSON.stringify(cmd).replace('\n','')); + eq = this.getDevicePropertiesFromCache(cmd.eqLogic_id); + if(!internal) {this.log('info','[Maj reçue de Jeedom] commande:'+ID+' value:'+value);} + else {this.log('info','[Maj interne] commande:'+ID+' value:'+value);} + this.log('info','[[Modification Cache Jeedom: '+eq.name+'>'+cmd.name+'('+cmd.generic_type+') de '+cmd.currentValue+' vers '+value+' dans ' + JSON.stringify(cmd).replace('\n','')); if(cmd.generic_type == 'ALARM_STATE') { if(cmd.currentValue != value) { cmd.currentValue=value; @@ -223,17 +192,16 @@ JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { } } else if (cmd.id == ID) { if(DEV_DEBUG) { - eq = that.getDevicePropertiesFromCache(cmd.eqLogic_id); - that.log('debug','[Maj reçue de Jeedom] commande:'+ID+' value:'+value); - that.log('debug','[[Pas une commande INFO ('+cmd.type+') '+eq.name+'>'+cmd.name+'('+cmd.generic_type+') '+value+' dans ' + JSON.stringify(cmd).replace('\n','')); + eq = this.getDevicePropertiesFromCache(cmd.eqLogic_id); + this.log('debug','[Maj reçue de Jeedom] commande:'+ID+' value:'+value); + this.log('debug','[[Pas une commande INFO ('+cmd.type+') '+eq.name+'>'+cmd.name+'('+cmd.generic_type+') '+value+' dans ' + JSON.stringify(cmd).replace('\n','')); } return false; } - } } if(DEV_DEBUG) { - that.log('debug','[Maj reçue de Jeedom] commande:'+ID+' value:'+value); - that.log('debug','Commande pas trouvée dans le cache jeedom (non visible ou pas envoyé à homebridge): '+ID); + this.log('debug','[Maj reçue de Jeedom] commande:'+ID+' value:'+value); + this.log('debug','Commande pas trouvée dans le cache jeedom (non visible ou pas envoyé à homebridge): '+ID); } return false; }; @@ -249,9 +217,7 @@ JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { }; JeedomClient.prototype._executeDeviceAction = function(ID, action, param) { - var that = this; var options = {}; - var url = that.url; // console.log('params : ' + param); if (param != null) { if (action == 'setRGB') { @@ -265,13 +231,13 @@ JeedomClient.prototype._executeDeviceAction = function(ID, action, param) { } } - return axios.post(url, + return axios.post(this.url, { jsonrpc:"2.0", id:(Math.floor(Math.random() * 1000)), method:"cmd::execCmd", params:{ - apikey:that.apikey, + apikey:this.apikey, id:ID, options:options, }, @@ -296,16 +262,13 @@ JeedomClient.prototype.executeScenarioAction = function(ID, action) { }; JeedomClient.prototype._executeScenarioAction = function(ID, action) { - var that = this; - var url = that.url; - - return axios.post(url, + return axios.post(this.url, { jsonrpc:"2.0", id:(Math.floor(Math.random() * 1000)), method:"scenario::changeState", params:{ - apikey:that.apikey, + apikey:this.apikey, id:ID, state:action, }, @@ -320,18 +283,15 @@ JeedomClient.prototype._executeScenarioAction = function(ID, action) { }; JeedomClient.prototype.refreshStates = function() { - var that = this; - var url = that.url; - - return axios.post(url, + return axios.post(this.url, { jsonrpc:"2.0", id:(Math.floor(Math.random() * 1000)), method:"event::changes", params:{ - apikey:that.apikey, + apikey:this.apikey, longPolling:30, - datetime:that.Plateform.lastPoll, + datetime:this.Plateform.lastPoll, filter:"homebridge", }, },{ From 749a8448884e2ace9d1143608b8f51500d5e76d7 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:28:25 +0100 Subject: [PATCH 092/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f327790..1b88c1a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0017", + "cust_serial": "0018", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From c9abcf782edb84cba635d76cc329aa9b9549e9aa Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:31:40 +0100 Subject: [PATCH 093/118] Update jeedom-api.js --- lib/jeedom-api.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index de65fb5..3cecee2 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -69,7 +69,7 @@ JeedomClient.prototype.getModel = function() { }; JeedomClient.prototype.getDevicePropertiesFromCache = function(ID) { - for (let e in this._cachedModel.eqLogics) { + for (const e in this._cachedModel.eqLogics) { if(this._cachedModel.eqLogics[e].id == ID) { return this._cachedModel.eqLogics[e]; } @@ -127,7 +127,7 @@ JeedomClient.prototype.daemonIsReady = function(port) { JeedomClient.prototype.getDeviceCmdFromCache = function(ID) { const clist = []; - for (let c in this._cachedModel.cmds) { + for (const c in this._cachedModel.cmds) { if (this._cachedModel.cmds[c].eqLogic_id == ID) { clist.push(this._cachedModel.cmds[c]); } @@ -136,7 +136,7 @@ JeedomClient.prototype.getDeviceCmdFromCache = function(ID) { }; JeedomClient.prototype.getScenarioPropertiesFromCache = function(ID) { - for (let s in this._cachedModel.scenarios) { + for (const s in this._cachedModel.scenarios) { if(this._cachedModel.scenarios[s].id == ID) { return this._cachedModel.scenarios[s]; } @@ -145,7 +145,7 @@ JeedomClient.prototype.getScenarioPropertiesFromCache = function(ID) { }; JeedomClient.prototype.updateModelScenario = function(ID,state) { - for (let s in this._cachedModel.scenarios) { + for (const s in this._cachedModel.scenarios) { if(this._cachedModel.scenarios[s].id == ID) { this.log('debug','[[Modification Cache Jeedom scenarios: '+this._cachedModel.scenarios[s].name+'> State de '+this._cachedModel.scenarios[s].state+' vers '+state+' dans ' + JSON.stringify(this._cachedModel.scenarios[s]).replace('\n','')); this._cachedModel.scenarios[s].state=state; @@ -157,7 +157,7 @@ JeedomClient.prototype.updateModelScenario = function(ID,state) { }; JeedomClient.prototype.updateModelEq = function(ID,eqLogic) { - for (let e in this._cachedModel.eqLogics) { + for (const e in this._cachedModel.eqLogics) { if(this._cachedModel.eqLogics[e].id == ID) { this.log('info','[[Modification Cache Jeedom eqLogic: '+this._cachedModel.eqLogics[e].name+'>'+eqLogic.name+' Enable de '+this._cachedModel.eqLogics[e].isEnable+' vers '+eqLogic.isEnable+' dans ' + JSON.stringify(eqLogic).replace('\n','')); this._cachedModel.eqLogics[e].isEnable=eqLogic.isEnable; @@ -171,8 +171,8 @@ JeedomClient.prototype.updateModelEq = function(ID,eqLogic) { }; JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { - for (let c in this._cachedModel.cmds) { - let cmd = this._cachedModel.cmds[c]; + for (const c in this._cachedModel.cmds) { + const cmd = this._cachedModel.cmds[c]; let eq; if(cmd.id == ID && cmd.type=='info') { eq = this.getDevicePropertiesFromCache(cmd.eqLogic_id); From 94800b17c8b1f6ddd8b8e50119b9a8ca63f71ca3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:32:58 +0000 Subject: [PATCH 094/118] Update axios requirement from >=1.6.5 to >=1.6.7 (#203) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b88c1a..d32ee9d 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ ], "dependencies": { "async": "^3.2.5", - "axios": ">=1.6.5", + "axios": ">=1.6.7", "express": "^4.18.2", "fakegato-history": "NebzHB/fakegato-history#master" }, From 2fa50cdbb530a53b55659f5b88bc517221a83ef2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:33:12 +0000 Subject: [PATCH 095/118] Update @babel/eslint-parser requirement from ^7.23.3 to ^7.23.9 (#202) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d32ee9d..0e35cca 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "@babel/core": ">=7.23.7", - "@babel/eslint-parser": "^7.23.3", + "@babel/eslint-parser": "^7.23.9", "eslint": "^8.56.0" }, "author": "Nebz ", From 004958d2d8d1fe90f443ed9987ffaf943fa621a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:36:47 +0000 Subject: [PATCH 096/118] Update @babel/core requirement from >=7.23.7 to >=7.23.9 (#201) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e35cca..3e27b52 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "fakegato-history": "NebzHB/fakegato-history#master" }, "devDependencies": { - "@babel/core": ">=7.23.7", + "@babel/core": ">=7.23.9", "@babel/eslint-parser": "^7.23.9", "eslint": "^8.56.0" }, From cdadc0cec238469fa0ccd499bc3e5a851e987aa7 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:37:31 +0100 Subject: [PATCH 097/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3e27b52..aded86f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0018", + "cust_serial": "0019", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 2c9b66abaa72fcd988e2f8224a88553f9c0cff95 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:45:17 +0100 Subject: [PATCH 098/118] Update myLogger.js --- lib/myLogger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/myLogger.js b/lib/myLogger.js index 6a7e9ea..e145032 100644 --- a/lib/myLogger.js +++ b/lib/myLogger.js @@ -61,7 +61,7 @@ function myLogger(debugLevel,logger,creationLogPath) { if(!this.creationPassed) { fs.writeFileSync(creationLogPath+startLog, '['+(new Date().toISOString())+'] '+msg+"\n", {flag: 'a'}); - if(msg && msg.includes("Homebridge est démarré")) { + if(msg && msg.includes("homebridge est démarré")) { fs.writeFileSync(creationLogPath+startLog, '['+(new Date().toISOString())+"] ----Fin du log de création----\n", {flag: 'a'}); this.creationPassed = true; } From 5fa74fe8eeefd8e97fc5746f3f4a38ae4dccb776 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:46:46 +0100 Subject: [PATCH 099/118] Update myLogger.js --- lib/myLogger.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/myLogger.js b/lib/myLogger.js index e145032..b44d9a2 100644 --- a/lib/myLogger.js +++ b/lib/myLogger.js @@ -46,14 +46,13 @@ function myLogger(debugLevel,logger,creationLogPath) { this.creationPassed = false; fs.writeFileSync(this.creationLogPath+startLog, '['+(new Date().toISOString())+"] ---Début du log de création---\n"); this.log = function(level, msg) { - level=level.toLowerCase(); msg = util.format.apply(util, Array.prototype.slice.call(arguments, 1)); if(msg) { - if(this.allowedLevel.indexOf(level) !== -1) { + if(this.allowedLevel.indexOf(level.toLowerCase()) !== -1) { msg="["+level.toUpperCase()+"] "+msg; } else { - msg=level+' '+msg; + msg=level.toLowerCase()+' '+msg; } } else { msg=level; From a41d1fc0d9e3de1162beb9b3b752c0a4b24b3ecc Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:46:57 +0100 Subject: [PATCH 100/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aded86f..19037ee 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0019", + "cust_serial": "0020", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 1349707f99840516ab1fa4868df77f5ae8b78ffe Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:47:20 +0100 Subject: [PATCH 101/118] Update myLogger.js --- lib/myLogger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/myLogger.js b/lib/myLogger.js index b44d9a2..4df98f6 100644 --- a/lib/myLogger.js +++ b/lib/myLogger.js @@ -60,7 +60,7 @@ function myLogger(debugLevel,logger,creationLogPath) { if(!this.creationPassed) { fs.writeFileSync(creationLogPath+startLog, '['+(new Date().toISOString())+'] '+msg+"\n", {flag: 'a'}); - if(msg && msg.includes("homebridge est démarré")) { + if(msg && msg.includes("Homebridge est démarré")) { fs.writeFileSync(creationLogPath+startLog, '['+(new Date().toISOString())+"] ----Fin du log de création----\n", {flag: 'a'}); this.creationPassed = true; } From fc5380994f58efa1ef832efa88a533b36ca6cde8 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:30:14 +0100 Subject: [PATCH 102/118] Update index.js --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f38eb82..7120f52 100755 --- a/index.js +++ b/index.js @@ -5130,7 +5130,7 @@ JeedomPlatform.prototype.command = function(action, value, service) { } found = true; cmdFound=cmd.generic_type; - needToTemporize=500; + needToTemporize=0; } break; case 'FLAP_HOR_TILT_SLIDER' : @@ -5160,7 +5160,7 @@ JeedomPlatform.prototype.command = function(action, value, service) { // brightness up to 100% in homekit, in Jeedom (Zwave) up to 99 max. Convert to Zwave found = true; cmdFound=cmd.generic_type; - needToTemporize=500; + needToTemporize=0; } break; case 'GB_OPEN' : From 34fdf16596f5f59b2129ce7da8329a138873fad5 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:07:16 +0100 Subject: [PATCH 103/118] Update index.js --- index.js | 60 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 7120f52..89ac960 100755 --- a/index.js +++ b/index.js @@ -617,7 +617,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.minValue=0; if(Serv.infos.state.subType == 'binary') { Serv.maxValue=1; - Serv.getCharacteristic(Characteristic.TargetPosition).setProps({minStep:100}); + //Serv.getCharacteristic(Characteristic.TargetPosition).setProps({minStep:1}); } else { Serv.maxValue=100; } @@ -3308,27 +3308,35 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser } break; case Characteristic.CurrentPosition.UUID: - case Characteristic.TargetPosition.UUID: case Characteristic.PositionState.UUID: // could be Service.Window or Service.Door too so we check + this.log('debug','************SHOULD NEVER COME HERE !!!!! *************'); + case Characteristic.TargetPosition.UUID: + if (service.UUID == Service.WindowCovering.UUID) { if(service.FlapType=="Closing") { // flap in percent Closing (100% = closed / 0% = open) if(service.actions.down && service.actions.up) { if (service.actions.slider) { if (parseInt(value) === service.minValue) { + service.TargetValue=0; action = 'flapUp'; } else if (parseInt(value) === service.maxValue) { + service.TargetValue=100; action = 'flapDown'; } else { action = 'setValue'; const oldValue = value; value = 100 - parseInt(value);// invert percentage value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue); // transform from percentage to scale + service.Moving=true; + service.TargetValue=value; this.log('debug','---------set Inverted Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue); } } - else if (parseInt(value) < ((service.maxValue-service.minValue)/2)) { + else if (parseInt(value) < 50) { + service.TargetValue=0; action = 'flapUp'; } else { + service.TargetValue=100; action = 'flapDown'; } @@ -3337,26 +3345,34 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser const oldValue = value; value = 100 - parseInt(value);// invert percentage value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue); // transform from percentage to scale + service.Moving=true; + service.TargetValue=value; this.log('debug','---------set Inverted Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue); } } else if (service.FlapType=="Opening") { // flap in percent Opening (100% = open / 0% = closed) if(service.actions.down && service.actions.up) { if (service.actions.slider) { if (parseInt(value) === service.minValue) { + service.TargetValue=0; action = 'flapDown'; } else if (parseInt(value) === service.maxValue) { + service.TargetValue=100; action = 'flapUp'; } else { action = 'setValue'; value = parseInt(value); const oldValue = value; value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue);// transform from percentage to scale + service.Moving=true; + service.TargetValue=value; this.log('debug','---------set Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue); } } - else if (parseInt(value) < ((service.maxValue-service.minValue)/2)) { + else if (parseInt(value) < 50) { + service.TargetValue=0; action = 'flapDown'; } else { + service.TargetValue=100; action = 'flapUp'; } } @@ -3365,6 +3381,8 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser value = parseInt(value); const oldValue = value; value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue);// transform from percentage to scale + service.Moving=true; + service.TargetValue=value; this.log('debug','---------set Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue); } } @@ -3376,20 +3394,26 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser if(service.actions.down && service.actions.up) { if (service.actions.slider) { if (parseInt(value) === service.minValue) { + service.TargetValue=0; action = 'windowDown'; } else if (parseInt(value) === service.maxValue) { + service.TargetValue=100; action = 'windowUp'; } else { action = 'setValue'; value = parseInt(value); const oldValue = value; value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue); + service.Moving=true; + service.TargetValue=value; this.log('debug','---------set WindowMoto Value:',oldValue,'% soit ',value,'/',service.maxValue); } } - else if (parseInt(value) < ((service.maxValue-service.minValue)/2)) { + else if (parseInt(value) < 50) { + service.TargetValue=0; action = 'windowDown'; } else { + service.TargetValue=100; action = 'windowUp'; } } @@ -3398,6 +3422,8 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser value = parseInt(value); const oldValue = value; value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue); + service.Moving=true; + service.TargetValue=value; this.log('debug','---------set WindowMoto Value:',oldValue,'% soit ',value,'/',service.maxValue); } @@ -4586,16 +4612,18 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i break; // Flaps & windowMoto case Characteristic.CurrentPosition.UUID : - case Characteristic.TargetPosition.UUID : + //case Characteristic.TargetPosition.UUID : for (const cmd of cmdList) { if (cmd.generic_type == 'FLAP_STATE' && cmd.id == service.cmd_id) { returnValue = parseInt(cmd.currentValue); returnValue = Math.round(((returnValue-service.minValue) / (service.maxValue-service.minValue))*100); - + if(service.maxValue == 100) { returnValue = returnValue > (service.maxValue-5) ? service.maxValue : returnValue; // >95% is 100% in home (flaps need yearly tunning) } that.log('debug','---------update Blinds Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue); + if(returnValue === service.TargetValue) {service.Moving=false;} + else if (service.TargetValue !== undefined && !service.Moving) {service.TargetValue=undefined;} break; } if (cmd.generic_type == 'FLAP_STATE_CLOSING' && cmd.id == service.cmd_id) { @@ -4606,6 +4634,8 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } returnValue = 100-returnValue; // invert percentage that.log('debug','---------update Inverted Blinds Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue); + if(returnValue === service.TargetValue) {service.Moving=false;} + else if (service.TargetValue !== undefined && !service.Moving) {service.TargetValue=undefined;} break; } if (cmd.generic_type == 'WINDOW_STATE' && cmd.id == service.cmd_id) { @@ -4613,13 +4643,27 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i returnValue = Math.round(((returnValue-service.minValue) / (service.maxValue-service.minValue))*100); that.log('debug','---------update WindowMoto Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue); + if(returnValue === service.TargetValue) {service.Moving=false;} + else if (service.TargetValue !== undefined && !service.Moving) {service.TargetValue=undefined;} break; } } break; + case Characteristic.TargetPosition.UUID : + if(service.TargetValue === undefined) { + returnValue = parseInt(service.infos.state.currentValue); + returnValue = Math.round(((returnValue-service.minValue) / (service.maxValue-service.minValue))*100); + + if(service.maxValue == 100) { + returnValue = returnValue > (service.maxValue-5) ? service.maxValue : returnValue; // >95% is 100% in home (flaps need yearly tunning) + } + } else { + returnValue = service.TargetValue; + } + that.log('debug','---------update TargetPosition(refresh):',returnValue,'%'); + break; case Characteristic.PositionState.UUID : returnValue = Characteristic.PositionState.STOPPED; - break; case Characteristic.CurrentHorizontalTiltAngle.UUID : case Characteristic.TargetHorizontalTiltAngle.UUID : From 2ed417e06dfbf36a94485e9c6b282e1f22d13e11 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:07:28 +0100 Subject: [PATCH 104/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 19037ee..4f8ca29 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0020", + "cust_serial": "0021", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From e7c7900dc95bc7d48009caf3bf92923e5f17baf6 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:59:51 +0100 Subject: [PATCH 105/118] Update index.js --- index.js | 170 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 121 insertions(+), 49 deletions(-) diff --git a/index.js b/index.js index 89ac960..0df75a6 100755 --- a/index.js +++ b/index.js @@ -3119,7 +3119,7 @@ JeedomPlatform.prototype.configureAccessory = function(accessory) { // -- Return : nothing JeedomPlatform.prototype.bindCharacteristicEvents = function(characteristic, service) { try{ - if (characteristic.UUID != Characteristic.PositionState.UUID) {this.updateSubscriptions.push({service, characteristic});} + /*if (characteristic.UUID != Characteristic.PositionState.UUID) {*/this.updateSubscriptions.push({service, characteristic});//} if (characteristic.props.perms.includes('pw')) { characteristic.on('set', (value, callback, context) => { if (context !== 'fromJeedom' && context !== 'fromSetValue') { // from Homekit @@ -3307,83 +3307,118 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser this.command('SetAlarmMode', value, service); } break; - case Characteristic.CurrentPosition.UUID: - case Characteristic.PositionState.UUID: // could be Service.Window or Service.Door too so we check - this.log('debug','************SHOULD NEVER COME HERE !!!!! *************'); case Characteristic.TargetPosition.UUID: - + value=parseInt(value); if (service.UUID == Service.WindowCovering.UUID) { if(service.FlapType=="Closing") { // flap in percent Closing (100% = closed / 0% = open) if(service.actions.down && service.actions.up) { if (service.actions.slider) { - if (parseInt(value) === service.minValue) { + if (value === 0) { + service.Moving=Characteristic.PositionState.DECREASING; service.TargetValue=0; action = 'flapUp'; - } else if (parseInt(value) === service.maxValue) { + this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); + } else if (value === 100) { + service.Moving=Characteristic.PositionState.INCREASING; service.TargetValue=100; action = 'flapDown'; + this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } else { action = 'setValue'; const oldValue = value; - value = 100 - parseInt(value);// invert percentage + value = 100 - value;// invert percentage value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue); // transform from percentage to scale - service.Moving=true; - service.TargetValue=value; - this.log('debug','---------set Inverted Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue); + if(value > service.infos.state.currentValue) { + service.Moving=Characteristic.PositionState.INCREASING; + } else if (value != service.infos.state.currentValue) { + service.Moving=Characteristic.PositionState.DECREASING; + } else { + service.Moving=Characteristic.PositionState.STOPPED; + } + service.TargetValue=oldValue; + this.log('debug','---------set Inverted Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue,' : ',positionStateLabel(service.Moving)); } } - else if (parseInt(value) < 50) { + else if (value < 50) { + service.Moving=Characteristic.PositionState.DECREASING; service.TargetValue=0; action = 'flapUp'; + this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } else { + service.Moving=Characteristic.PositionState.INCREASING; service.TargetValue=100; action = 'flapDown'; + this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } } else if (service.actions.slider) { action = 'setValue'; const oldValue = value; - value = 100 - parseInt(value);// invert percentage + value = 100 - value;// invert percentage value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue); // transform from percentage to scale - service.Moving=true; - service.TargetValue=value; - this.log('debug','---------set Inverted Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue); + if(value > service.infos.state.currentValue) { + service.Moving=Characteristic.PositionState.INCREASING; + } else if (value != service.infos.state.currentValue) { + service.Moving=Characteristic.PositionState.DECREASING; + } else { + service.Moving=Characteristic.PositionState.STOPPED; + } + service.TargetValue=oldValue; + this.log('debug','---------set Inverted Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue,' : ',positionStateLabel(service.Moving)); } } else if (service.FlapType=="Opening") { // flap in percent Opening (100% = open / 0% = closed) if(service.actions.down && service.actions.up) { if (service.actions.slider) { - if (parseInt(value) === service.minValue) { + if (value === 0) { + service.Moving=Characteristic.PositionState.DECREASING; service.TargetValue=0; action = 'flapDown'; - } else if (parseInt(value) === service.maxValue) { + this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); + } else if (value === 100) { + service.Moving=Characteristic.PositionState.INCREASING; service.TargetValue=100; action = 'flapUp'; + this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } else { action = 'setValue'; - value = parseInt(value); const oldValue = value; value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue);// transform from percentage to scale - service.Moving=true; - service.TargetValue=value; - this.log('debug','---------set Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue); + if(value > service.infos.state.currentValue) { + service.Moving=Characteristic.PositionState.INCREASING; + } else if (value != service.infos.state.currentValue) { + service.Moving=Characteristic.PositionState.DECREASING; + } else { + service.Moving=Characteristic.PositionState.STOPPED; + } + service.TargetValue=oldValue; + this.log('debug','---------set Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue,' : ',positionStateLabel(service.Moving)); } } - else if (parseInt(value) < 50) { + else if (value < 50) { + service.Moving=Characteristic.PositionState.DECREASING; service.TargetValue=0; action = 'flapDown'; + this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } else { + service.Moving=Characteristic.PositionState.INCREASING; service.TargetValue=100; action = 'flapUp'; + this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } } else if (service.actions.slider) { action = 'setValue'; - value = parseInt(value); const oldValue = value; value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue);// transform from percentage to scale - service.Moving=true; - service.TargetValue=value; - this.log('debug','---------set Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue); + if(value > service.infos.state.currentValue) { + service.Moving=Characteristic.PositionState.INCREASING; + } else if (value != service.infos.state.currentValue) { + service.Moving=Characteristic.PositionState.DECREASING; + } else { + service.Moving=Characteristic.PositionState.STOPPED; + } + service.TargetValue=oldValue; + this.log('debug','---------set Blinds Value:',oldValue,'% soit ',value,'/',service.maxValue,' : ',positionStateLabel(service.Moving)); } } @@ -3393,38 +3428,54 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser if (service.UUID == Service.Window.UUID) { if(service.actions.down && service.actions.up) { if (service.actions.slider) { - if (parseInt(value) === service.minValue) { + if (value === 0) { + service.Moving=Characteristic.PositionState.DECREASING; service.TargetValue=0; action = 'windowDown'; - } else if (parseInt(value) === service.maxValue) { + this.log('debug','---------set WindowMoto action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); + } else if (value === 100) { + service.Moving=Characteristic.PositionState.INCREASING; service.TargetValue=100; action = 'windowUp'; + this.log('debug','---------set WindowMoto action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } else { action = 'setValue'; - value = parseInt(value); const oldValue = value; value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue); - service.Moving=true; - service.TargetValue=value; - this.log('debug','---------set WindowMoto Value:',oldValue,'% soit ',value,'/',service.maxValue); + if(value > service.infos.state) { + service.Moving=Characteristic.PositionState.INCREASING; + } else if (value != service.infos.state) { + service.Moving=Characteristic.PositionState.DECREASING; + } + service.TargetValue=oldValue; + this.log('debug','---------set WindowMoto Value:',oldValue,'% soit ',value,'/',service.maxValue,' : ',positionStateLabel(service.Moving)); } } - else if (parseInt(value) < 50) { + else if (value < 50) { + service.Moving=Characteristic.PositionState.DECREASING; service.TargetValue=0; action = 'windowDown'; + this.log('debug','---------set WindowMoto action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } else { + service.Moving=Characteristic.PositionState.INCREASING; service.TargetValue=100; action = 'windowUp'; + this.log('debug','---------set WindowMoto action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } } else if (service.actions.slider) { action = 'setValue'; - value = parseInt(value); const oldValue = value; value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue); - service.Moving=true; - service.TargetValue=value; - this.log('debug','---------set WindowMoto Value:',oldValue,'% soit ',value,'/',service.maxValue); + if(value > service.infos.state) { + service.Moving=Characteristic.PositionState.INCREASING; + } else if (value != service.infos.state) { + service.Moving=Characteristic.PositionState.DECREASING; + } else { + service.Moving=Characteristic.PositionState.STOPPED; + } + service.TargetValue=oldValue; + this.log('debug','---------set WindowMoto Value:',oldValue,'% soit ',value,'/',service.maxValue,' : ',positionStateLabel(service.Moving)); } this.command(action, value, service); @@ -4612,7 +4663,6 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i break; // Flaps & windowMoto case Characteristic.CurrentPosition.UUID : - //case Characteristic.TargetPosition.UUID : for (const cmd of cmdList) { if (cmd.generic_type == 'FLAP_STATE' && cmd.id == service.cmd_id) { returnValue = parseInt(cmd.currentValue); @@ -4621,30 +4671,33 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(service.maxValue == 100) { returnValue = returnValue > (service.maxValue-5) ? service.maxValue : returnValue; // >95% is 100% in home (flaps need yearly tunning) } - that.log('debug','---------update Blinds Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue); - if(returnValue === service.TargetValue) {service.Moving=false;} - else if (service.TargetValue !== undefined && !service.Moving) {service.TargetValue=undefined;} + + if(returnValue === service.TargetValue) {service.Moving=Characteristic.PositionState.STOPPED;} + else if (service.TargetValue !== undefined && service.Moving===Characteristic.PositionState.STOPPED) {service.TargetValue=undefined;} + that.log('debug','---------update Blinds Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue,' : ',positionStateLabel(service.Moving)); break; } if (cmd.generic_type == 'FLAP_STATE_CLOSING' && cmd.id == service.cmd_id) { returnValue = parseInt(cmd.currentValue); returnValue = Math.round(((returnValue-service.minValue) / (service.maxValue-service.minValue))*100); + if(service.maxValue == 100) { returnValue = returnValue > (service.maxValue-5) ? service.maxValue : returnValue; // >95% is 100% in home (flaps need yearly tunning) } returnValue = 100-returnValue; // invert percentage - that.log('debug','---------update Inverted Blinds Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue); - if(returnValue === service.TargetValue) {service.Moving=false;} - else if (service.TargetValue !== undefined && !service.Moving) {service.TargetValue=undefined;} + + if(returnValue === service.TargetValue) {service.Moving=Characteristic.PositionState.STOPPED;} + else if (service.TargetValue !== undefined && service.Moving===Characteristic.PositionState.STOPPED) {service.TargetValue=undefined;} + that.log('debug','---------update Inverted Blinds Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue,' : ',positionStateLabel(service.Moving)); break; } if (cmd.generic_type == 'WINDOW_STATE' && cmd.id == service.cmd_id) { returnValue = parseInt(cmd.currentValue); returnValue = Math.round(((returnValue-service.minValue) / (service.maxValue-service.minValue))*100); - that.log('debug','---------update WindowMoto Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue); - if(returnValue === service.TargetValue) {service.Moving=false;} - else if (service.TargetValue !== undefined && !service.Moving) {service.TargetValue=undefined;} + if(returnValue === service.TargetValue) {service.Moving=Characteristic.PositionState.STOPPED;} + else if (service.TargetValue !== undefined && service.Moving===Characteristic.PositionState.STOPPED) {service.TargetValue=undefined;} + that.log('debug','---------update WindowMoto Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue,' : ',positionStateLabel(service.Moving)); break; } } @@ -4663,7 +4716,12 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i that.log('debug','---------update TargetPosition(refresh):',returnValue,'%'); break; case Characteristic.PositionState.UUID : - returnValue = Characteristic.PositionState.STOPPED; + if('Moving' in service) { + returnValue = service.Moving; + } else { + returnValue = Characteristic.PositionState.STOPPED; + } + that.log('debug','---------update PositionState(refresh):',positionStateLabel(returnValue)); break; case Characteristic.CurrentHorizontalTiltAngle.UUID : case Characteristic.TargetHorizontalTiltAngle.UUID : @@ -4976,6 +5034,20 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } }; +function positionStateLabel(ps) { + switch(ps) { + case Characteristic.PositionState.DECREASING: + return "DECREASING"; + break; + case Characteristic.PositionState.INCREASING: + return "INCREASING"; + break; + case Characteristic.PositionState.STOPPED: + return "STOPPED"; + break; + } + return "STOPPED"; +} // -- sanitizeValue // -- Desc : limit the value to the min and max characteristic + round the float to the same precision than the minStep From ced5b80057664fd0ca6d061706da676487ec91d2 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:02:04 +0100 Subject: [PATCH 106/118] Update index.js --- index.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 0df75a6..5dae6ed 100755 --- a/index.js +++ b/index.js @@ -5035,17 +5035,11 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i }; function positionStateLabel(ps) { - switch(ps) { - case Characteristic.PositionState.DECREASING: + if(ps == Characteristic.PositionState.DECREASING) { return "DECREASING"; - break; - case Characteristic.PositionState.INCREASING: + } else if (ps == Characteristic.PositionState.INCREASING) { return "INCREASING"; - break; - case Characteristic.PositionState.STOPPED: - return "STOPPED"; - break; - } + } return "STOPPED"; } From 029fea86571a57de824d6c17575d0a94eb69f1e0 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:03:14 +0100 Subject: [PATCH 107/118] Update index.js --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5dae6ed..ea53706 100755 --- a/index.js +++ b/index.js @@ -617,7 +617,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.minValue=0; if(Serv.infos.state.subType == 'binary') { Serv.maxValue=1; - //Serv.getCharacteristic(Characteristic.TargetPosition).setProps({minStep:1}); + // Serv.getCharacteristic(Characteristic.TargetPosition).setProps({minStep:1}); } else { Serv.maxValue=100; } @@ -3119,7 +3119,7 @@ JeedomPlatform.prototype.configureAccessory = function(accessory) { // -- Return : nothing JeedomPlatform.prototype.bindCharacteristicEvents = function(characteristic, service) { try{ - /*if (characteristic.UUID != Characteristic.PositionState.UUID) {*/this.updateSubscriptions.push({service, characteristic});//} + /* if (characteristic.UUID != Characteristic.PositionState.UUID) { */this.updateSubscriptions.push({service, characteristic});// } if (characteristic.props.perms.includes('pw')) { characteristic.on('set', (value, callback, context) => { if (context !== 'fromJeedom' && context !== 'fromSetValue') { // from Homekit From 0abfdbcb456a6eac0933251afebb0a1962f6cae7 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:06:26 +0100 Subject: [PATCH 108/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f8ca29..cf51b5b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0021", + "cust_serial": "0022", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 9f7c5058618282960d5af380dd9bace635c02e00 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:15:30 +0100 Subject: [PATCH 109/118] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b7f858f..1b23d97 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [18.x, 20.x, 21.x] + node-version: [20.x, 21.x] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} From db025c0c8ed8ac6ad0170271c8730fa3fa102e37 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:11:01 +0100 Subject: [PATCH 110/118] Update index.js --- index.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index ea53706..4776090 100755 --- a/index.js +++ b/index.js @@ -3316,12 +3316,12 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser if (value === 0) { service.Moving=Characteristic.PositionState.DECREASING; service.TargetValue=0; - action = 'flapUp'; + action = 'flapDown'; this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } else if (value === 100) { service.Moving=Characteristic.PositionState.INCREASING; service.TargetValue=100; - action = 'flapDown'; + action = 'flapUp'; this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } else { action = 'setValue'; @@ -3329,9 +3329,9 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser value = 100 - value;// invert percentage value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue); // transform from percentage to scale if(value > service.infos.state.currentValue) { - service.Moving=Characteristic.PositionState.INCREASING; - } else if (value != service.infos.state.currentValue) { service.Moving=Characteristic.PositionState.DECREASING; + } else if (value != service.infos.state.currentValue) { + service.Moving=Characteristic.PositionState.INCREASING; } else { service.Moving=Characteristic.PositionState.STOPPED; } @@ -3342,12 +3342,12 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser else if (value < 50) { service.Moving=Characteristic.PositionState.DECREASING; service.TargetValue=0; - action = 'flapUp'; + action = 'flapDown'; this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } else { service.Moving=Characteristic.PositionState.INCREASING; service.TargetValue=100; - action = 'flapDown'; + action = 'flapUp'; this.log('debug','---------set Blinds action:',action,' soit ',service.TargetValue,'/',100,' : ',positionStateLabel(service.Moving)); } @@ -3357,9 +3357,9 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser value = 100 - value;// invert percentage value = Math.round(((value / 100)*(service.maxValue-service.minValue))+service.minValue); // transform from percentage to scale if(value > service.infos.state.currentValue) { - service.Moving=Characteristic.PositionState.INCREASING; - } else if (value != service.infos.state.currentValue) { service.Moving=Characteristic.PositionState.DECREASING; + } else if (value != service.infos.state.currentValue) { + service.Moving=Characteristic.PositionState.INCREASING; } else { service.Moving=Characteristic.PositionState.STOPPED; } @@ -4710,6 +4710,10 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(service.maxValue == 100) { returnValue = returnValue > (service.maxValue-5) ? service.maxValue : returnValue; // >95% is 100% in home (flaps need yearly tunning) } + if(service.FlapType=="Closing" && service.Moving!==Characteristic.PositionState.STOPPED) { + that.log('debug','---------update TargetPosition(Closing)before:',returnValue,'%'); + returnValue=100-returnValue; + } } else { returnValue = service.TargetValue; } From 04e4e7d186f1138519ed4824a9a5671be7bae3f5 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:11:15 +0100 Subject: [PATCH 111/118] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cf51b5b..740cf73 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0022", + "cust_serial": "0023", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, From 5f5a96a990d78004639dbc737d3164f9a3bd9627 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:16:16 +0100 Subject: [PATCH 112/118] Update index.js --- index.js | 959 +++++++++++++++++++++++++++---------------------------- 1 file changed, 472 insertions(+), 487 deletions(-) diff --git a/index.js b/index.js index 4776090..3899cb6 100755 --- a/index.js +++ b/index.js @@ -182,40 +182,39 @@ JeedomPlatform.prototype.ConfigCMD = function(req, res) { // -- Return : nothing JeedomPlatform.prototype.addAccessories = function() { try{ - const that = this; - that.log('Synchronisation Jeedom <> Homebridge...'); - that.jeedomClient.getModel() - .then(function(model){ // we got the base Model from the API + this.log('Synchronisation Jeedom <> Homebridge...'); + this.jeedomClient.getModel() + .then((model) => { // we got the base Model from the API if(model && typeof model === 'object' && model.config && typeof model.config === 'object' && model.config.datetime) { - that.lastPoll=model.config.datetime; + this.lastPoll=model.config.datetime; - that.log('debug','Enumération des objets Jeedom (Pièces)...'); + this.log('debug','Enumération des objets Jeedom (Pièces)...'); if(model.objects && typeof model.objects === 'object' && Object.keys(model.objects).length !== 0) { - model.objects.map(function(r){ - that.rooms[r.id] = r.name; - that.log('debug','Pièce > ' + r.name); + model.objects.map((r) => { + this.rooms[r.id] = r.name; + this.log('debug','Pièce > ' + r.name); }); } else { - that.log('error','Pièce > '+model.objects); + this.log('error','Pièce > '+model.objects); throw new Error("Liste des pièces vide ou invalide, vérifiez que vous avez bien coché au moins une pièce à envoyer à homebridge !"); } - that.log('Enumération des scénarios Jeedom...'); - that.JeedomScenarios2HomeKitAccessories(model.scenarios); + this.log('Enumération des scénarios Jeedom...'); + this.JeedomScenarios2HomeKitAccessories(model.scenarios); - that.log('Enumération des périphériques Jeedom...'); + this.log('Enumération des périphériques Jeedom...'); if(model.eqLogics && typeof model.eqLogics === 'object' && Object.keys(model.eqLogics).length !== 0) { - that.JeedomDevices2HomeKitAccessories(model.eqLogics); + this.JeedomDevices2HomeKitAccessories(model.eqLogics); } else { - that.log('error','Périf > '+model.eqLogics); + this.log('error','Périf > '+model.eqLogics); throw new Error('eqLogics list empty'); } } else { - that.log('error','Model invalide > ',model); + this.log('error','Model invalide > ',model); throw new Error('Invalid Model'); } - }).catch(function(err) { - that.log('error','#2 Erreur de récupération des données Jeedom: ' , err); + }).catch((err) => { + this.log('error','#2 Erreur de récupération des données Jeedom: ' , err); if(err && err.stack) { console.error(err.stack); } }); } @@ -227,28 +226,22 @@ JeedomPlatform.prototype.addAccessories = function() { JeedomPlatform.prototype.JeedomScenarios2HomeKitAccessories = function(scenarios) { try{ - const that = this; + if (scenarios) { - scenarios.sort(function compare(a, b) { + scenarios.sort((a, b) => { // reorder by room name asc and name asc - const aC = that.rooms[a.object_id]+a.name; - const bC = that.rooms[b.object_id]+b.name; - if (aC > bC) { - return 1; - } - if (aC < bC) { - return -1; - } - return 0; + const aC = this.rooms[a.object_id] + a.name; + const bC = this.rooms[b.object_id] + b.name; + return aC.localeCompare(bC); }); - scenarios.map(function(scenario) { + scenarios.map((scenario) => { if (scenario.isActive == '1' && scenario.object_id != null && scenario.sendToHomebridge == '1') { - that.log('debug','Scenario > '+JSON.stringify(scenario).replace("\n",'')); - that.log('┌──── ' + that.rooms[scenario.object_id] + ' > ' +scenario.name+' ('+scenario.id+')'); + this.log('debug','Scenario > '+JSON.stringify(scenario).replace("\n",'')); + this.log('┌──── ' + this.rooms[scenario.object_id] + ' > ' +scenario.name+' ('+scenario.id+')'); const HBservice = { @@ -267,11 +260,11 @@ JeedomPlatform.prototype.JeedomScenarios2HomeKitAccessories = function(scenarios Serv.subtype = Serv.subtype || ''; Serv.subtype = scenario.id + '-' + Serv.subtype; - if(that.fakegato && !scenario.hasLogging) { + if(this.fakegato && !scenario.hasLogging) { // HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - scenario.loggingService = {type:"switch", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + scenario.loggingService = {type:"switch", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; scenario.hasLogging=true; } @@ -279,29 +272,29 @@ JeedomPlatform.prototype.JeedomScenarios2HomeKitAccessories = function(scenarios scenario.eqType_name = "Scenario"; scenario.logicalId = ""; - const createdAccessory = that.createAccessory([HBservice], scenario); - that.addAccessory(createdAccessory); - that.log('└─────────'); + const createdAccessory = this.createAccessory([HBservice], scenario); + this.addAccessory(createdAccessory); + this.log('└─────────'); } else { - that.log('debug','Scenario > '+JSON.stringify(scenario).replace("\n",'')); - that.log('┌──── ' + that.rooms[scenario.object_id] + ' > ' +scenario.name+' ('+scenario.id+')'); + this.log('debug','Scenario > '+JSON.stringify(scenario).replace("\n",'')); + this.log('┌──── ' + this.rooms[scenario.object_id] + ' > ' +scenario.name+' ('+scenario.id+')'); var Messg= '│ Scenario '; Messg += scenario.isVisible == '1' ? 'visible' : 'invisible'; Messg += scenario.isActive == '1' ? ', activé' : ', désactivé'; Messg += scenario.object_id != null ? '' : ', pas dans une pièce'; Messg += scenario.sendToHomebridge == '1' ? '' : ', pas coché pour Homebridge'; - that.log(Messg); + this.log(Messg); scenario.eqType_name = "Scenario"; scenario.logicalId = ""; - that.delAccessory( - that.createAccessory([], scenario) // create a cached lookalike object for unregistering it + this.delAccessory( + this.createAccessory([], scenario) // create a cached lookalike object for unregistering it ); - that.log('└─────────'); + this.log('└─────────'); } }); @@ -321,43 +314,42 @@ JeedomPlatform.prototype.JeedomScenarios2HomeKitAccessories = function(scenarios // -- Return : nothing JeedomPlatform.prototype.JeedomDevices2HomeKitAccessories = function(devices) { try{ - const that = this; if (devices) { devices.sort((a, b) => { // reorder by room name asc and name asc - const aC = that.rooms[a.object_id] + a.name; - const bC = that.rooms[b.object_id] + b.name; + const aC = this.rooms[a.object_id] + a.name; + const bC = this.rooms[b.object_id] + b.name; return aC.localeCompare(bC); }); - devices.map(function(device) { + devices.map((device) => { if (// device.isVisible == '1' && device.isEnable == '1' && device.object_id != null && device.sendToHomebridge != '0') { - that.AccessoireCreateHomebridge( - that.jeedomClient.ParseGenericType( + this.AccessoireCreateHomebridge( + this.jeedomClient.ParseGenericType( device, - that.jeedomClient.getDeviceCmdFromCache(device.id) + this.jeedomClient.getDeviceCmdFromCache(device.id) ) ); } else { - that.log('debug','eqLogic > '+JSON.stringify(device).replace("\n",'')); - that.log('┌──── ' + that.rooms[device.object_id] + ' > ' +device.name+((device.pseudo)?' > pseudo: '+device.pseudo:'')+' ('+device.id+')'); + this.log('debug','eqLogic > '+JSON.stringify(device).replace("\n",'')); + this.log('┌──── ' + this.rooms[device.object_id] + ' > ' +device.name+((device.pseudo)?' > pseudo: '+device.pseudo:'')+' ('+device.id+')'); var Messg= '│ Accessoire '; Messg += device.isVisible == '1' ? 'visible' : 'invisible'; Messg += device.isEnable == '1' ? ', activé' : ', désactivé'; Messg += device.object_id != null ? '' : ', pas dans une pièce'; Messg += device.sendToHomebridge != '0' ? '' : ', pas coché pour Homebridge'; - that.log(Messg); + this.log(Messg); - that.delAccessory( - that.createAccessory([], device) // create a cached lookalike object for unregistering it + this.delAccessory( + this.createAccessory([], device) // create a cached lookalike object for unregistering it ); - that.log('└─────────'); + this.log('└─────────'); } }); @@ -365,38 +357,38 @@ JeedomPlatform.prototype.JeedomDevices2HomeKitAccessories = function(devices) { var countA=0; if(!hasError) { - that.log('┌────RAMASSE-MIETTES─────'); - that.log('│ (Suppression des accessoires qui sont dans le cache mais plus dans jeedom (peut provenir de renommage ou changement de pièce))'); + this.log('┌────RAMASSE-MIETTES─────'); + this.log('│ (Suppression des accessoires qui sont dans le cache mais plus dans jeedom (peut provenir de renommage ou changement de pièce))'); var hasDeleted = false; - for (const a in that.accessories) + for (const a in this.accessories) { - if (that.accessories.hasOwnProperty(a)) { - if(!that.accessories[a].reviewed && - that.accessories[a].displayName) { - that.log('│ ┌──── Trouvé: '+that.accessories[a].displayName); - that.delAccessory(that.accessories[a],true); - that.log('│ │ Supprimé du cache !'); - that.log('│ └─────────'); + if (this.accessories.hasOwnProperty(a)) { + if(!this.accessories[a].reviewed && + this.accessories[a].displayName) { + this.log('│ ┌──── Trouvé: '+this.accessories[a].displayName); + this.delAccessory(this.accessories[a],true); + this.log('│ │ Supprimé du cache !'); + this.log('│ └─────────'); hasDeleted=true; - }else if(that.accessories[a].reviewed && - that.accessories[a].displayName) {countA++;} + }else if(this.accessories[a].reviewed && + this.accessories[a].displayName) {countA++;} } } - if(!hasDeleted) {that.log('│ Rien à supprimer');} - that.log('└────────────────────────'); + if(!hasDeleted) {this.log('│ Rien à supprimer');} + this.log('└────────────────────────'); } else { - that.log('error','!!! ERREUR DETECTÉE, ON QUITTE HOMEBRIDGE !!!'); + this.log('error','!!! ERREUR DETECTÉE, ON QUITTE HOMEBRIDGE !!!'); process.exit(1); } const endLog = '--== Homebridge est démarré et a intégré '+countA+' accessoire'+ (countA>1 ? 's' : '') +' ! ==--'; - that.log(endLog); - if(countA >= 150) {that.log('error','!!! ATTENTION !!! Vous avez '+countA+' accessoires + Jeedom et HomeKit en supporte 150 max au total !!');} - else if(countA >= 140) {that.log('warn','!! Avertissement, vous avez '+countA+' accessoires + Jeedom et HomeKit en supporte 150 max au total !!');} + this.log(endLog); + if(countA >= 150) {this.log('error','!!! ATTENTION !!! Vous avez '+countA+' accessoires + Jeedom et HomeKit en supporte 150 max au total !!');} + else if(countA >= 140) {this.log('warn','!! Avertissement, vous avez '+countA+' accessoires + Jeedom et HomeKit en supporte 150 max au total !!');} - that.log('debug','==START POLLING=='); - that.startPollingUpdate(); + this.log('debug','==START POLLING=='); + this.startPollingUpdate(); } catch(e){ this.log('error','Erreur de la fonction JeedomDevices2HomeKitAccessories :',e); @@ -412,18 +404,17 @@ JeedomPlatform.prototype.JeedomDevices2HomeKitAccessories = function(devices) { JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { var createdAccessory; try { - const that = this; var HBservices = []; var HBservice = null; const eqServicesCopy = eqLogic.services; - that.log('debug','eqLogic > '+JSON.stringify(eqLogic).replace("\n",'')); - that.log('┌──── ' + that.rooms[eqLogic.object_id] + ' > ' + eqLogic.name +((eqLogic.pseudo)?' > pseudo: '+eqLogic.pseudo:'')+ ' (' + eqLogic.id + ')'); + this.log('debug','eqLogic > '+JSON.stringify(eqLogic).replace("\n",'')); + this.log('┌──── ' + this.rooms[eqLogic.object_id] + ' > ' + eqLogic.name +((eqLogic.pseudo)?' > pseudo: '+eqLogic.pseudo:'')+ ' (' + eqLogic.id + ')'); eqLogic.origName=eqLogic.name; if(eqLogic.pseudo) { eqLogic.name = eqLogic.pseudo; } if (eqLogic.services.light) { - eqLogic.services.light.forEach(function(cmd) { + eqLogic.services.light.forEach((cmd) => { if (cmd.state) { let LightType="Switch"; HBservice = { @@ -438,7 +429,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { if(eqLogic.OnAfterBrightness) {Serv.OnAfterBrightness=true;} if(eqLogic.ignoreOnCommandOnBrightnessChange) {Serv.ignoreOnCommandOnBrightnessChange=true;} - eqServicesCopy.light.forEach(function(cmd2) { + eqServicesCopy.light.forEach((cmd2) => { if (cmd2.on) { Serv.actions.on=cmd2.on; } else if (cmd2.off) { @@ -459,13 +450,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.brightness=cmd2.brightness; } }); - if (Serv.actions.on && !Serv.actions.off) {that.log('warn','Pas de type générique "Action/Lumière OFF"');} - if (!Serv.actions.on && Serv.actions.off) {that.log('warn','Pas de type générique "Action/Lumière ON"');} - if (!Serv.actions.on && !Serv.actions.off) {that.log('warn','Pas de type générique "Action/Lumière ON" et "Action/Lumière OFF"');} - if (Serv.infos.color && !Serv.actions.setcolor) {that.log('warn','Pas de type générique "Action/Lumière Couleur"');} - if (!Serv.infos.color && Serv.actions.setcolor) {that.log('warn','Pas de type générique "Info/Lumière Couleur"');} - if (Serv.infos.color_temp && !Serv.actions.setcolor_temp) {that.log('warn','Pas de type générique "Action/Lumière Température Couleur"');} - if (!Serv.infos.color_temp && Serv.actions.setcolor_temp) {that.log('warn','Pas de type générique "Info/Lumière Température Couleur"');} + if (Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Lumière OFF"');} + if (!Serv.actions.on && Serv.actions.off) {this.log('warn','Pas de type générique "Action/Lumière ON"');} + if (!Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Lumière ON" et "Action/Lumière OFF"');} + if (Serv.infos.color && !Serv.actions.setcolor) {this.log('warn','Pas de type générique "Action/Lumière Couleur"');} + if (!Serv.infos.color && Serv.actions.setcolor) {this.log('warn','Pas de type générique "Info/Lumière Couleur"');} + if (Serv.infos.color_temp && !Serv.actions.setcolor_temp) {this.log('warn','Pas de type générique "Action/Lumière Température Couleur"');} + if (!Serv.infos.color_temp && Serv.actions.setcolor_temp) {this.log('warn','Pas de type générique "Info/Lumière Température Couleur"');} if(Serv.actions.slider) { if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { @@ -477,7 +468,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { HBservice.characteristics.push(Characteristic.Brightness); Serv.addCharacteristic(Characteristic.Brightness); } else { - that.log('info','La lumière n\'a pas de variateur'); + this.log('info','La lumière n\'a pas de variateur'); } if(Serv.infos.color) { LightType += "_RGB"; @@ -516,7 +507,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { LightType+=Serv.colorTempType; } } else { - that.log('error','"Action/Lumière Température Couleur" doit avoir un minimum et un maximum !'); + this.log('error','"Action/Lumière Température Couleur" doit avoir un minimum et un maximum !'); props.minValue = 0; // if not set in Jeedom it's 0 props.maxValue = 20000; // if not set in Jeedom it's 100 } @@ -528,7 +519,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if(eqLogic.hasAdaptive) { - if (that.adaptiveLightingSupport()) { + if (this.adaptiveLightingSupport()) { LightType+='_Adaptive'; } else { eqLogic.hasAdaptive=false; @@ -536,9 +527,9 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - that.log('info','La lumière est du type :',LightType); + this.log('info','La lumière est du type :',LightType); Serv.LightType = LightType; Serv.cmd_id = cmd.state.id; Serv.eqID = eqLogic.id; @@ -548,13 +539,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Lumière Etat"'); + this.log('warn','Pas de type générique "Info/Lumière Etat"'); } else { HBservice = null; } } if (eqLogic.services.flap) { - eqLogic.services.flap.forEach(function(cmd) { + eqLogic.services.flap.forEach((cmd) => { if (cmd.state || cmd.stateClosing) { HBservice = { controlService : new Service.WindowCovering(eqLogic.name), @@ -589,7 +580,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } } - eqServicesCopy.flap.forEach(function(cmd2) { + eqServicesCopy.flap.forEach((cmd2) => { if (cmd2.up) { Serv.actions.up = cmd2.up; } else if (cmd2.down) { @@ -606,14 +597,14 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.VerTiltState = cmd2.VerTiltState; } }); - if(Serv.actions.up && !Serv.actions.down) {that.log('warn','Pas de type générique "Action/Volet Bouton Descendre"');} - if(!Serv.actions.up && Serv.actions.down) {that.log('warn','Pas de type générique "Action/Volet Bouton Monter"');} - if(!Serv.actions.up && !Serv.actions.down) {that.log('warn','Pas de type générique "Action/Volet Bouton Descendre" et "Action/Volet Bouton Monter"');} - if(!Serv.actions.up && !Serv.actions.down && !Serv.actions.slider) {that.log('warn','Pas de type générique "Action/Volet Bouton Slider" et "Action/Volet Bouton Monter" et "Action/Volet Bouton Descendre"');} - if(Serv.actions.HorTiltSlider && !Serv.infos.HorTiltState) {that.log('warn','Pas de type générique "Info/Volet Etat Inclinaison Horizontale" malgré l\'action "Action/Volet Slider Inclinaison Horizontale"');} - if(Serv.actions.VerTiltSlider && !Serv.infos.VerTiltState) {that.log('warn','Pas de type générique "Info/Volet Etat Inclinaison Verticale" malgré l\'action "Action/Volet Slider Inclinaison Verticale"');} - if(!Serv.actions.HorTiltSlider && Serv.infos.HorTiltState) {that.log('warn','Pas de type générique "Action/Volet Slider Inclinaison Horizontale" malgré l\'état "Info/Volet Etat Inclinaison Horizontale"');} - if(!Serv.actions.VerTiltSlider && Serv.infos.VerTiltState) {that.log('warn','Pas de type générique "Action/Volet Slider Inclinaison Verticale" malgré l\'état "Info/Volet Etat Inclinaison Verticale"');} + if(Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Volet Bouton Descendre"');} + if(!Serv.actions.up && Serv.actions.down) {this.log('warn','Pas de type générique "Action/Volet Bouton Monter"');} + if(!Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Volet Bouton Descendre" et "Action/Volet Bouton Monter"');} + if(!Serv.actions.up && !Serv.actions.down && !Serv.actions.slider) {this.log('warn','Pas de type générique "Action/Volet Bouton Slider" et "Action/Volet Bouton Monter" et "Action/Volet Bouton Descendre"');} + if(Serv.actions.HorTiltSlider && !Serv.infos.HorTiltState) {this.log('warn','Pas de type générique "Info/Volet Etat Inclinaison Horizontale" malgré l\'action "Action/Volet Slider Inclinaison Horizontale"');} + if(Serv.actions.VerTiltSlider && !Serv.infos.VerTiltState) {this.log('warn','Pas de type générique "Info/Volet Etat Inclinaison Verticale" malgré l\'action "Action/Volet Slider Inclinaison Verticale"');} + if(!Serv.actions.HorTiltSlider && Serv.infos.HorTiltState) {this.log('warn','Pas de type générique "Action/Volet Slider Inclinaison Horizontale" malgré l\'état "Info/Volet Etat Inclinaison Horizontale"');} + if(!Serv.actions.VerTiltSlider && Serv.infos.VerTiltState) {this.log('warn','Pas de type générique "Action/Volet Slider Inclinaison Verticale" malgré l\'état "Info/Volet Etat Inclinaison Verticale"');} Serv.minValue=0; if(Serv.infos.state.subType == 'binary') { Serv.maxValue=1; @@ -648,7 +639,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { HBservice.characteristics.push(Characteristic.TargetHorizontalTiltAngle); Serv.addCharacteristic(Characteristic.TargetHorizontalTiltAngle); Serv.getCharacteristic(Characteristic.TargetHorizontalTiltAngle).setProps(props); - that.log('debug','Horizontal Slider props :'+JSON.stringify(props)+'/'+JSON.stringify(Serv.actions.HorTiltSlider.configuration)); + this.log('debug','Horizontal Slider props :'+JSON.stringify(props)+'/'+JSON.stringify(Serv.actions.HorTiltSlider.configuration)); } if(Serv.actions.VerTiltSlider) { @@ -670,11 +661,11 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { HBservice.characteristics.push(Characteristic.TargetVerticalTiltAngle); Serv.addCharacteristic(Characteristic.TargetVerticalTiltAngle); Serv.getCharacteristic(Characteristic.TargetVerticalTiltAngle).setProps(props); - that.log('debug','Vertical Slider props :'+JSON.stringify(props)+'/'+JSON.stringify(Serv.actions.VerTiltSlider.configuration)); + this.log('debug','Vertical Slider props :'+JSON.stringify(props)+'/'+JSON.stringify(Serv.actions.VerTiltSlider.configuration)); } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = Serv.infos.state.id; Serv.eqID = eqLogic.id; @@ -685,8 +676,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Volet Etat" ou "Info/Volet Etat Fermeture" on regarde s\'il y a uniquement les boutons...'); - eqLogic.services.flap.forEach(function(cmd) { + this.log('warn','Pas de type générique "Info/Volet Etat" ou "Info/Volet Etat Fermeture" on regarde s\'il y a uniquement les boutons...'); + eqLogic.services.flap.forEach((cmd) => { if (cmd.up) { const SwitchName=cmd.up.name; HBservice = { @@ -706,7 +697,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SwitchName); // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.up.id; Serv.eqID = eqLogic.id; @@ -733,7 +724,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SwitchName); // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.down.id; Serv.eqID = eqLogic.id; @@ -760,7 +751,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SwitchName); // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.stop.id; Serv.eqID = eqLogic.id; @@ -770,7 +761,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Action/Volet Bouton Monter" ou "Action/Volet Bouton Descendre" ou "Action/Volet Bouton Stop"'); + this.log('warn','Pas de type générique "Action/Volet Bouton Monter" ou "Action/Volet Bouton Descendre" ou "Action/Volet Bouton Stop"'); } else { HBservice = null; } @@ -779,7 +770,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } } if (eqLogic.services.windowMoto) { - eqLogic.services.windowMoto.forEach(function(cmd) { + eqLogic.services.windowMoto.forEach((cmd) => { if (cmd.state) { HBservice = { controlService : new Service.Window(eqLogic.name), @@ -791,7 +782,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos={}; Serv.infos.state=cmd.state; - eqServicesCopy.windowMoto.forEach(function(cmd2) { + eqServicesCopy.windowMoto.forEach((cmd2) => { if (cmd2.up) { Serv.actions.up = cmd2.up; } else if (cmd2.down) { @@ -802,10 +793,10 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); Serv.maxValue = 100; // if not set in Jeedom it's 100 Serv.minValue = 0; // if not set in Jeedom it's 0 - if(Serv.actions.up && !Serv.actions.down) {that.log('warn','Pas de type générique "Action/Fenêtre Motorisée Descendre"');} - if(!Serv.actions.up && Serv.actions.down) {that.log('warn','Pas de type générique "Action/Fenêtre Motorisée Monter"');} - if(!Serv.actions.up && !Serv.actions.down) {that.log('warn','Pas de type générique "Action/Fenêtre Motorisée Descendre" et "Action/Fenêtre Motorisée Monter"');} - if(!Serv.actions.up && !Serv.actions.down && !Serv.actions.slider) {that.log('warn','Pas de type générique "Action/Fenêtre Motorisée Slider" et "Action/Fenêtre Motorisée Monter" et "Action/Fenêtre Motorisée Descendre"');} + if(Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Descendre"');} + if(!Serv.actions.up && Serv.actions.down) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Monter"');} + if(!Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Descendre" et "Action/Fenêtre Motorisée Monter"');} + if(!Serv.actions.up && !Serv.actions.down && !Serv.actions.slider) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Slider" et "Action/Fenêtre Motorisée Monter" et "Action/Fenêtre Motorisée Descendre"');} if(Serv.actions.slider) { if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { Serv.maxValue = parseInt(Serv.actions.slider.configuration.maxValue); @@ -815,7 +806,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.state.id; Serv.eqID = eqLogic.id; @@ -826,13 +817,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Fenêtre Motorisée Etat"'); + this.log('warn','Pas de type générique "Info/Fenêtre Motorisée Etat"'); } else { HBservice = null; } } if (eqLogic.services.energy) { - eqLogic.services.energy.forEach(function(cmd) { + eqLogic.services.energy.forEach((cmd) => { if (cmd.state) { HBservice = { controlService : new Service.Outlet(eqLogic.name), @@ -843,7 +834,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.state=cmd.state; - eqServicesCopy.energy.forEach(function(cmd2) { + eqServicesCopy.energy.forEach((cmd2) => { if (cmd2.on) { Serv.actions.on = cmd2.on; } else if (cmd2.off) { @@ -852,12 +843,12 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.inuse = cmd2.inuse; } }); - if(!Serv.actions.on) {that.log('warn','Pas de type générique "Action/Prise Bouton On"');} - if(!Serv.actions.off) {that.log('warn','Pas de type générique "Action/Prise Bouton Off"');} + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Prise Bouton On"');} + if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Prise Bouton Off"');} // Test for AdminOnlyAccess, state need to have OwnerOnly attribute to True ou 1 if(Serv.infos.state.OwnerOnly) {Serv.getCharacteristic(Characteristic.On).setProps({adminOnlyAccess: [Access.WRITE]});} // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.state.id; Serv.eqID = eqLogic.id; @@ -867,13 +858,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Prise Etat"'); + this.log('warn','Pas de type générique "Info/Prise Etat"'); } else { HBservice = null; } } if (eqLogic.services.faucet) { - eqLogic.services.faucet.forEach(function(cmd) { + eqLogic.services.faucet.forEach((cmd) => { if (cmd.state) { HBservice = { controlService : new Service.Valve(eqLogic.name), @@ -886,18 +877,18 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.state=cmd.state; Serv.getCharacteristic(Characteristic.ValveType).setValue(Characteristic.ValveType.WATER_FAUCET); Serv.ValveType=Characteristic.ValveType.WATER_FAUCET; - eqServicesCopy.faucet.forEach(function(cmd2) { + eqServicesCopy.faucet.forEach((cmd2) => { if (cmd2.on) { Serv.actions.on = cmd2.on; } else if (cmd2.off) { Serv.actions.off = cmd2.off; } }); - if(!Serv.actions.on) {that.log('warn','Pas de type générique "Action/Robinet Bouton On"');} - if(!Serv.actions.off) {that.log('warn','Pas de type générique "Action/Robinet Bouton Off"');} + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Robinet Bouton On"');} + if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Robinet Bouton Off"');} // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.state.id; Serv.eqID = eqLogic.id; @@ -907,13 +898,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Robinet Etat"'); + this.log('warn','Pas de type générique "Info/Robinet Etat"'); } else { HBservice = null; } } if (eqLogic.services.irrigation) { - eqLogic.services.irrigation.forEach(function(cmd) { + eqLogic.services.irrigation.forEach((cmd) => { if (cmd.state) { HBservice = { controlService : new Service.Valve(eqLogic.name), @@ -926,18 +917,18 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.state=cmd.state; Serv.getCharacteristic(Characteristic.ValveType).setValue(Characteristic.ValveType.IRRIGATION); Serv.ValveType=Characteristic.ValveType.IRRIGATION; - eqServicesCopy.irrigation.forEach(function(cmd2) { + eqServicesCopy.irrigation.forEach((cmd2) => { if (cmd2.on) { Serv.actions.on = cmd2.on; } else if (cmd2.off) { Serv.actions.off = cmd2.off; } }); - if(!Serv.actions.on) {that.log('warn','Pas de type générique "Action/Irrigation Bouton On"');} - if(!Serv.actions.off) {that.log('warn','Pas de type générique "Action/Irrigation Bouton Off"');} + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Irrigation Bouton On"');} + if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Irrigation Bouton Off"');} // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.state.id; Serv.eqID = eqLogic.id; @@ -947,13 +938,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Irrigation Etat"'); + this.log('warn','Pas de type générique "Info/Irrigation Etat"'); } else { HBservice = null; } } if (eqLogic.services.valve) { - eqLogic.services.valve.forEach(function(cmd) { + eqLogic.services.valve.forEach((cmd) => { if (cmd.state) { HBservice = { controlService : new Service.Valve(eqLogic.name), @@ -966,7 +957,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.state=cmd.state; Serv.getCharacteristic(Characteristic.ValveType).setValue(Characteristic.ValveType.GENERIC_VALVE); Serv.ValveType=Characteristic.ValveType.GENERIC_VALVE; - eqServicesCopy.valve.forEach(function(cmd2) { + eqServicesCopy.valve.forEach((cmd2) => { if (cmd2.on) { Serv.actions.on = cmd2.on; } else if (cmd2.off) { @@ -977,8 +968,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.remainingDuration = cmd2.remainingDuration; } }); - if(!Serv.actions.on) {that.log('warn','Pas de type générique "Action/Valve générique Bouton On"');} - if(!Serv.actions.off) {that.log('warn','Pas de type générique "Action/Valve générique Bouton Off"');} + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Valve générique Bouton On"');} + if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Valve générique Bouton Off"');} if(Serv.actions.setDuration) { HBservice.characteristics.push(Characteristic.SetDuration); @@ -990,7 +981,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.state.id; Serv.eqID = eqLogic.id; @@ -1000,13 +991,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Valve générique Etat"'); + this.log('warn','Pas de type générique "Info/Valve générique Etat"'); } else { HBservice = null; } } if (eqLogic.services.fan) { - eqLogic.services.fan.forEach(function(cmd) { + eqLogic.services.fan.forEach((cmd) => { if (cmd.state) { let FanType="Switch"; let maxPower; @@ -1020,7 +1011,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos={}; Serv.infos.state=cmd.state; - eqServicesCopy.fan.forEach(function(cmd2) { + eqServicesCopy.fan.forEach((cmd2) => { if (cmd2.on) { Serv.actions.on=cmd2.on; } else if (cmd2.off) { @@ -1029,9 +1020,9 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions.slider=cmd2.slider; } }); - if (Serv.actions.on && !Serv.actions.off) {that.log('warn','Pas de type générique "Action/Ventilateur OFF"');} - if (!Serv.actions.on && Serv.actions.off) {that.log('warn','Pas de type générique "Action/Ventilateur ON"');} - if (!Serv.actions.on && !Serv.actions.off) {that.log('warn','Pas de type générique "Action/Ventilateur ON" et "Action/Ventilateur OFF"');} + if (Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Ventilateur OFF"');} + if (!Serv.actions.on && Serv.actions.off) {this.log('warn','Pas de type générique "Action/Ventilateur ON"');} + if (!Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Ventilateur ON" et "Action/Ventilateur OFF"');} if(Serv.actions.slider) { if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { @@ -1043,13 +1034,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { HBservice.characteristics.push(Characteristic.RotationSpeed); Serv.addCharacteristic(Characteristic.RotationSpeed); } else { - that.log('info','Le ventilateur n\'a pas de variateur'); + this.log('info','Le ventilateur n\'a pas de variateur'); } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - that.log('info','Le ventilateur est du type :',FanType+((maxPower)?','+maxPower:'')); + this.log('info','Le ventilateur est du type :',FanType+((maxPower)?','+maxPower:'')); Serv.FanType = FanType; Serv.maxPower = maxPower; Serv.cmd_id = cmd.state.id; @@ -1060,17 +1051,17 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Ventilateur Etat"'); + this.log('warn','Pas de type générique "Info/Ventilateur Etat"'); } else { HBservice = null; } } if (eqLogic.services.Switch) { - eqLogic.services.Switch.forEach(function(cmd) { + eqLogic.services.Switch.forEach((cmd) => { if (cmd.state) { let SwitchName = eqLogic.name; if(cmd.state.generic_type == 'CAMERA_RECORD_STATE' || (cmd.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1)) { - that.log('debug',"Switchs multiples dans même équipement, il y en a "+eqLogic.numSwitches); + this.log('debug',"Switchs multiples dans même équipement, il y en a "+eqLogic.numSwitches); SwitchName=cmd.state.name; } HBservice = { @@ -1079,7 +1070,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }; const Serv = HBservice.controlService; if(cmd.state.generic_type == 'CAMERA_RECORD_STATE' || (cmd.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1)) { - that.log('debug',"Nom du switch (multi) : "+SwitchName); + this.log('debug',"Nom du switch (multi) : "+SwitchName); Serv.getCharacteristic(Characteristic.On).displayName = SwitchName; Serv.ConfiguredName=SwitchName; @@ -1091,7 +1082,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.state=cmd.state; - eqServicesCopy.Switch.forEach(function(cmd2) { + eqServicesCopy.Switch.forEach((cmd2) => { if (cmd2.on) { if(Serv.infos.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1) { if(cmd2.on.value == cmd.state.id) { @@ -1110,22 +1101,22 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } } }); - if(!Serv.actions.on) {that.log('warn','Pas de type générique "Action/Interrupteur Bouton On"');} - if(!Serv.actions.off) {that.log('warn','Pas de type générique "Action/Interrupteur Bouton Off"');} + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Interrupteur Bouton On"');} + if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Interrupteur Bouton Off"');} // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.state.id; Serv.eqID = eqLogic.id; Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { + if(this.fakegato && !eqLogic.hasLogging) { // HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.loggingService = {type:"switch", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.loggingService = {type:"switch", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -1134,13 +1125,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Interrupteur Etat"'); + this.log('warn','Pas de type générique "Info/Interrupteur Etat"'); } else { HBservice = null; } } if (eqLogic.services.Push) { - eqLogic.services.Push.forEach(function(cmd) { + eqLogic.services.Push.forEach((cmd) => { if (cmd.Push && cmd.Push.subType == 'other') { const SwitchName=cmd.Push.name; HBservice = { @@ -1158,7 +1149,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SwitchName); // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.Push.id; Serv.eqID = eqLogic.id; @@ -1168,13 +1159,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','La Commande Action associée doit être du type "Autre"'); + this.log('warn','La Commande Action associée doit être du type "Autre"'); } else { HBservice = null; } } if (eqLogic.services.power || (eqLogic.services.power && eqLogic.services.consumption)) { - eqLogic.services.power.forEach(function(cmd) { + eqLogic.services.power.forEach((cmd) => { if (cmd.power) { HBservice = { controlService : new Service.PowerMonitor(eqLogic.name), @@ -1186,10 +1177,10 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos={}; Serv.infos.power=cmd.power; // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); if(eqServicesCopy.consumption) { - eqServicesCopy.consumption.forEach(function(cmd2) { + eqServicesCopy.consumption.forEach((cmd2) => { if (cmd2.consumption) { Serv.infos.consumption=cmd2.consumption; } @@ -1200,9 +1191,9 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.eqID = eqLogic.id; Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { + if(this.fakegato && !eqLogic.hasLogging) { // HBservice.characteristics.push(Characteristic.ResetTotal); - eqLogic.loggingService = {type:"energy", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.loggingService = {type:"energy", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -1212,7 +1203,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.battery) { - eqLogic.services.battery.forEach(function(cmd) { + eqLogic.services.battery.forEach((cmd) => { if (cmd.battery) { HBservice = { controlService : new Service.BatteryService(eqLogic.name), @@ -1224,7 +1215,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos={}; Serv.infos.battery=cmd.battery; Serv.infos.batteryCharging=cmd.batteryCharging || {id:'NOT'}; - eqServicesCopy.battery.forEach(function(cmd2) { + eqServicesCopy.battery.forEach((cmd2) => { if (cmd2.batteryCharging) { Serv.infos.batteryCharging=cmd2.batteryCharging; } else { @@ -1241,7 +1232,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.Noise) { - eqLogic.services.Noise.forEach(function(cmd) { + eqLogic.services.Noise.forEach((cmd) => { if (cmd.Noise) { HBservice = { controlService : new Service.NoiseSensor(eqLogic.name), @@ -1287,7 +1278,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.CO) { - eqLogic.services.CO.forEach(function(cmd) { + eqLogic.services.CO.forEach((cmd) => { if (cmd.CO) { HBservice = { controlService : new Service.CarbonMonoxideSensor(eqLogic.name), @@ -1311,7 +1302,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.CO2) { - eqLogic.services.CO2.forEach(function(cmd) { + eqLogic.services.CO2.forEach((cmd) => { if (cmd.CO2) { HBservice = { controlService : new Service.AirQualitySensor(eqLogic.name), @@ -1351,7 +1342,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.getCharacteristic(Characteristic.CarbonDioxideLevel).setProps(propsCO2); } - if(that.fakegato && !eqLogic.hasLogging) { + if(this.fakegato && !eqLogic.hasLogging) { HBservice.characteristics.push(Characteristic.PPM); Serv.addCharacteristic(Characteristic.PPM); const unite = Serv.infos.CO2.unite ? Serv.infos.CO2.unite : ''; @@ -1363,7 +1354,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { HBservice.characteristics.push(Characteristic.AQExtraCharacteristic); Serv.addCharacteristic(Characteristic.AQExtraCharacteristic); - eqLogic.loggingService ={type:"room", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.loggingService ={type:"room", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -1373,7 +1364,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.AirQualityCustom) { - eqLogic.services.AirQualityCustom.forEach(function(cmd) { + eqLogic.services.AirQualityCustom.forEach((cmd) => { if (cmd.Index) { HBservice = { controlService : new Service.AirQualitySensor(eqLogic.name), @@ -1390,35 +1381,35 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { if(eqLogic.customizedValues.EXCELLENT && eqLogic.customizedValues.EXCELLENT != "NOT") { Serv.levelNum[Characteristic.AirQuality.EXCELLENT] = parseInt(eqLogic.customizedValues.EXCELLENT); } else { - that.log('warn',"Pas de config de la valeur 'Excellent', on la défini sur 50"); + this.log('warn',"Pas de config de la valeur 'Excellent', on la défini sur 50"); Serv.levelNum[Characteristic.AirQuality.EXCELLENT]=50; } if(eqLogic.customizedValues.GOOD && eqLogic.customizedValues.GOOD != "NOT") { Serv.levelNum[Characteristic.AirQuality.GOOD] = parseInt(eqLogic.customizedValues.GOOD); } else { - that.log('warn',"Pas de config de la valeur 'Bon', on la défini sur 100"); + this.log('warn',"Pas de config de la valeur 'Bon', on la défini sur 100"); Serv.levelNum[Characteristic.AirQuality.GOOD]=100; } if(eqLogic.customizedValues.FAIR && eqLogic.customizedValues.FAIR != "NOT") { Serv.levelNum[Characteristic.AirQuality.FAIR] = parseInt(eqLogic.customizedValues.FAIR); } else { - that.log('warn',"Pas de config de la valeur 'Moyen', on la défini sur 150"); + this.log('warn',"Pas de config de la valeur 'Moyen', on la défini sur 150"); Serv.levelNum[Characteristic.AirQuality.FAIR]=150; } if(eqLogic.customizedValues.INFERIOR && eqLogic.customizedValues.INFERIOR != "NOT") { Serv.levelNum[Characteristic.AirQuality.INFERIOR] = parseInt(eqLogic.customizedValues.INFERIOR); } else { - that.log('warn',"Pas de config de la valeur 'Inférieur', on la défini sur 200"); + this.log('warn',"Pas de config de la valeur 'Inférieur', on la défini sur 200"); Serv.levelNum[Characteristic.AirQuality.INFERIOR]=200; } if(eqLogic.customizedValues.POOR && eqLogic.customizedValues.POOR != "NOT") { Serv.levelNum[Characteristic.AirQuality.POOR] = parseInt(eqLogic.customizedValues.POOR); } else { - that.log('warn',"Pas de config de la valeur 'Faible', on la défini sur 1000"); + this.log('warn',"Pas de config de la valeur 'Faible', on la défini sur 1000"); Serv.levelNum[Characteristic.AirQuality.POOR]=1000; } - } else if(that.myPlugin == "homebridge") { - that.log('warn',"Pas de config numérique des valeurs que qualité d'air"); + } else if(this.myPlugin == "homebridge") { + this.log('warn',"Pas de config numérique des valeurs que qualité d'air"); } @@ -1428,7 +1419,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { + if(this.fakegato && !eqLogic.hasLogging) { HBservice.characteristics.push(Characteristic.VOCDensity); Serv.addCharacteristic(Characteristic.VOCDensity); const unite = Serv.infos.Index.unite ? Serv.infos.Index.unite : ''; @@ -1441,7 +1432,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { HBservice.characteristics.push(Characteristic.AQExtraCharacteristic); Serv.addCharacteristic(Characteristic.AQExtraCharacteristic); - eqLogic.loggingService ={type:"room2", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.loggingService ={type:"room2", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -1451,7 +1442,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.AirQuality) { - eqLogic.services.AirQuality.forEach(function(cmd) { + eqLogic.services.AirQuality.forEach((cmd) => { if (cmd.Index) { HBservice = { controlService : new Service.AirQualitySensor(eqLogic.name), @@ -1462,7 +1453,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.Index=cmd.Index; - eqServicesCopy.AirQuality.forEach(function(cmd2) { + eqServicesCopy.AirQuality.forEach((cmd2) => { if (cmd2.PM25) { Serv.infos.PM25= cmd2.PM25; } @@ -1503,11 +1494,11 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.presence) { - eqLogic.services.presence.forEach(function(cmd) { + eqLogic.services.presence.forEach((cmd) => { if (cmd.presence) { let SensorName=eqLogic.name; if(eqLogic.numDetector>1) { - that.log('debug',"Detecteurs multiples dans même équipement, il y en a "+eqLogic.numDetector); + this.log('debug',"Detecteurs multiples dans même équipement, il y en a "+eqLogic.numDetector); SensorName=cmd.presence.name; } HBservice = { @@ -1516,7 +1507,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }; const Serv = HBservice.controlService; if(eqLogic.numDetector>1) { - that.log('debug',"Nom du détecteur (multi) : "+SensorName); + this.log('debug',"Nom du détecteur (multi) : "+SensorName); Serv.getCharacteristic(Characteristic.MotionDetected).displayName = SensorName; Serv.ConfiguredName=SensorName; @@ -1533,21 +1524,21 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.invertBinary=cmd.presence.display.invertBinary; } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.presence.id; Serv.eqID = eqLogic.id; Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { + if(this.fakegato && !eqLogic.hasLogging) { HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); Serv.addOptionalCharacteristic(Characteristic.Sensitivity); Serv.addOptionalCharacteristic(Characteristic.Duration); Serv.addOptionalCharacteristic(Characteristic.LastActivation); // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.loggingService = {type:"motion", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.loggingService = {type:"motion", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -1558,11 +1549,11 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.occupancy) { - eqLogic.services.occupancy.forEach(function(cmd) { + eqLogic.services.occupancy.forEach((cmd) => { if (cmd.occupancy) { let SensorName=eqLogic.name; if(eqLogic.numDetector>1) { - that.log('debug',"Detecteurs occupancy multiples dans même équipement, il y en a "+eqLogic.numDetector); + this.log('debug',"Detecteurs occupancy multiples dans même équipement, il y en a "+eqLogic.numDetector); SensorName=cmd.occupancy.name; } HBservice = { @@ -1571,7 +1562,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }; const Serv = HBservice.controlService; if(eqLogic.numDetector>1) { - that.log('debug',"Nom du détecteur (multi) : "+SensorName); + this.log('debug',"Nom du détecteur (multi) : "+SensorName); Serv.getCharacteristic(Characteristic.OccupancyDetected).displayName = SensorName; Serv.ConfiguredName=SensorName; @@ -1588,7 +1579,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.invertBinary=cmd.occupancy.display.invertBinary; } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.occupancy.id; Serv.eqID = eqLogic.id; @@ -1600,7 +1591,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.generic) { - eqLogic.services.generic.forEach(function(cmd) { + eqLogic.services.generic.forEach((cmd) => { if (cmd.state) { HBservice = { controlService : new Service.CustomService(cmd.state.name), @@ -1612,12 +1603,12 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos={}; Serv.infos.state=cmd.state; // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); var props = {}; var unite = ''; if(cmd.state.subType=="numeric") { - that.log('debug','Le générique',cmd.state.name,'est un numérique'); + this.log('debug','Le générique',cmd.state.name,'est un numérique'); // test if default value is Float or Int ? var CharactToSet=Characteristic.GenericFLOAT; var NumericGenericType='float'; @@ -1625,7 +1616,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { CharactToSet=Characteristic.GenericINT; NumericGenericType='int'; } - that.log('debug','Sur base de sa valeur actuelle',cmd.state.currentValue,', on determine un type :',NumericGenericType); + this.log('debug','Sur base de sa valeur actuelle',cmd.state.currentValue,', on determine un type :',NumericGenericType); HBservice.characteristics.push(CharactToSet); Serv.addCharacteristic(CharactToSet); Serv.getCharacteristic(CharactToSet).displayName = cmd.state.name; @@ -1642,16 +1633,16 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } } if(Object.keys(props).length !== 0) { - that.log('debug','On lui set les props suivants :',props); + this.log('debug','On lui set les props suivants :',props); Serv.getCharacteristic(CharactToSet).setProps(props); } } else if (cmd.state.subType=="binary") { - that.log('debug','Le générique',cmd.state.name,'est un booléen'); + this.log('debug','Le générique',cmd.state.name,'est un booléen'); HBservice.characteristics.push(Characteristic.GenericBOOL); Serv.addCharacteristic(Characteristic.GenericBOOL); Serv.getCharacteristic(Characteristic.GenericBOOL).displayName = cmd.state.name; } else if (cmd.state.subType=="string" || cmd.state.subType=="other") { - that.log('debug','Le générique',cmd.state.name,'est une chaîne'); + this.log('debug','Le générique',cmd.state.name,'est une chaîne'); HBservice.characteristics.push(Characteristic.GenericSTRING); Serv.addCharacteristic(Characteristic.GenericSTRING); Serv.getCharacteristic(Characteristic.GenericSTRING).displayName = cmd.state.name; @@ -1659,7 +1650,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { unite = cmd.state.unite ? cmd.state.unite : ''; if(unite) {props.unit=unite;} if(Object.keys(props).length !== 0) { - that.log('debug','On lui set les props suivants :',props); + this.log('debug','On lui set les props suivants :',props); Serv.getCharacteristic(Characteristic.GenericSTRING).setProps(props); } } @@ -1673,7 +1664,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.uv) { - eqLogic.services.uv.forEach(function(cmd) { + eqLogic.services.uv.forEach((cmd) => { if (cmd.uv) { HBservice = { controlService : new Service.WeatherService(eqLogic.name), @@ -1694,7 +1685,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.speaker) { - eqLogic.services.speaker.forEach(function(cmd) { + eqLogic.services.speaker.forEach((cmd) => { if (cmd.volume) { HBservice = { controlService : new Service.Speaker(eqLogic.name), @@ -1705,7 +1696,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.volume=cmd.volume; - eqServicesCopy.speaker.forEach(function(cmd2) { + eqServicesCopy.speaker.forEach((cmd2) => { if (cmd2.mute_toggle) { Serv.actions.mute_toggle = cmd2.mute_toggle; } else if (cmd2.mute_on) { @@ -1718,10 +1709,10 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.mute=cmd2.mute; } }); - if(!Serv.actions.set_volume) {that.log('warn','Pas de type générique "Action/Haut-Parleur Volume"');} - if(!Serv.actions.mute_toggle && !Serv.actions.mute_on && Serv.actions.mute_off) {that.log('warn','Pas de type générique "Action/Haut-Parleur Mute"');} - if(!Serv.actions.mute_toggle && Serv.actions.mute_on && !Serv.actions.mute_off) {that.log('warn','Pas de type générique "Action/Haut-Parleur UnMute"');} - if(!Serv.actions.mute_toggle && !Serv.actions.mute_on && !Serv.actions.mute_off) {that.log('warn','Pas de type générique "Action/Haut-Parleur Toggle Mute" / "Action/Haut-Parleur Mute" / "Action/Haut-Parleur UnMute"');} + if(!Serv.actions.set_volume) {this.log('warn','Pas de type générique "Action/Haut-Parleur Volume"');} + if(!Serv.actions.mute_toggle && !Serv.actions.mute_on && Serv.actions.mute_off) {this.log('warn','Pas de type générique "Action/Haut-Parleur Mute"');} + if(!Serv.actions.mute_toggle && Serv.actions.mute_on && !Serv.actions.mute_off) {this.log('warn','Pas de type générique "Action/Haut-Parleur UnMute"');} + if(!Serv.actions.mute_toggle && !Serv.actions.mute_on && !Serv.actions.mute_off) {this.log('warn','Pas de type générique "Action/Haut-Parleur Toggle Mute" / "Action/Haut-Parleur Mute" / "Action/Haut-Parleur UnMute"');} Serv.cmd_id = cmd.volume.id; Serv.eqID = eqLogic.id; Serv.subtype = Serv.subtype || ''; @@ -1730,13 +1721,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Haut-Parleur Volume"'); + this.log('warn','Pas de type générique "Info/Haut-Parleur Volume"'); } else { HBservice = null; } } if (eqLogic.services.temperature) { - eqLogic.services.temperature.forEach(function(cmd) { + eqLogic.services.temperature.forEach((cmd) => { if (cmd.temperature) { HBservice = { controlService : new Service.TemperatureSensor(eqLogic.name), @@ -1753,14 +1744,14 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.getCharacteristic(Characteristic.TemperatureDisplayUnits).updateValue(Characteristic.TemperatureDisplayUnits.CELSIUS); // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.temperature.id; Serv.eqID = eqLogic.id; Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService ={type:"weather", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService ={type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -1771,7 +1762,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.humidity) { - eqLogic.services.humidity.forEach(function(cmd) { + eqLogic.services.humidity.forEach((cmd) => { if (cmd.humidity) { HBservice = { controlService : new Service.HumiditySensor(eqLogic.name), @@ -1783,15 +1774,15 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos={}; Serv.infos.humidity=cmd.humidity; // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.humidity.id; Serv.eqID = eqLogic.id; Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService = {type:"weather", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService = {type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -1801,7 +1792,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.pressure) { - eqLogic.services.pressure.forEach(function(cmd) { + eqLogic.services.pressure.forEach((cmd) => { if (cmd.pressure) { HBservice = { controlService : new Service.PressureSensor(eqLogic.name), @@ -1817,8 +1808,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService = {type:"weather", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService = {type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -1828,7 +1819,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.smoke) { - eqLogic.services.smoke.forEach(function(cmd) { + eqLogic.services.smoke.forEach((cmd) => { if (cmd.smoke) { HBservice = { controlService : new Service.SmokeSensor(eqLogic.name), @@ -1844,7 +1835,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.invertBinary=cmd.smoke.display.invertBinary; } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.smoke.id; Serv.eqID = eqLogic.id; @@ -1856,7 +1847,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.flood) { - eqLogic.services.flood.forEach(function(cmd) { + eqLogic.services.flood.forEach((cmd) => { if (cmd.flood) { HBservice = { controlService : new Service.LeakSensor(eqLogic.name), @@ -1872,7 +1863,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.invertBinary=cmd.flood.display.invertBinary; } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.flood.id; Serv.eqID = eqLogic.id; @@ -1884,7 +1875,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.opening) { - eqLogic.services.opening.forEach(function(cmd) { + eqLogic.services.opening.forEach((cmd) => { if (cmd.opening) { HBservice = { controlService : new Service.ContactSensor(eqLogic.name), @@ -1900,14 +1891,14 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.invertBinary=cmd.opening.display.invertBinary; } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.opening.id; Serv.eqID = eqLogic.id; Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { + if(this.fakegato && !eqLogic.hasLogging) { // Serv.eqLogic.numberOpened = 0; HBservice.characteristics.push(Characteristic.TimesOpened,Characteristic.Char118,Characteristic.Char119,Characteristic.ResetTotal,Characteristic.LastActivation); Serv.addOptionalCharacteristic(Characteristic.TimesOpened); @@ -1916,7 +1907,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.addOptionalCharacteristic(Characteristic.ResetTotal); Serv.addOptionalCharacteristic(Characteristic.LastActivation); - eqLogic.loggingService = {type:"door", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.loggingService = {type:"door", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -1926,7 +1917,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.brightness) { - eqLogic.services.brightness.forEach(function(cmd) { + eqLogic.services.brightness.forEach((cmd) => { if (cmd.brightness) { HBservice = { controlService : new Service.LightSensor(eqLogic.name), @@ -1938,17 +1929,17 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos={}; Serv.infos.brightness=cmd.brightness; // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.brightness.id; Serv.eqID = eqLogic.id; Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { + if(this.fakegato && !eqLogic.hasLogging) { // HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.loggingService = {type:"custom", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.loggingService = {type:"custom", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -1958,7 +1949,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.GarageDoor) { - eqLogic.services.GarageDoor.forEach(function(cmd) { + eqLogic.services.GarageDoor.forEach((cmd) => { if (cmd.state) { HBservice = { controlService : new Service.GarageDoorOpener(eqLogic.name), @@ -1969,7 +1960,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.state=cmd.state; - eqServicesCopy.GarageDoor.forEach(function(cmd2) { + eqServicesCopy.GarageDoor.forEach((cmd2) => { if (cmd2.on) { Serv.actions.on = cmd2.on; } else if (cmd2.off) { @@ -1978,16 +1969,16 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions.toggle = cmd2.toggle; } }); - if(!Serv.actions.toggle && !Serv.actions.on && Serv.actions.off) {that.log('warn','Pas de type générique "Action/Portail ou garage bouton d\'ouverture"');} - if(!Serv.actions.toggle && Serv.actions.on && !Serv.actions.off) {that.log('warn','Pas de type générique "Action/Portail ou garage bouton de fermeture"');} - if(!Serv.actions.toggle && !Serv.actions.on && !Serv.actions.off) {that.log('warn','Pas de type générique ""Action/Portail ou garage bouton toggle" / "Action/Portail ou garage bouton d\'ouverture" / "Action/Portail ou garage bouton de fermeture"');} + if(!Serv.actions.toggle && !Serv.actions.on && Serv.actions.off) {this.log('warn','Pas de type générique "Action/Portail ou garage bouton d\'ouverture"');} + if(!Serv.actions.toggle && Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Portail ou garage bouton de fermeture"');} + if(!Serv.actions.toggle && !Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique ""Action/Portail ou garage bouton toggle" / "Action/Portail ou garage bouton d\'ouverture" / "Action/Portail ou garage bouton de fermeture"');} if(eqLogic.customizedValues) { Serv.customizedValues = eqLogic.customizedValues; } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.state.id; Serv.eqID = eqLogic.id; @@ -1997,13 +1988,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Garage état ouvrant" ou "Info/Portail état ouvrant"'); + this.log('warn','Pas de type générique "Info/Garage état ouvrant" ou "Info/Portail état ouvrant"'); } else { HBservice = null; } } if (eqLogic.services.lock) { - eqLogic.services.lock.forEach(function(cmd) { + eqLogic.services.lock.forEach((cmd) => { if (cmd.state) { HBservice = { controlService : new Service.LockMechanism(eqLogic.name), @@ -2014,18 +2005,18 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.actions={}; Serv.infos={}; Serv.infos.state=cmd.state; - eqServicesCopy.lock.forEach(function(cmd2) { + eqServicesCopy.lock.forEach((cmd2) => { if (cmd2.on) { Serv.actions.on = cmd2.on; } else if (cmd2.off) { Serv.actions.off = cmd2.off; } }); - if(!Serv.actions.on) {that.log('warn','Pas de type générique "Action/Serrure Bouton Ouvrir"');} - // if(!Serv.actions.off) {that.log('warn','Pas de type générique "Action/Serrure Bouton Fermer"');} + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Serrure Bouton Ouvrir"');} + // if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Serrure Bouton Fermer"');} // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.state.id; Serv.eqID = eqLogic.id; @@ -2035,13 +2026,13 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); if(!HBservice) { - that.log('warn','Pas de type générique "Info/Serrure Etat"'); + this.log('warn','Pas de type générique "Info/Serrure Etat"'); } else { HBservice = null; } } if (eqLogic.services.StatelessSwitch) { - eqLogic.services.StatelessSwitch.forEach(function(cmd) { + eqLogic.services.StatelessSwitch.forEach((cmd) => { if(cmd.eventType) { let buttonSingle,buttonDouble,buttonLong; @@ -2081,7 +2072,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { if(buttonSingle[b].trim() != '') {values.push(Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);} if(buttonDouble[b].trim() != '') {values.push(Characteristic.ProgrammableSwitchEvent.DOUBLE_PRESS);} if(buttonLong[b].trim() != '') {values.push(Characteristic.ProgrammableSwitchEvent.LONG_PRESS);} - that.log('debug','ValidValues',values); + this.log('debug','ValidValues',values); Serv.getCharacteristic(Characteristic.ProgrammableSwitchEvent).setProps({validValues:values}); Serv.getCharacteristic(Characteristic.ServiceLabelIndex).updateValue(Serv.ServiceLabelIndex); @@ -2111,14 +2102,14 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } } else { - that.log('warn',"Pas le même nombre de boutons pour chaque évènement (il doit y avoir le même nombre de ';')"); + this.log('warn',"Pas le même nombre de boutons pour chaque évènement (il doit y avoir le même nombre de ';')"); } } }); } if (eqLogic.services.StatelessSwitchMono) { const buttonList=[]; - eqLogic.services.StatelessSwitchMono.forEach(function(cmd) { + eqLogic.services.StatelessSwitchMono.forEach((cmd) => { if(cmd.Single || cmd.Double || cmd.Long) { let Label = ""; if(cmd.Single) {Label = "Simple";} @@ -2169,7 +2160,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.cmd_id += Serv.infos.Long.id; break; } - that.log('debug','ValidValues 0 Mono',values); + this.log('debug','ValidValues 0 Mono',values); Serv.getCharacteristic(Characteristic.ProgrammableSwitchEvent).setProps({validValues:values}); @@ -2225,7 +2216,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.Long=cmdType.Long; Serv.cmd_id += Serv.infos.Long.id; } - that.log('debug','ValidValues '+b+' Mono',values); + this.log('debug','ValidValues '+b+' Mono',values); Serv.getCharacteristic(Characteristic.ProgrammableSwitchEvent).setProps({validValues:values}); @@ -2260,7 +2251,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.weather) { - eqLogic.services.weather.forEach(function(cmd) { + eqLogic.services.weather.forEach((cmd) => { if(cmd.temperature) { HBservice = { controlService : new Service.TemperatureSensor(eqLogic.name), @@ -2278,7 +2269,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.getCharacteristic(Characteristic.TemperatureDisplayUnits).updateValue(Characteristic.TemperatureDisplayUnits.CELSIUS); // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); Serv.cmd_id = cmd.temperature.id; Serv.eqID = eqLogic.id; @@ -2286,8 +2277,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService ={type:"weather", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService ={type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -2311,8 +2302,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService ={type:"weather", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService ={type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -2336,8 +2327,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService ={type:"weather", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService ={type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } @@ -2355,7 +2346,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos={}; Serv.infos.condition=cmd.condition; - eqServicesCopy.weather.forEach(function(cmd2) { + eqServicesCopy.weather.forEach((cmd2) => { if (cmd2.wind_speed) { Serv.infos.wind_speed=cmd2.wind_speed; HBservice.characteristics.push(Characteristic.WindSpeed); @@ -2420,7 +2411,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.thermostat) { - eqLogic.services.thermostat.forEach(function(cmd) { + eqLogic.services.thermostat.forEach((cmd) => { if(cmd.setpoint) { HBservice = { controlService : new Service.Thermostat(eqLogic.name), @@ -2437,7 +2428,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.addOptionalCharacteristic(Characteristic.TemperatureDisplayUnits); Serv.getCharacteristic(Characteristic.TemperatureDisplayUnits).updateValue(Characteristic.TemperatureDisplayUnits.CELSIUS); - eqServicesCopy.thermostat.forEach(function(cmd2) { + eqServicesCopy.thermostat.forEach((cmd2) => { if (cmd2.state_name) { Serv.infos.state_name=cmd2.state_name; } else if (cmd2.lock) { @@ -2471,7 +2462,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.getCharacteristic(Characteristic.TargetTemperature).setProps(props); } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); props = {}; props.validValues=[0]; @@ -2483,7 +2474,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.thermo.chauf.mode_id = splitted[0]; props.validValues.push(1); } else { - that.log('warn','Pas de config du mode Chauffage'); + this.log('warn','Pas de config du mode Chauffage'); } if(eqLogic.thermoModes.Clim && eqLogic.thermoModes.Clim != "NOT") { Serv.thermo.clim = {}; @@ -2492,7 +2483,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.thermo.clim.mode_id = splitted[0]; props.validValues.push(2); } else { - that.log('warn','Pas de config du mode Climatisation'); + this.log('warn','Pas de config du mode Climatisation'); } if(eqLogic.thermoModes.Off && eqLogic.thermoModes.Off != "NOT") { Serv.thermo.off = {}; @@ -2500,8 +2491,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.thermo.off.mode_label = splitted[1]; Serv.thermo.off.mode_id = splitted[0]; } - } else if(that.myPlugin == "homebridge") { - that.log('warn','Pas de config des modes du thermostat'); + } else if(this.myPlugin == "homebridge") { + this.log('warn','Pas de config des modes du thermostat'); } // Serv.getCharacteristic(Characteristic.CurrentHeatingCoolingState).setProps(props); props.validValues.push(3); @@ -2510,8 +2501,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.eqID = eqLogic.id; Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(that.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService ={type:"thermo", options:{storage:'fs',path:that.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService ={type:"thermo", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; eqLogic.hasLogging=true; } HBservices.push(HBservice); @@ -2520,7 +2511,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.thermostatHC) { - eqLogic.services.thermostatHC.forEach(function(cmd) { + eqLogic.services.thermostatHC.forEach((cmd) => { if(cmd.setpointH) { HBservice = { controlService : new Service.HeaterCooler(eqLogic.name), @@ -2537,7 +2528,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.addOptionalCharacteristic(Characteristic.TemperatureDisplayUnits); Serv.getCharacteristic(Characteristic.TemperatureDisplayUnits).updateValue(Characteristic.TemperatureDisplayUnits.CELSIUS); - eqServicesCopy.thermostatHC.forEach(function(cmd2) { + eqServicesCopy.thermostatHC.forEach((cmd2) => { if (cmd2.setpointC) { Serv.infos.setpointC=cmd2.setpointC; } else if (cmd2.state_name) { @@ -2585,7 +2576,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.getCharacteristic(Characteristic.CoolingThresholdTemperature).setProps(props); } // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); props = {}; props.validValues=[0]; @@ -2597,7 +2588,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.thermoHC.chauf.mode_id = splitted[0]; props.validValues.push(1); } else { - that.log('warn','Pas de config du mode Chauffage'); + this.log('warn','Pas de config du mode Chauffage'); } if(eqLogic.thermoModes.Clim && eqLogic.thermoModes.Clim != "NOT") { Serv.thermoHC.clim = {}; @@ -2606,7 +2597,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.thermoHC.clim.mode_id = splitted[0]; props.validValues.push(2); } else { - that.log('warn','Pas de config du mode Climatisation'); + this.log('warn','Pas de config du mode Climatisation'); } if(eqLogic.thermoModes.Off && eqLogic.thermoModes.Off != "NOT") { Serv.thermoHC.off = {}; @@ -2615,8 +2606,8 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.thermoHC.off.mode_id = splitted[0]; } } - else if(that.myPlugin == "homebridge") { - that.log('warn','Pas de config des modes du thermostatHC'); + else if(this.myPlugin == "homebridge") { + this.log('warn','Pas de config des modes du thermostatHC'); } // Serv.getCharacteristic(Characteristic.CurrentHeatingCoolingState).setProps(props); props.validValues.push(3); @@ -2632,7 +2623,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.mode) { let modeState=null; - eqLogic.services.mode.forEach(function(cmd) { + eqLogic.services.mode.forEach((cmd) => { if(cmd.state) { HBservice = { controlService : new Service.CustomService(eqLogic.name), @@ -2658,9 +2649,9 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); if(modeState) { var set_state_previous = null; - eqLogic.services.mode.forEach(function(cmd) { + eqLogic.services.mode.forEach((cmd) => { if (cmd.set_state) { - cmd.set_state.forEach(function(set_action) { + cmd.set_state.forEach((set_action) => { var ModeName = ""; if(set_action.name.toLowerCase().includes('mode') || set_action.name.toLowerCase().includes('modo')) { ModeName = set_action.name; @@ -2682,7 +2673,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(ModeName); if(!set_state_previous) { - eqServicesCopy.mode.forEach(function(cmd2) { + eqServicesCopy.mode.forEach((cmd2) => { if (cmd2.set_state_previous) { Serv.actions.set_state_previous=cmd2.set_state_previous; set_state_previous=cmd2.set_state_previous; @@ -2706,11 +2697,11 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } }); } else { - that.log('warn','Vous utilisez le type générique Mode en dehors du plugin Mode !'); + this.log('warn','Vous utilisez le type générique Mode en dehors du plugin Mode !'); } } if (eqLogic.services.siren) { - eqLogic.services.siren.forEach(function(cmd) { + eqLogic.services.siren.forEach((cmd) => { if(cmd.state) { HBservice = { controlService : new Service.SecuritySystem(eqLogic.name), @@ -2723,7 +2714,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos.state=cmd.state; Serv.siren=true; - eqServicesCopy.siren.forEach(function(cmd2) { + eqServicesCopy.siren.forEach((cmd2) => { if (cmd2.on) { Serv.actions.on=cmd2.on; } else if (cmd2.off) { @@ -2732,7 +2723,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); // Serv.getCharacteristic(Characteristic.SecuritySystemCurrentState).setProps({validValues:[3,4]}); Serv.getCharacteristic(Characteristic.SecuritySystemTargetState).setProps({validValues:[3]}); @@ -2746,7 +2737,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); } if (eqLogic.services.alarm) { - eqLogic.services.alarm.forEach(function(cmd) { + eqLogic.services.alarm.forEach((cmd) => { if(cmd.enable_state) { HBservice = { controlService : new Service.SecuritySystem(eqLogic.name), @@ -2758,7 +2749,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.infos={}; Serv.infos.enable_state=cmd.enable_state; Serv.alarm={}; - eqServicesCopy.alarm.forEach(function(cmd2) { + eqServicesCopy.alarm.forEach((cmd2) => { if (cmd2.state) { Serv.infos.state=cmd2.state; } else if (cmd2.mode) { @@ -2767,7 +2758,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { }); // add Active, Tampered and Defect Characteristics if needed - HBservice=that.createStatusCharact(HBservice,eqServicesCopy); + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); var props = {}; props.validValues=[]; @@ -2781,7 +2772,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { props.validValues.push(Characteristic.SecuritySystemTargetState.STAY_ARM); Serv.hasAlarmModes=true; } else { - that.log('warn','Pas de config du mode Domicile/Présence'); + this.log('warn','Pas de config du mode Domicile/Présence'); } if(eqLogic.alarmModes.SetModeAbsent && eqLogic.alarmModes.SetModeAbsent != "NOT") { Serv.alarm.away = {}; @@ -2791,7 +2782,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { props.validValues.push(Characteristic.SecuritySystemTargetState.AWAY_ARM); Serv.hasAlarmModes=true; } else { - that.log('warn','Pas de config du mode À distance/Absence'); + this.log('warn','Pas de config du mode À distance/Absence'); } if(eqLogic.alarmModes.SetModeNuit && eqLogic.alarmModes.SetModeNuit != "NOT") { Serv.alarm.night = {}; @@ -2801,12 +2792,12 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { props.validValues.push(Characteristic.SecuritySystemTargetState.NIGHT_ARM); Serv.hasAlarmModes=true; } else { - that.log('warn','Pas de config du mode Nuit'); + this.log('warn','Pas de config du mode Nuit'); } } - if(that.myPlugin == "homebridge" && !Serv.hasAlarmModes) { + if(this.myPlugin == "homebridge" && !Serv.hasAlarmModes) { props.validValues.push(Characteristic.SecuritySystemTargetState.AWAY_ARM); - that.log('warn','Pas de config des modes de l\'alarme'); + this.log('warn','Pas de config des modes de l\'alarme'); } props.validValues.push(Characteristic.SecuritySystemTargetState.DISARM); Serv.getCharacteristic(Characteristic.SecuritySystemTargetState).setProps(props); @@ -2821,18 +2812,18 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (HBservices.length != 0) { - if (DEV_DEBUG) {that.log('debug','HBservices : '+JSON.stringify(HBservices));} - createdAccessory = that.createAccessory(HBservices, eqLogic); - that.addAccessory(createdAccessory); + if (DEV_DEBUG) {this.log('debug','HBservices : '+JSON.stringify(HBservices));} + createdAccessory = this.createAccessory(HBservices, eqLogic); + this.addAccessory(createdAccessory); HBservices = []; } else { - that.log('│ Accessoire sans Type Générique d\'Etat'); - createdAccessory = that.createAccessory([], eqLogic); // create a cached lookalike object for unregistering it - that.delAccessory(createdAccessory); + this.log('│ Accessoire sans Type Générique d\'Etat'); + createdAccessory = this.createAccessory([], eqLogic); // create a cached lookalike object for unregistering it + this.delAccessory(createdAccessory); } - that.log('└─────────'); + this.log('└─────────'); } catch(e){ this.log('error','Erreur de la fonction AccessoireCreateHomebridge :',e); @@ -3166,8 +3157,6 @@ JeedomPlatform.prototype.bindCharacteristicEvents = function(characteristic, ser // -- Return : nothing JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, service) { try{ - const that = this; - var action,rgb,cmdId; switch (characteristic.UUID) { case Characteristic.ConfiguredName.UUID : @@ -3184,10 +3173,10 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser action = 'stop'; cmdId = service.cmd_id; - that.jeedomClient.executeScenarioAction(cmdId, action).then(function(response) { - that.log('info','[Commande Scenario envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'response:'+JSON.stringify(response)); - }).catch(function(err) { - that.log('error','Erreur à l\'envoi de la commande Scenario ' + action + ' vers ' + cmdId , err); + this.jeedomClient.executeScenarioAction(cmdId, action).then((response) => { + this.log('info','[Commande Scenario envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'response:'+JSON.stringify(response)); + }).catch((err) => { + this.log('error','Erreur à l\'envoi de la commande Scenario ' + action + ' vers ' + cmdId , err); if(err && err.stack) { console.error(err.stack); } }); } else { @@ -3195,27 +3184,27 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser action = 'run'; cmdId = service.cmd_id; - that.jeedomClient.executeScenarioAction(cmdId, action).then(function(response) { - that.log('info','[Commande Scenario envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'response:'+JSON.stringify(response)); - }).catch(function(err) { - that.log('error','Erreur à l\'envoi de la commande Scenario ' + action + ' vers ' + cmdId , err); + this.jeedomClient.executeScenarioAction(cmdId, action).then((response) => { + this.log('info','[Commande Scenario envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'response:'+JSON.stringify(response)); + }).catch((err) => { + this.log('error','Erreur à l\'envoi de la commande Scenario ' + action + ' vers ' + cmdId , err); if(err && err.stack) { console.error(err.stack); } }); } } else if (service.actions.Push){ if(value == 1) { this.command('Pushed', null, service); - setTimeout(function() { + setTimeout(() => { characteristic.updateValue(sanitizeValue(false,characteristic), undefined, 'fromSetValue'); }, 100); } } else if (service.modeSwitch) { // modes plugin if(value == 0) {// turnOff // execute set mode Previous - that.log('debug','info about previous mode',service); + this.log('debug','info about previous mode',service); this.command('modeSetPrevious', null, service); } else {// turnOn - that.log('debug','info about mode',service); + this.log('debug','info about mode',service); this.command('modeSet', null, service); } } else { @@ -3245,7 +3234,7 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser } else { value = characteristic.value; } - setTimeout(function() { + setTimeout(() => { characteristic.updateValue(sanitizeValue(value,characteristic), undefined, 'fromSetValue'); }, 100); break; @@ -3256,7 +3245,7 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser } else { value = characteristic.value; } - setTimeout(function() { + setTimeout(() => { characteristic.updateValue(sanitizeValue(value,characteristic), undefined, 'fromSetValue'); }, 100); break; @@ -3267,7 +3256,7 @@ JeedomPlatform.prototype.setAccessoryValue = function(value, characteristic, ser } else { value = characteristic.value; } - setTimeout(function() { + setTimeout(() => { characteristic.updateValue(sanitizeValue(value,characteristic), undefined, 'fromSetValue'); }, 100); break; @@ -3574,21 +3563,20 @@ JeedomPlatform.prototype.findAccessoryByService = function(serviceToFind) { }; JeedomPlatform.prototype.changeAccessoryValue = function(characteristic, service) { - const that = this; - const cmdList = that.jeedomClient.getDeviceCmdFromCache(service.eqID); + const cmdList = this.jeedomClient.getDeviceCmdFromCache(service.eqID); switch (characteristic.UUID) { case Characteristic.ContactSensorState.UUID : for (const cmd of cmdList) { if ((cmd.generic_type == 'OPENING' || cmd.generic_type == 'OPENING_WINDOW') && cmd.id == service.cmd_id) { - if(that.fakegato) { + if(this.fakegato) { const realValue = parseInt(service.invertBinary)==0 ? toBool(cmd.currentValue) : !toBool(cmd.currentValue); // invertBinary ? if(realValue === false) { service.eqLogic.numberOpened++; } service.eqLogic.lastAct=Math.round(new Date().valueOf() / 1000)-service.eqLogic.loggingService.getInitialTime(); - that.api.updatePlatformAccessories([this.findAccessoryByService(service)]); + this.api.updatePlatformAccessories([this.findAccessoryByService(service)]); } break; } @@ -3597,9 +3585,9 @@ JeedomPlatform.prototype.changeAccessoryValue = function(characteristic, service case Characteristic.MotionDetected.UUID : for (const cmd of cmdList) { if (cmd.generic_type == 'PRESENCE' && cmd.id == service.cmd_id) { - if(that.fakegato) { + if(this.fakegato) { service.eqLogic.lastAct=Math.round(new Date().valueOf() / 1000)-service.eqLogic.loggingService.getInitialTime(); - that.api.updatePlatformAccessories([this.findAccessoryByService(service)]); + this.api.updatePlatformAccessories([this.findAccessoryByService(service)]); } break; } @@ -3616,8 +3604,6 @@ JeedomPlatform.prototype.changeAccessoryValue = function(characteristic, service // -- Return : nothing JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, info=null) { try{ - const that = this; - let customizedValues={}; if(service.customizedValues) { customizedValues=service.customizedValues; @@ -3627,7 +3613,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i let returnValue = 0; let HRreturnValue; - const cmdList = that.jeedomClient.getDeviceCmdFromCache(service.eqID); + const cmdList = this.jeedomClient.getDeviceCmdFromCache(service.eqID); let targetValueToTest,currentValueToTest; let hsv,mode_PRESENT,mode_AWAY,mode_NIGHT,mode_CLIM,mode_CHAUF; @@ -3643,7 +3629,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i break; case Characteristic.On.UUID : if(service.infos.scenario) { - const scenario = that.jeedomClient.getScenarioPropertiesFromCache(service.infos.scenario.id); + const scenario = this.jeedomClient.getScenarioPropertiesFromCache(service.infos.scenario.id); switch(scenario.state) { case 'stop': returnValue = false; @@ -3652,7 +3638,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i returnValue = true; break; } - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), status: ((returnValue)?1:0), @@ -3711,7 +3697,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i break; } else if ((cmd.generic_type == "SWITCH_STATE" || cmd.generic_type == "CAMERA_RECORD_STATE") && cmd.id == service.cmd_id) { returnValue = cmd.currentValue; - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), status: ((returnValue)?1:0), @@ -3750,11 +3736,11 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i break; // Generics case Characteristic.TimesOpened.UUID : - that.log('info','Demande du nombre d\'ouverture de la porte',service.eqLogic.numberOpened); + this.log('info','Demande du nombre d\'ouverture de la porte',service.eqLogic.numberOpened); returnValue = service.eqLogic.numberOpened; break; case Characteristic.LastActivation.UUID : - that.log('info','Demande de la dernière activation',service.eqLogic.lastAct); + this.log('info','Demande de la dernière activation',service.eqLogic.lastAct); returnValue = service.eqLogic.lastAct; break; case Characteristic.ServiceLabelIndex.UUID : @@ -3825,7 +3811,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i for (const cmd of cmdList) { if (cmd.generic_type == 'CO2' && cmd.id == service.cmd_id) { returnValue = parseInt(cmd.currentValue); - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), ppm: returnValue, @@ -3842,7 +3828,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(service.infos.Index && service.infos.Index.unite && service.infos.Index.unite.toLowerCase() == 'ppb') { // unit should be µg/m3 if it's ppb, multiply it by 4.57 returnValue = parseInt(returnValue*4.57); } - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), voc: returnValue, @@ -3914,7 +3900,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } else { returnValue = Characteristic.ContactSensorState.CONTACT_DETECTED; } - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { /* if(returnValue === Characteristic.ContactSensorState.CONTACT_NOT_DETECTED) { service.eqLogic.numberOpened++; } */ @@ -3932,7 +3918,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i for (const cmd of cmdList) { if (cmd.generic_type == 'BRIGHTNESS' && cmd.id == service.cmd_id) { returnValue = cmd.currentValue; - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), lux: returnValue, @@ -3950,7 +3936,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i (cmd.generic_type == 'WEATHER_TEMPERATURE' && cmd.id == service.infos.temperature.id)) { returnValue = cmd.currentValue; - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { if (cmd.generic_type == 'TEMPERATURE' || cmd.generic_type == 'WEATHER_TEMPERATURE') { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), @@ -3976,7 +3962,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i (cmd.generic_type == 'WEATHER_HUMIDITY' && cmd.id == service.infos.humidity.id)) { returnValue = cmd.currentValue; - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), humidity: returnValue, @@ -3992,7 +3978,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i (cmd.generic_type == 'WEATHER_PRESSURE' && cmd.id == service.infos.pressure.id)) { returnValue = cmd.currentValue; - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), pressure: returnValue, @@ -4074,7 +4060,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if (cmd.generic_type == 'PRESENCE' && cmd.id == service.cmd_id) { // returnValue = parseInt(service.invertBinary)==0 ? !toBool(cmd.currentValue) : toBool(cmd.currentValue); // invertBinary ? returnValue = toBool(cmd.currentValue); - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), status: returnValue?1:0, @@ -4138,8 +4124,8 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(maxJeedom) { returnValue = Math.round((returnValue / maxJeedom)*100); } - if (DEV_DEBUG) {that.log('debug','---------update Power(refresh):',returnValue,'% soit',cmd.currentValue,' / ',maxJeedom);} - // that.log('debug','------------PowerVentilo jeedom :',cmd.currentValue,'soit en homekit :',returnValue); + if (DEV_DEBUG) {this.log('debug','---------update Power(refresh):',returnValue,'% soit',cmd.currentValue,' / ',maxJeedom);} + // this.log('debug','------------PowerVentilo jeedom :',cmd.currentValue,'soit en homekit :',returnValue); break; } } @@ -4190,7 +4176,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i break; } } - hsv = that.updateHomeKitColorFromJeedom(returnValue, service); + hsv = this.updateHomeKitColorFromJeedom(returnValue, service); returnValue = Math.round(hsv.h); break; case Characteristic.Saturation.UUID : @@ -4200,7 +4186,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i break; } } - hsv = that.updateHomeKitColorFromJeedom(returnValue, service); + hsv = this.updateHomeKitColorFromJeedom(returnValue, service); returnValue = Math.round(hsv.s); break; case Characteristic.ColorTemperature.UUID : @@ -4224,8 +4210,8 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(maxJeedom != 0) { returnValue = Math.round((returnValue / maxJeedom)*100); } - if (DEV_DEBUG) {that.log('debug','---------update Bright(refresh):',returnValue,'% soit',cmd.currentValue,' / ',maxJeedom);} - // that.log('debug','------------Brightness jeedom :',cmd.currentValue,'soit en homekit :',returnValue); + if (DEV_DEBUG) {this.log('debug','---------update Bright(refresh):',returnValue,'% soit',cmd.currentValue,' / ',maxJeedom);} + // this.log('debug','------------Brightness jeedom :',cmd.currentValue,'soit en homekit :',returnValue); break; } else if (cmd.generic_type == 'LIGHT_BRIGHTNESS' && cmd.id == service.infos.brightness.id) { const maxJeedom = parseInt(service.maxBright) || 100; @@ -4233,8 +4219,8 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(maxJeedom != 0) { returnValue = Math.round((returnValue / maxJeedom)*100); } - if (DEV_DEBUG) {that.log('debug','---------update Bright(refresh):',returnValue,'% soit',cmd.currentValue,' / ',maxJeedom);} - // that.log('debug','------------Brightness jeedom :',cmd.currentValue,'soit en homekit :',returnValue); + if (DEV_DEBUG) {this.log('debug','---------update Bright(refresh):',returnValue,'% soit',cmd.currentValue,' / ',maxJeedom);} + // this.log('debug','------------Brightness jeedom :',cmd.currentValue,'soit en homekit :',returnValue); break; } } @@ -4249,34 +4235,34 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } for (const cmd of cmdList) { if (cmd.generic_type == 'SIREN_STATE') { - if (DEV_DEBUG) {that.log('debug',"Siren_state T=",cmd.currentValue);} + if (DEV_DEBUG) {this.log('debug',"Siren_state T=",cmd.currentValue);} returnValue = Characteristic.SecuritySystemTargetState.DISARM; break; } if(!service.hasAlarmModes) { if (cmd.generic_type == 'ALARM_ENABLE_STATE' && cmd.currentValue == 1) { - if (DEV_DEBUG) {that.log('debug',"Alarm_enable_state T=",cmd.currentValue,"NO MODES");} + if (DEV_DEBUG) {this.log('debug',"Alarm_enable_state T=",cmd.currentValue,"NO MODES");} returnValue = Characteristic.SecuritySystemTargetState.AWAY_ARM; break; } else if (cmd.generic_type == 'ALARM_ENABLE_STATE' && cmd.currentValue == 0) { - if (DEV_DEBUG) {that.log('debug',"Alarm_enable_state T=",cmd.currentValue,"NO MODES");} + if (DEV_DEBUG) {this.log('debug',"Alarm_enable_state T=",cmd.currentValue,"NO MODES");} returnValue = Characteristic.SecuritySystemTargetState.DISARM; break; } } else { if (cmd.generic_type == 'ALARM_ENABLE_STATE' && cmd.currentValue == 0) { - if (DEV_DEBUG) {that.log('debug',"Alarm_enable_state T=",cmd.currentValue);} + if (DEV_DEBUG) {this.log('debug',"Alarm_enable_state T=",cmd.currentValue);} returnValue = Characteristic.SecuritySystemTargetState.DISARM; break; } if (cmd.generic_type == 'ALARM_ENABLE_STATE' && cmd.currentValue == 1) { // if there is mode and alarm is enabled, will continue the search for mode instead ! - if (DEV_DEBUG) {that.log('debug',"Alarm_enable_state T=",cmd.currentValue,'return undefined');} + if (DEV_DEBUG) {this.log('debug',"Alarm_enable_state T=",cmd.currentValue,'return undefined');} returnValue = undefined; continue; } if (cmd.generic_type == 'ALARM_MODE') { - if (DEV_DEBUG) {that.log('debug',"alarm_mode T=",cmd.currentValue);} + if (DEV_DEBUG) {this.log('debug',"alarm_mode T=",cmd.currentValue);} if(service.alarm.present && service.alarm.present.mode_label != undefined) { mode_PRESENT=service.alarm.present.mode_label?.toLowerCase(); @@ -4289,23 +4275,23 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } switch (cmd.currentValue?.toLowerCase()) { case undefined: - if (DEV_DEBUG) {that.log('debug',"renvoie absent T via undefined",Characteristic.SecuritySystemTargetState.AWAY_ARM);} + if (DEV_DEBUG) {this.log('debug',"renvoie absent T via undefined",Characteristic.SecuritySystemTargetState.AWAY_ARM);} returnValue = Characteristic.SecuritySystemTargetState.AWAY_ARM; break; default: // back compatibility - if (DEV_DEBUG) {that.log('debug',"renvoie absent T via default",Characteristic.SecuritySystemTargetState.AWAY_ARM);} + if (DEV_DEBUG) {this.log('debug',"renvoie absent T via default",Characteristic.SecuritySystemTargetState.AWAY_ARM);} returnValue = Characteristic.SecuritySystemTargetState.AWAY_ARM; break; case mode_PRESENT: - if (DEV_DEBUG) {that.log('debug',"renvoie present T",Characteristic.SecuritySystemTargetState.STAY_ARM);} + if (DEV_DEBUG) {this.log('debug',"renvoie present T",Characteristic.SecuritySystemTargetState.STAY_ARM);} returnValue = Characteristic.SecuritySystemTargetState.STAY_ARM; break; case mode_AWAY: - if (DEV_DEBUG) {that.log('debug',"renvoie absent T",Characteristic.SecuritySystemTargetState.AWAY_ARM);} + if (DEV_DEBUG) {this.log('debug',"renvoie absent T",Characteristic.SecuritySystemTargetState.AWAY_ARM);} returnValue = Characteristic.SecuritySystemTargetState.AWAY_ARM; break; case mode_NIGHT: - if (DEV_DEBUG) {that.log('debug',"renvoie nuit T",Characteristic.SecuritySystemTargetState.NIGHT_ARM);} + if (DEV_DEBUG) {this.log('debug',"renvoie nuit T",Characteristic.SecuritySystemTargetState.NIGHT_ARM);} returnValue = Characteristic.SecuritySystemTargetState.NIGHT_ARM; break; } @@ -4325,56 +4311,56 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i for (const cmd of cmdList) { if (cmd.generic_type == 'SIREN_STATE') { if (cmd.currentValue == 1) { - if (DEV_DEBUG) {that.log('debug',"Siren_State C=",cmd.currentValue);} + if (DEV_DEBUG) {this.log('debug',"Siren_State C=",cmd.currentValue);} returnValue = Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED; break; } else if (cmd.currentValue == 0) { - if (DEV_DEBUG) {that.log('debug',"Siren_state C=",cmd.currentValue);} + if (DEV_DEBUG) {this.log('debug',"Siren_state C=",cmd.currentValue);} returnValue = Characteristic.SecuritySystemCurrentState.DISARMED; break; } else { - if (DEV_DEBUG) {that.log('debug',"Siren_state C IMPOSSIBLE =",cmd.currentValue);} + if (DEV_DEBUG) {this.log('debug',"Siren_state C IMPOSSIBLE =",cmd.currentValue);} returnValue = Characteristic.SecuritySystemCurrentState.DISARMED; break; } } if (cmd.generic_type == 'ALARM_STATE') { if(cmd.currentValue == 1) { - if (DEV_DEBUG) {that.log('debug',"Alarm_State C=",cmd.currentValue);} + if (DEV_DEBUG) {this.log('debug',"Alarm_State C=",cmd.currentValue);} returnValue = Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED; break; } else { continue; } } if (!service.hasAlarmModes) { if (cmd.generic_type == 'ALARM_ENABLE_STATE' && cmd.currentValue == 1) { - if (DEV_DEBUG) {that.log('debug',"Alarm_enable_state C=",cmd.currentValue,"NO MODES");} + if (DEV_DEBUG) {this.log('debug',"Alarm_enable_state C=",cmd.currentValue,"NO MODES");} returnValue = Characteristic.SecuritySystemCurrentState.AWAY_ARM; break; } else if (cmd.generic_type == 'ALARM_ENABLE_STATE' && cmd.currentValue == 0) { - if (DEV_DEBUG) {that.log('debug',"Alarm_enable_state C=",cmd.currentValue,"NO MODES");} + if (DEV_DEBUG) {this.log('debug',"Alarm_enable_state C=",cmd.currentValue,"NO MODES");} returnValue = Characteristic.SecuritySystemCurrentState.DISARMED; break; } } else { if (cmd.generic_type == 'ALARM_ENABLE_STATE' && cmd.currentValue == 0) { - if (DEV_DEBUG) {that.log('debug',"Alarm_enable_state C=",cmd.currentValue);} + if (DEV_DEBUG) {this.log('debug',"Alarm_enable_state C=",cmd.currentValue);} returnValue = Characteristic.SecuritySystemCurrentState.DISARMED; break; } if (cmd.generic_type == 'ALARM_ENABLE_STATE' && cmd.currentValue == 1) { // if there is mode and alarm is enabled, will continue the search for mode instead ! - if (DEV_DEBUG) {that.log('debug',"Alarm_enable_state C=",cmd.currentValue,'return undefined');} + if (DEV_DEBUG) {this.log('debug',"Alarm_enable_state C=",cmd.currentValue,'return undefined');} returnValue = undefined; if(info && info.generic_type == 'ALARM_ENABLE_STATE') { - if (DEV_DEBUG) {that.log('debug',"And break");} + if (DEV_DEBUG) {this.log('debug',"And break");} break; } else { - if (DEV_DEBUG) {that.log('debug',"And continue");} + if (DEV_DEBUG) {this.log('debug',"And continue");} continue; } } if (cmd.generic_type == 'ALARM_MODE') { - if (DEV_DEBUG) {that.log('debug',"alarm_mode C=",cmd.currentValue?.toLowerCase());} + if (DEV_DEBUG) {this.log('debug',"alarm_mode C=",cmd.currentValue?.toLowerCase());} if(service.alarm.present && service.alarm.present.mode_label != undefined) { mode_PRESENT=service.alarm.present.mode_label?.toLowerCase(); @@ -4387,23 +4373,23 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } switch (cmd.currentValue?.toLowerCase()) { case undefined: - if (DEV_DEBUG) {that.log('debug',"renvoie absent C via undefined",Characteristic.SecuritySystemCurrentState.AWAY_ARM);} + if (DEV_DEBUG) {this.log('debug',"renvoie absent C via undefined",Characteristic.SecuritySystemCurrentState.AWAY_ARM);} returnValue = Characteristic.SecuritySystemCurrentState.AWAY_ARM; break; default: // back compatibility - if (DEV_DEBUG) {that.log('debug',"renvoie absent C via default",Characteristic.SecuritySystemCurrentState.AWAY_ARM);} + if (DEV_DEBUG) {this.log('debug',"renvoie absent C via default",Characteristic.SecuritySystemCurrentState.AWAY_ARM);} returnValue = Characteristic.SecuritySystemCurrentState.AWAY_ARM; break; case mode_PRESENT: - if (DEV_DEBUG) {that.log('debug',"renvoie present C",Characteristic.SecuritySystemCurrentState.STAY_ARM);} + if (DEV_DEBUG) {this.log('debug',"renvoie present C",Characteristic.SecuritySystemCurrentState.STAY_ARM);} returnValue = Characteristic.SecuritySystemCurrentState.STAY_ARM; break; case mode_AWAY: - if (DEV_DEBUG) {that.log('debug',"renvoie absent C",Characteristic.SecuritySystemCurrentState.AWAY_ARM);} + if (DEV_DEBUG) {this.log('debug',"renvoie absent C",Characteristic.SecuritySystemCurrentState.AWAY_ARM);} returnValue = Characteristic.SecuritySystemCurrentState.AWAY_ARM; break; case mode_NIGHT: - if (DEV_DEBUG) {that.log('debug',"renvoie nuit C",Characteristic.SecuritySystemCurrentState.NIGHT_ARM);} + if (DEV_DEBUG) {this.log('debug',"renvoie nuit C",Characteristic.SecuritySystemCurrentState.NIGHT_ARM);} returnValue = Characteristic.SecuritySystemCurrentState.NIGHT_ARM; break; } @@ -4418,7 +4404,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i for (const cmd of cmdList) { if (cmd.generic_type == 'THERMOSTAT_STATE_NAME' || cmd.generic_type == 'THERMOSTAT_HC_STATE_NAME') { if(cmd.currentValue != undefined && cmd.currentValue != null) { - that.log('debug','----Current State Thermo :',cmd.currentValue.toString().toLowerCase()); + this.log('debug','----Current State Thermo :',cmd.currentValue.toString().toLowerCase()); switch(cmd.currentValue.toString().toLowerCase()) { default: case 'off' : // EN @@ -4481,7 +4467,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(service.thermo.chauf && service.thermo.chauf.mode_label !== undefined) { mode_CHAUF=service.thermo.chauf.mode_label.toString().toLowerCase(); } - that.log('debug','TargetThermo :',mode_CLIM,mode_CHAUF,':',cmd.currentValue.toString().toLowerCase()); + this.log('debug','TargetThermo :',mode_CLIM,mode_CHAUF,':',cmd.currentValue.toString().toLowerCase()); switch(cmd.currentValue.toString().toLowerCase()) { case 'off' : // EN case 'stopped' : // EN @@ -4522,7 +4508,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(service.thermoHC.chauf && service.thermoHC.chauf.mode_label !== undefined) { mode_CHAUF=service.thermoHC.chauf.mode_label.toString().toLowerCase(); } - that.log('debug','TargetThermo :',mode_CLIM,mode_CHAUF,':',cmd.currentValue.toString().toLowerCase()); + this.log('debug','TargetThermo :',mode_CLIM,mode_CHAUF,':',cmd.currentValue.toString().toLowerCase()); switch(cmd.currentValue.toString().toLowerCase()) { case 'off' : // EN case 'stopped' : // EN @@ -4560,7 +4546,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i for (const cmd of cmdList) { if (cmd.generic_type == 'THERMOSTAT_SETPOINT') { returnValue = cmd.currentValue; - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), setTemp : returnValue, @@ -4618,7 +4604,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } if (DEV_DEBUG) { console.log(customizedValues); - that.log('debug','Target Garage/Barrier Homekit: '+returnValue+' soit en Jeedom:'+cmd.currentValue+" ("+HRreturnValue+")"); + this.log('debug','Target Garage/Barrier Homekit: '+returnValue+' soit en Jeedom:'+cmd.currentValue+" ("+HRreturnValue+")"); } break; } @@ -4655,7 +4641,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } if (DEV_DEBUG) { console.log(customizedValues); - that.log('debug','Etat Garage/Barrier Homekit: '+returnValue+' soit en Jeedom:'+cmd.currentValue+" ("+HRreturnValue+")"); + this.log('debug','Etat Garage/Barrier Homekit: '+returnValue+' soit en Jeedom:'+cmd.currentValue+" ("+HRreturnValue+")"); } break; } @@ -4674,7 +4660,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(returnValue === service.TargetValue) {service.Moving=Characteristic.PositionState.STOPPED;} else if (service.TargetValue !== undefined && service.Moving===Characteristic.PositionState.STOPPED) {service.TargetValue=undefined;} - that.log('debug','---------update Blinds Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue,' : ',positionStateLabel(service.Moving)); + this.log('debug','---------update Blinds Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue,' : ',positionStateLabel(service.Moving)); break; } if (cmd.generic_type == 'FLAP_STATE_CLOSING' && cmd.id == service.cmd_id) { @@ -4688,7 +4674,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(returnValue === service.TargetValue) {service.Moving=Characteristic.PositionState.STOPPED;} else if (service.TargetValue !== undefined && service.Moving===Characteristic.PositionState.STOPPED) {service.TargetValue=undefined;} - that.log('debug','---------update Inverted Blinds Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue,' : ',positionStateLabel(service.Moving)); + this.log('debug','---------update Inverted Blinds Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue,' : ',positionStateLabel(service.Moving)); break; } if (cmd.generic_type == 'WINDOW_STATE' && cmd.id == service.cmd_id) { @@ -4697,7 +4683,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(returnValue === service.TargetValue) {service.Moving=Characteristic.PositionState.STOPPED;} else if (service.TargetValue !== undefined && service.Moving===Characteristic.PositionState.STOPPED) {service.TargetValue=undefined;} - that.log('debug','---------update WindowMoto Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue,' : ',positionStateLabel(service.Moving)); + this.log('debug','---------update WindowMoto Value(refresh):',returnValue,'% soit',cmd.currentValue,' / ',service.maxValue,' : ',positionStateLabel(service.Moving)); break; } } @@ -4711,13 +4697,13 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i returnValue = returnValue > (service.maxValue-5) ? service.maxValue : returnValue; // >95% is 100% in home (flaps need yearly tunning) } if(service.FlapType=="Closing" && service.Moving!==Characteristic.PositionState.STOPPED) { - that.log('debug','---------update TargetPosition(Closing)before:',returnValue,'%'); + this.log('debug','---------update TargetPosition(Closing)before:',returnValue,'%'); returnValue=100-returnValue; } } else { returnValue = service.TargetValue; } - that.log('debug','---------update TargetPosition(refresh):',returnValue,'%'); + this.log('debug','---------update TargetPosition(refresh):',returnValue,'%'); break; case Characteristic.PositionState.UUID : if('Moving' in service) { @@ -4725,14 +4711,14 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } else { returnValue = Characteristic.PositionState.STOPPED; } - that.log('debug','---------update PositionState(refresh):',positionStateLabel(returnValue)); + this.log('debug','---------update PositionState(refresh):',positionStateLabel(returnValue)); break; case Characteristic.CurrentHorizontalTiltAngle.UUID : case Characteristic.TargetHorizontalTiltAngle.UUID : for (const cmd of cmdList) { if (cmd.generic_type == 'FLAP_HOR_TILT_STATE') { returnValue = parseInt(cmd.currentValue); - that.log('debug','---------update Blinds HorTilt Value(refresh):',returnValue); + this.log('debug','---------update Blinds HorTilt Value(refresh):',returnValue); break; } } @@ -4742,7 +4728,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i for (const cmd of cmdList) { if (cmd.generic_type == 'FLAP_VER_TILT_STATE') { returnValue = parseInt(cmd.currentValue); - that.log('debug','---------update Blinds VerTilt Value(refresh):',returnValue); + this.log('debug','---------update Blinds VerTilt Value(refresh):',returnValue); break; } } @@ -4753,7 +4739,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if (cmd.generic_type == 'LOCK_STATE') { service.target=cmd.currentValue; if(cmd.eqType == 'nuki' || (cmd.eqType == 'jeelink' && cmd.real_eqType && cmd.real_eqType == 'nuki')) { - if (DEV_DEBUG) {that.log('debug','LockCurrentState (nuki) : ',cmd.currentValue);} + if (DEV_DEBUG) {this.log('debug','LockCurrentState (nuki) : ',cmd.currentValue);} switch(parseInt(cmd.currentValue)) { case 0 : returnValue=Characteristic.LockCurrentState.SECURED; @@ -4769,10 +4755,10 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i break; } // } else if(cmd.eqType == 'thekeys' || (cmd.eqType == 'jeelink' && cmd.real_eqType && cmd.real_eqType == 'thekeys')) { - // if (DEV_DEBUG) that.log('debug','LockCurrentState (thekeys) : ',cmd.currentValue); + // if (DEV_DEBUG) this.log('debug','LockCurrentState (thekeys) : ',cmd.currentValue); // returnValue = toBool(cmd.currentValue) === false ? Characteristic.LockCurrentState.SECURED : Characteristic.LockCurrentState.UNSECURED; } else { - if (DEV_DEBUG) {that.log('debug','LockCurrentState : ',cmd.currentValue);} + if (DEV_DEBUG) {this.log('debug','LockCurrentState : ',cmd.currentValue);} returnValue = toBool(cmd.currentValue) === true ? Characteristic.LockCurrentState.SECURED : Characteristic.LockCurrentState.UNSECURED; } } @@ -4786,13 +4772,13 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i else {service.target=targetVal;} if(cmd.eqType == 'nuki' || (cmd.eqType == 'jeelink' && cmd.real_eqType && cmd.real_eqType == 'nuki')) { - if (DEV_DEBUG) {that.log('debug','LockTargetState (nuki) : ',cmd.currentValue,'service.target : ',service.target);} + if (DEV_DEBUG) {this.log('debug','LockTargetState (nuki) : ',cmd.currentValue,'service.target : ',service.target);} returnValue = toBool(targetVal) === false ? Characteristic.LockTargetState.SECURED : Characteristic.LockTargetState.UNSECURED; // } else if(cmd.eqType == 'thekeys' || (cmd.eqType == 'jeelink' && cmd.real_eqType && cmd.real_eqType == 'thekeys')) { - // if (DEV_DEBUG) {that.log('debug','LockTargetState (thekeys) : ',cmd.currentValue);} + // if (DEV_DEBUG) {this.log('debug','LockTargetState (thekeys) : ',cmd.currentValue);} // returnValue = toBool(cmd.currentValue) === false ? Characteristic.LockTargetState.SECURED : Characteristic.LockTargetState.UNSECURED; } else { - if (DEV_DEBUG) {that.log('debug','LockTargetState : ',cmd.currentValue,'service.target : ',service.target);} + if (DEV_DEBUG) {this.log('debug','LockTargetState : ',cmd.currentValue,'service.target : ',service.target);} returnValue = toBool(targetVal) === true ? Characteristic.LockTargetState.SECURED : Characteristic.LockTargetState.UNSECURED; } } @@ -4915,7 +4901,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i if(service.infos.power && service.infos.power.unite && service.infos.power.unite.toLowerCase() == 'kw') { returnValue = Math.round(cmd.currentValue*1000); } - if(that.fakegato && service.eqLogic && service.eqLogic.hasLogging) { + if(this.fakegato && service.eqLogic && service.eqLogic.hasLogging) { service.eqLogic.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), power: returnValue, @@ -5001,7 +4987,7 @@ JeedomPlatform.prototype.getAccessoryValue = function(characteristic, service, i } } } - that.log('debug','**********GetState ProgrammableSwitchEvent: '+returnValue); + this.log('debug','**********GetState ProgrammableSwitchEvent: '+returnValue); break; case Characteristic.OutletInUse.UUID : for (const cmd of cmdList) { @@ -5141,9 +5127,7 @@ function toBool(val) { // -- Return : nothing JeedomPlatform.prototype.command = function(action, value, service) { try{ - const that = this; - - const cmdList = that.jeedomClient.getDeviceCmdFromCache(service.eqID); + const cmdList = this.jeedomClient.getDeviceCmdFromCache(service.eqID); var cmdId = service.cmd_id; let found=false; @@ -5533,7 +5517,7 @@ JeedomPlatform.prototype.command = function(action, value, service) { break; case 'ALARM_RELEASED' : if(action == 'SetAlarmMode' && value == Characteristic.SecuritySystemTargetState.DISARM) { - that.log('debug',"ALARM_RELEASED","setAlarmMode=",value,cmd.id); + this.log('debug',"ALARM_RELEASED","setAlarmMode=",value,cmd.id); cmdId = cmd.id; cmdFound=cmd.generic_type; found = true; @@ -5541,26 +5525,26 @@ JeedomPlatform.prototype.command = function(action, value, service) { break; case 'ALARM_SET_MODE' : if(action == 'SetAlarmMode' && service.hasAlarmModes) { - that.log('debug',"ALARM_SET_MODE","SetAlarmMode=",action,value); + this.log('debug',"ALARM_SET_MODE","SetAlarmMode=",action,value); cmdFound=cmd.generic_type; if(value == Characteristic.SecuritySystemTargetState.NIGHT_ARM && id_NIGHT != undefined) { cmdId = id_NIGHT; - that.log('debug',"set nuit"); + this.log('debug',"set nuit"); found = true; } else if(value == Characteristic.SecuritySystemTargetState.AWAY_ARM && id_AWAY != undefined) { cmdId = id_AWAY; - that.log('debug',"set absent"); + this.log('debug',"set absent"); found = true; } else if(value == Characteristic.SecuritySystemTargetState.STAY_ARM && id_PRESENT != undefined) { cmdId = id_PRESENT; - that.log('debug',"set present"); + this.log('debug',"set present"); found = true; } } break; case 'ALARM_ARMED' : if(action == 'SetAlarmMode' && value != Characteristic.SecuritySystemTargetState.DISARM && !service.hasAlarmModes) { - that.log('debug',"ALARM_ARMED","SetAlarmMode=",action,cmd.id); + this.log('debug',"ALARM_ARMED","SetAlarmMode=",action,cmd.id); cmdFound=cmd.generic_type; cmdId = cmd.id; found = true; @@ -5600,20 +5584,20 @@ JeedomPlatform.prototype.command = function(action, value, service) { if(action == 'TargetHeatingCoolingState') { if(value == Characteristic.TargetHeatingCoolingState.OFF && id_OFF != undefined) { cmdId = id_OFF; - that.log('debug',"set OFF"); + this.log('debug',"set OFF"); found = true; } else if(value == Characteristic.TargetHeatingCoolingState.HEAT && id_CHAUF != undefined) { cmdId = id_CHAUF; - that.log('debug',"set CHAUF"); + this.log('debug',"set CHAUF"); found = true; } else if(value == Characteristic.TargetHeatingCoolingState.COOL && id_CLIM != undefined) { cmdId = id_CLIM; - that.log('debug',"set CLIM"); + this.log('debug',"set CLIM"); found = true; } else if(value == Characteristic.TargetHeatingCoolingState.AUTO) { cmdId = service.actions.set_setpoint.id; value = service.infos.setpoint.currentValue; - that.log('debug','set AUTO',value); + this.log('debug','set AUTO',value); found = true; } } @@ -5622,20 +5606,20 @@ JeedomPlatform.prototype.command = function(action, value, service) { if(action == 'TargetHeatingCoolingState') { if(value == Characteristic.TargetHeatingCoolingState.OFF && id_OFF != undefined) { cmdId = id_OFF_HC; - that.log('debug',"set OFF"); + this.log('debug',"set OFF"); found = true; } else if(value == Characteristic.TargetHeatingCoolingState.HEAT && id_CHAUF != undefined) { cmdId = id_CHAUF_HC; - that.log('debug',"set CHAUF"); + this.log('debug',"set CHAUF"); found = true; } else if(value == Characteristic.TargetHeatingCoolingState.COOL && id_CLIM != undefined) { cmdId = id_CLIM_HC; - that.log('debug',"set CLIM"); + this.log('debug',"set CLIM"); found = true; } else if(value == Characteristic.TargetHeatingCoolingState.AUTO) { cmdId = service.actions.set_setpointH.id; value = service.infos.setpointH.currentValue; - that.log('debug','set AUTO',value); + this.log('debug','set AUTO',value); found = true; } } @@ -5646,43 +5630,43 @@ JeedomPlatform.prototype.command = function(action, value, service) { if(needToTemporize===0 && needToTemporizeSec===0) { if(cmdFound=="LIGHT_ON") { - if(that.settingLight) { + if(this.settingLight) { if(service.ignoreOnCommandOnBrightnessChange) { return; } } } - that.jeedomClient.executeDeviceAction(cmdId, action, value).then(function(response) { - that.log('info','[Commande envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'value: '+value,'generic:'+cmdFound,'response:'+JSON.stringify(response)); - }).catch(function(err) { - that.log('error','Erreur à l\'envoi de la commande ' + action + ' vers ' + service.cmd_id , err); + this.jeedomClient.executeDeviceAction(cmdId, action, value).then((response) => { + this.log('info','[Commande envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'value: '+value,'generic:'+cmdFound,'response:'+JSON.stringify(response)); + }).catch((err) => { + this.log('error','Erreur à l\'envoi de la commande ' + action + ' vers ' + service.cmd_id , err); if(err && err.stack) { console.error(err.stack); } }); } else if(needToTemporize) { if(service.temporizator) {clearTimeout(service.temporizator);} - service.temporizator = setTimeout(function(){ - if(cmdFound=="LIGHT_SLIDER") {that.settingLight=false;} - if(cmdFound=="FAN_SLIDER" || cmdFound=="FAN_SPEED") {that.settingFan=false;} + service.temporizator = setTimeout(() => { + if(cmdFound=="LIGHT_SLIDER") {this.settingLight=false;} + if(cmdFound=="FAN_SLIDER" || cmdFound=="FAN_SPEED") {this.settingFan=false;} - that.jeedomClient.executeDeviceAction(cmdId, action, value).then(function(response) { - that.log('info','[Commande T envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'value: '+value,'response:'+JSON.stringify(response)); - }).catch(function(err) { - that.log('error','Erreur à l\'envoi de la commande ' + action + ' vers ' + service.cmd_id , err); + this.jeedomClient.executeDeviceAction(cmdId, action, value).then((response) => { + this.log('info','[Commande T envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'value: '+value,'response:'+JSON.stringify(response)); + }).catch((err) => { + this.log('error','Erreur à l\'envoi de la commande ' + action + ' vers ' + service.cmd_id , err); if(err && err.stack) { console.error(err.stack); } }); },needToTemporize); } else if(needToTemporizeSec) { if(service.temporizatorSec) {clearTimeout(service.temporizatorSec);} - service.temporizatorSec = setTimeout(function(){ + service.temporizatorSec = setTimeout(() => { if(cmdFound=="LIGHT_ON") { - if(that.settingLight) { + if(this.settingLight) { if(!service.ignoreOnCommandOnBrightnessChange) { - // if(cmdFound=="LIGHT_ON" && service.infos && service.infos.state_bool && service.infos.state_bool.id) that.jeedomClient.updateModelInfo(service.infos.state_bool.id,true); - setTimeout(function(){ - that.jeedomClient.executeDeviceAction(cmdId, action, value).then(function(response) { - that.log('info','[Commande ON LATE envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'value: '+value,'response:'+JSON.stringify(response)); - }).catch(function(err) { - that.log('error','Erreur à l\'envoi de la commande ' + action + ' vers ' + service.cmd_id , err); + // if(cmdFound=="LIGHT_ON" && service.infos && service.infos.state_bool && service.infos.state_bool.id) this.jeedomClient.updateModelInfo(service.infos.state_bool.id,true); + setTimeout(() => { + this.jeedomClient.executeDeviceAction(cmdId, action, value).then((response) => { + this.log('info','[Commande ON LATE envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'value: '+value,'response:'+JSON.stringify(response)); + }).catch((err) => { + this.log('error','Erreur à l\'envoi de la commande ' + action + ' vers ' + service.cmd_id , err); if(err && err.stack) { console.error(err.stack); } }); },1000); @@ -5691,10 +5675,10 @@ JeedomPlatform.prototype.command = function(action, value, service) { } } - that.jeedomClient.executeDeviceAction(cmdId, action, value).then(function(response) { - that.log('info','[Commande T envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'value: '+value,'response:'+JSON.stringify(response)); - }).catch(function(err) { - that.log('error','Erreur à l\'envoi de la commande ' + action + ' vers ' + service.cmd_id , err); + this.jeedomClient.executeDeviceAction(cmdId, action, value).then((response) => { + this.log('info','[Commande T envoyée à Jeedom]','cmdId:' + cmdId,'action:' + action,'value: '+value,'response:'+JSON.stringify(response)); + }).catch((err) => { + this.log('error','Erreur à l\'envoi de la commande ' + action + ' vers ' + service.cmd_id , err); if(err && err.stack) { console.error(err.stack); } }); @@ -5712,55 +5696,54 @@ JeedomPlatform.prototype.command = function(action, value, service) { // -- Params -- // -- Return : nothing JeedomPlatform.prototype.startPollingUpdate = function() { - const that = this; - if(that.pollingUpdateRunning) {return;} - that.pollingUpdateRunning = true; - that.jeedomClient.refreshStates().then(function(updates) { - that.lastPoll = updates.datetime; + if(this.pollingUpdateRunning) {return;} + this.pollingUpdateRunning = true; + this.jeedomClient.refreshStates().then((updates) => { + this.lastPoll = updates.datetime; if (updates.result) { - updates.result.map(function(update) { + updates.result.map((update) => { if (update.name == 'cmd::update' && update.option.value != undefined && update.option.cmd_id) { - if(that.jeedomClient.updateModelInfo(update.option.cmd_id,update.option.value)){ // Update cachedModel - that.updateSubscribers(update);// Update subscribers + if(this.jeedomClient.updateModelInfo(update.option.cmd_id,update.option.value)){ // Update cachedModel + this.updateSubscribers(update);// Update subscribers } } else if(update.name == 'scenario::update' && update.option.state != undefined && update.option.scenario_id) { - if(that.jeedomClient.updateModelScenario(update.option.scenario_id,update.option.state)){ // Update cachedModel - that.updateSubscribers(update);// Update subscribers + if(this.jeedomClient.updateModelScenario(update.option.scenario_id,update.option.state)){ // Update cachedModel + this.updateSubscribers(update);// Update subscribers } } else if(DEV_DEBUG && update.name == 'eqLogic::update' && update.option.eqLogic_id) { - const cacheState = that.jeedomClient.getDevicePropertiesFromCache(update.option.eqLogic_id); - that.jeedomClient.getDeviceProperties(update.option.eqLogic_id).then(function(eqLogic){ + const cacheState = this.jeedomClient.getDevicePropertiesFromCache(update.option.eqLogic_id); + this.jeedomClient.getDeviceProperties(update.option.eqLogic_id).then((eqLogic) => { if(cacheState && eqLogic && cacheState.isEnable != eqLogic.isEnable) { - that.log('debug',"Changing Enable in",update.option.eqLogic_id,'from',cacheState.isEnable,'to',eqLogic.isEnable); - that.jeedomClient.updateModelEq(update.option.eqLogic_id,eqLogic); + this.log('debug',"Changing Enable in",update.option.eqLogic_id,'from',cacheState.isEnable,'to',eqLogic.isEnable); + this.jeedomClient.updateModelEq(update.option.eqLogic_id,eqLogic); } }).catch((e) => { - that.log('error','Erreur :',e); + this.log('error','Erreur :',e); }); - that.log('debug','[Reçu Type non géré]',update.name+' contenu: '+JSON.stringify(update).replace("\n","")); + this.log('debug','[Reçu Type non géré]',update.name+' contenu: '+JSON.stringify(update).replace("\n","")); } else if(DEV_DEBUG) { - that.log('debug','[Reçu Type non géré]',update.name+' ou contenu invalide: '+JSON.stringify(update).replace("\n","")); + this.log('debug','[Reçu Type non géré]',update.name+' ou contenu invalide: '+JSON.stringify(update).replace("\n","")); } }); } - }).then(function(){ - that.pollingUpdateRunning = false; - that.pollingID = setImmediate(() => that.startPollingUpdate()); - }).catch(function(err) { - that.log('error','Erreur de récupération des évènements de mise à jour: ', err); + }).then(() => { + this.pollingUpdateRunning = false; + this.pollingID = setImmediate(() => this.startPollingUpdate()); + }).catch((err) => { + this.log('error','Erreur de récupération des évènements de mise à jour: ', err); if(err && err.stack) { console.error(err.stack); } - that.pollingUpdateRunning = false; - that.pollingID = setTimeout(function(){ that.log('debug','!!RESTART POLLING AFTER ERROR!!');that.startPollingUpdate(); }, that.pollerPeriod * 2 * 1000); + this.pollingUpdateRunning = false; + this.pollingID = setTimeout(() => { this.log('debug','!!RESTART POLLING AFTER ERROR!!');this.startPollingUpdate(); }, this.pollerPeriod * 2 * 1000); }); }; @@ -5770,16 +5753,15 @@ JeedomPlatform.prototype.startPollingUpdate = function() { // -- update : the update received from Jeedom // -- Return : nothing JeedomPlatform.prototype.updateSubscribers = function(update) { - const that = this; const updateID = update.option.scenario_id || update.option.cmd_id; - for (let i = 0; i < that.updateSubscriptions.length; i++) { - const {characteristic: subCharact, service: subService} = that.updateSubscriptions[i]; + for (let i = 0; i < this.updateSubscriptions.length; i++) { + const {characteristic: subCharact, service: subService} = this.updateSubscriptions[i]; - // that.log('debug',"update :",updateID,JSON.stringify(subService.infos),JSON.stringify(subService.statusArr),subCharact.UUID); + // this.log('debug',"update :",updateID,JSON.stringify(subService.infos),JSON.stringify(subService.statusArr),subCharact.UUID); const infoFound = findMyID(subService.infos,updateID); const statusFound = findMyID(subService.statusArr,updateID); if(infoFound !== -1 || statusFound !== -1) { - let returnValue = that.getAccessoryValue(subCharact, subService, (infoFound !== -1?infoFound:statusFound)); + let returnValue = this.getAccessoryValue(subCharact, subService, (infoFound !== -1?infoFound:statusFound)); if (returnValue === 'no_response') { subCharact.updateValue(new Error('no_response'), undefined, 'fromJeedom'); @@ -5787,17 +5769,17 @@ JeedomPlatform.prototype.updateSubscribers = function(update) { returnValue = sanitizeValue(returnValue,subCharact); const logMessage = 'Cause de modif: "' + (infoFound && infoFound.name ? infoFound.name + '" (' + updateID + ')' : '') + (statusFound && statusFound.name ? statusFound.name + '" (' + updateID + ')' : '') + ' Envoi valeur:' + returnValue + ' dans ' + subCharact.displayName; if(infoFound !== -1 && infoFound.generic_type=="LIGHT_STATE") { // if it's a LIGHT_STATE - if(!that.settingLight) { // and it's not currently being modified - that.log('info','[Commande envoyée à HomeKit]',logMessage); + if(!this.settingLight) { // and it's not currently being modified + this.log('info','[Commande envoyée à HomeKit]',logMessage); subCharact.updateValue(returnValue, undefined, 'fromJeedom'); - } else if(DEV_DEBUG) {that.log('debug','//Commande NON envoyée à HomeKit',logMessage);} + } else if(DEV_DEBUG) {this.log('debug','//Commande NON envoyée à HomeKit',logMessage);} } else if(infoFound !== -1 && (infoFound.generic_type=="FAN_STATE" || infoFound.generic_type=="FAN_SPEED_STATE")) { // if it's a FAN_STATE - if(!that.settingFan) { // and it's not currently being modified - that.log('info','[Commande envoyée à HomeKit]',logMessage); + if(!this.settingFan) { // and it's not currently being modified + this.log('info','[Commande envoyée à HomeKit]',logMessage); subCharact.updateValue(returnValue, undefined, 'fromJeedom'); - } else if(DEV_DEBUG) {that.log('debug','//Commande NON envoyée à HomeKit',logMessage);} + } else if(DEV_DEBUG) {this.log('debug','//Commande NON envoyée à HomeKit',logMessage);} } else { - that.log('info','[Commande envoyée à HomeKit]',logMessage); + this.log('info','[Commande envoyée à HomeKit]',logMessage); subCharact.updateValue(returnValue, undefined, 'fromJeedom'); } } else {return;} @@ -5863,13 +5845,11 @@ JeedomPlatform.prototype.updateHomeKitColorFromJeedom = function(color, service) // -- service : service to set color to // -- Return : nothing JeedomPlatform.prototype.syncColorCharacteristics = function(rgb, service) { - const that = this; - clearTimeout(service.timeoutIdColorCharacteristics); - service.timeoutIdColorCharacteristics = setTimeout(function() { + service.timeoutIdColorCharacteristics = setTimeout(() => { const rgbColor = rgbToHex(rgb.r, rgb.g, rgb.b); - if (DEV_DEBUG) {that.log('debug',"---------setRGB : ",rgbColor);} - that.command('setRGB', rgbColor, service); + if (DEV_DEBUG) {this.log('debug',"---------setRGB : ",rgbColor);} + this.command('setRGB', rgbColor, service); }, 500); }; @@ -6662,7 +6642,12 @@ function RGBtoHSV(r, g, b) { // -- Params -- // -- id : id to find // -- Return : Object found -function findMyID(obj, id) { - if (!obj) {return -1;} - return Object.values(obj).find((item) => item && item.id == id) || -1; +function findMyID(obj,id) { + if (!obj) return -1; + for(const key in obj) { + if( obj.hasOwnProperty(key) && obj[key] && obj[key].id==id) { + return obj[key]; + } + } + return -1; } From 5e93664f735a9319abb8d309301445ce21beb600 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:20:21 +0100 Subject: [PATCH 113/118] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3899cb6..229b986 100755 --- a/index.js +++ b/index.js @@ -6643,7 +6643,7 @@ function RGBtoHSV(r, g, b) { // -- id : id to find // -- Return : Object found function findMyID(obj,id) { - if (!obj) return -1; + if (!obj) {return -1;} for(const key in obj) { if( obj.hasOwnProperty(key) && obj[key] && obj[key].id==id) { return obj[key]; From 9a42e5fbbffca559fee0289a6f858b9c7f84190a Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:24:59 +0100 Subject: [PATCH 114/118] Update jeedom-api.js --- lib/jeedom-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index 3cecee2..38d1ecf 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -547,6 +547,6 @@ const genTypesMapping = { 'GENERIC_INFO': {serviceType: 'generic', property: 'state'}, }; -module.exports.createClient = function(url, apikey, Plateform,myPlugin) { +module.exports.createClient = function(url, apikey, Plateform, myPlugin) { return new JeedomClient(url, apikey, Plateform,myPlugin); }; From 83d629dedbb807a0185313e7d157e2c7f360921d Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:45:21 +0100 Subject: [PATCH 115/118] Update index.js --- index.js | 3404 +++++++++++++++++++++++++++--------------------------- 1 file changed, 1682 insertions(+), 1722 deletions(-) diff --git a/index.js b/index.js index 229b986..4bc848e 100755 --- a/index.js +++ b/index.js @@ -415,128 +415,127 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.light) { eqLogic.services.light.forEach((cmd) => { - if (cmd.state) { - let LightType="Switch"; - HBservice = { - controlService : new Service.Lightbulb(eqLogic.name), - characteristics : [Characteristic.On], + if (!cmd.state) {return;} + let LightType="Switch"; + HBservice = { + controlService : new Service.Lightbulb(eqLogic.name), + characteristics : [Characteristic.On], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + if(eqLogic.OnAfterBrightness) {Serv.OnAfterBrightness=true;} + if(eqLogic.ignoreOnCommandOnBrightnessChange) {Serv.ignoreOnCommandOnBrightnessChange=true;} + + eqServicesCopy.light.forEach((cmd2) => { + if (cmd2.on) { + Serv.actions.on=cmd2.on; + } else if (cmd2.off) { + Serv.actions.off=cmd2.off; + } else if (cmd2.slider) { + Serv.actions.slider=cmd2.slider; + } else if (cmd2.setcolor) { + Serv.actions.setcolor=cmd2.setcolor; + } else if (cmd2.setcolor_temp) { + Serv.actions.setcolor_temp=cmd2.setcolor_temp; + } else if (cmd2.color) { + Serv.infos.color=cmd2.color; + } else if (cmd2.color_temp) { + Serv.infos.color_temp=cmd2.color_temp; + } else if (cmd2.state_bool) { + Serv.infos.state_bool=cmd2.state_bool; + } else if (cmd2.brightness) { + Serv.infos.brightness=cmd2.brightness; + } + }); + if (Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Lumière OFF"');} + if (!Serv.actions.on && Serv.actions.off) {this.log('warn','Pas de type générique "Action/Lumière ON"');} + if (!Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Lumière ON" et "Action/Lumière OFF"');} + if (Serv.infos.color && !Serv.actions.setcolor) {this.log('warn','Pas de type générique "Action/Lumière Couleur"');} + if (!Serv.infos.color && Serv.actions.setcolor) {this.log('warn','Pas de type générique "Info/Lumière Couleur"');} + if (Serv.infos.color_temp && !Serv.actions.setcolor_temp) {this.log('warn','Pas de type générique "Action/Lumière Température Couleur"');} + if (!Serv.infos.color_temp && Serv.actions.setcolor_temp) {this.log('warn','Pas de type générique "Info/Lumière Température Couleur"');} + + if(Serv.actions.slider) { + if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { + Serv.maxBright = parseInt(Serv.actions.slider.configuration.maxValue); + } else { + Serv.maxBright = 100; // if not set in Jeedom it's 100 + } + LightType += '_Slider,'+Serv.maxBright; + HBservice.characteristics.push(Characteristic.Brightness); + Serv.addCharacteristic(Characteristic.Brightness); + } else { + this.log('info','La lumière n\'a pas de variateur'); + } + if(Serv.infos.color) { + LightType += "_RGB"; + HBservice.characteristics.push(Characteristic.Hue); + Serv.addCharacteristic(Characteristic.Hue); + HBservice.characteristics.push(Characteristic.Saturation); + Serv.addCharacteristic(Characteristic.Saturation); + Serv.HSBValue = { + hue : 0, + saturation : 0, + brightness : 0, }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - if(eqLogic.OnAfterBrightness) {Serv.OnAfterBrightness=true;} - if(eqLogic.ignoreOnCommandOnBrightnessChange) {Serv.ignoreOnCommandOnBrightnessChange=true;} - - eqServicesCopy.light.forEach((cmd2) => { - if (cmd2.on) { - Serv.actions.on=cmd2.on; - } else if (cmd2.off) { - Serv.actions.off=cmd2.off; - } else if (cmd2.slider) { - Serv.actions.slider=cmd2.slider; - } else if (cmd2.setcolor) { - Serv.actions.setcolor=cmd2.setcolor; - } else if (cmd2.setcolor_temp) { - Serv.actions.setcolor_temp=cmd2.setcolor_temp; - } else if (cmd2.color) { - Serv.infos.color=cmd2.color; - } else if (cmd2.color_temp) { - Serv.infos.color_temp=cmd2.color_temp; - } else if (cmd2.state_bool) { - Serv.infos.state_bool=cmd2.state_bool; - } else if (cmd2.brightness) { - Serv.infos.brightness=cmd2.brightness; - } - }); - if (Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Lumière OFF"');} - if (!Serv.actions.on && Serv.actions.off) {this.log('warn','Pas de type générique "Action/Lumière ON"');} - if (!Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Lumière ON" et "Action/Lumière OFF"');} - if (Serv.infos.color && !Serv.actions.setcolor) {this.log('warn','Pas de type générique "Action/Lumière Couleur"');} - if (!Serv.infos.color && Serv.actions.setcolor) {this.log('warn','Pas de type générique "Info/Lumière Couleur"');} - if (Serv.infos.color_temp && !Serv.actions.setcolor_temp) {this.log('warn','Pas de type générique "Action/Lumière Température Couleur"');} - if (!Serv.infos.color_temp && Serv.actions.setcolor_temp) {this.log('warn','Pas de type générique "Info/Lumière Température Couleur"');} + Serv.RGBValue = { + red : 0, + green : 0, + blue : 0, + }; + // Serv.countColorCharacteristics = 0; + Serv.timeoutIdColorCharacteristics = 0; + } + if(Serv.infos.color_temp) { + LightType += "_Temp"; + const props = {}; - if(Serv.actions.slider) { - if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { - Serv.maxBright = parseInt(Serv.actions.slider.configuration.maxValue); - } else { - Serv.maxBright = 100; // if not set in Jeedom it's 100 + if(Serv.actions.setcolor_temp && Serv.actions.setcolor_temp.configuration && Serv.actions.setcolor_temp.configuration.maxValue && Serv.actions.setcolor_temp.configuration.minValue && parseInt(Serv.actions.setcolor_temp.configuration.maxValue) && parseInt(Serv.actions.setcolor_temp.configuration.minValue)) { + if(parseInt(Serv.actions.setcolor_temp.configuration.maxValue) > 500 && parseInt(Serv.actions.setcolor_temp.configuration.minValue) > 500) { // Kelvin + // convert to Mired (and take the max value to the min) + props.minValue = parseInt(1000000/Serv.actions.setcolor_temp.configuration.maxValue); + props.maxValue = parseInt(1000000/Serv.actions.setcolor_temp.configuration.minValue); + Serv.colorTempType="kelvin"; + LightType+=Serv.colorTempType; + } else { // already mired + props.minValue = parseInt(Serv.actions.setcolor_temp.configuration.minValue); + props.maxValue = parseInt(Serv.actions.setcolor_temp.configuration.maxValue); + Serv.colorTempType="mired"; + LightType+=Serv.colorTempType; } - LightType += '_Slider,'+Serv.maxBright; - HBservice.characteristics.push(Characteristic.Brightness); - Serv.addCharacteristic(Characteristic.Brightness); } else { - this.log('info','La lumière n\'a pas de variateur'); - } - if(Serv.infos.color) { - LightType += "_RGB"; - HBservice.characteristics.push(Characteristic.Hue); - Serv.addCharacteristic(Characteristic.Hue); - HBservice.characteristics.push(Characteristic.Saturation); - Serv.addCharacteristic(Characteristic.Saturation); - Serv.HSBValue = { - hue : 0, - saturation : 0, - brightness : 0, - }; - Serv.RGBValue = { - red : 0, - green : 0, - blue : 0, - }; - // Serv.countColorCharacteristics = 0; - Serv.timeoutIdColorCharacteristics = 0; - } - if(Serv.infos.color_temp) { - LightType += "_Temp"; - const props = {}; - - if(Serv.actions.setcolor_temp && Serv.actions.setcolor_temp.configuration && Serv.actions.setcolor_temp.configuration.maxValue && Serv.actions.setcolor_temp.configuration.minValue && parseInt(Serv.actions.setcolor_temp.configuration.maxValue) && parseInt(Serv.actions.setcolor_temp.configuration.minValue)) { - if(parseInt(Serv.actions.setcolor_temp.configuration.maxValue) > 500 && parseInt(Serv.actions.setcolor_temp.configuration.minValue) > 500) { // Kelvin - // convert to Mired (and take the max value to the min) - props.minValue = parseInt(1000000/Serv.actions.setcolor_temp.configuration.maxValue); - props.maxValue = parseInt(1000000/Serv.actions.setcolor_temp.configuration.minValue); - Serv.colorTempType="kelvin"; - LightType+=Serv.colorTempType; - } else { // already mired - props.minValue = parseInt(Serv.actions.setcolor_temp.configuration.minValue); - props.maxValue = parseInt(Serv.actions.setcolor_temp.configuration.maxValue); - Serv.colorTempType="mired"; - LightType+=Serv.colorTempType; - } - } else { - this.log('error','"Action/Lumière Température Couleur" doit avoir un minimum et un maximum !'); - props.minValue = 0; // if not set in Jeedom it's 0 - props.maxValue = 20000; // if not set in Jeedom it's 100 - } - const unite = Serv.infos.color_temp.unite ? Serv.infos.color_temp.unite : ''; - if(unite) {props.unit=unite;} - HBservice.characteristics.push(Characteristic.ColorTemperature); - Serv.addCharacteristic(Characteristic.ColorTemperature); - Serv.getCharacteristic(Characteristic.ColorTemperature).setProps(props); + this.log('error','"Action/Lumière Température Couleur" doit avoir un minimum et un maximum !'); + props.minValue = 0; // if not set in Jeedom it's 0 + props.maxValue = 20000; // if not set in Jeedom it's 100 } + const unite = Serv.infos.color_temp.unite ? Serv.infos.color_temp.unite : ''; + if(unite) {props.unit=unite;} + HBservice.characteristics.push(Characteristic.ColorTemperature); + Serv.addCharacteristic(Characteristic.ColorTemperature); + Serv.getCharacteristic(Characteristic.ColorTemperature).setProps(props); + } - if(eqLogic.hasAdaptive) { - if (this.adaptiveLightingSupport()) { - LightType+='_Adaptive'; - } else { - eqLogic.hasAdaptive=false; - } + if(eqLogic.hasAdaptive) { + if (this.adaptiveLightingSupport()) { + LightType+='_Adaptive'; + } else { + eqLogic.hasAdaptive=false; } - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - this.log('info','La lumière est du type :',LightType); - Serv.LightType = LightType; - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); } + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + this.log('info','La lumière est du type :',LightType); + Serv.LightType = LightType; + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Lumière Etat"'); @@ -546,134 +545,133 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.flap) { eqLogic.services.flap.forEach((cmd) => { - if (cmd.state || cmd.stateClosing) { - HBservice = { - controlService : new Service.WindowCovering(eqLogic.name), - characteristics : [Characteristic.CurrentPosition, Characteristic.TargetPosition, Characteristic.PositionState], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - - if(cmd.stateClosing) { - Serv.infos.state=cmd.stateClosing; - if(Serv.infos.state.subType == 'binary') { - if(Serv.infos.state.display && Serv.infos.state.display.invertBinary) { - Serv.FlapType="Opening"; - } else { - Serv.FlapType="Closing"; - } + if (!cmd.state && !cmd.stateClosing) {return;} + HBservice = { + controlService : new Service.WindowCovering(eqLogic.name), + characteristics : [Characteristic.CurrentPosition, Characteristic.TargetPosition, Characteristic.PositionState], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + + if(cmd.stateClosing) { + Serv.infos.state=cmd.stateClosing; + if(Serv.infos.state.subType == 'binary') { + if(Serv.infos.state.display && Serv.infos.state.display.invertBinary) { + Serv.FlapType="Opening"; } else { Serv.FlapType="Closing"; } - } else if(cmd.state) { - Serv.infos.state=cmd.state; - if(Serv.infos.state.subType == 'binary') { - if(Serv.infos.state.display && Serv.infos.state.display.invertBinary) { - Serv.FlapType="Closing"; - } else { - Serv.FlapType="Opening"; - } + } else { + Serv.FlapType="Closing"; + } + } else if(cmd.state) { + Serv.infos.state=cmd.state; + if(Serv.infos.state.subType == 'binary') { + if(Serv.infos.state.display && Serv.infos.state.display.invertBinary) { + Serv.FlapType="Closing"; } else { Serv.FlapType="Opening"; } - } - - eqServicesCopy.flap.forEach((cmd2) => { - if (cmd2.up) { - Serv.actions.up = cmd2.up; - } else if (cmd2.down) { - Serv.actions.down = cmd2.down; - } else if (cmd2.slider) { - Serv.actions.slider = cmd2.slider; - } else if (cmd2.HorTiltSlider) { - Serv.actions.HorTiltSlider = cmd2.HorTiltSlider; - } else if (cmd2.VerTiltSlider) { - Serv.actions.VerTiltSlider = cmd2.VerTiltSlider; - } else if (cmd2.HorTiltState) { - Serv.infos.HorTiltState = cmd2.HorTiltState; - } else if (cmd2.VerTiltState) { - Serv.infos.VerTiltState = cmd2.VerTiltState; - } - }); - if(Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Volet Bouton Descendre"');} - if(!Serv.actions.up && Serv.actions.down) {this.log('warn','Pas de type générique "Action/Volet Bouton Monter"');} - if(!Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Volet Bouton Descendre" et "Action/Volet Bouton Monter"');} - if(!Serv.actions.up && !Serv.actions.down && !Serv.actions.slider) {this.log('warn','Pas de type générique "Action/Volet Bouton Slider" et "Action/Volet Bouton Monter" et "Action/Volet Bouton Descendre"');} - if(Serv.actions.HorTiltSlider && !Serv.infos.HorTiltState) {this.log('warn','Pas de type générique "Info/Volet Etat Inclinaison Horizontale" malgré l\'action "Action/Volet Slider Inclinaison Horizontale"');} - if(Serv.actions.VerTiltSlider && !Serv.infos.VerTiltState) {this.log('warn','Pas de type générique "Info/Volet Etat Inclinaison Verticale" malgré l\'action "Action/Volet Slider Inclinaison Verticale"');} - if(!Serv.actions.HorTiltSlider && Serv.infos.HorTiltState) {this.log('warn','Pas de type générique "Action/Volet Slider Inclinaison Horizontale" malgré l\'état "Info/Volet Etat Inclinaison Horizontale"');} - if(!Serv.actions.VerTiltSlider && Serv.infos.VerTiltState) {this.log('warn','Pas de type générique "Action/Volet Slider Inclinaison Verticale" malgré l\'état "Info/Volet Etat Inclinaison Verticale"');} - Serv.minValue=0; - if(Serv.infos.state.subType == 'binary') { - Serv.maxValue=1; - // Serv.getCharacteristic(Characteristic.TargetPosition).setProps({minStep:1}); } else { - Serv.maxValue=100; + Serv.FlapType="Opening"; + } + } + + eqServicesCopy.flap.forEach((cmd2) => { + if (cmd2.up) { + Serv.actions.up = cmd2.up; + } else if (cmd2.down) { + Serv.actions.down = cmd2.down; + } else if (cmd2.slider) { + Serv.actions.slider = cmd2.slider; + } else if (cmd2.HorTiltSlider) { + Serv.actions.HorTiltSlider = cmd2.HorTiltSlider; + } else if (cmd2.VerTiltSlider) { + Serv.actions.VerTiltSlider = cmd2.VerTiltSlider; + } else if (cmd2.HorTiltState) { + Serv.infos.HorTiltState = cmd2.HorTiltState; + } else if (cmd2.VerTiltState) { + Serv.infos.VerTiltState = cmd2.VerTiltState; } - if(Serv.actions.slider) { - if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { - Serv.maxValue = parseInt(Serv.actions.slider.configuration.maxValue); - } - if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.minValue && parseInt(Serv.actions.slider.configuration.minValue)) { - Serv.minValue = parseInt(Serv.actions.slider.configuration.minValue); - } + }); + if(Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Volet Bouton Descendre"');} + if(!Serv.actions.up && Serv.actions.down) {this.log('warn','Pas de type générique "Action/Volet Bouton Monter"');} + if(!Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Volet Bouton Descendre" et "Action/Volet Bouton Monter"');} + if(!Serv.actions.up && !Serv.actions.down && !Serv.actions.slider) {this.log('warn','Pas de type générique "Action/Volet Bouton Slider" et "Action/Volet Bouton Monter" et "Action/Volet Bouton Descendre"');} + if(Serv.actions.HorTiltSlider && !Serv.infos.HorTiltState) {this.log('warn','Pas de type générique "Info/Volet Etat Inclinaison Horizontale" malgré l\'action "Action/Volet Slider Inclinaison Horizontale"');} + if(Serv.actions.VerTiltSlider && !Serv.infos.VerTiltState) {this.log('warn','Pas de type générique "Info/Volet Etat Inclinaison Verticale" malgré l\'action "Action/Volet Slider Inclinaison Verticale"');} + if(!Serv.actions.HorTiltSlider && Serv.infos.HorTiltState) {this.log('warn','Pas de type générique "Action/Volet Slider Inclinaison Horizontale" malgré l\'état "Info/Volet Etat Inclinaison Horizontale"');} + if(!Serv.actions.VerTiltSlider && Serv.infos.VerTiltState) {this.log('warn','Pas de type générique "Action/Volet Slider Inclinaison Verticale" malgré l\'état "Info/Volet Etat Inclinaison Verticale"');} + Serv.minValue=0; + if(Serv.infos.state.subType == 'binary') { + Serv.maxValue=1; + // Serv.getCharacteristic(Characteristic.TargetPosition).setProps({minStep:1}); + } else { + Serv.maxValue=100; + } + if(Serv.actions.slider) { + if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { + Serv.maxValue = parseInt(Serv.actions.slider.configuration.maxValue); } - if(Serv.actions.HorTiltSlider) { - const props = {}; - if(Serv.actions.HorTiltSlider.configuration && Serv.actions.HorTiltSlider.configuration.maxValue && parseInt(Serv.actions.HorTiltSlider.configuration.maxValue)) { - props.maxValue = parseInt(Serv.actions.HorTiltSlider.configuration.maxValue); - } else { - props.maxValue = 90; - } - if(Serv.actions.HorTiltSlider.configuration && Serv.actions.HorTiltSlider.configuration.minValue && parseInt(Serv.actions.HorTiltSlider.configuration.minValue)) { - props.minValue = parseInt(Serv.actions.HorTiltSlider.configuration.minValue); - } else { - props.minValue = 0; - } - HBservice.characteristics.push(Characteristic.CurrentHorizontalTiltAngle); - Serv.addCharacteristic(Characteristic.CurrentHorizontalTiltAngle); - Serv.getCharacteristic(Characteristic.CurrentHorizontalTiltAngle).setProps(props); - - HBservice.characteristics.push(Characteristic.TargetHorizontalTiltAngle); - Serv.addCharacteristic(Characteristic.TargetHorizontalTiltAngle); - Serv.getCharacteristic(Characteristic.TargetHorizontalTiltAngle).setProps(props); - this.log('debug','Horizontal Slider props :'+JSON.stringify(props)+'/'+JSON.stringify(Serv.actions.HorTiltSlider.configuration)); + if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.minValue && parseInt(Serv.actions.slider.configuration.minValue)) { + Serv.minValue = parseInt(Serv.actions.slider.configuration.minValue); } - - if(Serv.actions.VerTiltSlider) { - const props = {}; - if(Serv.actions.VerTiltSlider.configuration && Serv.actions.VerTiltSlider.configuration.maxValue && parseInt(Serv.actions.VerTiltSlider.configuration.maxValue)) { - props.maxValue = parseInt(Serv.actions.VerTiltSlider.configuration.maxValue); - } else { - props.maxValue = 90; - } - if(Serv.actions.VerTiltSlider.configuration && Serv.actions.VerTiltSlider.configuration.minValue && parseInt(Serv.actions.VerTiltSlider.configuration.minValue)) { - props.minValue = parseInt(Serv.actions.VerTiltSlider.configuration.minValue); - } else { - props.minValue = 0; - } - HBservice.characteristics.push(Characteristic.CurrentVerticalTiltAngle); - Serv.addCharacteristic(Characteristic.CurrentVerticalTiltAngle); - Serv.getCharacteristic(Characteristic.CurrentVerticalTiltAngle).setProps(props); - - HBservice.characteristics.push(Characteristic.TargetVerticalTiltAngle); - Serv.addCharacteristic(Characteristic.TargetVerticalTiltAngle); - Serv.getCharacteristic(Characteristic.TargetVerticalTiltAngle).setProps(props); - this.log('debug','Vertical Slider props :'+JSON.stringify(props)+'/'+JSON.stringify(Serv.actions.VerTiltSlider.configuration)); + } + if(Serv.actions.HorTiltSlider) { + const props = {}; + if(Serv.actions.HorTiltSlider.configuration && Serv.actions.HorTiltSlider.configuration.maxValue && parseInt(Serv.actions.HorTiltSlider.configuration.maxValue)) { + props.maxValue = parseInt(Serv.actions.HorTiltSlider.configuration.maxValue); + } else { + props.maxValue = 90; + } + if(Serv.actions.HorTiltSlider.configuration && Serv.actions.HorTiltSlider.configuration.minValue && parseInt(Serv.actions.HorTiltSlider.configuration.minValue)) { + props.minValue = parseInt(Serv.actions.HorTiltSlider.configuration.minValue); + } else { + props.minValue = 0; } + HBservice.characteristics.push(Characteristic.CurrentHorizontalTiltAngle); + Serv.addCharacteristic(Characteristic.CurrentHorizontalTiltAngle); + Serv.getCharacteristic(Characteristic.CurrentHorizontalTiltAngle).setProps(props); - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + HBservice.characteristics.push(Characteristic.TargetHorizontalTiltAngle); + Serv.addCharacteristic(Characteristic.TargetHorizontalTiltAngle); + Serv.getCharacteristic(Characteristic.TargetHorizontalTiltAngle).setProps(props); + this.log('debug','Horizontal Slider props :'+JSON.stringify(props)+'/'+JSON.stringify(Serv.actions.HorTiltSlider.configuration)); + } + + if(Serv.actions.VerTiltSlider) { + const props = {}; + if(Serv.actions.VerTiltSlider.configuration && Serv.actions.VerTiltSlider.configuration.maxValue && parseInt(Serv.actions.VerTiltSlider.configuration.maxValue)) { + props.maxValue = parseInt(Serv.actions.VerTiltSlider.configuration.maxValue); + } else { + props.maxValue = 90; + } + if(Serv.actions.VerTiltSlider.configuration && Serv.actions.VerTiltSlider.configuration.minValue && parseInt(Serv.actions.VerTiltSlider.configuration.minValue)) { + props.minValue = parseInt(Serv.actions.VerTiltSlider.configuration.minValue); + } else { + props.minValue = 0; + } + HBservice.characteristics.push(Characteristic.CurrentVerticalTiltAngle); + Serv.addCharacteristic(Characteristic.CurrentVerticalTiltAngle); + Serv.getCharacteristic(Characteristic.CurrentVerticalTiltAngle).setProps(props); - Serv.cmd_id = Serv.infos.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - - HBservices.push(HBservice); + HBservice.characteristics.push(Characteristic.TargetVerticalTiltAngle); + Serv.addCharacteristic(Characteristic.TargetVerticalTiltAngle); + Serv.getCharacteristic(Characteristic.TargetVerticalTiltAngle).setProps(props); + this.log('debug','Vertical Slider props :'+JSON.stringify(props)+'/'+JSON.stringify(Serv.actions.VerTiltSlider.configuration)); } + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = Serv.infos.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Volet Etat" ou "Info/Volet Etat Fermeture" on regarde s\'il y a uniquement les boutons...'); @@ -704,8 +702,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; HBservices.push(HBservice); - } - if (cmd.down) { + } else if (cmd.down) { const SwitchName=cmd.down.name; HBservice = { controlService : new Service.Switch(SwitchName), @@ -731,8 +728,7 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { Serv.subtype = Serv.subtype || ''; Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; HBservices.push(HBservice); - } - if (cmd.stop) { + } else if (cmd.stop) { const SwitchName=cmd.stop.name; HBservice = { controlService : new Service.Switch(SwitchName), @@ -771,50 +767,49 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.windowMoto) { eqLogic.services.windowMoto.forEach((cmd) => { - if (cmd.state) { - HBservice = { - controlService : new Service.Window(eqLogic.name), - characteristics : [Characteristic.CurrentPosition, Characteristic.TargetPosition, Characteristic.PositionState], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - - eqServicesCopy.windowMoto.forEach((cmd2) => { - if (cmd2.up) { - Serv.actions.up = cmd2.up; - } else if (cmd2.down) { - Serv.actions.down = cmd2.down; - } else if (cmd2.slider) { - Serv.actions.slider = cmd2.slider; - } - }); - Serv.maxValue = 100; // if not set in Jeedom it's 100 - Serv.minValue = 0; // if not set in Jeedom it's 0 - if(Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Descendre"');} - if(!Serv.actions.up && Serv.actions.down) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Monter"');} - if(!Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Descendre" et "Action/Fenêtre Motorisée Monter"');} - if(!Serv.actions.up && !Serv.actions.down && !Serv.actions.slider) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Slider" et "Action/Fenêtre Motorisée Monter" et "Action/Fenêtre Motorisée Descendre"');} - if(Serv.actions.slider) { - if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { - Serv.maxValue = parseInt(Serv.actions.slider.configuration.maxValue); - } - if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.minValue && parseInt(Serv.actions.slider.configuration.minValue)) { - Serv.minValue = parseInt(Serv.actions.slider.configuration.minValue); - } + if (!cmd.state) {return;} + HBservice = { + controlService : new Service.Window(eqLogic.name), + characteristics : [Characteristic.CurrentPosition, Characteristic.TargetPosition, Characteristic.PositionState], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + + eqServicesCopy.windowMoto.forEach((cmd2) => { + if (cmd2.up) { + Serv.actions.up = cmd2.up; + } else if (cmd2.down) { + Serv.actions.down = cmd2.down; + } else if (cmd2.slider) { + Serv.actions.slider = cmd2.slider; } - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + }); + Serv.maxValue = 100; // if not set in Jeedom it's 100 + Serv.minValue = 0; // if not set in Jeedom it's 0 + if(Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Descendre"');} + if(!Serv.actions.up && Serv.actions.down) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Monter"');} + if(!Serv.actions.up && !Serv.actions.down) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Descendre" et "Action/Fenêtre Motorisée Monter"');} + if(!Serv.actions.up && !Serv.actions.down && !Serv.actions.slider) {this.log('warn','Pas de type générique "Action/Fenêtre Motorisée Slider" et "Action/Fenêtre Motorisée Monter" et "Action/Fenêtre Motorisée Descendre"');} + if(Serv.actions.slider) { + if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { + Serv.maxValue = parseInt(Serv.actions.slider.configuration.maxValue); + } + if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.minValue && parseInt(Serv.actions.slider.configuration.minValue)) { + Serv.minValue = parseInt(Serv.actions.slider.configuration.minValue); + } + } + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - } + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Fenêtre Motorisée Etat"'); @@ -824,38 +819,37 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.energy) { eqLogic.services.energy.forEach((cmd) => { - if (cmd.state) { - HBservice = { - controlService : new Service.Outlet(eqLogic.name), - characteristics : [Characteristic.On, Characteristic.OutletInUse], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - eqServicesCopy.energy.forEach((cmd2) => { - if (cmd2.on) { - Serv.actions.on = cmd2.on; - } else if (cmd2.off) { - Serv.actions.off = cmd2.off; - } else if (cmd2.inuse) { - Serv.infos.inuse = cmd2.inuse; - } - }); - if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Prise Bouton On"');} - if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Prise Bouton Off"');} - // Test for AdminOnlyAccess, state need to have OwnerOnly attribute to True ou 1 - if(Serv.infos.state.OwnerOnly) {Serv.getCharacteristic(Characteristic.On).setProps({adminOnlyAccess: [Access.WRITE]});} - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - } + if (!cmd.state) {return;} + HBservice = { + controlService : new Service.Outlet(eqLogic.name), + characteristics : [Characteristic.On, Characteristic.OutletInUse], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + eqServicesCopy.energy.forEach((cmd2) => { + if (cmd2.on) { + Serv.actions.on = cmd2.on; + } else if (cmd2.off) { + Serv.actions.off = cmd2.off; + } else if (cmd2.inuse) { + Serv.infos.inuse = cmd2.inuse; + } + }); + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Prise Bouton On"');} + if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Prise Bouton Off"');} + // Test for AdminOnlyAccess, state need to have OwnerOnly attribute to True ou 1 + if(Serv.infos.state.OwnerOnly) {Serv.getCharacteristic(Characteristic.On).setProps({adminOnlyAccess: [Access.WRITE]});} + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Prise Etat"'); @@ -865,37 +859,36 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.faucet) { eqLogic.services.faucet.forEach((cmd) => { - if (cmd.state) { - HBservice = { - controlService : new Service.Valve(eqLogic.name), - characteristics : [Characteristic.Active,Characteristic.InUse,Characteristic.ValveType], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - Serv.getCharacteristic(Characteristic.ValveType).setValue(Characteristic.ValveType.WATER_FAUCET); - Serv.ValveType=Characteristic.ValveType.WATER_FAUCET; - eqServicesCopy.faucet.forEach((cmd2) => { - if (cmd2.on) { - Serv.actions.on = cmd2.on; - } else if (cmd2.off) { - Serv.actions.off = cmd2.off; - } - }); - if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Robinet Bouton On"');} - if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Robinet Bouton Off"');} - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - } + if (!cmd.state) {return;} + HBservice = { + controlService : new Service.Valve(eqLogic.name), + characteristics : [Characteristic.Active,Characteristic.InUse,Characteristic.ValveType], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + Serv.getCharacteristic(Characteristic.ValveType).setValue(Characteristic.ValveType.WATER_FAUCET); + Serv.ValveType=Characteristic.ValveType.WATER_FAUCET; + eqServicesCopy.faucet.forEach((cmd2) => { + if (cmd2.on) { + Serv.actions.on = cmd2.on; + } else if (cmd2.off) { + Serv.actions.off = cmd2.off; + } + }); + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Robinet Bouton On"');} + if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Robinet Bouton Off"');} + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Robinet Etat"'); @@ -905,37 +898,36 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.irrigation) { eqLogic.services.irrigation.forEach((cmd) => { - if (cmd.state) { - HBservice = { - controlService : new Service.Valve(eqLogic.name), - characteristics : [Characteristic.Active,Characteristic.InUse,Characteristic.ValveType], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - Serv.getCharacteristic(Characteristic.ValveType).setValue(Characteristic.ValveType.IRRIGATION); - Serv.ValveType=Characteristic.ValveType.IRRIGATION; - eqServicesCopy.irrigation.forEach((cmd2) => { - if (cmd2.on) { - Serv.actions.on = cmd2.on; - } else if (cmd2.off) { - Serv.actions.off = cmd2.off; - } - }); - if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Irrigation Bouton On"');} - if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Irrigation Bouton Off"');} - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - } + if (!cmd.state) {return;} + HBservice = { + controlService : new Service.Valve(eqLogic.name), + characteristics : [Characteristic.Active,Characteristic.InUse,Characteristic.ValveType], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + Serv.getCharacteristic(Characteristic.ValveType).setValue(Characteristic.ValveType.IRRIGATION); + Serv.ValveType=Characteristic.ValveType.IRRIGATION; + eqServicesCopy.irrigation.forEach((cmd2) => { + if (cmd2.on) { + Serv.actions.on = cmd2.on; + } else if (cmd2.off) { + Serv.actions.off = cmd2.off; + } + }); + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Irrigation Bouton On"');} + if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Irrigation Bouton Off"');} + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Irrigation Etat"'); @@ -945,50 +937,49 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.valve) { eqLogic.services.valve.forEach((cmd) => { - if (cmd.state) { - HBservice = { - controlService : new Service.Valve(eqLogic.name), - characteristics : [Characteristic.Active,Characteristic.InUse,Characteristic.ValveType], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - Serv.getCharacteristic(Characteristic.ValveType).setValue(Characteristic.ValveType.GENERIC_VALVE); - Serv.ValveType=Characteristic.ValveType.GENERIC_VALVE; - eqServicesCopy.valve.forEach((cmd2) => { - if (cmd2.on) { - Serv.actions.on = cmd2.on; - } else if (cmd2.off) { - Serv.actions.off = cmd2.off; - } else if (cmd2.setDuration) { - Serv.actions.setDuration = cmd2.setDuration; - } else if (cmd2.remainingDuration) { - Serv.infos.remainingDuration = cmd2.remainingDuration; - } - }); - if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Valve générique Bouton On"');} - if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Valve générique Bouton Off"');} - - if(Serv.actions.setDuration) { - HBservice.characteristics.push(Characteristic.SetDuration); - Serv.addOptionalCharacteristic(Characteristic.SetDuration); + if (!cmd.state) {return;} + HBservice = { + controlService : new Service.Valve(eqLogic.name), + characteristics : [Characteristic.Active,Characteristic.InUse,Characteristic.ValveType], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + Serv.getCharacteristic(Characteristic.ValveType).setValue(Characteristic.ValveType.GENERIC_VALVE); + Serv.ValveType=Characteristic.ValveType.GENERIC_VALVE; + eqServicesCopy.valve.forEach((cmd2) => { + if (cmd2.on) { + Serv.actions.on = cmd2.on; + } else if (cmd2.off) { + Serv.actions.off = cmd2.off; + } else if (cmd2.setDuration) { + Serv.actions.setDuration = cmd2.setDuration; + } else if (cmd2.remainingDuration) { + Serv.infos.remainingDuration = cmd2.remainingDuration; } - if(Serv.infos.remainingDuration) { - HBservice.characteristics.push(Characteristic.RemainingDuration); - Serv.addOptionalCharacteristic(Characteristic.RemainingDuration); - } - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); + }); + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Valve générique Bouton On"');} + if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Valve générique Bouton Off"');} + + if(Serv.actions.setDuration) { + HBservice.characteristics.push(Characteristic.SetDuration); + Serv.addOptionalCharacteristic(Characteristic.SetDuration); } + if(Serv.infos.remainingDuration) { + HBservice.characteristics.push(Characteristic.RemainingDuration); + Serv.addOptionalCharacteristic(Characteristic.RemainingDuration); + } + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Valve générique Etat"'); @@ -998,57 +989,56 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.fan) { eqLogic.services.fan.forEach((cmd) => { - if (cmd.state) { - let FanType="Switch"; - let maxPower; - HBservice = { - controlService : new Service.Fan(eqLogic.name), - characteristics : [Characteristic.On], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - - eqServicesCopy.fan.forEach((cmd2) => { - if (cmd2.on) { - Serv.actions.on=cmd2.on; - } else if (cmd2.off) { - Serv.actions.off=cmd2.off; - } else if (cmd2.slider) { - Serv.actions.slider=cmd2.slider; - } - }); - if (Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Ventilateur OFF"');} - if (!Serv.actions.on && Serv.actions.off) {this.log('warn','Pas de type générique "Action/Ventilateur ON"');} - if (!Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Ventilateur ON" et "Action/Ventilateur OFF"');} - - if(Serv.actions.slider) { - if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { - maxPower = parseInt(Serv.actions.slider.configuration.maxValue); - } else { - maxPower = 100; // if not set in Jeedom it's 100 - } - FanType += "_Slider"; - HBservice.characteristics.push(Characteristic.RotationSpeed); - Serv.addCharacteristic(Characteristic.RotationSpeed); + if (!cmd.state) {return;} + let FanType="Switch"; + let maxPower; + HBservice = { + controlService : new Service.Fan(eqLogic.name), + characteristics : [Characteristic.On], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + + eqServicesCopy.fan.forEach((cmd2) => { + if (cmd2.on) { + Serv.actions.on=cmd2.on; + } else if (cmd2.off) { + Serv.actions.off=cmd2.off; + } else if (cmd2.slider) { + Serv.actions.slider=cmd2.slider; + } + }); + if (Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Ventilateur OFF"');} + if (!Serv.actions.on && Serv.actions.off) {this.log('warn','Pas de type générique "Action/Ventilateur ON"');} + if (!Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Ventilateur ON" et "Action/Ventilateur OFF"');} + + if(Serv.actions.slider) { + if(Serv.actions.slider.configuration && Serv.actions.slider.configuration.maxValue && parseInt(Serv.actions.slider.configuration.maxValue)) { + maxPower = parseInt(Serv.actions.slider.configuration.maxValue); } else { - this.log('info','Le ventilateur n\'a pas de variateur'); + maxPower = 100; // if not set in Jeedom it's 100 } - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - this.log('info','Le ventilateur est du type :',FanType+((maxPower)?','+maxPower:'')); - Serv.FanType = FanType; - Serv.maxPower = maxPower; - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); + FanType += "_Slider"; + HBservice.characteristics.push(Characteristic.RotationSpeed); + Serv.addCharacteristic(Characteristic.RotationSpeed); + } else { + this.log('info','Le ventilateur n\'a pas de variateur'); } + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + this.log('info','Le ventilateur est du type :',FanType+((maxPower)?','+maxPower:'')); + Serv.FanType = FanType; + Serv.maxPower = maxPower; + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Ventilateur Etat"'); @@ -1058,71 +1048,70 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.Switch) { eqLogic.services.Switch.forEach((cmd) => { - if (cmd.state) { - let SwitchName = eqLogic.name; - if(cmd.state.generic_type == 'CAMERA_RECORD_STATE' || (cmd.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1)) { - this.log('debug',"Switchs multiples dans même équipement, il y en a "+eqLogic.numSwitches); - SwitchName=cmd.state.name; - } - HBservice = { - controlService : new Service.Switch(SwitchName), - characteristics : [Characteristic.On], - }; - const Serv = HBservice.controlService; - if(cmd.state.generic_type == 'CAMERA_RECORD_STATE' || (cmd.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1)) { - this.log('debug',"Nom du switch (multi) : "+SwitchName); - Serv.getCharacteristic(Characteristic.On).displayName = SwitchName; - - Serv.ConfiguredName=SwitchName; - HBservice.characteristics.push(Characteristic.ConfiguredName); - Serv.addCharacteristic(Characteristic.ConfiguredName); - Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SwitchName); - } - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - eqServicesCopy.Switch.forEach((cmd2) => { - if (cmd2.on) { - if(Serv.infos.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1) { - if(cmd2.on.value == cmd.state.id) { - Serv.actions.on = cmd2.on; - } - } else { + if (!cmd.state) {return;} + let SwitchName = eqLogic.name; + if(cmd.state.generic_type == 'CAMERA_RECORD_STATE' || (cmd.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1)) { + this.log('debug',"Switchs multiples dans même équipement, il y en a "+eqLogic.numSwitches); + SwitchName=cmd.state.name; + } + HBservice = { + controlService : new Service.Switch(SwitchName), + characteristics : [Characteristic.On], + }; + const Serv = HBservice.controlService; + if(cmd.state.generic_type == 'CAMERA_RECORD_STATE' || (cmd.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1)) { + this.log('debug',"Nom du switch (multi) : "+SwitchName); + Serv.getCharacteristic(Characteristic.On).displayName = SwitchName; + + Serv.ConfiguredName=SwitchName; + HBservice.characteristics.push(Characteristic.ConfiguredName); + Serv.addCharacteristic(Characteristic.ConfiguredName); + Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SwitchName); + } + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + eqServicesCopy.Switch.forEach((cmd2) => { + if (cmd2.on) { + if(Serv.infos.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1) { + if(cmd2.on.value == cmd.state.id) { Serv.actions.on = cmd2.on; } - } else if (cmd2.off) { - if(Serv.infos.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1) { - if(cmd2.off.value == cmd.state.id) { - Serv.actions.off = cmd2.off; - } - } else { + } else { + Serv.actions.on = cmd2.on; + } + } else if (cmd2.off) { + if(Serv.infos.state.generic_type == 'SWITCH_STATE' && eqLogic.numSwitches>1) { + if(cmd2.off.value == cmd.state.id) { Serv.actions.off = cmd2.off; } + } else { + Serv.actions.off = cmd2.off; } - }); - if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Interrupteur Bouton On"');} - if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Interrupteur Bouton Off"');} - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - - if(this.fakegato && !eqLogic.hasLogging) { - // HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); + } + }); + if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Interrupteur Bouton On"');} + if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Interrupteur Bouton Off"');} + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + + if(this.fakegato && !eqLogic.hasLogging) { + // HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); - // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.loggingService = {type:"switch", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.loggingService = {type:"switch", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; - } - - HBservices.push(HBservice); + eqLogic.hasLogging=true; } + + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Interrupteur Etat"'); @@ -1132,31 +1121,30 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.Push) { eqLogic.services.Push.forEach((cmd) => { - if (cmd.Push && cmd.Push.subType == 'other') { - const SwitchName=cmd.Push.name; - HBservice = { - controlService : new Service.Switch(SwitchName), - characteristics : [Characteristic.On,Characteristic.ConfiguredName], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.actions.Push = cmd.Push; - Serv.getCharacteristic(Characteristic.On).displayName = SwitchName; - - Serv.ConfiguredName=SwitchName; - Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SwitchName); - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.Push.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - } + if (!cmd.Push || cmd.Push.subType != 'other') {return;} + const SwitchName=cmd.Push.name; + HBservice = { + controlService : new Service.Switch(SwitchName), + characteristics : [Characteristic.On,Characteristic.ConfiguredName], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.actions.Push = cmd.Push; + Serv.getCharacteristic(Characteristic.On).displayName = SwitchName; + + Serv.ConfiguredName=SwitchName; + Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SwitchName); + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.Push.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','La Commande Action associée doit être du type "Autre"'); @@ -1166,559 +1154,547 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.power || (eqLogic.services.power && eqLogic.services.consumption)) { eqLogic.services.power.forEach((cmd) => { - if (cmd.power) { - HBservice = { - controlService : new Service.PowerMonitor(eqLogic.name), - characteristics : [Characteristic.CurrentPowerConsumption, Characteristic.TotalPowerConsumption], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.power=cmd.power; - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - if(eqServicesCopy.consumption) { - eqServicesCopy.consumption.forEach((cmd2) => { - if (cmd2.consumption) { - Serv.infos.consumption=cmd2.consumption; - } - }); - } - - Serv.cmd_id = cmd.power.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(this.fakegato && !eqLogic.hasLogging) { - // HBservice.characteristics.push(Characteristic.ResetTotal); - eqLogic.loggingService = {type:"energy", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + if (!cmd.power) {return;} + HBservice = { + controlService : new Service.PowerMonitor(eqLogic.name), + characteristics : [Characteristic.CurrentPowerConsumption, Characteristic.TotalPowerConsumption], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.power=cmd.power; + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + if(eqServicesCopy.consumption) { + eqServicesCopy.consumption.forEach((cmd2) => { + if (cmd2.consumption) { + Serv.infos.consumption=cmd2.consumption; + } + }); + } + + Serv.cmd_id = cmd.power.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + if(this.fakegato && !eqLogic.hasLogging) { + // HBservice.characteristics.push(Characteristic.ResetTotal); + eqLogic.loggingService = {type:"energy", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; - } - HBservices.push(HBservice); - HBservice = null; + eqLogic.hasLogging=true; } + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.battery) { eqLogic.services.battery.forEach((cmd) => { - if (cmd.battery) { - HBservice = { - controlService : new Service.BatteryService(eqLogic.name), - characteristics : [Characteristic.BatteryLevel,Characteristic.ChargingState,Characteristic.StatusLowBattery], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.battery=cmd.battery; - Serv.infos.batteryCharging=cmd.batteryCharging || {id:'NOT'}; - eqServicesCopy.battery.forEach((cmd2) => { - if (cmd2.batteryCharging) { - Serv.infos.batteryCharging=cmd2.batteryCharging; - } else { - Serv.infos.batteryCharging={id:'NOT'}; - } - }); - Serv.cmd_id = cmd.battery.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; - } + if (!cmd.battery) {return;} + HBservice = { + controlService : new Service.BatteryService(eqLogic.name), + characteristics : [Characteristic.BatteryLevel,Characteristic.ChargingState,Characteristic.StatusLowBattery], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.battery=cmd.battery; + Serv.infos.batteryCharging=cmd.batteryCharging || {id:'NOT'}; + eqServicesCopy.battery.forEach((cmd2) => { + if (cmd2.batteryCharging) { + Serv.infos.batteryCharging=cmd2.batteryCharging; + } else { + Serv.infos.batteryCharging={id:'NOT'}; + } + }); + Serv.cmd_id = cmd.battery.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.Noise) { eqLogic.services.Noise.forEach((cmd) => { - if (cmd.Noise) { - HBservice = { - controlService : new Service.NoiseSensor(eqLogic.name), - characteristics : [Characteristic.NoiseLevel,Characteristic.NoiseQuality], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.Noise=cmd.Noise; - - if(cmd.Noise.subType=='numeric') { - Serv.levelNum=[]; - Serv.levelNum[Characteristic.NoiseQuality.SILENT]=50; - Serv.levelNum[Characteristic.NoiseQuality.CALM]=65; - Serv.levelNum[Characteristic.NoiseQuality.LIGHTLYNOISY]=70; - Serv.levelNum[Characteristic.NoiseQuality.NOISY]=80; - Serv.levelNum[Characteristic.NoiseQuality.TOONOISY]=100; - } else { - Serv.levelTxt=[]; - Serv.levelTxt[Characteristic.NoiseQuality.SILENT]="Silencieux"; - Serv.levelTxt[Characteristic.NoiseQuality.CALM]="Calme"; - Serv.levelTxt[Characteristic.NoiseQuality.LIGHTLYNOISY]="Légèrement Bruyant"; - Serv.levelTxt[Characteristic.NoiseQuality.NOISY]="Bruyant"; - Serv.levelTxt[Characteristic.NoiseQuality.TOONOISY]="Trop Bruyant"; - } - - Serv.cmd_id = cmd.Noise.id; - Serv.eqID = eqLogic.id; - Serv.subtype = 'Noise'; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - const uniteNoise = Serv.infos.Noise.unite ? Serv.infos.Noise.unite : ''; - if(uniteNoise) { - const propsNoise = {}; - propsNoise.unit=uniteNoise; - Serv.getCharacteristic(Characteristic.NoiseLevel).setProps(propsNoise); - } - - HBservices.push(HBservice); - HBservice = null; + if (!cmd.Noise) {return;} + HBservice = { + controlService : new Service.NoiseSensor(eqLogic.name), + characteristics : [Characteristic.NoiseLevel,Characteristic.NoiseQuality], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.Noise=cmd.Noise; + + if(cmd.Noise.subType=='numeric') { + Serv.levelNum=[]; + Serv.levelNum[Characteristic.NoiseQuality.SILENT]=50; + Serv.levelNum[Characteristic.NoiseQuality.CALM]=65; + Serv.levelNum[Characteristic.NoiseQuality.LIGHTLYNOISY]=70; + Serv.levelNum[Characteristic.NoiseQuality.NOISY]=80; + Serv.levelNum[Characteristic.NoiseQuality.TOONOISY]=100; + } else { + Serv.levelTxt=[]; + Serv.levelTxt[Characteristic.NoiseQuality.SILENT]="Silencieux"; + Serv.levelTxt[Characteristic.NoiseQuality.CALM]="Calme"; + Serv.levelTxt[Characteristic.NoiseQuality.LIGHTLYNOISY]="Légèrement Bruyant"; + Serv.levelTxt[Characteristic.NoiseQuality.NOISY]="Bruyant"; + Serv.levelTxt[Characteristic.NoiseQuality.TOONOISY]="Trop Bruyant"; } + + Serv.cmd_id = cmd.Noise.id; + Serv.eqID = eqLogic.id; + Serv.subtype = 'Noise'; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + const uniteNoise = Serv.infos.Noise.unite ? Serv.infos.Noise.unite : ''; + if(uniteNoise) { + const propsNoise = {}; + propsNoise.unit=uniteNoise; + Serv.getCharacteristic(Characteristic.NoiseLevel).setProps(propsNoise); + } + + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.CO) { eqLogic.services.CO.forEach((cmd) => { - if (cmd.CO) { - HBservice = { - controlService : new Service.CarbonMonoxideSensor(eqLogic.name), - characteristics : [Characteristic.CarbonMonoxideDetected], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.CO=cmd.CO; - - Serv.cmd_id = cmd.CO.id; - Serv.eqID = eqLogic.id; - Serv.subtype = 'CO'; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - - HBservices.push(HBservice); - HBservice = null; - } + if (!cmd.CO) {return;} + HBservice = { + controlService : new Service.CarbonMonoxideSensor(eqLogic.name), + characteristics : [Characteristic.CarbonMonoxideDetected], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.CO=cmd.CO; + + Serv.cmd_id = cmd.CO.id; + Serv.eqID = eqLogic.id; + Serv.subtype = 'CO'; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.CO2) { eqLogic.services.CO2.forEach((cmd) => { - if (cmd.CO2) { - HBservice = { - controlService : new Service.AirQualitySensor(eqLogic.name), - characteristics : [Characteristic.AirQuality,Characteristic.CarbonDioxideLevel,Characteristic.CarbonDioxideDetected], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.CO2=cmd.CO2; - - if(cmd.CO2.subType=='numeric') { - Serv.levelNum=[]; - Serv.levelNum[Characteristic.AirQuality.EXCELLENT]=900;// 700 - Serv.levelNum[Characteristic.AirQuality.GOOD]=1150;// 1100 - Serv.levelNum[Characteristic.AirQuality.FAIR]=1400;// 1600 - Serv.levelNum[Characteristic.AirQuality.INFERIOR]=1600;// 2100 - Serv.levelNum[Characteristic.AirQuality.POOR]=100000; - } else { - Serv.levelTxt=[]; - Serv.levelTxt[Characteristic.AirQuality.EXCELLENT]="Excellent"; - Serv.levelTxt[Characteristic.AirQuality.GOOD]="Bon"; - Serv.levelTxt[Characteristic.AirQuality.FAIR]="Moyen"; - Serv.levelTxt[Characteristic.AirQuality.INFERIOR]="Inférieur"; - Serv.levelTxt[Characteristic.AirQuality.POOR]="Faible"; - } - - Serv.cmd_id = cmd.CO2.id; - Serv.eqID = eqLogic.id; - Serv.subtype = 'CO2'; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - const uniteCO2 = Serv.infos.CO2.unite ? Serv.infos.CO2.unite : ''; - if(uniteCO2) { - const propsCO2 = {}; - propsCO2.unit=uniteCO2; - Serv.getCharacteristic(Characteristic.CarbonDioxideLevel).setProps(propsCO2); - } - - if(this.fakegato && !eqLogic.hasLogging) { - HBservice.characteristics.push(Characteristic.PPM); - Serv.addCharacteristic(Characteristic.PPM); - const unite = Serv.infos.CO2.unite ? Serv.infos.CO2.unite : ''; - if(unite) { - const props = {}; - props.unit=unite; - Serv.getCharacteristic(Characteristic.PPM).setProps(props); - } - HBservice.characteristics.push(Characteristic.AQExtraCharacteristic); - Serv.addCharacteristic(Characteristic.AQExtraCharacteristic); - - eqLogic.loggingService ={type:"room", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; + if (!cmd.CO2) {return;} + HBservice = { + controlService : new Service.AirQualitySensor(eqLogic.name), + characteristics : [Characteristic.AirQuality,Characteristic.CarbonDioxideLevel,Characteristic.CarbonDioxideDetected], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.CO2=cmd.CO2; + + if(cmd.CO2.subType=='numeric') { + Serv.levelNum=[]; + Serv.levelNum[Characteristic.AirQuality.EXCELLENT]=900;// 700 + Serv.levelNum[Characteristic.AirQuality.GOOD]=1150;// 1100 + Serv.levelNum[Characteristic.AirQuality.FAIR]=1400;// 1600 + Serv.levelNum[Characteristic.AirQuality.INFERIOR]=1600;// 2100 + Serv.levelNum[Characteristic.AirQuality.POOR]=100000; + } else { + Serv.levelTxt=[]; + Serv.levelTxt[Characteristic.AirQuality.EXCELLENT]="Excellent"; + Serv.levelTxt[Characteristic.AirQuality.GOOD]="Bon"; + Serv.levelTxt[Characteristic.AirQuality.FAIR]="Moyen"; + Serv.levelTxt[Characteristic.AirQuality.INFERIOR]="Inférieur"; + Serv.levelTxt[Characteristic.AirQuality.POOR]="Faible"; + } + + Serv.cmd_id = cmd.CO2.id; + Serv.eqID = eqLogic.id; + Serv.subtype = 'CO2'; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + const uniteCO2 = Serv.infos.CO2.unite ? Serv.infos.CO2.unite : ''; + if(uniteCO2) { + const propsCO2 = {}; + propsCO2.unit=uniteCO2; + Serv.getCharacteristic(Characteristic.CarbonDioxideLevel).setProps(propsCO2); + } + + if(this.fakegato && !eqLogic.hasLogging) { + HBservice.characteristics.push(Characteristic.PPM); + Serv.addCharacteristic(Characteristic.PPM); + const unite = Serv.infos.CO2.unite ? Serv.infos.CO2.unite : ''; + if(unite) { + const props = {}; + props.unit=unite; + Serv.getCharacteristic(Characteristic.PPM).setProps(props); } - - HBservices.push(HBservice); - HBservice = null; + HBservice.characteristics.push(Characteristic.AQExtraCharacteristic); + Serv.addCharacteristic(Characteristic.AQExtraCharacteristic); + + eqLogic.loggingService ={type:"room", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.hasLogging=true; } + + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.AirQualityCustom) { eqLogic.services.AirQualityCustom.forEach((cmd) => { - if (cmd.Index) { - HBservice = { - controlService : new Service.AirQualitySensor(eqLogic.name), - characteristics : [Characteristic.AirQuality], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.Index=cmd.Index; - - if(eqLogic.customizedValues && cmd.Index.subType=='numeric') { - Serv.levelNum=[]; - if(eqLogic.customizedValues.EXCELLENT && eqLogic.customizedValues.EXCELLENT != "NOT") { - Serv.levelNum[Characteristic.AirQuality.EXCELLENT] = parseInt(eqLogic.customizedValues.EXCELLENT); - } else { - this.log('warn',"Pas de config de la valeur 'Excellent', on la défini sur 50"); - Serv.levelNum[Characteristic.AirQuality.EXCELLENT]=50; - } - if(eqLogic.customizedValues.GOOD && eqLogic.customizedValues.GOOD != "NOT") { - Serv.levelNum[Characteristic.AirQuality.GOOD] = parseInt(eqLogic.customizedValues.GOOD); - } else { - this.log('warn',"Pas de config de la valeur 'Bon', on la défini sur 100"); - Serv.levelNum[Characteristic.AirQuality.GOOD]=100; - } - if(eqLogic.customizedValues.FAIR && eqLogic.customizedValues.FAIR != "NOT") { - Serv.levelNum[Characteristic.AirQuality.FAIR] = parseInt(eqLogic.customizedValues.FAIR); - } else { - this.log('warn',"Pas de config de la valeur 'Moyen', on la défini sur 150"); - Serv.levelNum[Characteristic.AirQuality.FAIR]=150; - } - if(eqLogic.customizedValues.INFERIOR && eqLogic.customizedValues.INFERIOR != "NOT") { - Serv.levelNum[Characteristic.AirQuality.INFERIOR] = parseInt(eqLogic.customizedValues.INFERIOR); - } else { - this.log('warn',"Pas de config de la valeur 'Inférieur', on la défini sur 200"); - Serv.levelNum[Characteristic.AirQuality.INFERIOR]=200; - } - if(eqLogic.customizedValues.POOR && eqLogic.customizedValues.POOR != "NOT") { - Serv.levelNum[Characteristic.AirQuality.POOR] = parseInt(eqLogic.customizedValues.POOR); - } else { - this.log('warn',"Pas de config de la valeur 'Faible', on la défini sur 1000"); - Serv.levelNum[Characteristic.AirQuality.POOR]=1000; - } - } else if(this.myPlugin == "homebridge") { - this.log('warn',"Pas de config numérique des valeurs que qualité d'air"); + if (!cmd.Index) {return;} + HBservice = { + controlService : new Service.AirQualitySensor(eqLogic.name), + characteristics : [Characteristic.AirQuality], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.Index=cmd.Index; + + if(eqLogic.customizedValues && cmd.Index.subType=='numeric') { + Serv.levelNum=[]; + if(eqLogic.customizedValues.EXCELLENT && eqLogic.customizedValues.EXCELLENT != "NOT") { + Serv.levelNum[Characteristic.AirQuality.EXCELLENT] = parseInt(eqLogic.customizedValues.EXCELLENT); + } else { + this.log('warn',"Pas de config de la valeur 'Excellent', on la défini sur 50"); + Serv.levelNum[Characteristic.AirQuality.EXCELLENT]=50; + } + if(eqLogic.customizedValues.GOOD && eqLogic.customizedValues.GOOD != "NOT") { + Serv.levelNum[Characteristic.AirQuality.GOOD] = parseInt(eqLogic.customizedValues.GOOD); + } else { + this.log('warn',"Pas de config de la valeur 'Bon', on la défini sur 100"); + Serv.levelNum[Characteristic.AirQuality.GOOD]=100; + } + if(eqLogic.customizedValues.FAIR && eqLogic.customizedValues.FAIR != "NOT") { + Serv.levelNum[Characteristic.AirQuality.FAIR] = parseInt(eqLogic.customizedValues.FAIR); + } else { + this.log('warn',"Pas de config de la valeur 'Moyen', on la défini sur 150"); + Serv.levelNum[Characteristic.AirQuality.FAIR]=150; + } + if(eqLogic.customizedValues.INFERIOR && eqLogic.customizedValues.INFERIOR != "NOT") { + Serv.levelNum[Characteristic.AirQuality.INFERIOR] = parseInt(eqLogic.customizedValues.INFERIOR); + } else { + this.log('warn',"Pas de config de la valeur 'Inférieur', on la défini sur 200"); + Serv.levelNum[Characteristic.AirQuality.INFERIOR]=200; + } + if(eqLogic.customizedValues.POOR && eqLogic.customizedValues.POOR != "NOT") { + Serv.levelNum[Characteristic.AirQuality.POOR] = parseInt(eqLogic.customizedValues.POOR); + } else { + this.log('warn',"Pas de config de la valeur 'Faible', on la défini sur 1000"); + Serv.levelNum[Characteristic.AirQuality.POOR]=1000; } + } else if(this.myPlugin == "homebridge") { + this.log('warn',"Pas de config numérique des valeurs que qualité d'air"); + } - - Serv.cmd_id = cmd.Index.id; - Serv.eqID = eqLogic.id; - Serv.subtype = 'AirQualityCustom'; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - - if(this.fakegato && !eqLogic.hasLogging) { - HBservice.characteristics.push(Characteristic.VOCDensity); - Serv.addCharacteristic(Characteristic.VOCDensity); - const unite = Serv.infos.Index.unite ? Serv.infos.Index.unite : ''; - if(unite) { - const props = {}; - props.unit=unite; - if(Serv.levelNum) {props.maxValue=parseInt(Serv.levelNum[Characteristic.AirQuality.POOR]*4.57);} - Serv.getCharacteristic(Characteristic.VOCDensity).setProps(props); - } - HBservice.characteristics.push(Characteristic.AQExtraCharacteristic); - Serv.addCharacteristic(Characteristic.AQExtraCharacteristic); - - eqLogic.loggingService ={type:"room2", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; + + Serv.cmd_id = cmd.Index.id; + Serv.eqID = eqLogic.id; + Serv.subtype = 'AirQualityCustom'; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + + if(this.fakegato && !eqLogic.hasLogging) { + HBservice.characteristics.push(Characteristic.VOCDensity); + Serv.addCharacteristic(Characteristic.VOCDensity); + const unite = Serv.infos.Index.unite ? Serv.infos.Index.unite : ''; + if(unite) { + const props = {}; + props.unit=unite; + if(Serv.levelNum) {props.maxValue=parseInt(Serv.levelNum[Characteristic.AirQuality.POOR]*4.57);} + Serv.getCharacteristic(Characteristic.VOCDensity).setProps(props); } - - HBservices.push(HBservice); - HBservice = null; + HBservice.characteristics.push(Characteristic.AQExtraCharacteristic); + Serv.addCharacteristic(Characteristic.AQExtraCharacteristic); + + eqLogic.loggingService ={type:"room2", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.hasLogging=true; } + + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.AirQuality) { eqLogic.services.AirQuality.forEach((cmd) => { - if (cmd.Index) { - HBservice = { - controlService : new Service.AirQualitySensor(eqLogic.name), - characteristics : [Characteristic.AirQuality], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.Index=cmd.Index; - eqServicesCopy.AirQuality.forEach((cmd2) => { - if (cmd2.PM25) { - Serv.infos.PM25= cmd2.PM25; - } - }); - // if there is a PM2.5 density, display it - if(Serv.infos.PM25) { - HBservice.characteristics.push(Characteristic.PM2_5Density); - Serv.addCharacteristic(Characteristic.PM2_5Density); - } - // AQI Generic - HBservice.characteristics.push(Characteristic.AQI); - Serv.addCharacteristic(Characteristic.AQI); - Serv.getCharacteristic(Characteristic.AQI).displayName = cmd.Index.name; - - if(cmd.Index.subType=='numeric') { - Serv.levelNum=[]; - Serv.levelNum[Characteristic.AirQuality.EXCELLENT]=50; - Serv.levelNum[Characteristic.AirQuality.GOOD]=100; - Serv.levelNum[Characteristic.AirQuality.FAIR]=150; - Serv.levelNum[Characteristic.AirQuality.INFERIOR]=200; - Serv.levelNum[Characteristic.AirQuality.POOR]=1000; - } else { - Serv.levelTxt=[]; - Serv.levelTxt[Characteristic.AirQuality.EXCELLENT]="Excellent"; - Serv.levelTxt[Characteristic.AirQuality.GOOD]="Bon"; - Serv.levelTxt[Characteristic.AirQuality.FAIR]="Moyen"; - Serv.levelTxt[Characteristic.AirQuality.INFERIOR]="Inférieur"; - Serv.levelTxt[Characteristic.AirQuality.POOR]="Faible"; - } - Serv.cmd_id = cmd.Index.id; - Serv.eqID = eqLogic.id; - Serv.subtype = 'AQI'; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; - } + if (!cmd.Index) {return;} + HBservice = { + controlService : new Service.AirQualitySensor(eqLogic.name), + characteristics : [Characteristic.AirQuality], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.Index=cmd.Index; + eqServicesCopy.AirQuality.forEach((cmd2) => { + if (cmd2.PM25) { + Serv.infos.PM25= cmd2.PM25; + } + }); + // if there is a PM2.5 density, display it + if(Serv.infos.PM25) { + HBservice.characteristics.push(Characteristic.PM2_5Density); + Serv.addCharacteristic(Characteristic.PM2_5Density); + } + // AQI Generic + HBservice.characteristics.push(Characteristic.AQI); + Serv.addCharacteristic(Characteristic.AQI); + Serv.getCharacteristic(Characteristic.AQI).displayName = cmd.Index.name; + + if(cmd.Index.subType=='numeric') { + Serv.levelNum=[]; + Serv.levelNum[Characteristic.AirQuality.EXCELLENT]=50; + Serv.levelNum[Characteristic.AirQuality.GOOD]=100; + Serv.levelNum[Characteristic.AirQuality.FAIR]=150; + Serv.levelNum[Characteristic.AirQuality.INFERIOR]=200; + Serv.levelNum[Characteristic.AirQuality.POOR]=1000; + } else { + Serv.levelTxt=[]; + Serv.levelTxt[Characteristic.AirQuality.EXCELLENT]="Excellent"; + Serv.levelTxt[Characteristic.AirQuality.GOOD]="Bon"; + Serv.levelTxt[Characteristic.AirQuality.FAIR]="Moyen"; + Serv.levelTxt[Characteristic.AirQuality.INFERIOR]="Inférieur"; + Serv.levelTxt[Characteristic.AirQuality.POOR]="Faible"; + } + Serv.cmd_id = cmd.Index.id; + Serv.eqID = eqLogic.id; + Serv.subtype = 'AQI'; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.presence) { eqLogic.services.presence.forEach((cmd) => { - if (cmd.presence) { - let SensorName=eqLogic.name; - if(eqLogic.numDetector>1) { - this.log('debug',"Detecteurs multiples dans même équipement, il y en a "+eqLogic.numDetector); - SensorName=cmd.presence.name; - } - HBservice = { - controlService : new Service.MotionSensor(SensorName), - characteristics : [Characteristic.MotionDetected], - }; - const Serv = HBservice.controlService; - if(eqLogic.numDetector>1) { - this.log('debug',"Nom du détecteur (multi) : "+SensorName); - Serv.getCharacteristic(Characteristic.MotionDetected).displayName = SensorName; - - Serv.ConfiguredName=SensorName; - HBservice.characteristics.push(Characteristic.ConfiguredName); - Serv.addCharacteristic(Characteristic.ConfiguredName); - Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SensorName); - } - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.presence=cmd.presence; - Serv.invertBinary=0; - if(cmd.presence.display && cmd.presence.display.invertBinary != undefined) { - Serv.invertBinary=cmd.presence.display.invertBinary; - } - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.presence.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + if (!cmd.presence) {return;} + let SensorName=eqLogic.name; + if(eqLogic.numDetector>1) { + this.log('debug',"Detecteurs multiples dans même équipement, il y en a "+eqLogic.numDetector); + SensorName=cmd.presence.name; + } + HBservice = { + controlService : new Service.MotionSensor(SensorName), + characteristics : [Characteristic.MotionDetected], + }; + const Serv = HBservice.controlService; + if(eqLogic.numDetector>1) { + this.log('debug',"Nom du détecteur (multi) : "+SensorName); + Serv.getCharacteristic(Characteristic.MotionDetected).displayName = SensorName; - if(this.fakegato && !eqLogic.hasLogging) { - HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); - Serv.addOptionalCharacteristic(Characteristic.Sensitivity); - Serv.addOptionalCharacteristic(Characteristic.Duration); - Serv.addOptionalCharacteristic(Characteristic.LastActivation); + Serv.ConfiguredName=SensorName; + HBservice.characteristics.push(Characteristic.ConfiguredName); + Serv.addCharacteristic(Characteristic.ConfiguredName); + Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SensorName); + } + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.presence=cmd.presence; + Serv.invertBinary=0; + if(cmd.presence.display && cmd.presence.display.invertBinary != undefined) { + Serv.invertBinary=cmd.presence.display.invertBinary; + } + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.presence.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + + if(this.fakegato && !eqLogic.hasLogging) { + HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); + Serv.addOptionalCharacteristic(Characteristic.Sensitivity); + Serv.addOptionalCharacteristic(Characteristic.Duration); + Serv.addOptionalCharacteristic(Characteristic.LastActivation); - // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.loggingService = {type:"motion", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.loggingService = {type:"motion", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; - } - - HBservices.push(HBservice); - HBservice = null; + eqLogic.hasLogging=true; } + + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.occupancy) { eqLogic.services.occupancy.forEach((cmd) => { - if (cmd.occupancy) { - let SensorName=eqLogic.name; - if(eqLogic.numDetector>1) { - this.log('debug',"Detecteurs occupancy multiples dans même équipement, il y en a "+eqLogic.numDetector); - SensorName=cmd.occupancy.name; - } - HBservice = { - controlService : new Service.OccupancySensor(SensorName), - characteristics : [Characteristic.OccupancyDetected], - }; - const Serv = HBservice.controlService; - if(eqLogic.numDetector>1) { - this.log('debug',"Nom du détecteur (multi) : "+SensorName); - Serv.getCharacteristic(Characteristic.OccupancyDetected).displayName = SensorName; - - Serv.ConfiguredName=SensorName; - HBservice.characteristics.push(Characteristic.ConfiguredName); - Serv.addCharacteristic(Characteristic.ConfiguredName); - Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SensorName); - } - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.occupancy=cmd.occupancy; - Serv.invertBinary=0; - if(cmd.occupancy.display && cmd.occupancy.display.invertBinary != undefined) { - Serv.invertBinary=cmd.occupancy.display.invertBinary; - } - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.occupancy.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; - } + if (!cmd.occupancy) {return;} + let SensorName=eqLogic.name; + if(eqLogic.numDetector>1) { + this.log('debug',"Detecteurs occupancy multiples dans même équipement, il y en a "+eqLogic.numDetector); + SensorName=cmd.occupancy.name; + } + HBservice = { + controlService : new Service.OccupancySensor(SensorName), + characteristics : [Characteristic.OccupancyDetected], + }; + const Serv = HBservice.controlService; + if(eqLogic.numDetector>1) { + this.log('debug',"Nom du détecteur (multi) : "+SensorName); + Serv.getCharacteristic(Characteristic.OccupancyDetected).displayName = SensorName; + + Serv.ConfiguredName=SensorName; + HBservice.characteristics.push(Characteristic.ConfiguredName); + Serv.addCharacteristic(Characteristic.ConfiguredName); + Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(SensorName); + } + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.occupancy=cmd.occupancy; + Serv.invertBinary=0; + if(cmd.occupancy.display && cmd.occupancy.display.invertBinary != undefined) { + Serv.invertBinary=cmd.occupancy.display.invertBinary; + } + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.occupancy.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.generic) { eqLogic.services.generic.forEach((cmd) => { - if (cmd.state) { - HBservice = { - controlService : new Service.CustomService(cmd.state.name), - characteristics : [], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - var props = {}; - var unite = ''; - if(cmd.state.subType=="numeric") { - this.log('debug','Le générique',cmd.state.name,'est un numérique'); - // test if default value is Float or Int ? - var CharactToSet=Characteristic.GenericFLOAT; - var NumericGenericType='float'; - if(cmd.state.currentValue.toString().indexOf('.') == -1) { - CharactToSet=Characteristic.GenericINT; - NumericGenericType='int'; - } - this.log('debug','Sur base de sa valeur actuelle',cmd.state.currentValue,', on determine un type :',NumericGenericType); - HBservice.characteristics.push(CharactToSet); - Serv.addCharacteristic(CharactToSet); - Serv.getCharacteristic(CharactToSet).displayName = cmd.state.name; - - unite = cmd.state.unite ? cmd.state.unite : ''; - if(unite) {props.unit=unite;} - if(cmd.state.configuration) { - if(NumericGenericType=='float'){ - if(cmd.state.configuration.maxValue != null && cmd.state.configuration.maxValue != undefined && cmd.state.configuration.maxValue != "") {props.maxValue = parseFloat(cmd.state.configuration.maxValue);} - if(cmd.state.configuration.minValue != null && cmd.state.configuration.minValue != undefined && cmd.state.configuration.minValue != "") {props.minValue = parseFloat(cmd.state.configuration.minValue);} - } else if (NumericGenericType=='int'){ - if(cmd.state.configuration.maxValue != null && cmd.state.configuration.maxValue != undefined && cmd.state.configuration.maxValue != "") {props.maxValue = parseInt(cmd.state.configuration.maxValue);} - if(cmd.state.configuration.minValue != null && cmd.state.configuration.minValue != undefined && cmd.state.configuration.minValue != "") {props.minValue = parseInt(cmd.state.configuration.minValue);} - } - } - if(Object.keys(props).length !== 0) { - this.log('debug','On lui set les props suivants :',props); - Serv.getCharacteristic(CharactToSet).setProps(props); - } - } else if (cmd.state.subType=="binary") { - this.log('debug','Le générique',cmd.state.name,'est un booléen'); - HBservice.characteristics.push(Characteristic.GenericBOOL); - Serv.addCharacteristic(Characteristic.GenericBOOL); - Serv.getCharacteristic(Characteristic.GenericBOOL).displayName = cmd.state.name; - } else if (cmd.state.subType=="string" || cmd.state.subType=="other") { - this.log('debug','Le générique',cmd.state.name,'est une chaîne'); - HBservice.characteristics.push(Characteristic.GenericSTRING); - Serv.addCharacteristic(Characteristic.GenericSTRING); - Serv.getCharacteristic(Characteristic.GenericSTRING).displayName = cmd.state.name; - - unite = cmd.state.unite ? cmd.state.unite : ''; - if(unite) {props.unit=unite;} - if(Object.keys(props).length !== 0) { - this.log('debug','On lui set les props suivants :',props); - Serv.getCharacteristic(Characteristic.GenericSTRING).setProps(props); - } - } - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id +'-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; - } + if (!cmd.state) {return;} + HBservice = { + controlService : new Service.CustomService(cmd.state.name), + characteristics : [], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + var props = {}; + var unite = ''; + if(cmd.state.subType=="numeric") { + this.log('debug','Le générique',cmd.state.name,'est un numérique'); + // test if default value is Float or Int ? + var CharactToSet=Characteristic.GenericFLOAT; + var NumericGenericType='float'; + if(cmd.state.currentValue.toString().indexOf('.') == -1) { + CharactToSet=Characteristic.GenericINT; + NumericGenericType='int'; + } + this.log('debug','Sur base de sa valeur actuelle',cmd.state.currentValue,', on determine un type :',NumericGenericType); + HBservice.characteristics.push(CharactToSet); + Serv.addCharacteristic(CharactToSet); + Serv.getCharacteristic(CharactToSet).displayName = cmd.state.name; + + unite = cmd.state.unite ? cmd.state.unite : ''; + if(unite) {props.unit=unite;} + if(cmd.state.configuration) { + if(NumericGenericType=='float'){ + if(cmd.state.configuration.maxValue != null && cmd.state.configuration.maxValue != undefined && cmd.state.configuration.maxValue != "") {props.maxValue = parseFloat(cmd.state.configuration.maxValue);} + if(cmd.state.configuration.minValue != null && cmd.state.configuration.minValue != undefined && cmd.state.configuration.minValue != "") {props.minValue = parseFloat(cmd.state.configuration.minValue);} + } else if (NumericGenericType=='int'){ + if(cmd.state.configuration.maxValue != null && cmd.state.configuration.maxValue != undefined && cmd.state.configuration.maxValue != "") {props.maxValue = parseInt(cmd.state.configuration.maxValue);} + if(cmd.state.configuration.minValue != null && cmd.state.configuration.minValue != undefined && cmd.state.configuration.minValue != "") {props.minValue = parseInt(cmd.state.configuration.minValue);} + } + } + if(Object.keys(props).length !== 0) { + this.log('debug','On lui set les props suivants :',props); + Serv.getCharacteristic(CharactToSet).setProps(props); + } + } else if (cmd.state.subType=="binary") { + this.log('debug','Le générique',cmd.state.name,'est un booléen'); + HBservice.characteristics.push(Characteristic.GenericBOOL); + Serv.addCharacteristic(Characteristic.GenericBOOL); + Serv.getCharacteristic(Characteristic.GenericBOOL).displayName = cmd.state.name; + } else if (cmd.state.subType=="string" || cmd.state.subType=="other") { + this.log('debug','Le générique',cmd.state.name,'est une chaîne'); + HBservice.characteristics.push(Characteristic.GenericSTRING); + Serv.addCharacteristic(Characteristic.GenericSTRING); + Serv.getCharacteristic(Characteristic.GenericSTRING).displayName = cmd.state.name; + + unite = cmd.state.unite ? cmd.state.unite : ''; + if(unite) {props.unit=unite;} + if(Object.keys(props).length !== 0) { + this.log('debug','On lui set les props suivants :',props); + Serv.getCharacteristic(Characteristic.GenericSTRING).setProps(props); + } + } + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id +'-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.uv) { eqLogic.services.uv.forEach((cmd) => { - if (cmd.uv) { - HBservice = { - controlService : new Service.WeatherService(eqLogic.name), - characteristics : [Characteristic.UVIndex], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.uv=cmd.uv; - Serv.cmd_id = cmd.uv.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; - } + if (!cmd.uv) {return;} + HBservice = { + controlService : new Service.WeatherService(eqLogic.name), + characteristics : [Characteristic.UVIndex], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.uv=cmd.uv; + Serv.cmd_id = cmd.uv.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.speaker) { eqLogic.services.speaker.forEach((cmd) => { - if (cmd.volume) { - HBservice = { - controlService : new Service.Speaker(eqLogic.name), - characteristics : [Characteristic.Mute,Characteristic.Volume], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.volume=cmd.volume; - eqServicesCopy.speaker.forEach((cmd2) => { - if (cmd2.mute_toggle) { - Serv.actions.mute_toggle = cmd2.mute_toggle; - } else if (cmd2.mute_on) { - Serv.actions.mute_on = cmd2.mute_on; - } else if (cmd2.mute_off) { - Serv.actions.mute_off = cmd2.mute_off; - } else if (cmd2.set_volume) { - Serv.actions.set_volume = cmd2.set_volume; - } else if (cmd2.mute) { - Serv.infos.mute=cmd2.mute; - } - }); - if(!Serv.actions.set_volume) {this.log('warn','Pas de type générique "Action/Haut-Parleur Volume"');} - if(!Serv.actions.mute_toggle && !Serv.actions.mute_on && Serv.actions.mute_off) {this.log('warn','Pas de type générique "Action/Haut-Parleur Mute"');} - if(!Serv.actions.mute_toggle && Serv.actions.mute_on && !Serv.actions.mute_off) {this.log('warn','Pas de type générique "Action/Haut-Parleur UnMute"');} - if(!Serv.actions.mute_toggle && !Serv.actions.mute_on && !Serv.actions.mute_off) {this.log('warn','Pas de type générique "Action/Haut-Parleur Toggle Mute" / "Action/Haut-Parleur Mute" / "Action/Haut-Parleur UnMute"');} - Serv.cmd_id = cmd.volume.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - } + if (!cmd.volume) {return;} + HBservice = { + controlService : new Service.Speaker(eqLogic.name), + characteristics : [Characteristic.Mute,Characteristic.Volume], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.volume=cmd.volume; + eqServicesCopy.speaker.forEach((cmd2) => { + if (cmd2.mute_toggle) { + Serv.actions.mute_toggle = cmd2.mute_toggle; + } else if (cmd2.mute_on) { + Serv.actions.mute_on = cmd2.mute_on; + } else if (cmd2.mute_off) { + Serv.actions.mute_off = cmd2.mute_off; + } else if (cmd2.set_volume) { + Serv.actions.set_volume = cmd2.set_volume; + } else if (cmd2.mute) { + Serv.infos.mute=cmd2.mute; + } + }); + if(!Serv.actions.set_volume) {this.log('warn','Pas de type générique "Action/Haut-Parleur Volume"');} + if(!Serv.actions.mute_toggle && !Serv.actions.mute_on && Serv.actions.mute_off) {this.log('warn','Pas de type générique "Action/Haut-Parleur Mute"');} + if(!Serv.actions.mute_toggle && Serv.actions.mute_on && !Serv.actions.mute_off) {this.log('warn','Pas de type générique "Action/Haut-Parleur UnMute"');} + if(!Serv.actions.mute_toggle && !Serv.actions.mute_on && !Serv.actions.mute_off) {this.log('warn','Pas de type générique "Action/Haut-Parleur Toggle Mute" / "Action/Haut-Parleur Mute" / "Action/Haut-Parleur UnMute"');} + Serv.cmd_id = cmd.volume.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Haut-Parleur Volume"'); @@ -1728,264 +1704,256 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.temperature) { eqLogic.services.temperature.forEach((cmd) => { - if (cmd.temperature) { - HBservice = { - controlService : new Service.TemperatureSensor(eqLogic.name), - characteristics : [Characteristic.CurrentTemperature], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.temperature=cmd.temperature; - - HBservice.characteristics.push(Characteristic.TemperatureDisplayUnits); - Serv.addOptionalCharacteristic(Characteristic.TemperatureDisplayUnits); - Serv.getCharacteristic(Characteristic.TemperatureDisplayUnits).updateValue(Characteristic.TemperatureDisplayUnits.CELSIUS); - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.temperature.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(this.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService ={type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; - } - - HBservices.push(HBservice); - HBservice = null; + if (!cmd.temperature) {return;} + HBservice = { + controlService : new Service.TemperatureSensor(eqLogic.name), + characteristics : [Characteristic.CurrentTemperature], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.temperature=cmd.temperature; + + HBservice.characteristics.push(Characteristic.TemperatureDisplayUnits); + Serv.addOptionalCharacteristic(Characteristic.TemperatureDisplayUnits); + Serv.getCharacteristic(Characteristic.TemperatureDisplayUnits).updateValue(Characteristic.TemperatureDisplayUnits.CELSIUS); + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.temperature.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService ={type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.hasLogging=true; } + + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.humidity) { eqLogic.services.humidity.forEach((cmd) => { - if (cmd.humidity) { - HBservice = { - controlService : new Service.HumiditySensor(eqLogic.name), - characteristics : [Characteristic.CurrentRelativeHumidity], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.humidity=cmd.humidity; - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.humidity.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - - if(this.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService = {type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; - } - - HBservices.push(HBservice); - HBservice = null; + if (!cmd.humidity) {return;} + HBservice = { + controlService : new Service.HumiditySensor(eqLogic.name), + characteristics : [Characteristic.CurrentRelativeHumidity], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.humidity=cmd.humidity; + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.humidity.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService = {type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.hasLogging=true; } + + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.pressure) { eqLogic.services.pressure.forEach((cmd) => { - if (cmd.pressure) { - HBservice = { - controlService : new Service.PressureSensor(eqLogic.name), - characteristics : [Characteristic.AirPressure], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.pressure=cmd.pressure; - Serv.cmd_id = cmd.pressure.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - - if(this.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService = {type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; - } - - HBservices.push(HBservice); - HBservice = null; + if (!cmd.pressure) {return;} + HBservice = { + controlService : new Service.PressureSensor(eqLogic.name), + characteristics : [Characteristic.AirPressure], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.pressure=cmd.pressure; + Serv.cmd_id = cmd.pressure.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService = {type:"weather", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.hasLogging=true; } + + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.smoke) { eqLogic.services.smoke.forEach((cmd) => { - if (cmd.smoke) { - HBservice = { - controlService : new Service.SmokeSensor(eqLogic.name), - characteristics : [Characteristic.SmokeDetected], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.smoke=cmd.smoke; - Serv.invertBinary=0; - if(cmd.smoke.display && cmd.smoke.display.invertBinary != undefined) { - Serv.invertBinary=cmd.smoke.display.invertBinary; - } - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.smoke.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; - } + if (!cmd.smoke) {return;} + HBservice = { + controlService : new Service.SmokeSensor(eqLogic.name), + characteristics : [Characteristic.SmokeDetected], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.smoke=cmd.smoke; + Serv.invertBinary=0; + if(cmd.smoke.display && cmd.smoke.display.invertBinary != undefined) { + Serv.invertBinary=cmd.smoke.display.invertBinary; + } + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.smoke.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.flood) { eqLogic.services.flood.forEach((cmd) => { - if (cmd.flood) { - HBservice = { - controlService : new Service.LeakSensor(eqLogic.name), - characteristics : [Characteristic.LeakDetected], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.flood=cmd.flood; - Serv.invertBinary=0; - if(cmd.flood.display && cmd.flood.display.invertBinary != undefined) { - Serv.invertBinary=cmd.flood.display.invertBinary; - } - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.flood.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; - } + if (!cmd.flood) {return;} + HBservice = { + controlService : new Service.LeakSensor(eqLogic.name), + characteristics : [Characteristic.LeakDetected], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.flood=cmd.flood; + Serv.invertBinary=0; + if(cmd.flood.display && cmd.flood.display.invertBinary != undefined) { + Serv.invertBinary=cmd.flood.display.invertBinary; + } + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.flood.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.opening) { eqLogic.services.opening.forEach((cmd) => { - if (cmd.opening) { - HBservice = { - controlService : new Service.ContactSensor(eqLogic.name), - characteristics : [Characteristic.ContactSensorState], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.opening=cmd.opening; - Serv.invertBinary=0; - if(cmd.opening.display && cmd.opening.display.invertBinary != undefined) { - Serv.invertBinary=cmd.opening.display.invertBinary; - } - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.opening.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - - if(this.fakegato && !eqLogic.hasLogging) { - // Serv.eqLogic.numberOpened = 0; - HBservice.characteristics.push(Characteristic.TimesOpened,Characteristic.Char118,Characteristic.Char119,Characteristic.ResetTotal,Characteristic.LastActivation); - Serv.addOptionalCharacteristic(Characteristic.TimesOpened); - Serv.addOptionalCharacteristic(Characteristic.Char118); - Serv.addOptionalCharacteristic(Characteristic.Char119); - Serv.addOptionalCharacteristic(Characteristic.ResetTotal); - Serv.addOptionalCharacteristic(Characteristic.LastActivation); - - eqLogic.loggingService = {type:"door", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; - } - - HBservices.push(HBservice); - HBservice = null; + if (!cmd.opening) {return;} + HBservice = { + controlService : new Service.ContactSensor(eqLogic.name), + characteristics : [Characteristic.ContactSensorState], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.opening=cmd.opening; + Serv.invertBinary=0; + if(cmd.opening.display && cmd.opening.display.invertBinary != undefined) { + Serv.invertBinary=cmd.opening.display.invertBinary; + } + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.opening.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + + if(this.fakegato && !eqLogic.hasLogging) { + // Serv.eqLogic.numberOpened = 0; + HBservice.characteristics.push(Characteristic.TimesOpened,Characteristic.Char118,Characteristic.Char119,Characteristic.ResetTotal,Characteristic.LastActivation); + Serv.addOptionalCharacteristic(Characteristic.TimesOpened); + Serv.addOptionalCharacteristic(Characteristic.Char118); + Serv.addOptionalCharacteristic(Characteristic.Char119); + Serv.addOptionalCharacteristic(Characteristic.ResetTotal); + Serv.addOptionalCharacteristic(Characteristic.LastActivation); + + eqLogic.loggingService = {type:"door", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.hasLogging=true; } + + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.brightness) { eqLogic.services.brightness.forEach((cmd) => { - if (cmd.brightness) { - HBservice = { - controlService : new Service.LightSensor(eqLogic.name), - characteristics : [Characteristic.CurrentAmbientLightLevel], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.brightness=cmd.brightness; - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.brightness.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(this.fakegato && !eqLogic.hasLogging) { - // HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); + if (!cmd.brightness) {return;} + HBservice = { + controlService : new Service.LightSensor(eqLogic.name), + characteristics : [Characteristic.CurrentAmbientLightLevel], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.brightness=cmd.brightness; + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.brightness.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + if(this.fakegato && !eqLogic.hasLogging) { + // HBservice.characteristics.push(Characteristic.Sensitivity,Characteristic.Duration,Characteristic.LastActivation); - // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.loggingService = {type:"custom", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + // eqLogic.loggingService = {type:"motion", options:{storage:'googleDrive',folder:'fakegato',keyPath:'/home/pi/.homebridge/'},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.loggingService = {type:"custom", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; - } - HBservices.push(HBservice); - HBservice = null; + eqLogic.hasLogging=true; } + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.GarageDoor) { eqLogic.services.GarageDoor.forEach((cmd) => { - if (cmd.state) { - HBservice = { - controlService : new Service.GarageDoorOpener(eqLogic.name), - characteristics : [Characteristic.CurrentDoorState, Characteristic.TargetDoorState], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - eqServicesCopy.GarageDoor.forEach((cmd2) => { - if (cmd2.on) { - Serv.actions.on = cmd2.on; - } else if (cmd2.off) { - Serv.actions.off = cmd2.off; - } else if (cmd2.toggle) { - Serv.actions.toggle = cmd2.toggle; - } - }); - if(!Serv.actions.toggle && !Serv.actions.on && Serv.actions.off) {this.log('warn','Pas de type générique "Action/Portail ou garage bouton d\'ouverture"');} - if(!Serv.actions.toggle && Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Portail ou garage bouton de fermeture"');} - if(!Serv.actions.toggle && !Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique ""Action/Portail ou garage bouton toggle" / "Action/Portail ou garage bouton d\'ouverture" / "Action/Portail ou garage bouton de fermeture"');} - - if(eqLogic.customizedValues) { - Serv.customizedValues = eqLogic.customizedValues; + if (!cmd.state) {return;} + HBservice = { + controlService : new Service.GarageDoorOpener(eqLogic.name), + characteristics : [Characteristic.CurrentDoorState, Characteristic.TargetDoorState], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + eqServicesCopy.GarageDoor.forEach((cmd2) => { + if (cmd2.on) { + Serv.actions.on = cmd2.on; + } else if (cmd2.off) { + Serv.actions.off = cmd2.off; + } else if (cmd2.toggle) { + Serv.actions.toggle = cmd2.toggle; } - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); + }); + if(!Serv.actions.toggle && !Serv.actions.on && Serv.actions.off) {this.log('warn','Pas de type générique "Action/Portail ou garage bouton d\'ouverture"');} + if(!Serv.actions.toggle && Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique "Action/Portail ou garage bouton de fermeture"');} + if(!Serv.actions.toggle && !Serv.actions.on && !Serv.actions.off) {this.log('warn','Pas de type générique ""Action/Portail ou garage bouton toggle" / "Action/Portail ou garage bouton d\'ouverture" / "Action/Portail ou garage bouton de fermeture"');} + + if(eqLogic.customizedValues) { + Serv.customizedValues = eqLogic.customizedValues; } + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); }); if(!HBservice) { this.log('warn','Pas de type générique "Info/Garage état ouvrant" ou "Info/Portail état ouvrant"'); @@ -1995,115 +1963,113 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.lock) { eqLogic.services.lock.forEach((cmd) => { - if (cmd.state) { - HBservice = { - controlService : new Service.LockMechanism(eqLogic.name), - characteristics : [Characteristic.LockCurrentState, Characteristic.LockTargetState], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - eqServicesCopy.lock.forEach((cmd2) => { - if (cmd2.on) { - Serv.actions.on = cmd2.on; - } else if (cmd2.off) { - Serv.actions.off = cmd2.off; - } - }); - if(!Serv.actions.on) {this.log('warn','Pas de type générique "Action/Serrure Bouton Ouvrir"');} - // if(!Serv.actions.off) {this.log('warn','Pas de type générique "Action/Serrure Bouton Fermer"');} - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - } - }); - if(!HBservice) { - this.log('warn','Pas de type générique "Info/Serrure Etat"'); - } else { - HBservice = null; - } - } - if (eqLogic.services.StatelessSwitch) { - eqLogic.services.StatelessSwitch.forEach((cmd) => { - if(cmd.eventType) { - let buttonSingle,buttonDouble,buttonLong; - - if(cmd.eventType.customizedValues.SINGLE) { - buttonSingle = cmd.eventType.customizedValues.SINGLE.split(';'); - } else { - buttonSingle = [""]; - } - if(cmd.eventType.customizedValues.DOUBLE) { - buttonDouble = cmd.eventType.customizedValues.DOUBLE.split(';'); - } else { - buttonDouble = [""]; - } - if(cmd.eventType.customizedValues.LONG) { - buttonLong = cmd.eventType.customizedValues.LONG.split(';'); - } else { - buttonLong = [""]; + if (!cmd.state) {return;} + HBservice = { + controlService : new Service.LockMechanism(eqLogic.name), + characteristics : [Characteristic.LockCurrentState, Characteristic.LockTargetState], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + eqServicesCopy.lock.forEach((cmd2) => { + if (cmd2.on) { + Serv.actions.on = cmd2.on; + } else if (cmd2.off) { + Serv.actions.off = cmd2.off; } - const maxValues = Math.max(buttonSingle.length,buttonDouble.length,buttonLong.length); - - if(buttonSingle.length === buttonDouble.length && buttonDouble.length === buttonLong.length) { - - for(let b = 0;b { + if (!cmd.eventType) {return;} + let buttonSingle,buttonDouble,buttonLong; + + if(cmd.eventType.customizedValues.SINGLE) { + buttonSingle = cmd.eventType.customizedValues.SINGLE.split(';'); + } else { + buttonSingle = [""]; + } + if(cmd.eventType.customizedValues.DOUBLE) { + buttonDouble = cmd.eventType.customizedValues.DOUBLE.split(';'); + } else { + buttonDouble = [""]; + } + if(cmd.eventType.customizedValues.LONG) { + buttonLong = cmd.eventType.customizedValues.LONG.split(';'); + } else { + buttonLong = [""]; + } + const maxValues = Math.max(buttonSingle.length,buttonDouble.length,buttonLong.length); + + if(buttonSingle.length === buttonDouble.length && buttonDouble.length === buttonLong.length) { + + for(let b = 0;b { - if(cmd.setpoint) { - HBservice = { - controlService : new Service.Thermostat(eqLogic.name), - characteristics : [Characteristic.CurrentTemperature, Characteristic.TargetTemperature, Characteristic.CurrentHeatingCoolingState, Characteristic.TargetHeatingCoolingState], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.setpoint=cmd.setpoint; - Serv.thermo={}; - - HBservice.characteristics.push(Characteristic.TemperatureDisplayUnits); - Serv.addOptionalCharacteristic(Characteristic.TemperatureDisplayUnits); - Serv.getCharacteristic(Characteristic.TemperatureDisplayUnits).updateValue(Characteristic.TemperatureDisplayUnits.CELSIUS); - - eqServicesCopy.thermostat.forEach((cmd2) => { - if (cmd2.state_name) { - Serv.infos.state_name=cmd2.state_name; - } else if (cmd2.lock) { - Serv.infos.lock=cmd2.lock; - HBservice.characteristics.push(Characteristic.LockPhysicalControls); - Serv.addCharacteristic(Characteristic.LockPhysicalControls); - Serv.getCharacteristic(Characteristic.LockPhysicalControls).displayName = cmd2.lock.name; - } else if (cmd2.mode) { - Serv.infos.mode=cmd2.mode; - } else if (cmd2.temperature) { - Serv.infos.temperature=cmd2.temperature; - } else if (cmd2.state) { - Serv.infos.state=cmd2.state; - } else if (cmd2.set_lock) { - Serv.actions.set_lock=cmd2.set_lock; - } else if (cmd2.set_unlock) { - Serv.actions.set_unlock=cmd2.set_unlock; - } else if (cmd2.set_setpoint) { - Serv.actions.set_setpoint=cmd2.set_setpoint; - } - }); - - var props = {}; - if(Serv.actions.set_setpoint && Serv.actions.set_setpoint.configuration && Serv.actions.set_setpoint.configuration.minValue && parseInt(Serv.actions.set_setpoint.configuration.minValue)) { - props.minValue = parseInt(Serv.actions.set_setpoint.configuration.minValue); - } - if(Serv.actions.set_setpoint && Serv.actions.set_setpoint.configuration && Serv.actions.set_setpoint.configuration.maxValue && parseInt(Serv.actions.set_setpoint.configuration.maxValue)) { - props.maxValue = parseInt(Serv.actions.set_setpoint.configuration.maxValue); - } - if(props.minValue && props.maxValue) { - Serv.getCharacteristic(Characteristic.TargetTemperature).setProps(props); + if (!cmd.setpoint) {return;} + HBservice = { + controlService : new Service.Thermostat(eqLogic.name), + characteristics : [Characteristic.CurrentTemperature, Characteristic.TargetTemperature, Characteristic.CurrentHeatingCoolingState, Characteristic.TargetHeatingCoolingState], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.setpoint=cmd.setpoint; + Serv.thermo={}; + + HBservice.characteristics.push(Characteristic.TemperatureDisplayUnits); + Serv.addOptionalCharacteristic(Characteristic.TemperatureDisplayUnits); + Serv.getCharacteristic(Characteristic.TemperatureDisplayUnits).updateValue(Characteristic.TemperatureDisplayUnits.CELSIUS); + + eqServicesCopy.thermostat.forEach((cmd2) => { + if (cmd2.state_name) { + Serv.infos.state_name=cmd2.state_name; + } else if (cmd2.lock) { + Serv.infos.lock=cmd2.lock; + HBservice.characteristics.push(Characteristic.LockPhysicalControls); + Serv.addCharacteristic(Characteristic.LockPhysicalControls); + Serv.getCharacteristic(Characteristic.LockPhysicalControls).displayName = cmd2.lock.name; + } else if (cmd2.mode) { + Serv.infos.mode=cmd2.mode; + } else if (cmd2.temperature) { + Serv.infos.temperature=cmd2.temperature; + } else if (cmd2.state) { + Serv.infos.state=cmd2.state; + } else if (cmd2.set_lock) { + Serv.actions.set_lock=cmd2.set_lock; + } else if (cmd2.set_unlock) { + Serv.actions.set_unlock=cmd2.set_unlock; + } else if (cmd2.set_setpoint) { + Serv.actions.set_setpoint=cmd2.set_setpoint; } - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + }); - props = {}; - props.validValues=[0]; - if(eqLogic.thermoModes) { - if(eqLogic.thermoModes.Chauf && eqLogic.thermoModes.Chauf != "NOT") { - Serv.thermo.chauf = {}; - const splitted = eqLogic.thermoModes.Chauf.split('|'); - Serv.thermo.chauf.mode_label = splitted[1]; - Serv.thermo.chauf.mode_id = splitted[0]; - props.validValues.push(1); - } else { - this.log('warn','Pas de config du mode Chauffage'); - } - if(eqLogic.thermoModes.Clim && eqLogic.thermoModes.Clim != "NOT") { - Serv.thermo.clim = {}; - const splitted = eqLogic.thermoModes.Clim.split('|'); - Serv.thermo.clim.mode_label = splitted[1]; - Serv.thermo.clim.mode_id = splitted[0]; - props.validValues.push(2); - } else { - this.log('warn','Pas de config du mode Climatisation'); - } - if(eqLogic.thermoModes.Off && eqLogic.thermoModes.Off != "NOT") { - Serv.thermo.off = {}; - const splitted = eqLogic.thermoModes.Off.split('|'); - Serv.thermo.off.mode_label = splitted[1]; - Serv.thermo.off.mode_id = splitted[0]; - } - } else if(this.myPlugin == "homebridge") { - this.log('warn','Pas de config des modes du thermostat'); - } - // Serv.getCharacteristic(Characteristic.CurrentHeatingCoolingState).setProps(props); - props.validValues.push(3); - Serv.getCharacteristic(Characteristic.TargetHeatingCoolingState).setProps(props); - Serv.cmd_id = cmd.setpoint.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - if(this.fakegato && !eqLogic.hasLogging) { - eqLogic.loggingService ={type:"thermo", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; - eqLogic.hasLogging=true; - } - HBservices.push(HBservice); - HBservice = null; + var props = {}; + if(Serv.actions.set_setpoint && Serv.actions.set_setpoint.configuration && Serv.actions.set_setpoint.configuration.minValue && parseInt(Serv.actions.set_setpoint.configuration.minValue)) { + props.minValue = parseInt(Serv.actions.set_setpoint.configuration.minValue); + } + if(Serv.actions.set_setpoint && Serv.actions.set_setpoint.configuration && Serv.actions.set_setpoint.configuration.maxValue && parseInt(Serv.actions.set_setpoint.configuration.maxValue)) { + props.maxValue = parseInt(Serv.actions.set_setpoint.configuration.maxValue); } + if(props.minValue && props.maxValue) { + Serv.getCharacteristic(Characteristic.TargetTemperature).setProps(props); + } + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + props = {}; + props.validValues=[0]; + if(eqLogic.thermoModes) { + if(eqLogic.thermoModes.Chauf && eqLogic.thermoModes.Chauf != "NOT") { + Serv.thermo.chauf = {}; + const splitted = eqLogic.thermoModes.Chauf.split('|'); + Serv.thermo.chauf.mode_label = splitted[1]; + Serv.thermo.chauf.mode_id = splitted[0]; + props.validValues.push(1); + } else { + this.log('warn','Pas de config du mode Chauffage'); + } + if(eqLogic.thermoModes.Clim && eqLogic.thermoModes.Clim != "NOT") { + Serv.thermo.clim = {}; + const splitted = eqLogic.thermoModes.Clim.split('|'); + Serv.thermo.clim.mode_label = splitted[1]; + Serv.thermo.clim.mode_id = splitted[0]; + props.validValues.push(2); + } else { + this.log('warn','Pas de config du mode Climatisation'); + } + if(eqLogic.thermoModes.Off && eqLogic.thermoModes.Off != "NOT") { + Serv.thermo.off = {}; + const splitted = eqLogic.thermoModes.Off.split('|'); + Serv.thermo.off.mode_label = splitted[1]; + Serv.thermo.off.mode_id = splitted[0]; + } + } else if(this.myPlugin == "homebridge") { + this.log('warn','Pas de config des modes du thermostat'); + } + // Serv.getCharacteristic(Characteristic.CurrentHeatingCoolingState).setProps(props); + props.validValues.push(3); + Serv.getCharacteristic(Characteristic.TargetHeatingCoolingState).setProps(props); + Serv.cmd_id = cmd.setpoint.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + if(this.fakegato && !eqLogic.hasLogging) { + eqLogic.loggingService ={type:"thermo", options:{storage:'fs',path:this.pathHomebridgeConf},subtype:Serv.eqID+'-history',cmd_id:Serv.eqID}; + eqLogic.hasLogging=true; + } + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.thermostatHC) { eqLogic.services.thermostatHC.forEach((cmd) => { - if(cmd.setpointH) { - HBservice = { - controlService : new Service.HeaterCooler(eqLogic.name), - characteristics : [Characteristic.CurrentTemperature, Characteristic.CoolingThresholdTemperature, Characteristic.HeatingThresholdTemperature, Characteristic.CurrentHeatingCoolingState, Characteristic.TargetHeatingCoolingState], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.setpointH=cmd.setpointH; - Serv.thermoHC={}; - - HBservice.characteristics.push(Characteristic.TemperatureDisplayUnits); - Serv.addOptionalCharacteristic(Characteristic.TemperatureDisplayUnits); - Serv.getCharacteristic(Characteristic.TemperatureDisplayUnits).updateValue(Characteristic.TemperatureDisplayUnits.CELSIUS); - - eqServicesCopy.thermostatHC.forEach((cmd2) => { - if (cmd2.setpointC) { - Serv.infos.setpointC=cmd2.setpointC; - } else if (cmd2.state_name) { - Serv.infos.state_name=cmd2.state_name; - } else if (cmd2.lock) { - Serv.infos.lock=cmd2.lock; - HBservice.characteristics.push(Characteristic.LockPhysicalControls); - Serv.addCharacteristic(Characteristic.LockPhysicalControls); - Serv.getCharacteristic(Characteristic.LockPhysicalControls).displayName = cmd2.lock.name; - } else if (cmd2.mode) { - Serv.infos.mode=cmd2.mode; - } else if (cmd2.temperature) { - Serv.infos.temperature=cmd2.temperature; - } else if (cmd2.state) { - Serv.infos.state=cmd2.state; - } else if (cmd2.set_lock) { - Serv.actions.set_lock=cmd2.set_lock; - } else if (cmd2.set_unlock) { - Serv.actions.set_unlock=cmd2.set_unlock; - } else if (cmd2.set_setpointH) { - Serv.actions.set_setpointH=cmd2.set_setpointH; - } else if (cmd2.set_setpointC) { - Serv.actions.set_setpointC=cmd2.set_setpointC; - } - }); - - var props = {}; - if(Serv.actions.set_setpointH && Serv.actions.set_setpointH.configuration && Serv.actions.set_setpointH.configuration.minValue && parseInt(Serv.actions.set_setpointH.configuration.minValue)) { - props.minValue = parseInt(Serv.actions.set_setpointH.configuration.minValue); - } - if(Serv.actions.set_setpointH && Serv.actions.set_setpointH.configuration && Serv.actions.set_setpointH.configuration.maxValue && parseInt(Serv.actions.set_setpointH.configuration.maxValue)) { - props.maxValue = parseInt(Serv.actions.set_setpointH.configuration.maxValue); - } - if(props.minValue && props.maxValue) { - Serv.getCharacteristic(Characteristic.HeatingThresholdTemperature).setProps(props); - } - props = {}; - if(Serv.actions.set_setpointC && Serv.actions.set_setpointC.configuration && Serv.actions.set_setpointC.configuration.minValue && parseInt(Serv.actions.set_setpointC.configuration.minValue)) { - props.minValue = parseInt(Serv.actions.set_setpointC.configuration.minValue); - } - if(Serv.actions.set_setpointC && Serv.actions.set_setpointC.configuration && Serv.actions.set_setpointC.configuration.maxValue && parseInt(Serv.actions.set_setpointC.configuration.maxValue)) { - props.maxValue = parseInt(Serv.actions.set_setpointC.configuration.maxValue); - } - if(props.minValue && props.maxValue) { - Serv.getCharacteristic(Characteristic.CoolingThresholdTemperature).setProps(props); + if (!cmd.setpointH) {return;} + HBservice = { + controlService : new Service.HeaterCooler(eqLogic.name), + characteristics : [Characteristic.CurrentTemperature, Characteristic.CoolingThresholdTemperature, Characteristic.HeatingThresholdTemperature, Characteristic.CurrentHeatingCoolingState, Characteristic.TargetHeatingCoolingState], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.setpointH=cmd.setpointH; + Serv.thermoHC={}; + + HBservice.characteristics.push(Characteristic.TemperatureDisplayUnits); + Serv.addOptionalCharacteristic(Characteristic.TemperatureDisplayUnits); + Serv.getCharacteristic(Characteristic.TemperatureDisplayUnits).updateValue(Characteristic.TemperatureDisplayUnits.CELSIUS); + + eqServicesCopy.thermostatHC.forEach((cmd2) => { + if (cmd2.setpointC) { + Serv.infos.setpointC=cmd2.setpointC; + } else if (cmd2.state_name) { + Serv.infos.state_name=cmd2.state_name; + } else if (cmd2.lock) { + Serv.infos.lock=cmd2.lock; + HBservice.characteristics.push(Characteristic.LockPhysicalControls); + Serv.addCharacteristic(Characteristic.LockPhysicalControls); + Serv.getCharacteristic(Characteristic.LockPhysicalControls).displayName = cmd2.lock.name; + } else if (cmd2.mode) { + Serv.infos.mode=cmd2.mode; + } else if (cmd2.temperature) { + Serv.infos.temperature=cmd2.temperature; + } else if (cmd2.state) { + Serv.infos.state=cmd2.state; + } else if (cmd2.set_lock) { + Serv.actions.set_lock=cmd2.set_lock; + } else if (cmd2.set_unlock) { + Serv.actions.set_unlock=cmd2.set_unlock; + } else if (cmd2.set_setpointH) { + Serv.actions.set_setpointH=cmd2.set_setpointH; + } else if (cmd2.set_setpointC) { + Serv.actions.set_setpointC=cmd2.set_setpointC; } - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + }); - props = {}; - props.validValues=[0]; - if(eqLogic.thermoModes) { - if(eqLogic.thermoModes.Chauf && eqLogic.thermoModes.Chauf != "NOT") { - Serv.thermoHC.chauf = {}; - const splitted = eqLogic.thermoModes.Chauf.split('|'); - Serv.thermoHC.chauf.mode_label = splitted[1]; - Serv.thermoHC.chauf.mode_id = splitted[0]; - props.validValues.push(1); - } else { - this.log('warn','Pas de config du mode Chauffage'); - } - if(eqLogic.thermoModes.Clim && eqLogic.thermoModes.Clim != "NOT") { - Serv.thermoHC.clim = {}; - const splitted = eqLogic.thermoModes.Clim.split('|'); - Serv.thermoHC.clim.mode_label = splitted[1]; - Serv.thermoHC.clim.mode_id = splitted[0]; - props.validValues.push(2); - } else { - this.log('warn','Pas de config du mode Climatisation'); - } - if(eqLogic.thermoModes.Off && eqLogic.thermoModes.Off != "NOT") { - Serv.thermoHC.off = {}; - const splitted = eqLogic.thermoModes.Off.split('|'); - Serv.thermoHC.off.mode_label = splitted[1]; - Serv.thermoHC.off.mode_id = splitted[0]; - } - } - else if(this.myPlugin == "homebridge") { - this.log('warn','Pas de config des modes du thermostatHC'); - } - // Serv.getCharacteristic(Characteristic.CurrentHeatingCoolingState).setProps(props); - props.validValues.push(3); - Serv.getCharacteristic(Characteristic.TargetHeatingCoolingState).setProps(props); - Serv.cmd_id = cmd.setpointH.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; + var props = {}; + if(Serv.actions.set_setpointH && Serv.actions.set_setpointH.configuration && Serv.actions.set_setpointH.configuration.minValue && parseInt(Serv.actions.set_setpointH.configuration.minValue)) { + props.minValue = parseInt(Serv.actions.set_setpointH.configuration.minValue); + } + if(Serv.actions.set_setpointH && Serv.actions.set_setpointH.configuration && Serv.actions.set_setpointH.configuration.maxValue && parseInt(Serv.actions.set_setpointH.configuration.maxValue)) { + props.maxValue = parseInt(Serv.actions.set_setpointH.configuration.maxValue); + } + if(props.minValue && props.maxValue) { + Serv.getCharacteristic(Characteristic.HeatingThresholdTemperature).setProps(props); + } + props = {}; + if(Serv.actions.set_setpointC && Serv.actions.set_setpointC.configuration && Serv.actions.set_setpointC.configuration.minValue && parseInt(Serv.actions.set_setpointC.configuration.minValue)) { + props.minValue = parseInt(Serv.actions.set_setpointC.configuration.minValue); + } + if(Serv.actions.set_setpointC && Serv.actions.set_setpointC.configuration && Serv.actions.set_setpointC.configuration.maxValue && parseInt(Serv.actions.set_setpointC.configuration.maxValue)) { + props.maxValue = parseInt(Serv.actions.set_setpointC.configuration.maxValue); } + if(props.minValue && props.maxValue) { + Serv.getCharacteristic(Characteristic.CoolingThresholdTemperature).setProps(props); + } + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + props = {}; + props.validValues=[0]; + if(eqLogic.thermoModes) { + if(eqLogic.thermoModes.Chauf && eqLogic.thermoModes.Chauf != "NOT") { + Serv.thermoHC.chauf = {}; + const splitted = eqLogic.thermoModes.Chauf.split('|'); + Serv.thermoHC.chauf.mode_label = splitted[1]; + Serv.thermoHC.chauf.mode_id = splitted[0]; + props.validValues.push(1); + } else { + this.log('warn','Pas de config du mode Chauffage'); + } + if(eqLogic.thermoModes.Clim && eqLogic.thermoModes.Clim != "NOT") { + Serv.thermoHC.clim = {}; + const splitted = eqLogic.thermoModes.Clim.split('|'); + Serv.thermoHC.clim.mode_label = splitted[1]; + Serv.thermoHC.clim.mode_id = splitted[0]; + props.validValues.push(2); + } else { + this.log('warn','Pas de config du mode Climatisation'); + } + if(eqLogic.thermoModes.Off && eqLogic.thermoModes.Off != "NOT") { + Serv.thermoHC.off = {}; + const splitted = eqLogic.thermoModes.Off.split('|'); + Serv.thermoHC.off.mode_label = splitted[1]; + Serv.thermoHC.off.mode_id = splitted[0]; + } + } + else if(this.myPlugin == "homebridge") { + this.log('warn','Pas de config des modes du thermostatHC'); + } + // Serv.getCharacteristic(Characteristic.CurrentHeatingCoolingState).setProps(props); + props.validValues.push(3); + Serv.getCharacteristic(Characteristic.TargetHeatingCoolingState).setProps(props); + Serv.cmd_id = cmd.setpointH.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.mode) { let modeState=null; eqLogic.services.mode.forEach((cmd) => { - if(cmd.state) { - HBservice = { - controlService : new Service.CustomService(eqLogic.name), - characteristics : [Characteristic.GenericSTRING], - }; - const Serv = HBservice.controlService; - - Serv.addCharacteristic(Characteristic.GenericSTRING); - Serv.getCharacteristic(Characteristic.GenericSTRING).displayName = cmd.state.name; - - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - modeState=cmd.state; - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; - } + if (!cmd.state) {return;} + HBservice = { + controlService : new Service.CustomService(eqLogic.name), + characteristics : [Characteristic.GenericSTRING], + }; + const Serv = HBservice.controlService; + + Serv.addCharacteristic(Characteristic.GenericSTRING); + Serv.getCharacteristic(Characteristic.GenericSTRING).displayName = cmd.state.name; + + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + modeState=cmd.state; + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); if(modeState) { var set_state_previous = null; eqLogic.services.mode.forEach((cmd) => { - if (cmd.set_state) { - cmd.set_state.forEach((set_action) => { - var ModeName = ""; - if(set_action.name.toLowerCase().includes('mode') || set_action.name.toLowerCase().includes('modo')) { - ModeName = set_action.name; - } else { - ModeName = "Mode "+set_action.name; - } - HBservice = { - controlService : new Service.Switch(ModeName), - characteristics : [Characteristic.On,Characteristic.ConfiguredName], - }; - const Serv = HBservice.controlService; - Serv.modeSwitch=set_action.name; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=modeState; - - Serv.ConfiguredName=ModeName; - Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(ModeName); - - if(!set_state_previous) { - eqServicesCopy.mode.forEach((cmd2) => { - if (cmd2.set_state_previous) { - Serv.actions.set_state_previous=cmd2.set_state_previous; - set_state_previous=cmd2.set_state_previous; - } - }); - } else { - Serv.actions.set_state_previous=set_state_previous; - } - - Serv.cmd_id = modeState.id; - Serv.eqID = eqLogic.id; - Serv.subtype = set_action.id || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - - const set_state_name = set_action.name; - Serv.actions[set_state_name]={"set_state":set_action}; - - HBservices.push(HBservice); - HBservice = null; - }); - } + if (!cmd.set_state) {return;} + cmd.set_state.forEach((set_action) => { + var ModeName = ""; + if(set_action.name.toLowerCase().includes('mode') || set_action.name.toLowerCase().includes('modo')) { + ModeName = set_action.name; + } else { + ModeName = "Mode "+set_action.name; + } + HBservice = { + controlService : new Service.Switch(ModeName), + characteristics : [Characteristic.On,Characteristic.ConfiguredName], + }; + const Serv = HBservice.controlService; + Serv.modeSwitch=set_action.name; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=modeState; + + Serv.ConfiguredName=ModeName; + Serv.getCharacteristic(Characteristic.ConfiguredName).setValue(ModeName); + + if(!set_state_previous) { + eqServicesCopy.mode.forEach((cmd2) => { + if (cmd2.set_state_previous) { + Serv.actions.set_state_previous=cmd2.set_state_previous; + set_state_previous=cmd2.set_state_previous; + } + }); + } else { + Serv.actions.set_state_previous=set_state_previous; + } + + Serv.cmd_id = modeState.id; + Serv.eqID = eqLogic.id; + Serv.subtype = set_action.id || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + + const set_state_name = set_action.name; + Serv.actions[set_state_name]={"set_state":set_action}; + + HBservices.push(HBservice); + HBservice = null; + }); }); } else { this.log('warn','Vous utilisez le type générique Mode en dehors du plugin Mode !'); @@ -2702,112 +2664,110 @@ JeedomPlatform.prototype.AccessoireCreateHomebridge = function(eqLogic) { } if (eqLogic.services.siren) { eqLogic.services.siren.forEach((cmd) => { - if(cmd.state) { - HBservice = { - controlService : new Service.SecuritySystem(eqLogic.name), - characteristics : [Characteristic.SecuritySystemCurrentState, Characteristic.SecuritySystemTargetState], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.state=cmd.state; - Serv.siren=true; - - eqServicesCopy.siren.forEach((cmd2) => { - if (cmd2.on) { - Serv.actions.on=cmd2.on; - } else if (cmd2.off) { - Serv.actions.off=cmd2.off; - } - }); - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - // Serv.getCharacteristic(Characteristic.SecuritySystemCurrentState).setProps({validValues:[3,4]}); - Serv.getCharacteristic(Characteristic.SecuritySystemTargetState).setProps({validValues:[3]}); - Serv.cmd_id = cmd.state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; - } + if (!cmd.state) {return;} + HBservice = { + controlService : new Service.SecuritySystem(eqLogic.name), + characteristics : [Characteristic.SecuritySystemCurrentState, Characteristic.SecuritySystemTargetState], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.state=cmd.state; + Serv.siren=true; + + eqServicesCopy.siren.forEach((cmd2) => { + if (cmd2.on) { + Serv.actions.on=cmd2.on; + } else if (cmd2.off) { + Serv.actions.off=cmd2.off; + } + }); + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + // Serv.getCharacteristic(Characteristic.SecuritySystemCurrentState).setProps({validValues:[3,4]}); + Serv.getCharacteristic(Characteristic.SecuritySystemTargetState).setProps({validValues:[3]}); + Serv.cmd_id = cmd.state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); } if (eqLogic.services.alarm) { eqLogic.services.alarm.forEach((cmd) => { - if(cmd.enable_state) { - HBservice = { - controlService : new Service.SecuritySystem(eqLogic.name), - characteristics : [Characteristic.SecuritySystemCurrentState, Characteristic.SecuritySystemTargetState], - }; - const Serv = HBservice.controlService; - Serv.eqLogic=eqLogic; - Serv.actions={}; - Serv.infos={}; - Serv.infos.enable_state=cmd.enable_state; - Serv.alarm={}; - eqServicesCopy.alarm.forEach((cmd2) => { - if (cmd2.state) { - Serv.infos.state=cmd2.state; - } else if (cmd2.mode) { - Serv.infos.mode=cmd2.mode; - } - }); - - // add Active, Tampered and Defect Characteristics if needed - HBservice=this.createStatusCharact(HBservice,eqServicesCopy); - - var props = {}; - props.validValues=[]; - Serv.hasAlarmModes=false; - if(eqLogic.alarmModes) { - if(eqLogic.alarmModes.SetModePresent && eqLogic.alarmModes.SetModePresent != "NOT") { - Serv.alarm.present = {}; - const splitted = eqLogic.alarmModes.SetModePresent.split('|'); - Serv.alarm.present.mode_label = splitted[1]; - Serv.alarm.present.mode_id = splitted[0]; - props.validValues.push(Characteristic.SecuritySystemTargetState.STAY_ARM); - Serv.hasAlarmModes=true; - } else { - this.log('warn','Pas de config du mode Domicile/Présence'); - } - if(eqLogic.alarmModes.SetModeAbsent && eqLogic.alarmModes.SetModeAbsent != "NOT") { - Serv.alarm.away = {}; - const splitted = eqLogic.alarmModes.SetModeAbsent.split('|'); - Serv.alarm.away.mode_label = splitted[1]; - Serv.alarm.away.mode_id = splitted[0]; - props.validValues.push(Characteristic.SecuritySystemTargetState.AWAY_ARM); - Serv.hasAlarmModes=true; - } else { - this.log('warn','Pas de config du mode À distance/Absence'); - } - if(eqLogic.alarmModes.SetModeNuit && eqLogic.alarmModes.SetModeNuit != "NOT") { - Serv.alarm.night = {}; - const splitted = eqLogic.alarmModes.SetModeNuit.split('|'); - Serv.alarm.night.mode_label = splitted[1]; - Serv.alarm.night.mode_id = splitted[0]; - props.validValues.push(Characteristic.SecuritySystemTargetState.NIGHT_ARM); - Serv.hasAlarmModes=true; - } else { - this.log('warn','Pas de config du mode Nuit'); - } + if (!cmd.enable_state) {return;} + HBservice = { + controlService : new Service.SecuritySystem(eqLogic.name), + characteristics : [Characteristic.SecuritySystemCurrentState, Characteristic.SecuritySystemTargetState], + }; + const Serv = HBservice.controlService; + Serv.eqLogic=eqLogic; + Serv.actions={}; + Serv.infos={}; + Serv.infos.enable_state=cmd.enable_state; + Serv.alarm={}; + eqServicesCopy.alarm.forEach((cmd2) => { + if (cmd2.state) { + Serv.infos.state=cmd2.state; + } else if (cmd2.mode) { + Serv.infos.mode=cmd2.mode; + } + }); + + // add Active, Tampered and Defect Characteristics if needed + HBservice=this.createStatusCharact(HBservice,eqServicesCopy); + + var props = {}; + props.validValues=[]; + Serv.hasAlarmModes=false; + if(eqLogic.alarmModes) { + if(eqLogic.alarmModes.SetModePresent && eqLogic.alarmModes.SetModePresent != "NOT") { + Serv.alarm.present = {}; + const splitted = eqLogic.alarmModes.SetModePresent.split('|'); + Serv.alarm.present.mode_label = splitted[1]; + Serv.alarm.present.mode_id = splitted[0]; + props.validValues.push(Characteristic.SecuritySystemTargetState.STAY_ARM); + Serv.hasAlarmModes=true; + } else { + this.log('warn','Pas de config du mode Domicile/Présence'); } - if(this.myPlugin == "homebridge" && !Serv.hasAlarmModes) { + if(eqLogic.alarmModes.SetModeAbsent && eqLogic.alarmModes.SetModeAbsent != "NOT") { + Serv.alarm.away = {}; + const splitted = eqLogic.alarmModes.SetModeAbsent.split('|'); + Serv.alarm.away.mode_label = splitted[1]; + Serv.alarm.away.mode_id = splitted[0]; props.validValues.push(Characteristic.SecuritySystemTargetState.AWAY_ARM); - this.log('warn','Pas de config des modes de l\'alarme'); + Serv.hasAlarmModes=true; + } else { + this.log('warn','Pas de config du mode À distance/Absence'); + } + if(eqLogic.alarmModes.SetModeNuit && eqLogic.alarmModes.SetModeNuit != "NOT") { + Serv.alarm.night = {}; + const splitted = eqLogic.alarmModes.SetModeNuit.split('|'); + Serv.alarm.night.mode_label = splitted[1]; + Serv.alarm.night.mode_id = splitted[0]; + props.validValues.push(Characteristic.SecuritySystemTargetState.NIGHT_ARM); + Serv.hasAlarmModes=true; + } else { + this.log('warn','Pas de config du mode Nuit'); } - props.validValues.push(Characteristic.SecuritySystemTargetState.DISARM); - Serv.getCharacteristic(Characteristic.SecuritySystemTargetState).setProps(props); - Serv.cmd_id = cmd.enable_state.id; - Serv.eqID = eqLogic.id; - Serv.subtype = Serv.subtype || ''; - Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; - HBservices.push(HBservice); - HBservice = null; } + if(this.myPlugin == "homebridge" && !Serv.hasAlarmModes) { + props.validValues.push(Characteristic.SecuritySystemTargetState.AWAY_ARM); + this.log('warn','Pas de config des modes de l\'alarme'); + } + props.validValues.push(Characteristic.SecuritySystemTargetState.DISARM); + Serv.getCharacteristic(Characteristic.SecuritySystemTargetState).setProps(props); + Serv.cmd_id = cmd.enable_state.id; + Serv.eqID = eqLogic.id; + Serv.subtype = Serv.subtype || ''; + Serv.subtype = eqLogic.id + '-' + Serv.cmd_id + '-' + Serv.subtype; + HBservices.push(HBservice); + HBservice = null; }); } From a34113c81b9b887364b13c93e43a4d89a39026b9 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sun, 4 Feb 2024 12:46:31 +0100 Subject: [PATCH 116/118] Delete changelog.asciidoc --- changelog.asciidoc | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 changelog.asciidoc diff --git a/changelog.asciidoc b/changelog.asciidoc deleted file mode 100644 index 67b1f12..0000000 --- a/changelog.asciidoc +++ /dev/null @@ -1,5 +0,0 @@ -== Changelog - -=== Homebridge - -Voir changelog.asciidoc de plugin-homebridge From 3bfd2dedb69bf48c02c5ff16276c3c1310d5cf1a Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Thu, 8 Feb 2024 13:05:16 +0100 Subject: [PATCH 117/118] Update package.json --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 740cf73..489700b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nebz/homebridge-jeedom", "version": "v1.7.0", - "cust_serial": "0023", + "cust_serial": "0024", "description": "Homebridge plugin for Jeedom ", "main": "index.js", "private":true, @@ -25,9 +25,9 @@ "Siri" ], "dependencies": { - "async": "^3.2.5", - "axios": ">=1.6.7", - "express": "^4.18.2", + "async": "3.2.5", + "axios": "1.6.7", + "express": "4.18.2", "fakegato-history": "NebzHB/fakegato-history#master" }, "devDependencies": { From fa7d576b0439e6b67d5586cd4f3a5b30c95512fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 12:18:41 +0000 Subject: [PATCH 118/118] Update @babel/eslint-parser requirement from ^7.23.9 to ^7.23.10 (#204) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 489700b..5f1fb9f 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "@babel/core": ">=7.23.9", - "@babel/eslint-parser": "^7.23.9", + "@babel/eslint-parser": "^7.23.10", "eslint": "^8.56.0" }, "author": "Nebz ",