Homebridge eWeLink 插件使用教程
1. 项目的目录结构及介绍
homebridge-ewelink/
├── config.schema.json
├── dist/
│ ├── accessory.d.ts
│ ├── accessory.js
│ ├── accessory.js.map
│ ├── api.d.ts
│ ├── api.js
│ ├── api.js.map
│ ├── index.d.ts
│ ├── index.js
│ ├── index.js.map
│ ├── platform.d.ts
│ ├── platform.js
│ ├── platform.js.map
│ ├── utils.d.ts
│ ├── utils.js
│ └── utils.js.map
├── LICENSE
├── package.json
├── README.md
├── src/
│ ├── accessory.ts
│ ├── api.ts
│ ├── index.ts
│ ├── platform.ts
│ └── utils.ts
└── tsconfig.json
config.schema.json
: 配置文件的 schema 定义。dist/
: 编译后的 JavaScript 文件目录。LICENSE
: 项目的许可证文件。package.json
: 项目的依赖和脚本定义。README.md
: 项目的说明文档。src/
: 源代码目录,包含 TypeScript 文件。tsconfig.json
: TypeScript 配置文件。
2. 项目的启动文件介绍
项目的启动文件是 src/index.ts
,编译后对应 dist/index.js
。这个文件是插件的入口点,负责初始化和注册插件。
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service, Characteristic } from 'homebridge';
import { PLATFORM_NAME, PLUGIN_NAME } from './settings';
import { eWeLinkPlatform } from './platform';
export = (api: API) => {
api.registerPlatform(PLUGIN_NAME, PLATFORM_NAME, eWeLinkPlatform);
};
3. 项目的配置文件介绍
配置文件的 schema 定义在 config.schema.json
中。这个文件定义了插件的配置选项和结构。
{
"type": "object",
"properties": {
"platform": {
"title": "eWeLink",
"type": "string",
"default": "eWeLink",
"required": true
},
"name": {
"title": "Name",
"type": "string",
"default": "eWeLink",
"required": true
},
"email": {
"title": "Email",
"type": "string",
"required": true
},
"password": {
"title": "Password",
"type": "string",
"required": true
},
"countryCode": {
"title": "Country Code",
"type": "string",
"required": true
},
"imei": {
"title": "IMEI",
"type": "string",
"required": false
},
"disableDeviceLogging": {
"title": "Disable Device Logging",
"type": "boolean",
"default": false,
"required": false
},
"disablePluginLogging": {
"title": "Disable Plugin Logging",
"type": "boolean",
"default": false,
"required": false
}
}
}
这个配置文件包含了插件的基本信息和用户认证信息,如邮箱、密码和国家代码等。用户可以根据需要进行配置。