Update 适配器.md
This commit is contained in:
parent
bdee72c7f0
commit
7b0ef48560
48
适配器.md
48
适配器.md
@ -43,12 +43,14 @@ Data storage can be represented as database (redis/couchDB) or just text file, b
|
||||
oBroker中的适配器是一个独立的进程,它在中央数据存储中读取和写入对象和状态。数据存储可以表示为数据库(redis / couchDB)或只是文本文件,但连接方式始终相同 - 通过API。这意味着,开发人员不应该关心数据库是什么以及如何在那里存储和交付数据。
|
||||
|
||||
There are two types of data in the storage:
|
||||
|
||||
存储中有两种类型的数据:
|
||||
|
||||
- Objects
|
||||
- States
|
||||
|
||||
Objects are static descriptions of some data point. States are the dynamic values of data points. So normally for every state there is a object with description. (But not vice versa).
|
||||
|
||||
对象是某些数据点的静态描述。状态是数据点的动态值。所以通常对于每个州都有一个描述对象。(但反之亦然)
|
||||
|
||||
Objects additionally describe:
|
||||
@ -72,10 +74,12 @@ There is a system objects (name starts with _ or "system.") and adapter objects
|
||||
|
||||
|
||||
**Note:** here and forth **adapterName** is the name of the adapter that a developer wants to create.
|
||||
|
||||
注意 adapterName是开发人员想要创建的适配器的名称。
|
||||
|
||||
|
||||
The states can be grouped in channels and the channels in devices. Here is a example of Homematic groups and channels:
|
||||
|
||||
状态可以分组在通道和设备中的通道中。以下是Homematic组和频道的示例:
|
||||
|
||||
|
||||
@ -88,6 +92,7 @@ The states can be grouped in channels and the channels in devices. Here is a exa
|
||||
- hm-rpc.0.IEQ1234567.0.BATTERY - state
|
||||
|
||||
The state ID must always start with channel name and channel name with device name. E.g. in the state name **hm-rpc.0.IEQ1234567.0.INFO** above, the part **hm-rpc.0.IEQ1234567.0** is the channel name and **hm-rpc.0.IEQ1234567** is the device name.
|
||||
|
||||
状态ID必须始终以通道名称和通道名称与设备名称开头
|
||||
|
||||
It is used to build the coordination of device, channels and states in hierarchy.
|
||||
@ -95,6 +100,7 @@ It is used to build the coordination of device, channels and states in hierarchy
|
||||
它用于在层次结构中建立设备,通道和状态的协调。
|
||||
|
||||
**Note:** If adapter is not so complex, the devices and even channels can be omitted.
|
||||
|
||||
注意:如果适配器不是那么复杂,可以省略设备和偶数通道。
|
||||
|
||||
|
||||
@ -106,9 +112,11 @@ Adapter只是文件包,放在node_modules目录中。对于每个适配器,
|
||||
|
||||
|
||||
**Instance** is an instance of adapter. Depending on type of adapter more than one instance can be created , but for some adapters there is no use to create more than one instance. E.g. in case of vis or rickshaw only one instance can be created. This behavior is controlled by flags in _io-package.json_.
|
||||
|
||||
**Instance** 是适配器的实例。根据适配器的类型,可以创建多个实例,但对于某些适配器,创建多个实例是没有用的。例如,在vis或rickshaw的情况下,只能创建一个实例。此行为由io-package.json中的标志控制。
|
||||
|
||||
For each instance the configuration object can be found in the data storage under "_system.adapter.adapterName.X_" ID, where X is the adapter instance number. It contains the settings for this instance of the adapter. Normally it consist of "common" and "native" settings. Common settings are:
|
||||
|
||||
对于每个实例,可以在“ system.adapter.adapterName.X ”ID 下的数据存储中找到配置对象,其中X是适配器实例编号。它包含适配器的此实例的设置。通常它由“常见”和“原生”设置组成。常见设置是:
|
||||
|
||||
|
||||
@ -117,19 +125,24 @@ For each instance the configuration object can be found in the data storage unde
|
||||
- mode: none, daemon, subscribe, schedule, once;
|
||||
|
||||
Description can be found [here](https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#instance)
|
||||
|
||||
描述可以在这里找到
|
||||
|
||||
|
||||
"Native" settings consist of **specific** configurations for this adapter, e.g.: IP address of device, device settings and so on.
|
||||
|
||||
“本机”设置由此适配器的特定配置组成,例如:设备的IP地址,设备设置等。
|
||||
|
||||
**Note:** Instances can run on different hosts (in multi-hosts systems) and the adapters can have different version on different hosts.
|
||||
|
||||
注意:实例可以在不同的主机上运行(在多主机系统中),并且适配器可以在不同的主机上具有不同的版本。
|
||||
|
||||
All adapter instance object IDs starts with _adapterName.X_, where X is number of adapter instance.
|
||||
|
||||
所有适配器实例对象ID都以adapterName.X开头,其中X是适配器实例的编号。
|
||||
|
||||
Objects have different [types](https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#object-types) for different purposes.
|
||||
|
||||
对象具有不同类型以用于不同目的。
|
||||
|
||||
For every adapter (not the instance) the following objects will be created automatically:
|
||||
@ -154,8 +167,14 @@ Explanation of memory states can be found [here](http://stackoverflow.com/questi
|
||||
If adapter has mode 'none' or 'once', then alive, uptime, ... objects will not be created.
|
||||
|
||||
## Directory structure of adapter
|
||||
|
||||
适配器的目录结构
|
||||
|
||||
Adapter package must have some mandatory directories and files:
|
||||
|
||||
适配器包必须具有一些必需的目录和文件:
|
||||
|
||||
|
||||
- admin (mandatory directory)
|
||||
- index.html
|
||||
- xxx.png - optional, better if it has name adapterName.png (any image formats are supported: jpeg, jpg, svg, bmp, ...)
|
||||
@ -168,9 +187,16 @@ Adapter package must have some mandatory directories and files:
|
||||
|
||||
**Note**: lib/utils.js is a common file for all adapters, used to detect the position of js-controller and accordingly path to iobroker.js-controller/lib/adapter.js. Most actual utils.js can be downloaded [here](https://github.com/ioBroker/ioBroker.build/blob/master/adapters/utils.js). _Do not change this file._
|
||||
|
||||
注意:lib / utils.js是所有适配器的公共文件,用于检测js-controller的位置以及相应的iobroker.js-controller / lib / adapter.js路径。大多数实际的utils.js都可以在这里下载。请勿更改此文件。
|
||||
|
||||
|
||||
## File naming
|
||||
文件命名
|
||||
|
||||
Adapter must must follow some naming convention to be accepted and started by ioBroker controller.
|
||||
|
||||
适配器必须遵循某些命名约定,以便由ioBroker控制器接受和启动。
|
||||
|
||||
1. On github (or somewhere else) it must have name _io**B**roker.adapterName_.
|
||||
2. If the adapter will be available on npm it must have name _io**b**roker.adapterName_, because npm doe snot allow capital letters in package names. It can be defined in in _package.json_
|
||||
3. GUI html file for configuration of adapter must have name admin/index.html. It can be more files in the "admin" directory, but index.html must exist.
|
||||
@ -178,12 +204,23 @@ Adapter must must follow some naming convention to be accepted and started by io
|
||||
4. Name of adapter must be unique, lowercase, with no special characters and without spaces. "-", "_" are allowed in the name of adapter.
|
||||
|
||||
## Structure of io-package.json
|
||||
|
||||
io-package.json is used by js-controller to show information about adapter and to know how to treat it.
|
||||
Complete description of all fields in common part can be found [here](https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#adapter)
|
||||
|
||||
js-controller使用io-package.json来显示有关适配器的信息并知道如何处理它。可以在[here](https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#adapter)找到共同部分中所有字段的完整描述
|
||||
|
||||
|
||||
|
||||
io-package.json will be read by "admin" to find out the online version of adapter.
|
||||
|
||||
io-package.json将被“admin”读取以找出适配器的在线版本。
|
||||
|
||||
|
||||
### Common fields
|
||||
|
||||
|
||||
|
||||
Most important fields in **common** are:
|
||||
|
||||
- name: mandatory. Name of adapter without "ioBroker.", like adapterName and not "ioBroker.adapterName"
|
||||
@ -199,12 +236,14 @@ Most important fields in **common** are:
|
||||
}
|
||||
```
|
||||
If no entry exists for the current language, the description in english will be shown.
|
||||
如果当前语言不存在条目,则将显示英语说明。
|
||||
|
||||
- platform: mandatory. Actually only "Javascript/Node.js" is supported.
|
||||
- mode: mandatory. The mode how the adapter will be started.
|
||||
|
||||
- platform: 必须. Actually only "Javascript/Node.js" is supported.
|
||||
- mode: 必须. 适配器启动的模式。
|
||||
- enabled: optional. When set to true, the instance will be activated after addition.
|
||||
- license": license name under what the adapter is licensed;
|
||||
- loglevel": initial log level that will be set after creation of instance. Can be "debug", "info", "warn" or "error"
|
||||
- loglevel": 创建实例后将设置的初始日志级别。 Can be "debug", "info", "warn" or "error"
|
||||
- readme": link to readme page in internet. Used by admin adapter to show the link if "?" button clicked.
|
||||
- icon": icon name (not the path) of adapter icon. This icon must be in admin directory of adapter.
|
||||
- extIcon: icon path in internet to show the icon for adapter if the adapter is not yet installed.
|
||||
@ -215,6 +254,8 @@ If no entry exists for the current language, the description in english will be
|
||||
|
||||
**Note:** localLink can have special keys, that will be replaced by real values.
|
||||
|
||||
注意: localLink可以有特殊键,它将被实际值替换。
|
||||
|
||||
- %ip%: will be replaced with IP address defined in first "web" instance.
|
||||
- %field%, where field is attribute from "native" part of configuration of adapter instance.
|
||||
|
||||
@ -222,6 +263,7 @@ E.g. "http://%ip%:%port%" will be shown as "http://192.168.0.1:8080", where "192
|
||||
|
||||
|
||||
### Object fields
|
||||
|
||||
objects - static objects for all instances of adapter (xxx.object)
|
||||
By installation of adapter (not the instance creation) some predefined objects (normally that describe something) can be created automatically. These objects must not depend on some specific instance and are common for all instances of this adapter. For example [hm-rpc](https://github.com/ioBroker/ioBroker.hm-rpc/blob/master/io-package.json) adapter has the structure description of all HomeMatic devices.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user