diff --git a/适配器.md b/适配器.md index 98226d1..d7350b7 100644 --- a/适配器.md +++ b/适配器.md @@ -15,9 +15,9 @@ - [Options of adapter](#options-of-adapter) - [Attributes of adapter object](#attributes-of-adapter-object) - [Most important events](#most-important-events) - - [Logging](#logging) - - [Instance configuration](#instance-configuration) - - [How to read state](#how-to-read-state) + - [日志记录](#logging) + - [实例配置](#instance-configuration) + - [如何读取状态](#how-to-read-state) - [Commands and Statuses](#commands-and-statuses) - [How to write state](#how-to-write-state) - [Structure of state](#structure-of-state) @@ -568,7 +568,7 @@ adapter.on('ready', function () { }); ``` #### Logging -#### 记录 +#### 日志记录 能够记录事件以进行调试和控制是非常重要的。以下函数可用于记录事件: @@ -588,7 +588,8 @@ adapter.on('ready', function () { #### 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". 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", "language": "" } ``` + 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". 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({ 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({ name: 'adapterName', // adapter name @@ -640,9 +641,12 @@ var adapter = utils.adapter({ ``` Date format will be available under ```adapter.dateFormat```. -All other configurations can be read manually with ```getForeignObject``` function. +可以使用```getForeignObject```功能手动读取所有其他配置。 + #### How to read state +#### 如何读取状态 + There are two modes to read states in ioBroker adapter: - event subscription (suggested) - polling