diff --git a/README.md b/README.md index 82bf522..b5c7f67 100644 --- a/README.md +++ b/README.md @@ -206,9 +206,6 @@ The returned object must contain: This method can be implemented asynchronously and can take a lot of time to complete. -Reserved control names: -- `disabled` - The disabled control has its own pre-defined place on the device card and is used to disable the device. The state of this control is boolean. - ### `handleDeviceControlState(deviceId: string, controlId: string, context: MessageContext) This method is called when GUI requests the update of the state. @@ -234,6 +231,8 @@ For interactions, there are methods you can call on `context`: There are some reserved action names, you can find the list below: - `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. +- `disable` - This action will be called when the user clicks on the `enabled` icon. `disable` and `enable` actions cannot be together. +- `enable` - This action will be called when the user clicks on the `disabled` icon. `disable` and `enable` actions cannot be together. ### `showMessage(text: ioBroker.StringOrTranslated)` diff --git a/src/types/base.ts b/src/types/base.ts index 4ad652f..3b110d3 100644 --- a/src/types/base.ts +++ b/src/types/base.ts @@ -6,7 +6,17 @@ export type Color = 'primary' | 'secondary' | (string & {}); // color (you can u export type ControlState = string | number | boolean | null; +/** Reserved action names */ +export const ACTIONS = { + /** This action will be called when user clicks on connection icon */ + STATUS: 'status', + /** This action will be called when user clicks on connection icon */ + DISABLE: 'disable', + ENABLE: 'enable', +}; + export interface ActionBase { + /** Unique (for this adapter) action ID. It could be the name from ACTIONS too, but in this case some predefined appearance will be applied */ id: string; /** * This can either be base64 or the URL to an icon.