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 = [];