diff --git a/README.md b/README.md index f868999..09b7720 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ After sending the state will be set to 0 again. ## Changelog +### 0.9.1 +please delete all harmony.x objects once +* (Pmant) fix problematic chars + + ### 0.7.0 * (Pmant) support multiple hubs * (Pmant) removed hub config from admin diff --git a/harmony.js b/harmony.js index 0ac9b3d..c2894e0 100644 --- a/harmony.js +++ b/harmony.js @@ -15,6 +15,10 @@ var utils = require(__dirname + '/lib/utils'); // Get common adapter utils var adapter = utils.adapter('harmony'); var hubs = {}; var discover; +const FORBIDDEN_CHARS = /[\]\[*,;'"`<>\\?]/g; +const fixId = function(id) { + return id.replace(FORBIDDEN_CHARS, '_'); +} adapter.on('stateChange', function (id, state) { @@ -173,7 +177,7 @@ function discoverStart() { // Triggered when a new hub was found if (hub.host_name !== 'undefined' && hub.host_name !== undefined) { adapter.log.info('discovered ' + hub.host_name); - var hubName = hub.host_name.replace(/[.\s]+/g, '_'); + var hubName = fixId(hub.host_name); initHub(hubName, function () { //wait 2 seconds for hub before connecting adapter.log.info('connecting to ' + hub.host_name); @@ -187,7 +191,7 @@ function discoverStart() { // Triggered when a hub disappeared if (hub.host_name !== 'undefined' && hub.host_name !== undefined) { adapter.log.warn('lost ' + hub.host_name); - var hubName = hub.host_name.replace(/[.\s]+/g, '_'); + var hubName = fixId(hub.host_name.replace); //stop reconnect timer if (hubs[hubName]) { clearTimeout(hubs[hubName].reconnectTimer); @@ -442,7 +446,7 @@ function processConfig(hub, hubObj, config) { } config.activity.forEach(function (activity) { - var activityLabel = activity.label.replace(/[.\s]+/g, '_'); + var activityLabel = fixId(activity.label); hubs[hub].activities[activity.id] = activityLabel; hubs[hub].activities_reverse[activityLabel] = activity.id; if (activity.id == '-1') return; @@ -477,7 +481,7 @@ function processConfig(hub, hubObj, config) { adapter.log.debug('creating devices'); channelName = hub; config.device.forEach(function (device) { - var deviceLabel = device.label.replace(/[.\s]+/g, '_'); + var deviceLabel = fixId(device.label); var deviceChannelName = channelName + '.' + deviceLabel; var controlGroup = device.controlGroup; hubs[hub].devices[device.id] = deviceLabel; @@ -499,7 +503,7 @@ function processConfig(hub, hubObj, config) { controlGroup.function.forEach(function (command) { command.controlGroup = groupName; command.deviceId = device.id; - var commandName = command.name.replace(/[.\s]+/g, '_'); + var commandName = fixId(command.name); //create command adapter.setObject(deviceChannelName + '.' + commandName, { type: 'state', @@ -587,7 +591,7 @@ function setStatusFromActivityID(hub, id, value) { adapter.log.warn('unknown activityId: ' + id); return; } - var channelName = hub + '.activities.' + hubs[hub].activities[id].replace(/[.\s]+/g, '_'); + var channelName = fixId(hub + '.activities.' + hubs[hub].activities[id]); adapter.setState(channelName, {val: value, ack: true}); } diff --git a/io-package.json b/io-package.json index 5f0f9c5..cb578a8 100644 --- a/io-package.json +++ b/io-package.json @@ -1,7 +1,7 @@ { "common": { "name": "harmony", - "version": "0.9.0", + "version": "0.9.1", "title": "Logitech Harmony Adapter", "desc": { "en": "Control your harmony activities from ioBroker", @@ -12,6 +12,11 @@ "Pmant " ], "news": { + "0.9.1": { + "en": "fix problematic chars", + "de": "Fix für problemantische Zeichen", + "ru": "fix problematic chars" + }, "0.7.1": { "en": "bug fixes", "de": "bug fixes", diff --git a/package.json b/package.json index 1d37093..5869233 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,16 @@ { "name": "iobroker.harmony", - "version": "0.9.0", + "version": "0.9.1", "description": "Control your harmony activities from ioBroker.", "author": "Pmant ", - "contributors": [ - ], + "contributors": [], "homepage": "https://github.com/pmant/ioBroker.harmony", "license": "MIT", "keywords": [ "ioBroker", - "harmony", "hub", "logitech", + "harmony", + "hub", + "logitech", "home automation" ], "repository": { @@ -18,8 +19,8 @@ }, "dependencies": { "harmonyhubjs-client": "^1.1.10", - "harmonyhubjs-discover": "^1.0.2", - "semaphore": "~1.0.3" + "harmonyhubjs-discover": "^1.1.1", + "semaphore": "~1.0.3" }, "devDependencies": { "grunt": "^0.4.5", diff --git a/tasks/jscs.js b/tasks/jscs.js index 588b6f2..5d63426 100644 --- a/tasks/jscs.js +++ b/tasks/jscs.js @@ -1,14 +1,14 @@ -var srcDir = __dirname + "/../"; +var srcDir = __dirname + '/../'; module.exports = { all: { src: [ - srcDir + "*.js", - srcDir + "lib/*.js", - srcDir + "adapter/example/*.js", - srcDir + "tasks/**/*.js", - srcDir + "www/**/*.js", - '!' + srcDir + "www/lib/**/*.js", + srcDir + '*.js', + srcDir + 'lib/*.js', + srcDir + 'adapter/example/*.js', + srcDir + 'tasks/**/*.js', + srcDir + 'www/**/*.js', + '!' + srcDir + 'www/lib/**/*.js', '!' + srcDir + 'node_modules/**/*.js', '!' + srcDir + 'adapter/*/node_modules/**/*.js' ], diff --git a/tasks/jshint.js b/tasks/jshint.js index f823ebc..3a2ffe5 100644 --- a/tasks/jshint.js +++ b/tasks/jshint.js @@ -1,16 +1,16 @@ -var srcDir = __dirname + "/../"; +var srcDir = __dirname + '/../'; module.exports = { options: { force: true }, all: [ - srcDir + "*.js", - srcDir + "lib/*.js", - srcDir + "adapter/example/*.js", - srcDir + "tasks/**/*.js", - srcDir + "www/**/*.js", - '!' + srcDir + "www/lib/**/*.js", + srcDir + '*.js', + srcDir + 'lib/*.js', + srcDir + 'adapter/example/*.js', + srcDir + 'tasks/**/*.js', + srcDir + 'www/**/*.js', + '!' + srcDir + 'www/lib/**/*.js', '!' + srcDir + 'node_modules/**/*.js', '!' + srcDir + 'adapter/*/node_modules/**/*.js' ]