iobroker.innogy-smarthome
Advanced tools
Comparing version 0.2.0 to 0.2.2
{ | ||
"common": { | ||
"name": "innogy-smarthome", | ||
"version": "0.2.0", | ||
"version": "0.2.2", | ||
"title": "Innogy Smarthome Adapter", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
102
lib/utils.js
@@ -1,37 +0,45 @@ | ||
var controllerDir; | ||
var appName; | ||
'use strict'; | ||
function getAppName() { | ||
var parts = __dirname.replace(/\\/g, '/').split('/'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
let controllerDir; | ||
let appName; | ||
/** | ||
* returns application name | ||
* | ||
* The name of the application can be different and this function finds it out. | ||
* | ||
* @returns {string} | ||
*/ | ||
function getAppName() { | ||
const parts = __dirname.replace(/\\/g, '/').split('/'); | ||
return parts[parts.length - 2].split('.')[0]; | ||
} | ||
// Get js-controller directory to load libs | ||
/** | ||
* looks for js-controller home folder | ||
* | ||
* @param {boolean} isInstall | ||
* @returns {string} | ||
*/ | ||
function getControllerDir(isInstall) { | ||
var fs = require('fs'); | ||
// Find the js-controller location | ||
var controllerDir = __dirname.replace(/\\/g, '/'); | ||
controllerDir = controllerDir.split('/'); | ||
if (controllerDir[controllerDir.length - 3] === 'adapter') { | ||
controllerDir.splice(controllerDir.length - 3, 3); | ||
controllerDir = controllerDir.join('/'); | ||
} else if (controllerDir[controllerDir.length - 3] === 'node_modules') { | ||
controllerDir.splice(controllerDir.length - 3, 3); | ||
controllerDir = controllerDir.join('/'); | ||
if (fs.existsSync(controllerDir + '/node_modules/' + appName + '.js-controller')) { | ||
controllerDir += '/node_modules/' + appName + '.js-controller'; | ||
} else if (fs.existsSync(controllerDir + '/node_modules/' + appName.toLowerCase() + '.js-controller')) { | ||
controllerDir += '/node_modules/' + appName.toLowerCase() + '.js-controller'; | ||
} else if (!fs.existsSync(controllerDir + '/controller.js')) { | ||
if (!isInstall) { | ||
console.log('Cannot find js-controller'); | ||
process.exit(10); | ||
} else { | ||
process.exit(); | ||
const possibilities = [ | ||
'iobroker.js-controller', | ||
'ioBroker.js-controller', | ||
]; | ||
/** @type {string} */ | ||
let controllerPath; | ||
for (const pkg of possibilities) { | ||
try { | ||
const possiblePath = require.resolve(pkg); | ||
if (fs.existsSync(possiblePath)) { | ||
controllerPath = possiblePath; | ||
break; | ||
} | ||
} | ||
} else if (fs.existsSync(__dirname + '/../../node_modules/' + appName.toLowerCase() + '.js-controller')) { | ||
controllerDir.splice(controllerDir.length - 2, 2); | ||
return controllerDir.join('/') + '/node_modules/' + appName.toLowerCase() + '.js-controller'; | ||
} else { | ||
} catch (e) { /* not found */ } | ||
} | ||
if (controllerPath == null) { | ||
if (!isInstall) { | ||
@@ -44,12 +52,22 @@ console.log('Cannot find js-controller'); | ||
} | ||
return controllerDir; | ||
// we found the controller | ||
return path.dirname(controllerPath); | ||
} | ||
// Read controller configuration file | ||
function getConfig() { | ||
var fs = require('fs'); | ||
if (fs.existsSync(controllerDir + '/conf/' + appName + '.json')) { | ||
return JSON.parse(fs.readFileSync(controllerDir + '/conf/' + appName + '.json')); | ||
} else if (fs.existsSync(controllerDir + '/conf/' + appName.toLowerCase() + '.json')) { | ||
return JSON.parse(fs.readFileSync(controllerDir + '/conf/' + appName.toLowerCase() + '.json')); | ||
/** | ||
* reads controller base settings | ||
* | ||
* @alias getConfig | ||
* @returns {object} | ||
*/ | ||
function getConfig() { | ||
let configPath; | ||
if (fs.existsSync( | ||
configPath = path.join(controllerDir, 'conf', appName + '.json') | ||
)) { | ||
return JSON.parse(fs.readFileSync(configPath, 'utf8')); | ||
} else if (fs.existsSync( | ||
configPath = path.join(controllerDir, 'conf', + appName.toLowerCase() + '.json') | ||
)) { | ||
return JSON.parse(fs.readFileSync(configPath, 'utf8')); | ||
} else { | ||
@@ -59,9 +77,9 @@ throw new Error('Cannot find ' + controllerDir + '/conf/' + appName + '.json'); | ||
} | ||
appName = getAppName(); | ||
appName = getAppName(); | ||
controllerDir = getControllerDir(typeof process !== 'undefined' && process.argv && process.argv.indexOf('--install') !== -1); | ||
const adapter = require(path.join(controllerDir, 'lib/adapter.js')); | ||
exports.controllerDir = controllerDir; | ||
exports.getConfig = getConfig; | ||
exports.Adapter = require(controllerDir + '/lib/adapter.js'); | ||
exports.appName = appName; | ||
exports.getConfig = getConfig; | ||
exports.Adapter = adapter; | ||
exports.appName = appName; |
20
main.js
@@ -451,2 +451,22 @@ /* jshint -W097 */// jshint strict:false | ||
break; | ||
case "/types/device/FSC8.RWE/1.1/ValveType": | ||
res.type = "string"; | ||
res.role = "indicator.valvetype"; | ||
res.read = true; | ||
res.write = true; | ||
res.states = { | ||
"NormalClose": "Normal Close", | ||
"NormalOpen": "Normal Open" | ||
}; | ||
break; | ||
case "/types/device/FSC8.RWE/1.1/ControlMode": | ||
res.type = "string"; | ||
res.role = "indicator.controlmode"; | ||
res.read = true; | ||
res.write = true; | ||
res.states = { | ||
"Heating": "Heating", | ||
"Cooling": "Cooling" | ||
}; | ||
break; | ||
default: | ||
@@ -453,0 +473,0 @@ res.type = "string"; |
{ | ||
"name": "iobroker.innogy-smarthome", | ||
"version": "0.2.0", | ||
"version": "0.2.2", | ||
"description": "ioBroker Innogy SmartHome Adapter", | ||
@@ -28,3 +28,3 @@ "author": { | ||
"dependencies": { | ||
"innogy-smarthome-lib": "^0.3.0" | ||
"innogy-smarthome-lib": "^0.3.1" | ||
}, | ||
@@ -31,0 +31,0 @@ "devDependencies": { |
@@ -12,2 +12,11 @@ ![Logo](admin/innogy-smarthome.png) | ||
### 0.2.2 | ||
Fixed reauth problems | ||
Fixed initial auth problems | ||
Optimized API errors | ||
Optimized caching of descriptor files | ||
### 0.2.1 | ||
Fixed reauth problems | ||
### 0.2.0 | ||
@@ -14,0 +23,0 @@ Removed external OAuth2 lib |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
45634
571
134
Updatedinnogy-smarthome-lib@^0.3.1