Update 适配器.md
This commit is contained in:
parent
4cf8f5015b
commit
4d0c8c8ad0
26
适配器.md
26
适配器.md
@ -15,9 +15,9 @@
|
|||||||
- [Options of adapter](#options-of-adapter)
|
- [Options of adapter](#options-of-adapter)
|
||||||
- [Attributes of adapter object](#attributes-of-adapter-object)
|
- [Attributes of adapter object](#attributes-of-adapter-object)
|
||||||
- [Most important events](#most-important-events)
|
- [Most important events](#most-important-events)
|
||||||
- [Logging](#logging)
|
- [日志记录](#logging)
|
||||||
- [Instance configuration](#instance-configuration)
|
- [实例配置](#instance-configuration)
|
||||||
- [How to read state](#how-to-read-state)
|
- [如何读取状态](#how-to-read-state)
|
||||||
- [Commands and Statuses](#commands-and-statuses)
|
- [Commands and Statuses](#commands-and-statuses)
|
||||||
- [How to write state](#how-to-write-state)
|
- [How to write state](#how-to-write-state)
|
||||||
- [Structure of state](#structure-of-state)
|
- [Structure of state](#structure-of-state)
|
||||||
@ -568,7 +568,7 @@ adapter.on('ready', function () {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
#### Logging
|
#### Logging
|
||||||
#### 记录
|
#### 日志记录
|
||||||
|
|
||||||
能够记录事件以进行调试和控制是非常重要的。以下函数可用于记录事件:
|
能够记录事件以进行调试和控制是非常重要的。以下函数可用于记录事件:
|
||||||
|
|
||||||
@ -588,7 +588,8 @@ adapter.on('ready', function () {
|
|||||||
#### Instance configuration
|
#### Instance configuration
|
||||||
#### 实例配置
|
#### 实例配置
|
||||||
|
|
||||||
There is an attribute of adapter object to read the configuration of the instance: "adapter.config".
|
适配器对象的属性用于读取实例的配置: "adapter.config".
|
||||||
|
|
||||||
This object consist of "**native**" part of object "system.adapter.adapterName.X".
|
This object consist of "**native**" part of object "system.adapter.adapterName.X".
|
||||||
E.g. if **io-package.json** looks like:
|
E.g. if **io-package.json** looks like:
|
||||||
|
|
||||||
@ -604,13 +605,15 @@ E.g. if **io-package.json** looks like:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
So the adapter.config is equal to:
|
所以adapter.config等于:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"location": "Stuttgart",
|
"location": "Stuttgart",
|
||||||
"language": ""
|
"language": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
and has the data entered by user in configuration dialog.
|
and has the data entered by user in configuration dialog.
|
||||||
You can access the **common **part of instance configuration with attribute "common" of object "adapter".
|
You can access the **common **part of instance configuration with attribute "common" of object "adapter".
|
||||||
E.g. for the shown io-package.json "adapter.common" will be:
|
E.g. for the shown io-package.json "adapter.common" will be:
|
||||||
@ -621,8 +624,7 @@ E.g. for the shown io-package.json "adapter.common" will be:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
To access the **ioBroker configuration** (stored in file iobroker-data/iobroker.json) set the adapter option systemConfig to true.
|
要访问ioBroker配置(存储在文件iobroker-data / iobroker.json中),请将适配器选项systemConfig设置为true。
|
||||||
|
|
||||||
```
|
```
|
||||||
var adapter = utils.adapter({
|
var adapter = utils.adapter({
|
||||||
name: 'adapterName', // adapter name
|
name: 'adapterName', // adapter name
|
||||||
@ -630,8 +632,7 @@ var adapter = utils.adapter({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
To get the global date format the option "**useFormatDate**" must be set to true:
|
要获取全局日期格式,必须将选项 "**useFormatDate**" 设置为true:
|
||||||
|
|
||||||
```
|
```
|
||||||
var adapter = utils.adapter({
|
var adapter = utils.adapter({
|
||||||
name: 'adapterName', // adapter name
|
name: 'adapterName', // adapter name
|
||||||
@ -640,9 +641,12 @@ var adapter = utils.adapter({
|
|||||||
```
|
```
|
||||||
Date format will be available under ```adapter.dateFormat```.
|
Date format will be available under ```adapter.dateFormat```.
|
||||||
|
|
||||||
All other configurations can be read manually with ```getForeignObject``` function.
|
可以使用```getForeignObject```功能手动读取所有其他配置。
|
||||||
|
|
||||||
|
|
||||||
#### How to read state
|
#### How to read state
|
||||||
|
#### 如何读取状态
|
||||||
|
|
||||||
There are two modes to read states in ioBroker adapter:
|
There are two modes to read states in ioBroker adapter:
|
||||||
- event subscription (suggested)
|
- event subscription (suggested)
|
||||||
- polling
|
- polling
|
||||||
|
Loading…
Reference in New Issue
Block a user