This commit is contained in:
zhongjin 2018-12-20 22:06:06 +08:00
parent 6b4ec16652
commit 7f92cd3156
14 changed files with 94 additions and 93 deletions

View File

@ -12,7 +12,7 @@ before_script:
- 'if [[ $NPMVERSION == 5 ]]; then npm install -g npm@5; fi' - 'if [[ $NPMVERSION == 5 ]]; then npm install -g npm@5; fi'
- npm -v - npm -v
- npm install winston@2.3.1 - npm install winston@2.3.1
- 'npm install https://github.com/ioBroker/ioBroker.js-controller/tarball/master --production' - 'npm install https://github.com/yunkong2/yunkong2.js-controller/tarball/master --production'
env: env:
- CXX=g++-4.8 - CXX=g++-4.8
addons: addons:

View File

@ -1,11 +1,11 @@
![Logo](admin/node-red.png) ![Logo](admin/node-red.png)
# ioBroker node-red Adapter # yunkong2 node-red Adapter
============== ==============
[![NPM version](http://img.shields.io/npm/v/iobroker.node-red.svg)](https://www.npmjs.com/package/iobroker.node-red) [![NPM version](http://img.shields.io/npm/v/yunkong2.node-red.svg)](https://www.npmjs.com/package/yunkong2.node-red)
[![Downloads](https://img.shields.io/npm/dm/iobroker.node-red.svg)](https://www.npmjs.com/package/iobroker.node-red) [![Downloads](https://img.shields.io/npm/dm/yunkong2.node-red.svg)](https://www.npmjs.com/package/yunkong2.node-red)
[![Tests](https://travis-ci.org/ioBroker/ioBroker.node-red.svg?branch=master)](https://travis-ci.org/ioBroker/ioBroker.node-red) [![Tests](https://travis-ci.org/yunkong2/yunkong2.node-red.svg?branch=master)](https://travis-ci.org/yunkong2/yunkong2.node-red)
[![NPM](https://nodei.co/npm/iobroker.node-red.png?downloads=true)](https://nodei.co/npm/iobroker.node-red/) [![NPM](https://nodei.co/npm/yunkong2.node-red.png?downloads=true)](https://nodei.co/npm/yunkong2.node-red/)
# Starts node-red instance and communicates with it. # Starts node-red instance and communicates with it.
@ -13,7 +13,7 @@
This adapter uses the node-red server from https://github.com/node-red/node-red This adapter uses the node-red server from https://github.com/node-red/node-red
**Note:** If in select ID dialog of the ioBroker node you cannot find some variable, restart node-red instance. By restarting the new list of objects will be created. **Note:** If in select ID dialog of the yunkong2 node you cannot find some variable, restart node-red instance. By restarting the new list of objects will be created.
## Changelog ## Changelog
### 1.7.1 (2017-09-24) ### 1.7.1 (2017-09-24)
@ -30,7 +30,7 @@ This adapter uses the node-red server from https://github.com/node-red/node-red
* (bluefox) add credentialSecret option * (bluefox) add credentialSecret option
### 1.5.1 (2017-02-16) ### 1.5.1 (2017-02-16)
* (Apollon77) queue set state requests till ioBroker connection has been initialized * (Apollon77) queue set state requests till yunkong2 connection has been initialized
### 1.5.0 (2018-02-14) ### 1.5.0 (2018-02-14)
* (Apollon77) use newer version of node-red 0.18.2 * (Apollon77) use newer version of node-red 0.18.2
@ -87,7 +87,7 @@ This adapter uses the node-red server from https://github.com/node-red/node-red
### 0.4.1 (2016-01-14) ### 0.4.1 (2016-01-14)
* (nobodyMO) Add --max-old-space-size=128 to support systems with low memory. * (nobodyMO) Add --max-old-space-size=128 to support systems with low memory.
* (nobodyMO) Add version 0.12.5 for node-red because it works. * (nobodyMO) Add version 0.12.5 for node-red because it works.
* (nobodyMO) Add ioBroker get node. * (nobodyMO) Add yunkong2 get node.
* (nobodyMO) Set _maxListeners = 100 to suppress warnings in the log. * (nobodyMO) Set _maxListeners = 100 to suppress warnings in the log.
### 0.3.5 (2015-08-23) ### 0.3.5 (2015-08-23)
@ -100,14 +100,14 @@ This adapter uses the node-red server from https://github.com/node-red/node-red
* (bluefox) enable node-red 0.11.x * (bluefox) enable node-red 0.11.x
### 0.3.2 (2015-06-29) ### 0.3.2 (2015-06-29)
* (bluefox) fix error with ioBroker nodes * (bluefox) fix error with yunkong2 nodes
### 0.3.1 (2015-06-28) ### 0.3.1 (2015-06-28)
* (bluefox) change link in admin to node-red web server * (bluefox) change link in admin to node-red web server
### 0.3.0 (2015-05-18) ### 0.3.0 (2015-05-18)
* (bluefox) add flag "stopBeforeUpdate" * (bluefox) add flag "stopBeforeUpdate"
* (bluefox) store data in iobroker-data directory * (bluefox) store data in yunkong2-data directory
### 0.2.2 (2015-05-17) ### 0.2.2 (2015-05-17)
* (bluefox) fix error with invalid additional npm package * (bluefox) fix error with invalid additional npm package
@ -125,7 +125,7 @@ This adapter uses the node-red server from https://github.com/node-red/node-red
* (bluefox) remove warnings * (bluefox) remove warnings
### 0.1.6 (2015-03-18) ### 0.1.6 (2015-03-18)
* (bluefox) make node-red compatible with ioBroker again * (bluefox) make node-red compatible with yunkong2 again
### 0.1.5 (2015-02-12) ### 0.1.5 (2015-02-12)
* (bluefox) update node-red to 0.10.1 * (bluefox) update node-red to 0.10.1
@ -163,14 +163,14 @@ This adapter uses the node-red server from https://github.com/node-red/node-red
* (bluefox) fix some errors * (bluefox) fix some errors
### 0.0.2 (2014-11-04) ### 0.0.2 (2014-11-04)
* (bluefox) use adapter.js to communicate with ioBroker * (bluefox) use adapter.js to communicate with yunkong2
### 0.0.1 (2014-11-03) ### 0.0.1 (2014-11-03)
* (bluefox) initial commit * (bluefox) initial commit
## Install ## Install
```node iobroker.js add node-red``` ```node yunkong2.js add node-red```
## Configuration ## Configuration

View File

@ -10,7 +10,7 @@ systemDictionary = {
"Divided by comma": { "en": "Divided by comma", "de": "Getrennt mit Komma", "ru": "Через запятую", "pt": "Dividido por vírgula", "nl": "Verdeeld door een komma", "fr": "Divisé par une virgule", "it": "Diviso in virgola", "es": "Dividido por coma", "pl": "Podzielone przecinkiem"}, "Divided by comma": { "en": "Divided by comma", "de": "Getrennt mit Komma", "ru": "Через запятую", "pt": "Dividido por vírgula", "nl": "Verdeeld door een komma", "fr": "Divisé par une virgule", "it": "Diviso in virgola", "es": "Dividido por coma", "pl": "Podzielone przecinkiem"},
"Additional npm modules:": { "en": "Additional npm modules", "de": "Zusätzliche NPM-Module", "ru": "Дополнительные NPM Модули", "pt": "Módulos npm adicionais", "nl": "Extra npm-modules", "fr": "Modules NPM supplémentaires", "it": "Ulteriori moduli npm", "es": "Módulos npm adicionales", "pl": "Dodatkowe moduły npm"}, "Additional npm modules:": { "en": "Additional npm modules", "de": "Zusätzliche NPM-Module", "ru": "Дополнительные NPM Модули", "pt": "Módulos npm adicionais", "nl": "Extra npm-modules", "fr": "Modules NPM supplémentaires", "it": "Ulteriori moduli npm", "es": "Módulos npm adicionales", "pl": "Dodatkowe moduły npm"},
"http root directory:": { "en": "http root directory", "de": "http Stammpfad", "ru": "http root directory", "pt": "diretório raiz http", "nl": "http root directory", "fr": "répertoire racine http", "it": "directory root http", "es": "directorio raíz http", "pl": "główny katalog http"}, "http root directory:": { "en": "http root directory", "de": "http Stammpfad", "ru": "http root directory", "pt": "diretório raiz http", "nl": "http root directory", "fr": "répertoire racine http", "it": "directory root http", "es": "directorio raíz http", "pl": "główny katalog http"},
"Convert values to string:": { "en": "Convert ioBroker values to string", "de": "ioBroker-Werte in String konvertieren:", "ru": "Конвертировать значения из ioBroker в строки", "pt": "Converter valores de ioBroker em string", "nl": "IoBroker-waarden converteren naar tekenreeks", "fr": "Convertir les valeurs de ioBroker en chaîne", "it": "Converti i valori di ioBroker in stringa", "es": "Convierta los valores de ioBroker en una cadena", "pl": "Konwertuj wartości ioBroker na ciąg"}, "Convert values to string:": { "en": "Convert yunkong2 values to string", "de": "yunkong2-Werte in String konvertieren:", "ru": "Конвертировать значения из yunkong2 в строки", "pt": "Converter valores de yunkong2 em string", "nl": "yunkong2-waarden converteren naar tekenreeks", "fr": "Convertir les valeurs de yunkong2 en chaîne", "it": "Converti i valori di yunkong2 in stringa", "es": "Convierta los valores de yunkong2 en una cadena", "pl": "Konwertuj wartości yunkong2 na ciąg"},
"Add module": { "en": "Add module", "de": "Modul hinzufügen", "ru": "Добавить модуль", "pt": "Adicionar módulo", "nl": "Module toevoegen", "fr": "Ajouter un module", "it": "Aggiungi modulo", "es": "Agregar módulo", "pl": "Dodaj moduł"}, "Add module": { "en": "Add module", "de": "Modul hinzufügen", "ru": "Добавить модуль", "pt": "Adicionar módulo", "nl": "Module toevoegen", "fr": "Ajouter un module", "it": "Aggiungi modulo", "es": "Agregar módulo", "pl": "Dodaj moduł"},
"Max allocated RAM:": { "en": "Max allocated RAM", "de": "Max zugewiesener RAM", "ru": "Выделено RAM", "pt": "RAM alocada máxima", "nl": "Max toegewezen RAM", "fr": "Max allouée RAM", "it": "RAM allocata massima", "es": "RAM máxima asignada", "pl": "Maksymalna przydzielona pamięć RAM"}, "Max allocated RAM:": { "en": "Max allocated RAM", "de": "Max zugewiesener RAM", "ru": "Выделено RAM", "pt": "RAM alocada máxima", "nl": "Max toegewezen RAM", "fr": "Max allouée RAM", "it": "RAM allocata massima", "es": "RAM máxima asignada", "pl": "Maksymalna przydzielona pamięć RAM"},
"Module names": { "en": "Module names", "de": "Modulnamen", "ru": "Имена модулей", "pt": "Nomes de módulos", "nl": "Module namen", "fr": "Noms de modules", "it": "Nomi dei moduli", "es": "Nombres de módulos", "pl": "Nazwy modułów"}, "Module names": { "en": "Module names", "de": "Modulnamen", "ru": "Имена модулей", "pt": "Nomes de módulos", "nl": "Module namen", "fr": "Noms de modules", "it": "Nomi dei moduli", "es": "Nombres de módulos", "pl": "Nazwy modułów"},

View File

@ -16,7 +16,7 @@ install:
- ps: npm --version - ps: npm --version
- npm install - npm install
- npm install winston@2.3.1 - npm install winston@2.3.1
- 'npm install https://github.com/ioBroker/ioBroker.js-controller/tarball/master --production' - 'npm install https://github.com/yunkong2/yunkong2.js-controller/tarball/master --production'
test_script: test_script:
- echo %cd% - echo %cd%
- node --version - node --version

View File

@ -38,9 +38,9 @@
"pl": "zastosowano nowszą wersję węzła-czerwonego 0.18.7\nZaimplementowano okno Admin3\nDodano ustawienia pamięci RAM" "pl": "zastosowano nowszą wersję węzła-czerwonego 0.18.7\nZaimplementowano okno Admin3\nDodano ustawienia pamięci RAM"
}, },
"1.5.1": { "1.5.1": {
"en": "queue set state requests till ioBroker connection has been initialized", "en": "queue set state requests till yunkong2 connection has been initialized",
"de": "Verzögern von ioBroker-Schreibaktionen bis Verbindung zu ioBroker initialisiert wurde", "de": "Verzögern von yunkong2-Schreibaktionen bis Verbindung zu yunkong2 initialisiert wurde",
"ru": "queue set state requests till ioBroker connection has been initialized" "ru": "queue set state requests till yunkong2 connection has been initialized"
}, },
"1.5.0": { "1.5.0": {
"en": "use newer version of node-red 0.18.2", "en": "use newer version of node-red 0.18.2",
@ -98,7 +98,7 @@
"logic", "logic",
"script" "script"
], ],
"extIcon": "https://raw.githubusercontent.com/ioBroker/ioBroker.node-red/master/admin/node-red.png", "extIcon": "https://raw.githubusercontent.com/yunkong2/yunkong2.node-red/master/admin/node-red.png",
"localLink": "http://%ip%:%port%%httpRoot%", "localLink": "http://%ip%:%port%%httpRoot%",
"enabled": true, "enabled": true,
"singletonHost": true, "singletonHost": true,
@ -106,7 +106,7 @@
"unsafePerm": true, "unsafePerm": true,
"materialize": true, "materialize": true,
"type": "logic", "type": "logic",
"readme": "https://github.com/ioBroker/ioBroker.node-red/blob/master/README.md", "readme": "https://github.com/yunkong2/yunkong2.node-red/blob/master/README.md",
"stopBeforeUpdate": true, "stopBeforeUpdate": true,
"adminTab": { "adminTab": {
"link": "http://%ip%:%port%%httpRoot%", "link": "http://%ip%:%port%%httpRoot%",

View File

@ -27,8 +27,8 @@ let appName;
function getControllerDir(isInstall) { function getControllerDir(isInstall) {
// Find the js-controller location // Find the js-controller location
const possibilities = [ const possibilities = [
'iobroker.js-controller', 'yunkong2.js-controller',
'ioBroker.js-controller', 'yunkong2.js-controller',
]; ];
/** @type {string} */ /** @type {string} */
let controllerPath; let controllerPath;

10
main.js
View File

@ -1,6 +1,6 @@
/** /**
* *
* ioBroker node-red Adapter * yunkong2 node-red Adapter
* *
* (c) 2014 bluefox<bluefox@ccu.io> * (c) 2014 bluefox<bluefox@ccu.io>
* *
@ -289,7 +289,7 @@ function writeStateList(callback) {
} }
} }
fs.writeFileSync(nodePath + '/public/iobroker.json', JSON.stringify(obj)); fs.writeFileSync(nodePath + '/public/yunkong2.json', JSON.stringify(obj));
if (callback) callback(err); if (callback) callback(err);
}); });
} }
@ -393,14 +393,14 @@ function installNotifierCreds(isFirst) {
function main() { function main() {
// Find userdata directory // Find userdata directory
// normally /opt/iobroker/node_modules/iobroker.js-controller // normally /opt/yunkong2/node_modules/yunkong2.js-controller
// but can be /example/ioBroker.js-controller // but can be /example/yunkong2.js-controller
const controllerDir = utils.controllerDir; const controllerDir = utils.controllerDir;
const parts = controllerDir.split('/'); const parts = controllerDir.split('/');
if (parts.length > 1 && parts[parts.length - 2] === 'node_modules') { if (parts.length > 1 && parts[parts.length - 2] === 'node_modules') {
parts.splice(parts.length - 2, 2); parts.splice(parts.length - 2, 2);
userdataDir = parts.join('/'); userdataDir = parts.join('/');
userdataDir += '/iobroker-data/node-red/'; userdataDir += '/yunkong2-data/node-red/';
} }
// create userdata directory // create userdata directory

View File

@ -14,7 +14,7 @@
limitations under the License. limitations under the License.
--> -->
<script type="text/x-red" data-template-name="ioBroker in"> <script type="text/x-red" data-template-name="yunkong2 in">
<div class="form-row"> <div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label> <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="."/> <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="."/>
@ -50,8 +50,8 @@
</div> </div>
</script> </script>
<script type="text/x-red" data-help-name="ioBroker in"> <script type="text/x-red" data-help-name="yunkong2 in">
<p>ioBroker input node. Connects to a ioBroker and subscribes to the specified topic. The topic may contain redis wildcards (*).</p> <p>yunkong2 input node. Connects to a yunkong2 and subscribes to the specified topic. The topic may contain redis wildcards (*).</p>
<p>Outputs an object called <b>msg</b> containing <b>msg.topic, msg.payload, msg.timestamp, msg.lastchange and msg.acknowledged.</p> <p>Outputs an object called <b>msg</b> containing <b>msg.topic, msg.payload, msg.timestamp, msg.lastchange and msg.acknowledged.</p>
<p>The checkbox determines whether only States with ack == true or all events are forwarded.</p> <p>The checkbox determines whether only States with ack == true or all events are forwarded.</p>
<p>The select box Mode offers further filtering options. The options are the same as for the RBE node.</p> <p>The select box Mode offers further filtering options. The options are the same as for the RBE node.</p>
@ -70,7 +70,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('ioBroker in',{ RED.nodes.registerType('yunkong2 in',{
category: 'input', category: 'input',
defaults: { defaults: {
name: {value:""}, name: {value:""},
@ -84,19 +84,19 @@
color:"#a8bfd8", color:"#a8bfd8",
inputs:0, inputs:0,
outputs:1, outputs:1,
icon: "ioBroker.png", icon: "yunkong2.png",
label: function() { label: function() {
return this.name||this.topic||"ioBroker"; return this.name||this.topic||"yunkong2";
}, },
labelStyle: function() { labelStyle: function() {
return this.name?"node_label_italic":""; return this.name?"node_label_italic":"";
}, },
oneditprepare: function() { oneditprepare: function() {
if (!window.__iobroker) { if (!window.__yunkong2) {
$.getJSON("iobroker.json", function(data) { $.getJSON("yunkong2.json", function(data) {
window.__iobroker = data; window.__yunkong2 = data;
$('#dialog-select-member').selectId('init', { $('#dialog-select-member').selectId('init', {
objects: window.__iobroker, objects: window.__yunkong2,
noMultiselect: true, noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'], columns: ['name', 'role', 'enum', 'room'],
states: null, states: null,
@ -105,7 +105,7 @@
}); });
} else { } else {
$('#dialog-select-member').selectId('init', { $('#dialog-select-member').selectId('init', {
objects: window.__iobroker, objects: window.__yunkong2,
noMultiselect: true, noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'], columns: ['name', 'role', 'enum', 'room'],
states: null, states: null,
@ -142,7 +142,7 @@
}); });
</script> </script>
<script type="text/x-red" data-template-name="ioBroker out"> <script type="text/x-red" data-template-name="yunkong2 out">
<div class="form-row"> <div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label> <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="."/> <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="."/>
@ -169,14 +169,14 @@
<div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div> <div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
</script> </script>
<script type="text/x-red" data-help-name="ioBroker out"> <script type="text/x-red" data-help-name="yunkong2 out">
<p>Connects to a ioBroker and publishes <b>msg.payload</b> either to the <b>msg.topic</b> or to the topic specified in the edit window. The value in the edit window has precedence.</p> <p>Connects to a yunkong2 and publishes <b>msg.payload</b> either to the <b>msg.topic</b> or to the topic specified in the edit window. The value in the edit window has precedence.</p>
<p>If <b>msg.payload</b> contains an object it will be stringified before being sent.</p> <p>If <b>msg.payload</b> contains an object it will be stringified before being sent.</p>
<p>If <b>msg.payload</b> contains "__create__", the object will be only created, but no value will be written.</p> <p>If <b>msg.payload</b> contains "__create__", the object will be only created, but no value will be written.</p>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('ioBroker out',{ RED.nodes.registerType('yunkong2 out',{
category: 'output', category: 'output',
defaults: { defaults: {
name: {value:""}, name: {value:""},
@ -187,20 +187,20 @@ RED.nodes.registerType('ioBroker out',{
color:"#a8bfd8", color:"#a8bfd8",
inputs:1, inputs:1,
outputs:0, outputs:0,
icon: "ioBroker.png", icon: "yunkong2.png",
align: "right", align: "right",
label: function() { label: function() {
return this.name||this.topic||"ioBroker"; return this.name||this.topic||"yunkong2";
}, },
labelStyle: function() { labelStyle: function() {
return this.name?"node_label_italic":""; return this.name?"node_label_italic":"";
}, },
oneditprepare: function() { oneditprepare: function() {
if (!window.__iobroker) { if (!window.__yunkong2) {
$.getJSON("iobroker.json", function(data) { $.getJSON("yunkong2.json", function(data) {
window.__iobroker = data; window.__yunkong2 = data;
$('#dialog-select-member').selectId('init', { $('#dialog-select-member').selectId('init', {
objects: window.__iobroker, objects: window.__yunkong2,
noMultiselect: true, noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'], columns: ['name', 'role', 'enum', 'room'],
states: null, states: null,
@ -209,7 +209,7 @@ RED.nodes.registerType('ioBroker out',{
}); });
} else { } else {
$('#dialog-select-member').selectId('init', { $('#dialog-select-member').selectId('init', {
objects: window.__iobroker, objects: window.__yunkong2,
noMultiselect: true, noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'], columns: ['name', 'role', 'enum', 'room'],
states: null, states: null,
@ -236,7 +236,7 @@ RED.nodes.registerType('ioBroker out',{
}); });
</script> </script>
<script type="text/x-red" data-template-name="ioBroker get"> <script type="text/x-red" data-template-name="yunkong2 get">
<div class="form-row"> <div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label> <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="."/> <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="."/>
@ -260,14 +260,14 @@ RED.nodes.registerType('ioBroker out',{
<div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div> <div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
</script> </script>
<script type="text/x-red" data-help-name="ioBroker get"> <script type="text/x-red" data-help-name="yunkong2 get">
<p>Connects to a ioBroker and returns the requested value or the object in the massage attribute in the properties dialog, e.g. <b>msg.payload</b>. The object could be identified either by the <b>msg.topic</b> or specified in the poperties dialog. The value in the poperties dialog has precedence.</p> <p>Connects to a yunkong2 and returns the requested value or the object in the massage attribute in the properties dialog, e.g. <b>msg.payload</b>. The object could be identified either by the <b>msg.topic</b> or specified in the poperties dialog. The value in the poperties dialog has precedence.</p>
<p>The msg object also contains the attributs <b>msg.timestamp</b>, <b>msg.lastchange</b> and <b>msg.acknowledged</b>. All other attributes ob the input msg object will be passed to the output msg object.</p> <p>The msg object also contains the attributs <b>msg.timestamp</b>, <b>msg.lastchange</b> and <b>msg.acknowledged</b>. All other attributes ob the input msg object will be passed to the output msg object.</p>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('ioBroker get',{ RED.nodes.registerType('yunkong2 get',{
category: 'function', category: 'function',
defaults: { defaults: {
name: {value:""}, name: {value:""},
@ -278,19 +278,19 @@ RED.nodes.registerType('ioBroker get',{
color:"#a8bfd8", color:"#a8bfd8",
inputs:1, inputs:1,
outputs:1, outputs:1,
icon: "ioBroker.png", icon: "yunkong2.png",
label: function() { label: function() {
return this.name||this.topic||"ioBroker get"; return this.name||this.topic||"yunkong2 get";
}, },
labelStyle: function() { labelStyle: function() {
return this.name?"node_label_italic":""; return this.name?"node_label_italic":"";
}, },
oneditprepare: function() { oneditprepare: function() {
if (!window.__iobroker) { if (!window.__yunkong2) {
$.getJSON("iobroker.json", function(data) { $.getJSON("yunkong2.json", function(data) {
window.__iobroker = data; window.__yunkong2 = data;
$('#dialog-select-member').selectId('init', { $('#dialog-select-member').selectId('init', {
objects: window.__iobroker, objects: window.__yunkong2,
noMultiselect: true, noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'], columns: ['name', 'role', 'enum', 'room'],
states: null, states: null,
@ -299,7 +299,7 @@ RED.nodes.registerType('ioBroker get',{
}); });
} else { } else {
$('#dialog-select-member').selectId('init', { $('#dialog-select-member').selectId('init', {
objects: window.__iobroker, objects: window.__yunkong2,
noMultiselect: true, noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'], columns: ['name', 'role', 'enum', 'room'],
states: null, states: null,

View File

@ -24,8 +24,8 @@ module.exports = function(RED) {
// Get the redis address // Get the redis address
var settings = require(process.env.NODE_RED_HOME + '/red/red').settings; var settings = require(process.env.NODE_RED_HOME + '/red/red').settings;
var instance = settings.get('iobrokerInstance') || 0; var instance = settings.get('yunkong2Instance') || 0;
var config = settings.get('iobrokerConfig'); var config = settings.get('yunkong2Config');
var valueConvert = settings.get('valueConvert'); var valueConvert = settings.get('valueConvert');
if (typeof config == 'string') { if (typeof config == 'string') {
config = JSON.parse(config); config = JSON.parse(config);
@ -47,7 +47,7 @@ module.exports = function(RED) {
adapter.subscribeForeignStates('*'); adapter.subscribeForeignStates('*');
while (nodes.length) { while (nodes.length) {
var node = nodes.pop(); var node = nodes.pop();
if (node instanceof IOBrokerInNode) { if (node instanceof yunkong2InNode) {
adapter.on('stateChange', node.stateChange); adapter.on('stateChange', node.stateChange);
} }
node.status({fill: 'green', shape: 'dot', text: 'connected'}); node.status({fill: 'green', shape: 'dot', text: 'connected'});
@ -58,7 +58,7 @@ module.exports = function(RED) {
nodeSetData.node.emit('input', nodeSetData.msg); nodeSetData.node.emit('input', nodeSetData.msg);
count++; count++;
} }
if (count > 0) log(count + ' queued state values set in ioBroker'); if (count > 0) log(count + ' queued state values set in yunkong2');
}); });
@ -85,7 +85,7 @@ module.exports = function(RED) {
if (!obj) { if (!obj) {
adapter.getForeignObject(id, function (err, obj) { adapter.getForeignObject(id, function (err, obj) {
if (!obj) { if (!obj) {
log('State "' + id + '" was created in the ioBroker as ' + adapter._fixId(id)); log('State "' + id + '" was created in the yunkong2 as ' + adapter._fixId(id));
// Create object // Create object
adapter.setObject(id, { adapter.setObject(id, {
common: { common: {
@ -130,7 +130,7 @@ module.exports = function(RED) {
}); });
} }
function IOBrokerInNode(n) { function yunkong2InNode(n) {
var node = this; var node = this;
RED.nodes.createNode(node,n); RED.nodes.createNode(node,n);
node.topic = (n.topic || '*').replace(/\//g, '.'); node.topic = (n.topic || '*').replace(/\//g, '.');
@ -226,9 +226,9 @@ module.exports = function(RED) {
nodes.push(node); nodes.push(node);
} }
} }
RED.nodes.registerType('ioBroker in', IOBrokerInNode); RED.nodes.registerType('yunkong2 in', yunkong2InNode);
function IOBrokerOutNode(n) { function yunkong2OutNode(n) {
var node = this; var node = this;
RED.nodes.createNode(node,n); RED.nodes.createNode(node,n);
node.topic = n.topic; node.topic = n.topic;
@ -257,7 +257,7 @@ module.exports = function(RED) {
var id = node.topic || msg.topic; var id = node.topic || msg.topic;
if (!ready) { if (!ready) {
nodeSets.push({'node': node, 'msg': msg}); nodeSets.push({'node': node, 'msg': msg});
//log('Message for "' + id + '" queued because ioBroker connection not initialized'); //log('Message for "' + id + '" queued because yunkong2 connection not initialized');
return; return;
} }
if (id) { if (id) {
@ -280,12 +280,12 @@ module.exports = function(RED) {
adapter.setForeignState(id, {val: msg.payload, ack: node.ack}); adapter.setForeignState(id, {val: msg.payload, ack: node.ack});
node.status({fill: 'green', shape: 'dot', text: msg.payload.toString() }); node.status({fill: 'green', shape: 'dot', text: msg.payload.toString() });
} else { } else {
log('State "' + id + '" does not exist in the ioBroker'); log('State "' + id + '" does not exist in the yunkong2');
} }
}); });
} else { } else {
if (id.indexOf('*') !== -1) { if (id.indexOf('*') !== -1) {
log('Invalid topic name "' + id + '" for ioBroker'); log('Invalid topic name "' + id + '" for yunkong2');
} else { } else {
setState(id, msg.payload, node.ack); setState(id, msg.payload, node.ack);
node.status({fill: 'green', shape: 'dot', text: msg.payload.toString() }); node.status({fill: 'green', shape: 'dot', text: msg.payload.toString() });
@ -305,9 +305,9 @@ module.exports = function(RED) {
// }); // });
} }
RED.nodes.registerType('ioBroker out', IOBrokerOutNode); RED.nodes.registerType('yunkong2 out', yunkong2OutNode);
function IOBrokerGetNode(n) { function yunkong2GetNode(n) {
var node = this; var node = this;
RED.nodes.createNode(node,n); RED.nodes.createNode(node,n);
node.topic = (typeof n.topic=== 'string' && n.topic.length > 0 ? n.topic.replace(/\//g, '.') : null) ; node.topic = (typeof n.topic=== 'string' && n.topic.length > 0 ? n.topic.replace(/\//g, '.') : null) ;
@ -350,7 +350,7 @@ module.exports = function(RED) {
}); });
node.send(msg); node.send(msg);
} else { } else {
log('State "' + id + '" does not exist in the ioBroker'); log('State "' + id + '" does not exist in the yunkong2');
} }
}; };
}; };
@ -359,7 +359,7 @@ module.exports = function(RED) {
var id = node.topic || msg.topic; var id = node.topic || msg.topic;
if (!ready) { if (!ready) {
nodeSets.push({'node': node, 'msg': msg}); nodeSets.push({'node': node, 'msg': msg});
//log('Message for "' + id + '" queued because ioBroker connection not initialized'); //log('Message for "' + id + '" queued because yunkong2 connection not initialized');
return; return;
} }
if (id) { if (id) {
@ -370,7 +370,7 @@ module.exports = function(RED) {
adapter.getForeignState(id, node.getStateValue(msg)); adapter.getForeignState(id, node.getStateValue(msg));
} else { } else {
if (id.indexOf('*') !== -1) { if (id.indexOf('*') !== -1) {
log('Invalid topic name "' + id + '" for ioBroker'); log('Invalid topic name "' + id + '" for yunkong2');
} else { } else {
adapter.getState(id, node.getStateValue(msg)); adapter.getState(id, node.getStateValue(msg));
} }
@ -385,5 +385,5 @@ module.exports = function(RED) {
} }
} }
RED.nodes.registerType('ioBroker get', IOBrokerGetNode); RED.nodes.registerType('yunkong2 get', yunkong2GetNode);
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "iobroker.node-red", "name": "yunkong2.node-red",
"description": "This adapter uses node-red as a service of ioBroker. No additional node-red instance required.", "description": "This adapter uses node-red as a service of yunkong2. No additional node-red instance required.",
"version": "1.7.1", "version": "1.7.1",
"author": { "author": {
"name": "bluefox", "name": "bluefox",
@ -12,16 +12,16 @@
"email": "dogafox@gmail.com" "email": "dogafox@gmail.com"
} }
], ],
"homepage": "https://github.com/ioBroker/ioBroker.node-red", "homepage": "https://github.com/yunkong2/yunkong2.node-red",
"license": "Apache-2.0", "license": "Apache-2.0",
"keywords": [ "keywords": [
"ioBroker", "yunkong2",
"node-red", "node-red",
"home automation" "home automation"
], ],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/ioBroker/ioBroker.node-red" "url": "https://github.com/yunkong2/yunkong2.node-red"
}, },
"optionalDependencies": { "optionalDependencies": {
"js2xmlparser": "^3.0.0", "js2xmlparser": "^3.0.0",
@ -34,7 +34,8 @@
"node-red-contrib-os": "^0.1.7", "node-red-contrib-os": "^0.1.7",
"node-red-dashboard": "^2.9.8", "node-red-dashboard": "^2.9.8",
"node-red-contrib-aggregator": "^1.3.0", "node-red-contrib-aggregator": "^1.3.0",
"node-red-contrib-polymer": "^0.0.21" "node-red-contrib-polymer": "^0.0.21",
"node-red-dashboard": ""
}, },
"devDependencies": { "devDependencies": {
"gulp": "^3.9.1", "gulp": "^3.9.1",
@ -43,7 +44,7 @@
"chai": "^4.1.2" "chai": "^4.1.2"
}, },
"bugs": { "bugs": {
"url": "https://github.com/ioBroker/ioBroker.node-red/issues" "url": "https://github.com/yunkong2/yunkong2.node-red/issues"
}, },
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {

View File

@ -3,7 +3,7 @@
version: 1.0.2 (2017.04.13) version: 1.0.2 (2017.04.13)
To use this dialog as standalone in ioBroker environment include: To use this dialog as standalone in yunkong2 environment include:
<link type="text/css" rel="stylesheet" href="lib/css/redmond/jquery-ui.min.css"> <link type="text/css" rel="stylesheet" href="lib/css/redmond/jquery-ui.min.css">
<link rel="stylesheet" type="text/css" href="lib/css/fancytree/ui.fancytree.min.css"/> <link rel="stylesheet" type="text/css" href="lib/css/fancytree/ui.fancytree.min.css"/>
@ -101,7 +101,7 @@
editStart: null, // function (id, $inputs) called after edit start to correct input fields (inputs are jquery objects), editStart: null, // function (id, $inputs) called after edit start to correct input fields (inputs are jquery objects),
zindex: null, // z-index of dialog or table zindex: null, // z-index of dialog or table
customButtonFilter: null, // if in the filter over the buttons some specific button must be shown. It has type like {icons:{primary: 'ui-icon-close'}, text: false, callback: function ()} customButtonFilter: null, // if in the filter over the buttons some specific button must be shown. It has type like {icons:{primary: 'ui-icon-close'}, text: false, callback: function ()}
expertModeRegEx: null // list of regex with objects, that will be shown only in expert mode, like /^system\.|^iobroker\.|^_|^[\w-]+$|^enum\.|^[\w-]+\.admin/ expertModeRegEx: null // list of regex with objects, that will be shown only in expert mode, like /^system\.|^yunkong2\.|^_|^[\w-]+$|^enum\.|^[\w-]+\.admin/
quickEdit: null, // list of fields with edit on click. Elements can be just names from standard list or objects like: quickEdit: null, // list of fields with edit on click. Elements can be just names from standard list or objects like:
// {name: 'field', options: {a1: 'a111_Text', a2: 'a22_Text'}}, options can be a function (id, name), that give back such an object // {name: 'field', options: {a1: 'a111_Text', a2: 'a22_Text'}}, options can be a function (id, name), that give back such an object
quickEditCallback: null // function (id, attr, newValue, oldValue) quickEditCallback: null // function (id, attr, newValue, oldValue)

View File

@ -27,8 +27,8 @@ module.exports = {
// The following property can be used to listen on a specific interface. For // The following property can be used to listen on a specific interface. For
// example, the following would only allow connections from the local machine. // example, the following would only allow connections from the local machine.
//uiHost: "127.0.0.1", //uiHost: "127.0.0.1",
iobrokerInstance: '%%instance%%', yunkong2Instance: '%%instance%%',
iobrokerConfig: '%%config%%', yunkong2Config: '%%config%%',
// Retry time in milliseconds for MQTT connections // Retry time in milliseconds for MQTT connections
mqttReconnectTime: 15000, mqttReconnectTime: 15000,

View File

@ -415,7 +415,7 @@ function clearControllerLog() {
} }
function clearDB() { function clearDB() {
var dirPath = rootDir + 'tmp/iobroker-data/sqlite'; var dirPath = rootDir + 'tmp/yunkong2-data/sqlite';
var files; var files;
try { try {
if (fs.existsSync(dirPath)) { if (fs.existsSync(dirPath)) {

View File

@ -52,12 +52,12 @@ describe('Test package.json and io-package.json', function() {
console.log(); console.log();
} }
if ( if (
ioPackage.common.title.indexOf('iobroker') !== -1 || ioPackage.common.title.indexOf('yunkong2') !== -1 ||
ioPackage.common.title.indexOf('ioBroker') !== -1 || ioPackage.common.title.indexOf('yunkong2') !== -1 ||
ioPackage.common.title.indexOf('adapter') !== -1 || ioPackage.common.title.indexOf('adapter') !== -1 ||
ioPackage.common.title.indexOf('Adapter') !== -1 ioPackage.common.title.indexOf('Adapter') !== -1
) { ) {
console.log('WARNING: title contains Adapter or ioBroker. It is clear anyway, that it is adapter for ioBroker.'); console.log('WARNING: title contains Adapter or yunkong2. It is clear anyway, that it is adapter for yunkong2.');
console.log(); console.log();
} }