@iobroker/dm-utils 1.0.0 → 1.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 +14 -4
- package/build/types/base.d.ts +10 -2
- package/build/types/base.js +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ In most cases, you will get all states of your instance and fill the array with
|
|
|
114
114
|
|
|
115
115
|
Every array entry is an object of type `DeviceInfo` which has the following properties:
|
|
116
116
|
|
|
117
|
-
- `id` (string): a unique (human
|
|
117
|
+
- `id` (string): a unique (human-readable) identifier of the device (it must be unique for your adapter instance only)
|
|
118
118
|
- `name` (string or translations): the human-readable name of this device
|
|
119
119
|
- `status` (optional): the current status of the device, which can be one of:
|
|
120
120
|
- `"disconnected"`
|
|
@@ -197,8 +197,8 @@ This method is called when the user clicks on a control (i.e., slider) in the de
|
|
|
197
197
|
|
|
198
198
|
The parameters of this method are:
|
|
199
199
|
- `deviceId` (string): the `id` that was given in `listDevices()` --> `[].id`
|
|
200
|
-
- `controlId` (string): the `id` that was given in `listDevices()` --> `[].controls[].id
|
|
201
|
-
- `state` (string | number | boolean): new state for the control, that will be sent to real device
|
|
200
|
+
- `controlId` (string): the `id` that was given in `listDevices()` --> `[].controls[].id`. There are some reserved control names, you can find the list below.
|
|
201
|
+
- `state` (string | number | boolean): new state for the control, that will be sent to a real device
|
|
202
202
|
- `context` (object): object containing helper methods that can be used when executing the action
|
|
203
203
|
|
|
204
204
|
The returned object must contain:
|
|
@@ -226,7 +226,13 @@ To allow your adapter to interact with the user, you can use "actions".
|
|
|
226
226
|
|
|
227
227
|
As described above, there are actions on the instance and on devices. The behavior of both methods is similar.
|
|
228
228
|
|
|
229
|
-
Inside an action method (`handleInstanceAction()` or `handleDeviceAction()`) you can perform arbitrary actions, like talking to a device or API, and you can interact with the user.
|
|
229
|
+
Inside an action method (`handleInstanceAction()` or `handleDeviceAction()`) you can perform arbitrary actions, like talking to a device or API, and you can interact with the user.
|
|
230
|
+
For interactions, there are methods you can call on `context`:
|
|
231
|
+
|
|
232
|
+
There are some reserved action names, you can find the list below:
|
|
233
|
+
- `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.
|
|
234
|
+
- `disable` - This action will be called when the user clicks on the `enabled` icon. `disable` and `enable` actions cannot be together.
|
|
235
|
+
- `enable` - This action will be called when the user clicks on the `disabled` icon. `disable` and `enable` actions cannot be together.
|
|
230
236
|
|
|
231
237
|
### `showMessage(text: ioBroker.StringOrTranslated)`
|
|
232
238
|
|
|
@@ -295,6 +301,10 @@ This method returns a promise that resolves to a `ProgressDialog` object.
|
|
|
295
301
|
### **WORK IN PROGRESS**
|
|
296
302
|
-->
|
|
297
303
|
## Changelog
|
|
304
|
+
### 1.0.2 (2025-01-09)
|
|
305
|
+
|
|
306
|
+
* (@GermanBluefox) Added description for `disabled` control and `status` action.
|
|
307
|
+
|
|
298
308
|
### 1.0.0 (2025-01-08)
|
|
299
309
|
|
|
300
310
|
* (@GermanBluefox) Added `disabled` options for a device
|
package/build/types/base.d.ts
CHANGED
|
@@ -3,7 +3,16 @@ import type { ApiVersion, DeviceRefresh, DeviceStatus, RetVal } from './common';
|
|
|
3
3
|
type ActionType = 'api' | 'adapter';
|
|
4
4
|
export type Color = 'primary' | 'secondary' | (string & {});
|
|
5
5
|
export type ControlState = string | number | boolean | null;
|
|
6
|
+
/** Reserved action names */
|
|
7
|
+
export declare const ACTIONS: {
|
|
8
|
+
/** This action will be called when user clicks on connection icon */
|
|
9
|
+
STATUS: string;
|
|
10
|
+
/** This action will be called when user clicks on connection icon */
|
|
11
|
+
DISABLE: string;
|
|
12
|
+
ENABLE: string;
|
|
13
|
+
};
|
|
6
14
|
export interface ActionBase<T extends ActionType> {
|
|
15
|
+
/** Unique (for this adapter) action ID. It could be the name from ACTIONS too, but in this case some predefined appearance will be applied */
|
|
7
16
|
id: string;
|
|
8
17
|
/**
|
|
9
18
|
* This can either be base64 or the URL to an icon.
|
|
@@ -101,8 +110,7 @@ export interface DeviceInfo<T extends ActionType = 'api'> {
|
|
|
101
110
|
actions?: DeviceAction<T>[];
|
|
102
111
|
controls?: DeviceControl<T>[];
|
|
103
112
|
hasDetails?: boolean;
|
|
104
|
-
/**
|
|
105
|
-
disabled?: boolean;
|
|
113
|
+
/** Device type for grouping */
|
|
106
114
|
group?: {
|
|
107
115
|
key: string;
|
|
108
116
|
name?: ioBroker.StringOrTranslated;
|
package/build/types/base.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ACTIONS = void 0;
|
|
4
|
+
/** Reserved action names */
|
|
5
|
+
exports.ACTIONS = {
|
|
6
|
+
/** This action will be called when user clicks on connection icon */
|
|
7
|
+
STATUS: 'status',
|
|
8
|
+
/** This action will be called when user clicks on connection icon */
|
|
9
|
+
DISABLE: 'disable',
|
|
10
|
+
ENABLE: 'enable',
|
|
11
|
+
};
|