This adapter is a template for the creation of an ioBroker adapter. You do not need it, at least that you plan developing your own adapter.
This adapter is a template for the creation of an yunkong2 adapter. You do not need it, at least that you plan developing your own adapter.
This is extension of [ioBroker.template](https://github.com/ioBroker/ioBroker.template) adapter with REST service.
This is extension of [yunkong2.template](https://git.spacen.net/yunkong2/yunkong2.template) adapter with REST service.
By default the WEB server will be started to serve HTTP GET/POST requests. It can be started as secure(https) or unsecure(http) and with authentication or without.
Additionally is shown how to poll some other URL for JSON data and parse them.
##Steps
1. download and unpack this packet from github ```https://github.com/ioBroker/ioBroker.template/archive/master.zip```
or clone git repository ```git clone https://github.com/ioBroker/ioBroker.template.git```
1. download and unpack this packet from github ```https://git.spacen.net/yunkong2/yunkong2.template/archive/master.zip```
or clone git repository ```git clone https://git.spacen.net/yunkong2/yunkong2.template.git```
2. download required npm packets. Write in ioBroker.template directory:
2. download required npm packets. Write in yunkong2.template directory:
```npm install```
@ -27,29 +27,29 @@ Additionally is shown how to poll some other URL for JSON data and parse them.
```npm install -g grunt-cli```
4. rename directory from *ioBroker.template* (can be *ioBroker.template-master*) to *iobroker.mynewname*
4. rename directory from *yunkong2.template* (can be *yunkong2.template-master*) to *yunkong2.mynewname*
5. to use this template you should copy it into *.../iobroker/node_modules* directory and then create an instance for it with iobroker.admin
5. to use this template you should copy it into *.../yunkong2/node_modules* directory and then create an instance for it with yunkong2.admin
6. create your adapter:
* you might want to start with main.js (code running within iobroker) and admin/index.html (the adapter settings page).
* you might want to start with main.js (code running within yunkong2) and admin/index.html (the adapter settings page).
* [Installation, setup and first steps with an ioBroker Development Environment](https://github.com/ioBroker/ioBroker/wiki/Installation,-setup-and-first-steps-with-an-ioBroker-Development-Environment)
* [Installation, setup and first steps with an yunkong2 Development Environment](https://git.spacen.net/yunkong2/yunkong2/wiki/Installation,-setup-and-first-steps-with-an-yunkong2-Development-Environment)
* [Write and debug vis widgets](https://github.com/ioBroker/ioBroker/wiki/How-to-debug-vis-and-to-write-own-widget-set)
* [Write and debug vis widgets](https://git.spacen.net/yunkong2/yunkong2/wiki/How-to-debug-vis-and-to-write-own-widget-set)
* files under the www folders are made available under http://<iobrokerIP>:8082/<adapter-name>/
* for this to work the iobroker.vis adapter has to be installed
* files under the www folders are made available under http://<yunkong2IP>:8082/<adapter-name>/
* for this to work the yunkong2.vis adapter has to be installed
* delete this folder if you do not plan to export any files this way
* call ```iobroker upload <adapter-name>``` after you change files in the www folder to get the new files uploaded to vis
* call ```yunkong2 upload <adapter-name>``` after you change files in the www folder to get the new files uploaded to vis
* the widget folder contains an example of a vis widget
* you might want to start with *widget/<adapter-name>.html* and *widget/js/<adapter-name>.js*
* call ```iobroker visdebug <adapter-name>``` to enable debugging and upload widget to "vis". (This works only from V0.7.15 of js-controller)
* call ```yunkong2 visdebug <adapter-name>``` to enable debugging and upload widget to "vis". (This works only from V0.7.15 of js-controller)
* If you do not plan to export any widget then delete the whole widget folder and remove the ```"restartAdapters": ["vis"]``` statement from *io-package.json*
* After admin/index.html is changed you must execute ```iobroker upload mynewname``` to see changes in admin console. The same is valid for any files in *admin* and *www* directory
* After admin/index.html is changed you must execute ```yunkong2 upload mynewname``` to see changes in admin console. The same is valid for any files in *admin* and *www* directory
7. change version: edit package.json and then call ```grunt p``` in your adapter directory.
*"auth":false,// if basic authentication is required. If enabled, the secure connection should be used.
*"secure":false,// If SSL communication must be used. Should has the name "secure", because it can be changed from console.
*"bind":"0.0.0.0",// Specific address, where the server will be started. "0.0.0.0" means that it will be available for all addresses. Should has the name "bind", because it can be changed from console.
*"defaultUser":"admin",// If authentication is disabled, here can be specified as which user the requests will be done to iobroker DB.
*"certPublic":"defaultPublic",// Required for SSL communication: name of some public certificate from iobroker DB
*"certPrivate":"defaultPrivate"// Required for SSL communication: name of some private key from iobroker DB
*"defaultUser":"admin",// If authentication is disabled, here can be specified as which user the requests will be done to yunkong2 DB.
*"certPublic":"defaultPublic",// Required for SSL communication: name of some public certificate from yunkong2 DB
*"certPrivate":"defaultPrivate"// Required for SSL communication: name of some private key from yunkong2 DB
*
*"pollURL":"",// Request all 30 seconds the JSON from this URL, parse it and store in ioBroker
*"pollURL":"",// Request all 30 seconds the JSON from this URL, parse it and store in yunkong2
*"interval":30000// polling interval
*}
*}
@ -53,7 +53,7 @@ var request = null; // will be initialized later if polling enabled
// you have to call the adapter function and pass a options object
// name has to be set and has to be equal to adapters folder name and main file name excluding extension
// adapter will be restarted automatically every time as the configuration changed, e.g system.adapter.template.0