@iobroker/dm-utils 2.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +197 -123
- package/build/ActionContext.d.ts +2 -6
- package/build/DeviceManagement.d.ts +25 -29
- package/build/DeviceManagement.js +190 -106
- package/build/ProgressDialog.d.ts +2 -6
- package/build/types/adapter.d.ts +4 -3
- package/build/types/api.d.ts +58 -0
- package/build/types/base.d.ts +42 -27
- package/build/types/common.d.ts +108 -106
- package/build/types/index.d.ts +1 -1
- package/build/types/index.js +1 -1
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Utility classes for ioBroker adapters to support [ioBroker.device-manager](https
|
|
|
6
6
|
|
|
7
7
|
Add in your `io-package.json` the property `deviceManager: true` to `common.supportedMessages`.
|
|
8
8
|
Note: If you don't have a `common.supportedMessages` property yet, you have to add it.
|
|
9
|
-
Also, if you
|
|
9
|
+
Also, if you have a `common.messagebox` property for the adapter-specific messages, you can remove it and add `common.supportedMessages.custom: true`. (see
|
|
10
10
|
https://github.com/ioBroker/ioBroker.js-controller/blob/274f9e8f84dbdaaba9830a6cc00ddf083e989090/schemas/io-package.json#L754C104-L754C178)
|
|
11
11
|
|
|
12
12
|
In your ioBroker adapter, add a subclass of `DeviceManagement` and override the methods you need (see next chapters):
|
|
@@ -30,7 +30,7 @@ class MyAdapter extends utils.Adapter {
|
|
|
30
30
|
public constructor(options: Partial<utils.AdapterOptions> = {}) {
|
|
31
31
|
super({
|
|
32
32
|
...options,
|
|
33
|
-
name:
|
|
33
|
+
name: 'my-adapter',
|
|
34
34
|
});
|
|
35
35
|
this.deviceManagement = new DmTestDeviceManagement(this);
|
|
36
36
|
|
|
@@ -62,7 +62,7 @@ the `DeviceManagement` implementation's `handleXxxAction()` is called, and the a
|
|
|
62
62
|
|
|
63
63
|
### Controls
|
|
64
64
|
|
|
65
|
-
The device manager tab allows the user to control devices too. If devices are controllable, the device manager tab shows
|
|
65
|
+
The device manager tab allows the user to control devices too. If devices are controllable, the device manager tab shows the control elements in the device card.
|
|
66
66
|
|
|
67
67
|
When the user clicks on a control (i.e., a button in the UI),
|
|
68
68
|
the `DeviceManagement` implementation's `handleXxxAction()` is called, and the adapter can perform arbitrary actions
|
|
@@ -73,7 +73,8 @@ the `DeviceManagement` implementation's `handleXxxAction()` is called, and the a
|
|
|
73
73
|
The communication between the `ioBroker.device-manager` tab and the adapter happens through `sendTo`.
|
|
74
74
|
|
|
75
75
|
**IMPORTANT:** make sure your adapter doesn't handle `sendTo` messages starting with `dm:`, otherwise the communication will not work.
|
|
76
|
-
|
|
76
|
+
|
|
77
|
+
- Use, for example, this on the top of your onMessage Methode:
|
|
77
78
|
|
|
78
79
|
```js
|
|
79
80
|
if (obj.command?.startsWith('dm:')) {
|
|
@@ -88,12 +89,13 @@ You can access all adapter methods like `getState()` or `getStateAsync()` via `t
|
|
|
88
89
|
Example: `this.getState()` -> `this.adapter.getState()`
|
|
89
90
|
|
|
90
91
|
### Error Codes
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
92
|
+
|
|
93
|
+
| Code | Description |
|
|
94
|
+
| ---- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
95
|
+
| 101 | Instance action ${actionId} was called before getInstanceInfo() was called. This could happen if the instance has restarted. |
|
|
96
|
+
| 102 | Instance action ${actionId} is unknown. |
|
|
97
|
+
| 103 | Instance action ${actionId} is disabled because it has no handler. |
|
|
98
|
+
| 201 | Device action ${actionId} was called before loadDevices() was called. This could happen if the instance has restarted. |
|
|
97
99
|
| 202 | Device action ${actionId} was called on unknown device: ${deviceId}. |
|
|
98
100
|
| 203 | Device action ${actionId} doesn't exist on device ${deviceId}. |
|
|
99
101
|
| 204 | Device action ${actionId} on ${deviceId} is disabled because it has no handler. |
|
|
@@ -101,6 +103,7 @@ Example: `this.getState()` -> `this.adapter.getState()`
|
|
|
101
103
|
## Examples
|
|
102
104
|
|
|
103
105
|
To get an idea of how to use `dm-utils`, please have a look at:
|
|
106
|
+
|
|
104
107
|
- [the folder "examples"](examples/dm-test.ts) or
|
|
105
108
|
- [ioBroker.dm-test](https://github.com/UncleSamSwiss/ioBroker.dm-test)
|
|
106
109
|
|
|
@@ -110,30 +113,33 @@ All methods can either return an object of the defined value or a `Promise` reso
|
|
|
110
113
|
|
|
111
114
|
This allows you to implement the method synchronously or asynchronously, depending on your implementation.
|
|
112
115
|
|
|
113
|
-
### `
|
|
116
|
+
### `loadDevices(context: DeviceLoadContext)`
|
|
114
117
|
|
|
115
118
|
This method must always be overridden (as it is abstract in the base class).
|
|
116
119
|
|
|
117
|
-
You must
|
|
120
|
+
You must fill the `context` with information about all devices of this adapter's instance.
|
|
121
|
+
|
|
122
|
+
You may call `context.setTotalDevices(count: number)` as soon as possible to let the GUI know how many devices in total will be loaded. This allows the GUI to show the loading progress.
|
|
118
123
|
|
|
119
124
|
This method is called when the user expands an instance in the list.
|
|
120
125
|
|
|
121
|
-
In most cases, you will get all states of your instance and fill the
|
|
126
|
+
In most cases, you will get all states of your instance and fill the `context` with the relevant information.
|
|
122
127
|
|
|
123
|
-
Every
|
|
128
|
+
Every item is an object of type `DeviceInfo` which has the following properties:
|
|
124
129
|
|
|
125
|
-
- `id` (
|
|
130
|
+
- `id` (JSON object): a unique identifier of the device (it must be unique for your adapter instance only)
|
|
131
|
+
- `identifier` (optional): a human-readable identifier of the device
|
|
126
132
|
- `name` (string or translations): the human-readable name of this device
|
|
127
133
|
- `status` (optional): the current status of the device, which has to be an object containing:
|
|
128
134
|
- `connection` (string): alowed values are: `"connected"` / `"disconnected"`
|
|
129
135
|
- `rssi` (number): rssi value of the connection
|
|
130
|
-
- `battery` (boolean / number): if boolean: false
|
|
131
|
-
- `warning` (boolean / string): if boolean: true indicates a warning. If string: shows also the warning with mouseover
|
|
136
|
+
- `battery` (boolean / number): if boolean: false - the battery is empty. If number: the battery level of the device (shows also a battery symbol on the card)
|
|
137
|
+
- `warning` (boolean / string): if boolean: true indicates a warning. If a string: shows also the warning with mouseover
|
|
132
138
|
- `actions` (array, optional): an array of actions that can be performed on the device; each object contains:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
- `id` (string): unique identifier to recognize an action (never shown to the user)
|
|
140
|
+
- `icon` (string): an icon shown on the button (see below for details)
|
|
141
|
+
- `description` (string, optional): a text that will be shown as a tooltip on the button
|
|
142
|
+
- `handler` (function, optional): function that will be called when the user clicks on the button; if not given, the button will be disabled in the UI
|
|
137
143
|
- `hasDetails` (boolean, optional): if set to `true`, the row of the device can be expanded and details are shown below
|
|
138
144
|
|
|
139
145
|
Possible strings for device icons are here: [TYPE ICONS](https://github.com/ioBroker/adapter-react-v5/blob/main/src/Components/DeviceType/DeviceTypeIcon.tsx#L68)
|
|
@@ -142,28 +148,30 @@ Possible strings for action icons are here: [ACTION NAMES](https://github.com/io
|
|
|
142
148
|
<br/>
|
|
143
149
|
Possible strings for configuration icons are here: [CONFIGURATION TYPES](https://github.com/ioBroker/dm-utils/blob/b3e54ecfaedd6a239beec59c5deb8117d1d59d7f/src/types/common.ts#L110)
|
|
144
150
|
<br/>
|
|
151
|
+
|
|
145
152
|
### `getInstanceInfo()`
|
|
146
153
|
|
|
147
154
|
This method allows the device manager tab to gather some general information about the instance. It is called when the user opens the tab.
|
|
148
155
|
|
|
149
156
|
If you override this method, the returned object must contain:
|
|
150
157
|
|
|
151
|
-
- `apiVersion` (string): the supported API version; must be `"
|
|
158
|
+
- `apiVersion` (string): the supported API version; must be `"v3"`
|
|
152
159
|
- `actions` (array, optional): an array of actions that can be performed on the instance; each object contains:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
- `communicationStateId` (string
|
|
160
|
+
- `id` (string): unique identifier to recognize an action (never shown to the user)
|
|
161
|
+
- `icon` (string): an icon shown on the button (see below for details)
|
|
162
|
+
- `title` (string): the title shown next to the icon on the button
|
|
163
|
+
- `description` (string, optional): a text that will be shown as a tooltip on the button
|
|
164
|
+
- `handler` (function, optional): function that will be called when the user clicks on the button; if not given, the button will be disabled in the UI
|
|
165
|
+
- `communicationStateId` (string, optional): the ID of the state that is used by backend for communication with front-end
|
|
166
|
+
- `identifierLabel` (string or translations, optional): the human-readable label next to the identifier
|
|
159
167
|
|
|
160
|
-
### `getDeviceDetails(id:
|
|
168
|
+
### `getDeviceDetails(id: DeviceId)`
|
|
161
169
|
|
|
162
170
|
This method is called if a device's `hasDetails` is set to `true` and the user clicks on the expander.
|
|
163
171
|
|
|
164
172
|
The returned object must contain:
|
|
165
173
|
|
|
166
|
-
- `id` (
|
|
174
|
+
- `id` (JSON object): the `id` given as parameter to the method call
|
|
167
175
|
- `schema` (Custom JSON form schema): the schema of the Custom JSON form to show below the device information
|
|
168
176
|
- `data` (object, optional): the data used to populate the Custom JSON form
|
|
169
177
|
|
|
@@ -171,31 +179,37 @@ For more details about the schema, see [here](https://github.com/ioBroker/ioBrok
|
|
|
171
179
|
|
|
172
180
|
Please keep in mind that there is no "Save" button, so in most cases, the form shouldn't contain editable fields, but you may use `sendTo<xxx>` objects to send data to the adapter.
|
|
173
181
|
|
|
174
|
-
|
|
182
|
+
## `DeviceManagement` handlers
|
|
175
183
|
|
|
176
|
-
|
|
184
|
+
### InstanceInfo action handlers
|
|
185
|
+
|
|
186
|
+
These functions are called when the user clicks on an action (i.e., button) for an adapter instance.
|
|
187
|
+
|
|
188
|
+
The parameters of this function are:
|
|
177
189
|
|
|
178
|
-
The parameters of this method are:
|
|
179
|
-
- `actionId` (string): the `id` that was given in `getInstanceInfo()` --> `actions[].id`
|
|
180
190
|
- `context` (object): object containing helper methods that can be used when executing the action
|
|
191
|
+
- `options` (object): object containing the action `value` (if given)
|
|
181
192
|
|
|
182
193
|
The returned object must contain:
|
|
194
|
+
|
|
183
195
|
- `refresh` (boolean): set this to `true` if you want the list to be reloaded after this action
|
|
184
196
|
|
|
185
197
|
This method can be implemented asynchronously and can take a lot of time to complete.
|
|
186
198
|
|
|
187
199
|
See below for how to interact with the user.
|
|
188
200
|
|
|
189
|
-
###
|
|
201
|
+
### DeviceInfo action handlers
|
|
190
202
|
|
|
191
|
-
|
|
203
|
+
These functions are called when the user clicks on an action (i.e., button) for an adapter instance.
|
|
192
204
|
|
|
193
|
-
The parameters of this
|
|
194
|
-
|
|
195
|
-
- `
|
|
205
|
+
The parameters of this function are:
|
|
206
|
+
|
|
207
|
+
- `deviceId` (JSON object): the `id` of the device
|
|
196
208
|
- `context` (object): object containing helper methods that can be used when executing the action
|
|
209
|
+
- `options` (object): object containing the action `value` (if given)
|
|
197
210
|
|
|
198
211
|
The returned object must contain:
|
|
212
|
+
|
|
199
213
|
- `refresh` (string / boolean): the following values are allowed:
|
|
200
214
|
- `"device"`: if you want the device details to be reloaded after this action
|
|
201
215
|
- `"instance"`: if you want the entire device list to be reloaded after this action
|
|
@@ -205,32 +219,32 @@ This method can be implemented asynchronously and can take a lot of time to comp
|
|
|
205
219
|
|
|
206
220
|
See below for how to interact with the user.
|
|
207
221
|
|
|
208
|
-
###
|
|
222
|
+
### DeviceInfo control handlers
|
|
209
223
|
|
|
210
|
-
|
|
224
|
+
These functions are called when the user clicks on a control (i.e., slider) in the device card.
|
|
211
225
|
|
|
212
226
|
The parameters of this method are:
|
|
213
|
-
|
|
214
|
-
- `
|
|
215
|
-
- `
|
|
227
|
+
|
|
228
|
+
- `deviceId` (JSON object): the `id` that was given in `loadDevices()` --> `[].id`
|
|
229
|
+
- `controlId` (string): the `id` that was given in `loadDevices()` --> `[].controls[].id`. There are some reserved control names, you can find the list below.
|
|
230
|
+
- `newState` (string | number | boolean): new state for the control, that will be sent to a real device
|
|
216
231
|
- `context` (object): object containing helper methods that can be used when executing the action
|
|
217
232
|
|
|
218
|
-
The returned object must
|
|
219
|
-
- `state`: ioBroker state object
|
|
233
|
+
The returned object must be an ioBroker state object.
|
|
220
234
|
|
|
221
235
|
This method can be implemented asynchronously and can take a lot of time to complete.
|
|
222
236
|
|
|
223
|
-
###
|
|
237
|
+
### DeviceInfo getState handlers
|
|
224
238
|
|
|
225
|
-
|
|
239
|
+
These functions are called when GUI requests the update of the state.
|
|
226
240
|
|
|
227
241
|
The parameters of this method are:
|
|
228
|
-
|
|
229
|
-
- `
|
|
242
|
+
|
|
243
|
+
- `deviceId` (JSON object): the `id` that was given in `loadDevices()` --> `[].id`
|
|
244
|
+
- `controlId` (string): the `id` that was given in `loadDevices()` --> `[].controls[].id`
|
|
230
245
|
- `context` (object): object containing helper methods that can be used when executing the action
|
|
231
246
|
|
|
232
|
-
The returned object must
|
|
233
|
-
- `state`: ioBroker state object
|
|
247
|
+
The returned object must be an ioBroker state object.
|
|
234
248
|
|
|
235
249
|
This method can be implemented asynchronously and can take a lot of time to complete.
|
|
236
250
|
|
|
@@ -244,6 +258,7 @@ Inside an action method (`handleInstanceAction()` or `handleDeviceAction()`) you
|
|
|
244
258
|
For interactions, there are methods you can call on `context`:
|
|
245
259
|
|
|
246
260
|
There are some reserved action names, you can find the list below:
|
|
261
|
+
|
|
247
262
|
- `status` - This action is called when the user clicks on the status icon. So to implement the "click-on-status" functionality, the developer has to implement this action.
|
|
248
263
|
- `disable` - This action will be called when the user clicks on the `enabled` icon. `disable` and `enable` actions cannot be together.
|
|
249
264
|
- `enable` - This action will be called when the user clicks on the `disabled` icon. `disable` and `enable` actions cannot be together.
|
|
@@ -253,6 +268,7 @@ There are some reserved action names, you can find the list below:
|
|
|
253
268
|
Shows a message to the user.
|
|
254
269
|
|
|
255
270
|
The method has the following parameter:
|
|
271
|
+
|
|
256
272
|
- `text` (string or translation): the text to show to the user
|
|
257
273
|
|
|
258
274
|
This asynchronous method returns (or rather: the Promise is resolved) once the user has clicked on "OK".
|
|
@@ -262,23 +278,28 @@ This asynchronous method returns (or rather: the Promise is resolved) once the u
|
|
|
262
278
|
Lets the user confirm an action by showing a message with an "OK" and "Cancel" button.
|
|
263
279
|
|
|
264
280
|
The method has the following parameter:
|
|
281
|
+
|
|
265
282
|
- `text` (string or translation): the text to show to the user
|
|
266
283
|
|
|
267
284
|
This asynchronous method returns (or rather: the Promise is resolved) once the user has clicked a button in the dialog:
|
|
285
|
+
|
|
268
286
|
- `true` if the user clicked "OK"
|
|
269
287
|
- `false` if the user clicked "Cancel"
|
|
270
288
|
|
|
271
|
-
### `showForm(schema: JsonFormSchema, options?: { data?: JsonFormData; title?: string })`
|
|
289
|
+
### `showForm(schema: JsonFormSchema, options?: { data?: JsonFormData; title?: string; ignoreApplyDisabled?: boolean })`
|
|
272
290
|
|
|
273
291
|
Shows a dialog with a Custom JSON form that can be edited by the user.
|
|
274
292
|
|
|
275
293
|
The method has the following parameters:
|
|
294
|
+
|
|
276
295
|
- `schema` (Custom JSON form schema): the schema of the Custom JSON form to show in the dialog
|
|
277
296
|
- `options` (object, optional): options to configure the dialog further
|
|
278
|
-
|
|
279
|
-
|
|
297
|
+
- `data` (object, optional): the data used to populate the Custom JSON form
|
|
298
|
+
- `title` (string, optional): the dialog title
|
|
299
|
+
- `ignoreApplyDisabled` (boolean, optional): set to `true` to always enable the "OK" button even if the form is unchanged
|
|
280
300
|
|
|
281
301
|
This asynchronous method returns (or rather: the Promise is resolved) once the user has clicked a button in the dialog:
|
|
302
|
+
|
|
282
303
|
- the form data, if the user clicked "OK"
|
|
283
304
|
- `undefined`, if the user clicked "Cancel"
|
|
284
305
|
|
|
@@ -287,11 +308,12 @@ This asynchronous method returns (or rather: the Promise is resolved) once the u
|
|
|
287
308
|
Shows a dialog with a linear progress bar to the user. There is no way for the user to dismiss this dialog.
|
|
288
309
|
|
|
289
310
|
The method has the following parameters:
|
|
311
|
+
|
|
290
312
|
- `title` (string): the dialog title
|
|
291
313
|
- `options` (object, optional): options to configure the dialog further
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
314
|
+
- `indeterminate` (boolean, optional): set to `true` to visualize an unspecified wait time
|
|
315
|
+
- `value` (number, optional): the progress value to show to the user (if set, it must be a value between 0 and 100)
|
|
316
|
+
- `label` (string, optional): the label to show to the right of the progress bar; you may show the progress value in a human-readable way (e.g. "42%") or show the current step in multi-step progress (e.g. "Logging in...")
|
|
295
317
|
|
|
296
318
|
This method returns a promise that resolves to a `ProgressDialog` object.
|
|
297
319
|
|
|
@@ -300,156 +322,208 @@ This method returns a promise that resolves to a `ProgressDialog` object.
|
|
|
300
322
|
`ProgressDialog` has two methods:
|
|
301
323
|
|
|
302
324
|
- `update(update: { title?: string; indeterminate?: boolean; value?:number; label?: string; })`
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
325
|
+
- Updates the progress dialog with new values
|
|
326
|
+
- The method has the following parameter:
|
|
327
|
+
- `update` (object): what to update in the dialog
|
|
328
|
+
- `title` (string, optional): change the dialog title
|
|
329
|
+
- `indeterminate` (boolean, optional): change whether the progress is indeterminate
|
|
330
|
+
- `value` (number, optional): change the progress value (if set, it must be a value between 0 and 100)
|
|
331
|
+
- `label` (string, optional): change the label to the right of the progress bar
|
|
310
332
|
- `close()`
|
|
311
|
-
|
|
333
|
+
- Closes the progress dialog (and allows you to open other dialogs)
|
|
312
334
|
|
|
313
335
|
### `sendCommandToGui(command: BackendToGuiCommand)`
|
|
314
336
|
|
|
315
|
-
Sends command to GUI to add/update/delete devices or to update the status of device.
|
|
337
|
+
Sends command to GUI to add/update/delete devices or to update the status of a device.
|
|
316
338
|
|
|
317
|
-
**It is suggested** to use the state's ID directly in DeviceInfo structure instead of sending the command every time to GUI on status update.
|
|
339
|
+
**It is suggested** to use the state's ID directly in the DeviceInfo structure instead of sending the command every time to GUI on status update.
|
|
340
|
+
|
|
341
|
+
See the example below:
|
|
318
342
|
|
|
319
|
-
See example below:
|
|
320
343
|
```ts
|
|
321
344
|
class MyAdapterDeviceManagement extends DeviceManagement<MyAdapter> {
|
|
322
|
-
protected
|
|
345
|
+
protected loadDevices(context: DeviceLoadContext<string>): void {
|
|
323
346
|
const deviceInfo: DeviceInfo = {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
347
|
+
id: 'uniqieID',
|
|
348
|
+
name: 'My device',
|
|
349
|
+
icon: 'node', // find possible icons here: https://github.com/ioBroker/adapter-react-v5/blob/main/src/Components/DeviceType/DeviceTypeIcon.tsx#L68
|
|
350
|
+
manufacturer: { objectId: 'uniqieID', property: 'native.manufacturer' },
|
|
351
|
+
model: { objectId: 'uniqieID', property: 'native.model' },
|
|
352
|
+
status: {
|
|
353
|
+
battery: { stateId: 'uniqieID.DevicePower0.BatteryPercent' },
|
|
354
|
+
connection: { stateId: 'uniqieID.online', mapping: { true: 'connected', false: 'disconnected' } },
|
|
355
|
+
rssi: { stateId: 'uniqieID.rssi' },
|
|
356
|
+
},
|
|
357
|
+
hasDetails: true,
|
|
335
358
|
};
|
|
336
|
-
|
|
359
|
+
context.addDevice(deviceInfo);
|
|
337
360
|
}
|
|
338
361
|
}
|
|
339
362
|
```
|
|
340
|
-
|
|
363
|
+
|
|
364
|
+
## Migration from 1.x to 2.x
|
|
365
|
+
|
|
366
|
+
Between versions 1.x and 2.x, there are some breaking changes. Please also have a look at the changelog below for more information.
|
|
367
|
+
|
|
368
|
+
### Incremental loading of devices
|
|
369
|
+
|
|
370
|
+
In version 1.x, the `listDevices()` method had to return the full list of devices.
|
|
371
|
+
In version 2.x, this method was replaced by `loadDevices(context: DeviceLoadContext)` that allows incremental loading of devices.
|
|
372
|
+
|
|
373
|
+
Instead of creating and returning an array of `DeviceInfo` objects, you have to call `context.addDevice(deviceInfo)` for each device you want to add to the list.
|
|
374
|
+
|
|
375
|
+
You may also call `context.setTotalDevices(count: number)` as soon as possible to let the GUI know how many devices in total will be loaded.
|
|
376
|
+
|
|
377
|
+
### Refresh response of device actions
|
|
378
|
+
|
|
379
|
+
In version 2.x, the refresh response of device actions has changed.
|
|
380
|
+
|
|
381
|
+
| Version 1.x | Version 2.x | Description |
|
|
382
|
+
| ------------ | ------------ | --------------------------------------------------------------------------- |
|
|
383
|
+
| `true` | `'all'` | the instance information as well as the entire device list will be reloaded |
|
|
384
|
+
| `false` | `'none'` | nothing will be reloaded |
|
|
385
|
+
| `'device'` | `'devices'` | the entire device list will be reloaded |
|
|
386
|
+
| `'instance'` | `'instance'` | (unchanged) only the instance information will be reloaded |
|
|
387
|
+
|
|
388
|
+
## Changelog
|
|
389
|
+
|
|
341
390
|
<!--
|
|
342
391
|
Placeholder for the next version (at the beginning of the line):
|
|
343
392
|
### **WORK IN PROGRESS**
|
|
344
393
|
-->
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
394
|
+
### 3.0.0 (2026-03-01)
|
|
395
|
+
|
|
396
|
+
- (@UncleSamSwiss) Enabled incremental loading of devices
|
|
397
|
+
- (@UncleSamSwiss) Removed direct access to `DeviceManagement.handleXxx()` methods (use `handler` and similar properties instead)
|
|
398
|
+
- (@UncleSamSwiss) Added `identifier` property to `DeviceInfo` for human-readable identifiers
|
|
399
|
+
- (@UncleSamSwiss) Device refresh responses can no longer be a `boolean` and `'device'` was renamed to `'devices'`.
|
|
400
|
+
- (@UncleSamSwiss) Added `info` icon and possibility for actions to be a link (by providing a `url` property instead of a `handler` function)
|
|
401
|
+
|
|
402
|
+
### 2.0.2 (2026-01-28)
|
|
403
|
+
|
|
404
|
+
- (@GermanBluefox) BREAKING: Admin/GUI must have version 9 (or higher) of `dm-gui-components`
|
|
405
|
+
- (@GermanBluefox) Added types to update the status of a device directly from the state
|
|
406
|
+
- (@GermanBluefox) Added backend to GUI communication possibility
|
|
407
|
+
- (@GermanBluefox) Added `dm:deviceInfo` command
|
|
408
|
+
- (@GermanBluefox) Added `dm:deviceStatus` command
|
|
350
409
|
|
|
351
410
|
### 1.0.16 (2026-01-02)
|
|
352
|
-
|
|
353
|
-
|
|
411
|
+
|
|
412
|
+
- (@GermanBluefox) Added `ignoreApplyDisabled` flag
|
|
413
|
+
- (@GermanBluefox) Added `update` icon
|
|
354
414
|
|
|
355
415
|
### 1.0.13 (2025-10-21)
|
|
356
|
-
|
|
416
|
+
|
|
417
|
+
- (@GermanBluefox) Updated packages
|
|
357
418
|
|
|
358
419
|
### 1.0.10 (2025-05-05)
|
|
359
420
|
|
|
360
|
-
|
|
361
|
-
|
|
421
|
+
- (@GermanBluefox) Added timeout property to actions
|
|
422
|
+
- (@GermanBluefox) Updated packages
|
|
362
423
|
|
|
363
424
|
### 1.0.9 (2025-01-25)
|
|
364
425
|
|
|
365
|
-
|
|
426
|
+
- (@GermanBluefox) Added copyToClipboard dialog button
|
|
366
427
|
|
|
367
428
|
### 1.0.8 (2025-01-24)
|
|
368
429
|
|
|
369
|
-
|
|
430
|
+
- (@GermanBluefox) Removed `headerTextColor` to device info
|
|
370
431
|
|
|
371
432
|
### 1.0.6 (2025-01-14)
|
|
372
|
-
|
|
373
|
-
|
|
433
|
+
|
|
434
|
+
- (@GermanBluefox) Added the connection type indication
|
|
374
435
|
|
|
375
436
|
### 1.0.5 (2025-01-11)
|
|
376
437
|
|
|
377
|
-
|
|
438
|
+
- (@GermanBluefox) Added action ENABLE_DISABLE and `enabled` status
|
|
378
439
|
|
|
379
440
|
### 1.0.0 (2025-01-08)
|
|
380
441
|
|
|
381
|
-
|
|
382
|
-
|
|
442
|
+
- (@GermanBluefox) Added `disabled` options for a device
|
|
443
|
+
- (@GermanBluefox) Major release just because it is good enough. No breaking changes.
|
|
383
444
|
|
|
384
445
|
### 0.6.11 (2024-12-11)
|
|
385
446
|
|
|
386
|
-
|
|
447
|
+
- (@GermanBluefox) Do not close handler for progress
|
|
387
448
|
|
|
388
449
|
### 0.6.10 (2024-12-10)
|
|
389
450
|
|
|
390
|
-
|
|
451
|
+
- (@GermanBluefox) Export `BackEndCommandJsonFormOptions` type
|
|
391
452
|
|
|
392
453
|
### 0.6.9 (2024-11-22)
|
|
393
454
|
|
|
394
|
-
|
|
455
|
+
- (@GermanBluefox) Added a max-width option for form
|
|
395
456
|
|
|
396
457
|
### 0.6.8 (2024-11-22)
|
|
397
458
|
|
|
398
|
-
|
|
459
|
+
- (@GermanBluefox) Allowed grouping of devices
|
|
399
460
|
|
|
400
461
|
### 0.6.7 (2024-11-20)
|
|
401
462
|
|
|
402
|
-
|
|
463
|
+
- (@GermanBluefox) Updated types
|
|
403
464
|
|
|
404
465
|
### 0.6.6 (2024-11-18)
|
|
405
466
|
|
|
406
|
-
|
|
467
|
+
- (@GermanBluefox) Added configurable buttons for form
|
|
407
468
|
|
|
408
469
|
### 0.6.0 (2024-11-17)
|
|
409
470
|
|
|
410
|
-
|
|
411
|
-
|
|
471
|
+
- (@GermanBluefox) used new ioBroker/eslint-config lib and changed prettifier settings
|
|
472
|
+
- (@GermanBluefox) updated JsonConfig types
|
|
412
473
|
|
|
413
474
|
### 0.5.0 (2024-08-30)
|
|
414
|
-
|
|
475
|
+
|
|
476
|
+
- (bluefox) Migrated to eslint 9
|
|
415
477
|
|
|
416
478
|
### 0.4.0 (2024-08-30)
|
|
417
|
-
|
|
479
|
+
|
|
480
|
+
- (bluefox) Added `state` type for JSON config
|
|
418
481
|
|
|
419
482
|
### 0.3.1 (2024-07-18)
|
|
420
|
-
|
|
483
|
+
|
|
484
|
+
- (bluefox) Added qrCode type for JSON config
|
|
421
485
|
|
|
422
486
|
### 0.3.0 (2024-07-17)
|
|
423
|
-
|
|
424
|
-
|
|
487
|
+
|
|
488
|
+
- (bluefox) packages updated
|
|
489
|
+
- (bluefox) Updated JSON config types
|
|
425
490
|
|
|
426
491
|
### 0.2.2 (2024-06-26)
|
|
427
|
-
|
|
492
|
+
|
|
493
|
+
- (bluefox) packages updated
|
|
428
494
|
|
|
429
495
|
### 0.2.0 (2024-05-29)
|
|
430
|
-
|
|
431
|
-
|
|
496
|
+
|
|
497
|
+
- (bluefox) enhanced type exports
|
|
498
|
+
- (bluefox) added confirmation and input text options
|
|
432
499
|
|
|
433
500
|
### 0.1.9 (2023-12-25)
|
|
434
|
-
|
|
501
|
+
|
|
502
|
+
- (foxriver76) enhanced type exports
|
|
435
503
|
|
|
436
504
|
### 0.1.8 (2023-12-17)
|
|
437
|
-
|
|
505
|
+
|
|
506
|
+
- (bluefox) corrected control error
|
|
438
507
|
|
|
439
508
|
### 0.1.7 (2023-12-17)
|
|
440
|
-
|
|
509
|
+
|
|
510
|
+
- (bluefox) added channel info
|
|
441
511
|
|
|
442
512
|
### 0.1.5 (2023-12-16)
|
|
443
|
-
|
|
513
|
+
|
|
514
|
+
- (bluefox) extended controls with unit and new control types
|
|
444
515
|
|
|
445
516
|
### 0.1.4 (2023-12-13)
|
|
446
|
-
|
|
517
|
+
|
|
518
|
+
- (bluefox) added error codes
|
|
447
519
|
|
|
448
520
|
### 0.1.3 (2023-12-10)
|
|
449
|
-
|
|
450
|
-
|
|
521
|
+
|
|
522
|
+
- (bluefox) added some fields to DeviceInfo interface
|
|
523
|
+
- (bluefox) added control possibilities
|
|
451
524
|
|
|
452
525
|
## License
|
|
526
|
+
|
|
453
527
|
MIT License
|
|
454
528
|
|
|
455
529
|
Copyright (c) 2023-2026 ioBroker Community Developers
|
package/build/ActionContext.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import type { BackEndCommandJsonFormOptions, JsonFormData, JsonFormSchema } from '.';
|
|
1
|
+
import type { BackEndCommandJsonFormOptions, JsonFormData, JsonFormSchema, ProgressOptions } from '.';
|
|
2
2
|
import type { ProgressDialog } from './ProgressDialog';
|
|
3
3
|
export interface ActionContext {
|
|
4
4
|
showMessage(text: ioBroker.StringOrTranslated): Promise<void>;
|
|
5
5
|
showConfirmation(text: ioBroker.StringOrTranslated): Promise<boolean>;
|
|
6
6
|
showForm(schema: JsonFormSchema, options?: BackEndCommandJsonFormOptions): Promise<JsonFormData | undefined>;
|
|
7
|
-
openProgress(title: string, options?:
|
|
8
|
-
indeterminate?: boolean;
|
|
9
|
-
value?: number;
|
|
10
|
-
label?: ioBroker.StringOrTranslated;
|
|
11
|
-
}): Promise<ProgressDialog>;
|
|
7
|
+
openProgress(title: string, options?: ProgressOptions): Promise<ProgressDialog>;
|
|
12
8
|
}
|