You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ADVANCED_OPTIONS.md
+28-29Lines changed: 28 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,32 +2,31 @@
2
2
3
3
**During the beta version, the options are unstable, may get changed during updates.**
4
4
5
-
The main function of `deviceOverrides` is to convert "non-standard schema" to "standard schema", making device compatible with this plugin.
5
+
The main function of `deviceOverrides` is to convert "non-standard schema" to "standard schema", making the device compatible with this plugin.
6
6
7
-
Before config, you may need to:
8
-
- Have basic programming skills of JavaScript (Only used in `onGet`/`onSet`handler).
9
-
- Understand the meaning of device schema (aka Data Type): [Tuya IoT Development Platform > Cloud Development > Standard Instruction Set > Data Type](https://developer.tuya.com/en/docs/iot/datatypedescription?id=K9i5ql2jo7j1k)
10
-
- Find your device product's "Standard Instruction Set" and "Standard Status Set" documentation under [Tuya IoT Development Platform > Cloud Development > Standard Instruction Set](https://developer.tuya.com/en/docs/iot/datatypedescription?id=K9i5ql6waswzq)
11
-
-Get your device's detail information from `/path/to/persist/TuyaDeviceList.xxx.json` (Full path can be found from logs).
12
-
-Find the "wrong schema", then convert to the "correct schema" from product documentation.
7
+
Before configuring, you may need to:
8
+
- Have basic programming skills in JavaScript (Only used in `onGet`/`onSet`handlers).
9
+
- Understand the concept of device schema (also known as Data Type): [Tuya IoT Development Platform > Cloud Development > Standard Instruction Set > Data Type](https://developer.tuya.com/en/docs/iot/datatypedescription?id=K9i5ql2jo7j1k)
10
+
- Find the "Standard Instruction Set" and "Standard Status Set" documentation for your device product under [Tuya IoT Development Platform > Cloud Development > Standard Instruction Set](https://developer.tuya.com/en/docs/iot/datatypedescription?id=K9i5ql6waswzq)
11
+
-Obtain detailed information about your device from `/path/to/persist/TuyaDeviceList.xxx.json` (the full path can be found from logs).
12
+
-Identify the "incorrect schema" and convert it to the "correct schema" according to the product documentation.
13
13
14
14
15
15
### Configuration
16
16
17
-
-`options.deviceOverrides` - **optional**: An array of device overriding config objects.
18
-
-`options.deviceOverrides[].id` - **required**: Device ID, Product ID, Scene ID, or `global`.
19
-
<!--
20
-
- `options.deviceOverrides[].accessoryCategory` - **optional**: Accessory Category ID. Overriding this property can change accessory's icon. See: [Homebridge Plugin Documentation > Categories](https://developers.homebridge.io/#/categories)
21
-
-->
22
-
-`options.deviceOverrides[].category` - **optional**: Device category code. See [SUPPORTED_DEVICES.md](./SUPPORTED_DEVICES.md). Also you can use `hidden` to hide device, product, or scene. **⚠️Overriding this property may leads to unexpected behaviors and exceptions. Please remove accessory cache after change this.**
23
-
24
-
-`options.deviceOverrides[].schema` - **optional**: An array of schema overriding config objects, used for describing datapoint(DP). When your device have non-standard DP, you need to transform them manually with config.
25
-
-`options.deviceOverrides[].schema[].oldCode` - **required**: Original DP code.
26
-
-`options.deviceOverrides[].schema[].code` - **required**: New DP code.
27
-
-`options.deviceOverrides[].schema[].type` - **optional**: New DP type. One of the `Boolean`, `Integer`, `Enum`, `String`, `Json`, `Raw`.
28
-
-`options.deviceOverrides[].schema[].property` - **optional**: New DP property object. For `Integer` type, the object should contains `min`, `max`, `scale`, `step`; For `Enum` type, the object should contains `range`. For detail information, please see `TuyaDeviceSchemaProperty` in [TuyaDevice.ts](./src/device/TuyaDevice.ts).
29
-
-`options.deviceOverrides[].schema[].onGet` - **optional**: An one-line JavaScript code convert old value to new value. The function is called with two arguments: `device`, `value`.
30
-
-`options.deviceOverrides[].schema[].onSet` - **optional**: An one-line JavaScript code convert new value to old value. The function is called with two arguments: `device`, `value`. return `undefined` means skip send this command.
17
+
`options.deviceOverrides` is an **optional** array of device overriding config objects, which is used for converting "non-standard schema" to "standard schema", making the device compatible with this plugin. The structure of each element in the array is described as follows:
18
+
19
+
-`id` - **required**: Device ID, Product ID, Scene ID, or `global`.
20
+
-`category` - **optional**: Device category code. See [SUPPORTED_DEVICES.md](./SUPPORTED_DEVICES.md). Also you can use `hidden` to hide the device, product, or scene. **⚠️Overriding this property may lead to unexpected behaviors and exceptions, so please remove the accessory cache after making changes.**
21
+
-`schema` - **optional**: An array of schema overriding config objects, used for describing datapoint (DP). When your device has non-standard DP, you need to transform them manually with configuration. Each element in the schema array is described as follows:
22
+
-`code` - **required**: DP code.
23
+
-`newCode` - **optional**: New DP code.
24
+
-`type` - **optional**: New DP type. One of `Boolean`, `Integer`, `Enum`, `String`, `Json`, or `Raw`.
25
+
-`property` - **optional**: New DP property object. For `Integer` type, the object should contain `min`, `max`, `scale`, and `step`. For `Enum` type, the object should contain `range`. For more information, see `TuyaDeviceSchemaProperty` in [TuyaDevice.ts](./src/device/TuyaDevice.ts).
26
+
-`onGet` - **optional**: A one-line JavaScript code to convert the old value to the new value. The function is called with two arguments: `device` and `value`.
27
+
-`onSet` - **optional**: A one-line JavaScript code to convert the new value to the old value. The function is called with two arguments: `device` and `value`. Returning `undefined` means to skip sending the command.
28
+
-`hidden` - **optional**: Whether to hide the schema. Defaults to `false`.
29
+
31
30
32
31
## Examples
33
32
@@ -61,6 +60,7 @@ Just the same way as changing category code.
61
60
}
62
61
```
63
62
63
+
64
64
### Offline as off
65
65
66
66
If you want to display off status when device is offline:
@@ -71,7 +71,6 @@ If you want to display off status when device is offline:
71
71
"deviceOverrides": [{
72
72
"id":"{device_id}",
73
73
"schema": [{
74
-
"oldCode":"{dp_code}",
75
74
"code":"{dp_code}",
76
75
"onGet":"(device.online && value)"
77
76
}]
@@ -80,6 +79,7 @@ If you want to display off status when device is offline:
80
79
}
81
80
```
82
81
82
+
83
83
### Change DP code
84
84
85
85
```js
@@ -97,6 +97,7 @@ If you want to display off status when device is offline:
97
97
}
98
98
```
99
99
100
+
100
101
### Convert from enum DP to boolean DP
101
102
102
103
A example of convert `open`/`close` into `true`/`false`.
@@ -107,8 +108,7 @@ A example of convert `open`/`close` into `true`/`false`.
107
108
"deviceOverrides": [{
108
109
"id":"{device_id}",
109
110
"schema": [{
110
-
"oldCode":"{old_dp_code}",
111
-
"code":"{new_dp_code}",
111
+
"code":"{dp_code}",
112
112
"type":"Boolean",
113
113
"onGet":"(value === 'open') ? true : false;",
114
114
"onSet":"(value === true) ? 'open' : 'close';"
@@ -118,6 +118,7 @@ A example of convert `open`/`close` into `true`/`false`.
118
118
}
119
119
```
120
120
121
+
121
122
### Adjust integer DP ranges
122
123
123
124
Some odd thermostat stores double of the real value to keep the decimal part (0.5°C).
@@ -146,7 +147,6 @@ Here's the example config:
146
147
"deviceOverrides": [{
147
148
"id":"{device_id}",
148
149
"schema": [{
149
-
"oldCode":"temp_set",
150
150
"code":"temp_set",
151
151
"onGet":"(value * 5);",
152
152
"onSet":"(value / 5);",
@@ -164,6 +164,7 @@ Here's the example config:
164
164
165
165
After transform value using `onGet` and `onSet`, and new range in `property`, it should be working now.
166
166
167
+
167
168
### Reverse curtain motor's on/off state
168
169
169
170
Most curtain motor have "reverse mode" setting in the Tuya App, if you don't have this, you can reverse `percent_control`/`position` and `percent_state` in the plugin config:
@@ -175,12 +176,10 @@ Most curtain motor have "reverse mode" setting in the Tuya App, if you don't hav
175
176
"deviceOverrides": [{
176
177
"id":"{device_id}",
177
178
"schema": [{
178
-
"oldCode":"percent_control",
179
179
"code":"percent_control",
180
180
"onGet":"(100 - value)",
181
181
"onSet":"(100 - value)"
182
182
}, {
183
-
"oldCode":"percent_state",
184
183
"code":"percent_state",
185
184
"onGet":"(100 - value)",
186
185
"onSet":"(100 - value)"
@@ -190,6 +189,7 @@ Most curtain motor have "reverse mode" setting in the Tuya App, if you don't hav
190
189
}
191
190
```
192
191
192
+
193
193
### Skip send on/off command when touching brightness/speed slider
194
194
195
195
Some products (dimmer, fan) having issue when sending brightness/speed command with on/off command together. Here's an example of skip on/off command.
@@ -201,7 +201,6 @@ Some products (dimmer, fan) having issue when sending brightness/speed command w
0 commit comments