@iobroker/dm-utils 2.0.1 → 3.0.2
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 +204 -124
- 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/index.d.ts +1 -1
- package/build/index.js +0 -2
- package/build/types/adapter.d.ts +4 -3
- package/build/types/api.d.ts +65 -0
- package/build/types/base.d.ts +49 -34
- package/build/types/base.js +2 -2
- 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
|
-
- `connection` (string):
|
|
134
|
+
- `connection` (string): allowed 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,66 +179,75 @@ 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
|
|
202
216
|
- `false`: if you don't want anything to be refreshed (important: this is a boolean, not a string!)
|
|
217
|
+
or
|
|
218
|
+
- `url` (string) This URL must be opened
|
|
219
|
+
- `target` (string) Target window for url (`_blank` is default)
|
|
203
220
|
|
|
204
221
|
This method can be implemented asynchronously and can take a lot of time to complete.
|
|
205
222
|
|
|
206
223
|
See below for how to interact with the user.
|
|
207
224
|
|
|
208
|
-
###
|
|
225
|
+
### DeviceInfo control handlers
|
|
209
226
|
|
|
210
|
-
|
|
227
|
+
These functions are called when the user clicks on a control (i.e., slider) in the device card.
|
|
211
228
|
|
|
212
229
|
The parameters of this method are:
|
|
213
|
-
|
|
214
|
-
- `
|
|
215
|
-
- `
|
|
230
|
+
|
|
231
|
+
- `deviceId` (JSON object): the `id` that was given in `loadDevices()` --> `[].id`
|
|
232
|
+
- `controlId` (string): the `id` that was given in `loadDevices()` --> `[].controls[].id`. There are some reserved control names, you can find the list below.
|
|
233
|
+
- `newState` (string | number | boolean): new state for the control, that will be sent to a real device
|
|
216
234
|
- `context` (object): object containing helper methods that can be used when executing the action
|
|
217
235
|
|
|
218
|
-
The returned object must
|
|
219
|
-
- `state`: ioBroker state object
|
|
236
|
+
The returned object must be an ioBroker state object.
|
|
220
237
|
|
|
221
238
|
This method can be implemented asynchronously and can take a lot of time to complete.
|
|
222
239
|
|
|
223
|
-
###
|
|
240
|
+
### DeviceInfo getState handlers
|
|
224
241
|
|
|
225
|
-
|
|
242
|
+
These functions are called when GUI requests the update of the state.
|
|
226
243
|
|
|
227
244
|
The parameters of this method are:
|
|
228
|
-
|
|
229
|
-
- `
|
|
245
|
+
|
|
246
|
+
- `deviceId` (JSON object): the `id` that was given in `loadDevices()` --> `[].id`
|
|
247
|
+
- `controlId` (string): the `id` that was given in `loadDevices()` --> `[].controls[].id`
|
|
230
248
|
- `context` (object): object containing helper methods that can be used when executing the action
|
|
231
249
|
|
|
232
|
-
The returned object must
|
|
233
|
-
- `state`: ioBroker state object
|
|
250
|
+
The returned object must be an ioBroker state object.
|
|
234
251
|
|
|
235
252
|
This method can be implemented asynchronously and can take a lot of time to complete.
|
|
236
253
|
|
|
@@ -244,6 +261,7 @@ Inside an action method (`handleInstanceAction()` or `handleDeviceAction()`) you
|
|
|
244
261
|
For interactions, there are methods you can call on `context`:
|
|
245
262
|
|
|
246
263
|
There are some reserved action names, you can find the list below:
|
|
264
|
+
|
|
247
265
|
- `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
266
|
- `disable` - This action will be called when the user clicks on the `enabled` icon. `disable` and `enable` actions cannot be together.
|
|
249
267
|
- `enable` - This action will be called when the user clicks on the `disabled` icon. `disable` and `enable` actions cannot be together.
|
|
@@ -253,6 +271,7 @@ There are some reserved action names, you can find the list below:
|
|
|
253
271
|
Shows a message to the user.
|
|
254
272
|
|
|
255
273
|
The method has the following parameter:
|
|
274
|
+
|
|
256
275
|
- `text` (string or translation): the text to show to the user
|
|
257
276
|
|
|
258
277
|
This asynchronous method returns (or rather: the Promise is resolved) once the user has clicked on "OK".
|
|
@@ -262,23 +281,28 @@ This asynchronous method returns (or rather: the Promise is resolved) once the u
|
|
|
262
281
|
Lets the user confirm an action by showing a message with an "OK" and "Cancel" button.
|
|
263
282
|
|
|
264
283
|
The method has the following parameter:
|
|
284
|
+
|
|
265
285
|
- `text` (string or translation): the text to show to the user
|
|
266
286
|
|
|
267
287
|
This asynchronous method returns (or rather: the Promise is resolved) once the user has clicked a button in the dialog:
|
|
288
|
+
|
|
268
289
|
- `true` if the user clicked "OK"
|
|
269
290
|
- `false` if the user clicked "Cancel"
|
|
270
291
|
|
|
271
|
-
### `showForm(schema: JsonFormSchema, options?: { data?: JsonFormData; title?: string })`
|
|
292
|
+
### `showForm(schema: JsonFormSchema, options?: { data?: JsonFormData; title?: string; ignoreApplyDisabled?: boolean })`
|
|
272
293
|
|
|
273
294
|
Shows a dialog with a Custom JSON form that can be edited by the user.
|
|
274
295
|
|
|
275
296
|
The method has the following parameters:
|
|
297
|
+
|
|
276
298
|
- `schema` (Custom JSON form schema): the schema of the Custom JSON form to show in the dialog
|
|
277
299
|
- `options` (object, optional): options to configure the dialog further
|
|
278
|
-
|
|
279
|
-
|
|
300
|
+
- `data` (object, optional): the data used to populate the Custom JSON form
|
|
301
|
+
- `title` (string, optional): the dialog title
|
|
302
|
+
- `ignoreApplyDisabled` (boolean, optional): set to `true` to always enable the "OK" button even if the form is unchanged
|
|
280
303
|
|
|
281
304
|
This asynchronous method returns (or rather: the Promise is resolved) once the user has clicked a button in the dialog:
|
|
305
|
+
|
|
282
306
|
- the form data, if the user clicked "OK"
|
|
283
307
|
- `undefined`, if the user clicked "Cancel"
|
|
284
308
|
|
|
@@ -287,11 +311,12 @@ This asynchronous method returns (or rather: the Promise is resolved) once the u
|
|
|
287
311
|
Shows a dialog with a linear progress bar to the user. There is no way for the user to dismiss this dialog.
|
|
288
312
|
|
|
289
313
|
The method has the following parameters:
|
|
314
|
+
|
|
290
315
|
- `title` (string): the dialog title
|
|
291
316
|
- `options` (object, optional): options to configure the dialog further
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
317
|
+
- `indeterminate` (boolean, optional): set to `true` to visualize an unspecified wait time
|
|
318
|
+
- `value` (number, optional): the progress value to show to the user (if set, it must be a value between 0 and 100)
|
|
319
|
+
- `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
320
|
|
|
296
321
|
This method returns a promise that resolves to a `ProgressDialog` object.
|
|
297
322
|
|
|
@@ -300,156 +325,211 @@ This method returns a promise that resolves to a `ProgressDialog` object.
|
|
|
300
325
|
`ProgressDialog` has two methods:
|
|
301
326
|
|
|
302
327
|
- `update(update: { title?: string; indeterminate?: boolean; value?:number; label?: string; })`
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
328
|
+
- Updates the progress dialog with new values
|
|
329
|
+
- The method has the following parameter:
|
|
330
|
+
- `update` (object): what to update in the dialog
|
|
331
|
+
- `title` (string, optional): change the dialog title
|
|
332
|
+
- `indeterminate` (boolean, optional): change whether the progress is indeterminate
|
|
333
|
+
- `value` (number, optional): change the progress value (if set, it must be a value between 0 and 100)
|
|
334
|
+
- `label` (string, optional): change the label to the right of the progress bar
|
|
310
335
|
- `close()`
|
|
311
|
-
|
|
336
|
+
- Closes the progress dialog (and allows you to open other dialogs)
|
|
312
337
|
|
|
313
338
|
### `sendCommandToGui(command: BackendToGuiCommand)`
|
|
314
339
|
|
|
315
|
-
Sends command to GUI to add/update/delete devices or to update the status of device.
|
|
340
|
+
Sends command to GUI to add/update/delete devices or to update the status of a device.
|
|
341
|
+
|
|
342
|
+
**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.
|
|
316
343
|
|
|
317
|
-
|
|
344
|
+
See the example below:
|
|
318
345
|
|
|
319
|
-
See example below:
|
|
320
346
|
```ts
|
|
321
347
|
class MyAdapterDeviceManagement extends DeviceManagement<MyAdapter> {
|
|
322
|
-
protected
|
|
348
|
+
protected loadDevices(context: DeviceLoadContext<string>): void {
|
|
323
349
|
const deviceInfo: DeviceInfo = {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
350
|
+
id: 'uniqieID',
|
|
351
|
+
name: 'My device',
|
|
352
|
+
icon: 'node', // find possible icons here: https://github.com/ioBroker/adapter-react-v5/blob/main/src/Components/DeviceType/DeviceTypeIcon.tsx#L68
|
|
353
|
+
manufacturer: { objectId: 'uniqieID', property: 'native.manufacturer' },
|
|
354
|
+
model: { objectId: 'uniqieID', property: 'native.model' },
|
|
355
|
+
status: {
|
|
356
|
+
battery: { stateId: 'uniqieID.DevicePower0.BatteryPercent' },
|
|
357
|
+
connection: { stateId: 'uniqieID.online', mapping: { true: 'connected', false: 'disconnected' } },
|
|
358
|
+
rssi: { stateId: 'uniqieID.rssi' },
|
|
359
|
+
},
|
|
360
|
+
hasDetails: true,
|
|
335
361
|
};
|
|
336
|
-
|
|
362
|
+
context.addDevice(deviceInfo);
|
|
337
363
|
}
|
|
338
364
|
}
|
|
339
365
|
```
|
|
340
|
-
|
|
366
|
+
|
|
367
|
+
## Migration from 2.x to 3.x
|
|
368
|
+
|
|
369
|
+
Between versions 2.x and 3.x, there are some breaking changes. Please also have a look at the changelog below for more information.
|
|
370
|
+
|
|
371
|
+
### Incremental loading of devices
|
|
372
|
+
|
|
373
|
+
In versions 1.x and 2.x, the `listDevices()` method had to return the full list of devices.
|
|
374
|
+
In version 3.x, this method was replaced by `loadDevices(context: DeviceLoadContext)` that allows incremental loading of devices.
|
|
375
|
+
|
|
376
|
+
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.
|
|
377
|
+
|
|
378
|
+
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.
|
|
379
|
+
|
|
380
|
+
### Refresh response of device actions
|
|
381
|
+
|
|
382
|
+
In version 3.x, the refresh response of device actions has changed.
|
|
383
|
+
|
|
384
|
+
| Version 1.x/2.x | Version 3.x | Description |
|
|
385
|
+
|-----------------|--------------|-----------------------------------------------------------------------------|
|
|
386
|
+
| `true` | `'all'` | the instance information as well as the entire device list will be reloaded |
|
|
387
|
+
| `false` | `'none'` | nothing will be reloaded |
|
|
388
|
+
| `'device'` | `'devices'` | the entire device list will be reloaded |
|
|
389
|
+
| `'instance'` | `'instance'` | (unchanged) only the instance information will be reloaded |
|
|
390
|
+
|
|
391
|
+
## Changelog
|
|
392
|
+
|
|
341
393
|
<!--
|
|
342
394
|
Placeholder for the next version (at the beginning of the line):
|
|
343
395
|
### **WORK IN PROGRESS**
|
|
344
396
|
-->
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
397
|
+
### 3.0.2 (2026-03-26)
|
|
398
|
+
- (@GermanBluefox) Added types to call URL directly on the action button
|
|
399
|
+
|
|
400
|
+
### 3.0.0 (2026-03-01)
|
|
401
|
+
|
|
402
|
+
- (@UncleSamSwiss) Enabled incremental loading of devices
|
|
403
|
+
- (@UncleSamSwiss) Removed direct access to `DeviceManagement.handleXxx()` methods (use `handler` and similar properties instead)
|
|
404
|
+
- (@UncleSamSwiss) Added `identifier` property to `DeviceInfo` for human-readable identifiers
|
|
405
|
+
- (@UncleSamSwiss) Device refresh responses can no longer be a `boolean` and `'device'` was renamed to `'devices'`.
|
|
406
|
+
- (@UncleSamSwiss) Added `info` icon and possibility for actions to be a link (by providing a `url` property instead of a `handler` function)
|
|
407
|
+
|
|
408
|
+
### 2.0.2 (2026-01-28)
|
|
409
|
+
|
|
410
|
+
- (@GermanBluefox) BREAKING: Admin/GUI must have version 9 (or higher) of `dm-gui-components`
|
|
411
|
+
- (@GermanBluefox) Added types to update the status of a device directly from the state
|
|
412
|
+
- (@GermanBluefox) Added backend to GUI communication possibility
|
|
413
|
+
- (@GermanBluefox) Added `dm:deviceInfo` command
|
|
414
|
+
- (@GermanBluefox) Added `dm:deviceStatus` command
|
|
350
415
|
|
|
351
416
|
### 1.0.16 (2026-01-02)
|
|
352
|
-
|
|
353
|
-
|
|
417
|
+
|
|
418
|
+
- (@GermanBluefox) Added `ignoreApplyDisabled` flag
|
|
419
|
+
- (@GermanBluefox) Added `update` icon
|
|
354
420
|
|
|
355
421
|
### 1.0.13 (2025-10-21)
|
|
356
|
-
|
|
422
|
+
|
|
423
|
+
- (@GermanBluefox) Updated packages
|
|
357
424
|
|
|
358
425
|
### 1.0.10 (2025-05-05)
|
|
359
426
|
|
|
360
|
-
|
|
361
|
-
|
|
427
|
+
- (@GermanBluefox) Added timeout property to actions
|
|
428
|
+
- (@GermanBluefox) Updated packages
|
|
362
429
|
|
|
363
430
|
### 1.0.9 (2025-01-25)
|
|
364
431
|
|
|
365
|
-
|
|
432
|
+
- (@GermanBluefox) Added copyToClipboard dialog button
|
|
366
433
|
|
|
367
434
|
### 1.0.8 (2025-01-24)
|
|
368
435
|
|
|
369
|
-
|
|
436
|
+
- (@GermanBluefox) Removed `headerTextColor` to device info
|
|
370
437
|
|
|
371
438
|
### 1.0.6 (2025-01-14)
|
|
372
|
-
|
|
373
|
-
|
|
439
|
+
|
|
440
|
+
- (@GermanBluefox) Added the connection type indication
|
|
374
441
|
|
|
375
442
|
### 1.0.5 (2025-01-11)
|
|
376
443
|
|
|
377
|
-
|
|
444
|
+
- (@GermanBluefox) Added action ENABLE_DISABLE and `enabled` status
|
|
378
445
|
|
|
379
446
|
### 1.0.0 (2025-01-08)
|
|
380
447
|
|
|
381
|
-
|
|
382
|
-
|
|
448
|
+
- (@GermanBluefox) Added `disabled` options for a device
|
|
449
|
+
- (@GermanBluefox) Major release just because it is good enough. No breaking changes.
|
|
383
450
|
|
|
384
451
|
### 0.6.11 (2024-12-11)
|
|
385
452
|
|
|
386
|
-
|
|
453
|
+
- (@GermanBluefox) Do not close handler for progress
|
|
387
454
|
|
|
388
455
|
### 0.6.10 (2024-12-10)
|
|
389
456
|
|
|
390
|
-
|
|
457
|
+
- (@GermanBluefox) Export `BackEndCommandJsonFormOptions` type
|
|
391
458
|
|
|
392
459
|
### 0.6.9 (2024-11-22)
|
|
393
460
|
|
|
394
|
-
|
|
461
|
+
- (@GermanBluefox) Added a max-width option for form
|
|
395
462
|
|
|
396
463
|
### 0.6.8 (2024-11-22)
|
|
397
464
|
|
|
398
|
-
|
|
465
|
+
- (@GermanBluefox) Allowed grouping of devices
|
|
399
466
|
|
|
400
467
|
### 0.6.7 (2024-11-20)
|
|
401
468
|
|
|
402
|
-
|
|
469
|
+
- (@GermanBluefox) Updated types
|
|
403
470
|
|
|
404
471
|
### 0.6.6 (2024-11-18)
|
|
405
472
|
|
|
406
|
-
|
|
473
|
+
- (@GermanBluefox) Added configurable buttons for form
|
|
407
474
|
|
|
408
475
|
### 0.6.0 (2024-11-17)
|
|
409
476
|
|
|
410
|
-
|
|
411
|
-
|
|
477
|
+
- (@GermanBluefox) used new ioBroker/eslint-config lib and changed prettifier settings
|
|
478
|
+
- (@GermanBluefox) updated JsonConfig types
|
|
412
479
|
|
|
413
480
|
### 0.5.0 (2024-08-30)
|
|
414
|
-
|
|
481
|
+
|
|
482
|
+
- (bluefox) Migrated to eslint 9
|
|
415
483
|
|
|
416
484
|
### 0.4.0 (2024-08-30)
|
|
417
|
-
|
|
485
|
+
|
|
486
|
+
- (bluefox) Added `state` type for JSON config
|
|
418
487
|
|
|
419
488
|
### 0.3.1 (2024-07-18)
|
|
420
|
-
|
|
489
|
+
|
|
490
|
+
- (bluefox) Added qrCode type for JSON config
|
|
421
491
|
|
|
422
492
|
### 0.3.0 (2024-07-17)
|
|
423
|
-
|
|
424
|
-
|
|
493
|
+
|
|
494
|
+
- (bluefox) packages updated
|
|
495
|
+
- (bluefox) Updated JSON config types
|
|
425
496
|
|
|
426
497
|
### 0.2.2 (2024-06-26)
|
|
427
|
-
|
|
498
|
+
|
|
499
|
+
- (bluefox) packages updated
|
|
428
500
|
|
|
429
501
|
### 0.2.0 (2024-05-29)
|
|
430
|
-
|
|
431
|
-
|
|
502
|
+
|
|
503
|
+
- (bluefox) enhanced type exports
|
|
504
|
+
- (bluefox) added confirmation and input text options
|
|
432
505
|
|
|
433
506
|
### 0.1.9 (2023-12-25)
|
|
434
|
-
|
|
507
|
+
|
|
508
|
+
- (foxriver76) enhanced type exports
|
|
435
509
|
|
|
436
510
|
### 0.1.8 (2023-12-17)
|
|
437
|
-
|
|
511
|
+
|
|
512
|
+
- (bluefox) corrected control error
|
|
438
513
|
|
|
439
514
|
### 0.1.7 (2023-12-17)
|
|
440
|
-
|
|
515
|
+
|
|
516
|
+
- (bluefox) added channel info
|
|
441
517
|
|
|
442
518
|
### 0.1.5 (2023-12-16)
|
|
443
|
-
|
|
519
|
+
|
|
520
|
+
- (bluefox) extended controls with unit and new control types
|
|
444
521
|
|
|
445
522
|
### 0.1.4 (2023-12-13)
|
|
446
|
-
|
|
523
|
+
|
|
524
|
+
- (bluefox) added error codes
|
|
447
525
|
|
|
448
526
|
### 0.1.3 (2023-12-10)
|
|
449
|
-
|
|
450
|
-
|
|
527
|
+
|
|
528
|
+
- (bluefox) added some fields to DeviceInfo interface
|
|
529
|
+
- (bluefox) added control possibilities
|
|
451
530
|
|
|
452
531
|
## License
|
|
532
|
+
|
|
453
533
|
MIT License
|
|
454
534
|
|
|
455
535
|
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
|
}
|