Skip to content

Commit

Permalink
Merge pull request #39 from athombv/master
Browse files Browse the repository at this point in the history
mmip #patch
  • Loading branch information
jeroenwienk authored Nov 20, 2024
2 parents ab5726b + 99878cb commit e5d7c9c
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 2 deletions.
3 changes: 2 additions & 1 deletion homey.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import Signal = require("./lib/Signal.js");
import Signal433 = require("./lib/Signal433.js");
import Signal868 = require("./lib/Signal868.js");
import SignalInfrared = require("./lib/SignalInfrared.js");
import Widget = require("./lib/Widget.js");
import ZigBeeNode = require("./lib/ZigBeeNode.js");
import ZwaveCommandClass = require("./lib/ZwaveCommandClass.js");
import ZwaveNode = require("./lib/ZwaveNode.js");
export { SimpleClass, Api, ApiApp, App, BleAdvertisement, BleCharacteristic, BleDescriptor, BlePeripheral, BleService, CloudOAuth2Callback, CloudWebhook, Device, DiscoveryResult, DiscoveryResultMAC, DiscoveryResultMDNSSD, DiscoveryResultSSDP, DiscoveryStrategy, Driver, FlowArgument, FlowCard, FlowCardAction, FlowCardCondition, FlowCardTrigger, FlowCardTriggerDevice, FlowToken, Image, InsightsLog, LedringAnimation, LedringAnimationSystem, LedringAnimationSystemProgress, Manager, Signal, Signal433, Signal868, SignalInfrared, ZigBeeNode, ZwaveCommandClass, ZwaveNode };
export { SimpleClass, Api, ApiApp, App, BleAdvertisement, BleCharacteristic, BleDescriptor, BlePeripheral, BleService, CloudOAuth2Callback, CloudWebhook, Device, DiscoveryResult, DiscoveryResultMAC, DiscoveryResultMDNSSD, DiscoveryResultSSDP, DiscoveryStrategy, Driver, FlowArgument, FlowCard, FlowCardAction, FlowCardCondition, FlowCardTrigger, FlowCardTriggerDevice, FlowToken, Image, InsightsLog, LedringAnimation, LedringAnimationSystem, LedringAnimationSystemProgress, Manager, Signal, Signal433, Signal868, SignalInfrared, Widget, ZigBeeNode, ZwaveCommandClass, ZwaveNode };
4 changes: 4 additions & 0 deletions lib/Homey.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export = Homey;
* @typedef {import('../manager/ble')} ManagerBLE
* @typedef {import('../manager/cloud')} ManagerCloud
* @typedef {import('../manager/clock')} ManagerClock
* @typedef {import('../manager/dashboards')} ManagerDashboards
* @typedef {import('../manager/drivers')} ManagerDrivers
* @typedef {import('../manager/discovery')} ManagerDiscovery
* @typedef {import('../manager/flow')} ManagerFlow
Expand Down Expand Up @@ -84,6 +85,8 @@ declare class Homey extends SimpleClass {
cloud: ManagerCloud;
/** @type {ManagerClock} */
clock: ManagerClock;
/** @type {ManagerDashboards} */
dashboards: ManagerDashboards;
/** @type {ManagerDrivers} */
drivers: ManagerDrivers;
/** @type {ManagerDiscovery} */
Expand Down Expand Up @@ -177,6 +180,7 @@ type ManagerAudio = import('../manager/audio');
type ManagerBLE = import('../manager/ble');
type ManagerCloud = import('../manager/cloud');
type ManagerClock = import('../manager/clock');
type ManagerDashboards = import('../manager/dashboards');
type ManagerDrivers = import('../manager/drivers');
type ManagerDiscovery = import('../manager/discovery');
type ManagerFlow = import('../manager/flow');
Expand Down
65 changes: 65 additions & 0 deletions lib/Widget.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export = Widget;
/**
* This class represents a Widget.
* This class should not be instanced manually, but retrieved using a method in {@link ManagerDashboards} instead.
*/
declare class Widget {
/**
* @typedef {object} Widget.SettingAutocompleteResults
* @property {string} name
* @property {string=} description
* @property {string=} image
*/
/**
* @callback Widget.SettingAutocompleteCallback
* @param {string} query The typed query by the user
* @param {any} settings The current state of the settings, as selected by the user in the front-end
* @returns {Promise<Widget.SettingAutocompleteResults> | Widget.SettingAutocompleteResults}
*/
/**
* Register a listener for a autocomplete event.
* This is fired when the widget is of type `autocomplete` and the user typed a query.
*
* @param {string} name - name of the desired widget setting.
* @param {SettingAutocompleteCallback} listener - Should return a promise that resolves to the autocomplete results.
* @returns {Widget}
*
* @example
* const widget = this.homey.dashboards.getWidget('my-widget')
*
* widget.registerSettingAutocompleteListener('composer', async (query, settings) => {
* return [
* {
* name: "Mozart",
* // Optionally provide the following properties.
* description: "...",
* image: "https://some.url/",
*
* // You can freely add additional properties
* // that you can access in Homey.getSettings()['mySettingId'].
* id: "mozart",
* },
* {
* name: "Amadeus",
*
* // You can freely add additional properties
* // that you can access in Homey.getSettings()['mySettingId'].
* id: "amadeus",
* },
* ].filter((item) => item.name.toLowerCase().includes(query.toLowerCase()));
* });
*/
registerSettingAutocompleteListener(name: string, listener: Widget.SettingAutocompleteCallback): Widget;
}
declare namespace Widget {
export { SettingAutocompleteResults, SettingAutocompleteCallback };
}

type SettingAutocompleteResult = {
name: string;
description?: string | undefined;
image?: string | undefined;
[key: string]: any;
};
type SettingAutocompleteResults = Array<SettingAutocompleteResult>;
type SettingAutocompleteCallback = (query: string, settings: any) => Promise<Widget.SettingAutocompleteResults> | Widget.SettingAutocompleteResults;
17 changes: 17 additions & 0 deletions manager/dashboards.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export = ManagerDashboards;
/**
* @hideconstructor
* @classdesc
* You can access this manager through the {@link Homey} instance as `this.homey.dashboards`
*/
declare class ManagerDashboards extends Manager {
static ID: string;
/**
* Get a widget
* @param {string} id
* @returns {Widget}
*/
getWidget(id: string): Widget;
}
import Manager = require("../lib/Manager.js");
import Widget = require("../lib/Widget.js");
1 change: 0 additions & 1 deletion manager/drivers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ declare class ManagerDrivers extends Manager {
};
}
import Manager = require("../lib/Manager.js");
import PairSession = require("../lib/PairSession.js");
import Driver = require("../lib/Driver.js");

0 comments on commit e5d7c9c

Please sign in to comment.