@basmilius/homey-common 1.17.0 → 1.17.1
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/package.json +1 -2
- package/src/app.ts +0 -135
- package/src/data/colors.json +0 -142
- package/src/data/icons.json +0 -1
- package/src/data/index.ts +0 -11
- package/src/decorator.ts +0 -41
- package/src/device.ts +0 -112
- package/src/flow.ts +0 -165
- package/src/globals.d.ts +0 -8
- package/src/index.ts +0 -60
- package/src/registry.ts +0 -86
- package/src/types.ts +0 -57
- package/src/utils.ts +0 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basmilius/homey-common",
|
|
3
3
|
"description": "Common code shared across my Homey apps.",
|
|
4
|
-
"version": "1.17.
|
|
4
|
+
"version": "1.17.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"funding": "https://github.com/sponsors/basmilius",
|
|
7
7
|
"author": {
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
],
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
|
-
"src",
|
|
25
24
|
"CODEOWNERS",
|
|
26
25
|
"LICENSE"
|
|
27
26
|
],
|
package/src/app.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import Homey from 'homey';
|
|
2
|
-
import type HomeyNS from 'homey/lib/Homey';
|
|
3
|
-
import type { Device, Driver } from './device';
|
|
4
|
-
import { Registry } from './registry';
|
|
5
|
-
import type { Language } from './types';
|
|
6
|
-
|
|
7
|
-
export class App<TApp extends App<any>> extends Homey.App {
|
|
8
|
-
|
|
9
|
-
get registry(): Registry<TApp> {
|
|
10
|
-
return this.#registry;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
readonly #registry: Registry<TApp>;
|
|
14
|
-
|
|
15
|
-
constructor(...args: any[]) {
|
|
16
|
-
super(...args);
|
|
17
|
-
|
|
18
|
-
this.#registry = new Registry<TApp>(this as unknown as TApp);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async getDevice<TDevice extends Device<TApp, any>>(id: string): Promise<TDevice | null> {
|
|
22
|
-
const drivers = await this.getDrivers();
|
|
23
|
-
|
|
24
|
-
for (const driver of drivers) {
|
|
25
|
-
const devices = await this.getDevices<TDevice>(driver.id);
|
|
26
|
-
|
|
27
|
-
for (const device of devices) {
|
|
28
|
-
if (device.id === id) {
|
|
29
|
-
return device;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async getDevices<TDevice extends Device<TApp, any>>(driverId: string): Promise<TDevice[] | null> {
|
|
38
|
-
const drivers = await this.getDrivers();
|
|
39
|
-
|
|
40
|
-
for (const driver of drivers) {
|
|
41
|
-
if (driver.id !== driverId) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return driver.getDevices() as TDevice[];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async getDrivers(): Promise<Driver<TApp>[]> {
|
|
52
|
-
return Object.values(this.homey.drivers.getDrivers()) as Driver<TApp>[];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export class Shortcuts<TApp extends App<TApp>> {
|
|
58
|
-
|
|
59
|
-
get app(): TApp {
|
|
60
|
-
return this.#app;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get homey(): HomeyNS {
|
|
64
|
-
return this.app.homey;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
get registry(): Registry<TApp> {
|
|
68
|
-
return this.app.registry;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
get dashboards(): HomeyNS['dashboards'] {
|
|
72
|
-
return this.homey.dashboards;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
get discovery(): HomeyNS['discovery'] {
|
|
76
|
-
return this.homey.discovery;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
get flow(): HomeyNS['flow'] {
|
|
80
|
-
return this.homey.flow;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
get settings(): HomeyNS['settings'] {
|
|
84
|
-
return this.homey.settings;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
get language(): Language {
|
|
88
|
-
return this.homey.i18n.getLanguage() as Language;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
readonly #app: TApp;
|
|
92
|
-
|
|
93
|
-
constructor(app: TApp) {
|
|
94
|
-
this.#app = app;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async notify(message: string): Promise<void> {
|
|
98
|
-
try {
|
|
99
|
-
await this.homey.notifications.createNotification({
|
|
100
|
-
excerpt: message
|
|
101
|
-
});
|
|
102
|
-
} catch (err) {
|
|
103
|
-
this.log('Tried to notify the timeline, but notifications are probably disabled.', err);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
log(...args: any[]): void {
|
|
108
|
-
this.homey.log(`[${this.constructor.name}]`, ...args);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
realtime(event: string, data: any = undefined): void {
|
|
112
|
-
this.homey.api.realtime(event, data);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
translate(key: string, tags?: Record<string, string | number>): string {
|
|
116
|
-
return this.homey.__(key, tags);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
clearInterval(interval: NodeJS.Timeout): void {
|
|
120
|
-
this.homey.clearInterval(interval);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
setInterval(callback: Function, ms: number): NodeJS.Timeout {
|
|
124
|
-
return this.homey.setInterval(callback, ms);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
clearTimeout(interval: NodeJS.Timeout): void {
|
|
128
|
-
this.homey.clearTimeout(interval);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
setTimeout(callback: Function, ms: number): NodeJS.Timeout {
|
|
132
|
-
return this.homey.setTimeout(callback, ms);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
}
|
package/src/data/colors.json
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"hex": "#ef4444",
|
|
4
|
-
"label": "color.red"
|
|
5
|
-
},
|
|
6
|
-
{
|
|
7
|
-
"hex": "#f97316",
|
|
8
|
-
"label": "color.orange"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"hex": "#f59e0b",
|
|
12
|
-
"label": "color.amber"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"hex": "#eab308",
|
|
16
|
-
"label": "color.yellow"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"hex": "#c4b106",
|
|
20
|
-
"label": "color.citron"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"hex": "#84cc16",
|
|
24
|
-
"label": "color.lime"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"hex": "#52c41a",
|
|
28
|
-
"label": "color.grass"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"hex": "#22c55e",
|
|
32
|
-
"label": "color.green"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"hex": "#17c078",
|
|
36
|
-
"label": "color.spring"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"hex": "#10b981",
|
|
40
|
-
"label": "color.emerald"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"hex": "#12b894",
|
|
44
|
-
"label": "color.mint"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"hex": "#14b8a6",
|
|
48
|
-
"label": "color.teal"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"hex": "#0cb7bd",
|
|
52
|
-
"label": "color.turquoise"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"hex": "#06b6d4",
|
|
56
|
-
"label": "color.cyan"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"hex": "#09aee6",
|
|
60
|
-
"label": "color.azure"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"hex": "#0ea5e9",
|
|
64
|
-
"label": "color.sky"
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"hex": "#2494f0",
|
|
68
|
-
"label": "color.ocean"
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"hex": "#3b82f6",
|
|
72
|
-
"label": "color.blue"
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"hex": "#4f72f3",
|
|
76
|
-
"label": "color.royal"
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"hex": "#6366f1",
|
|
80
|
-
"label": "color.indigo"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"hex": "#7761f3",
|
|
84
|
-
"label": "color.iris"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"hex": "#8b5cf6",
|
|
88
|
-
"label": "color.violet"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"hex": "#9a58f7",
|
|
92
|
-
"label": "color.grape"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"hex": "#a855f7",
|
|
96
|
-
"label": "color.purple"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"hex": "#c24bfb",
|
|
100
|
-
"label": "color.orchid"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"hex": "#d946ef",
|
|
104
|
-
"label": "color.fuchsia"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"hex": "#e547d4",
|
|
108
|
-
"label": "color.magenta"
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
"hex": "#ec4899",
|
|
112
|
-
"label": "color.pink"
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
"hex": "#f0436c",
|
|
116
|
-
"label": "color.watermelon"
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
"hex": "#f43f5e",
|
|
120
|
-
"label": "color.rose"
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
"hex": "#64748b",
|
|
124
|
-
"label": "color.slate"
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
"hex": "#6b7280",
|
|
128
|
-
"label": "color.gray"
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
"hex": "#71717a",
|
|
132
|
-
"label": "color.zinc"
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
"hex": "#737373",
|
|
136
|
-
"label": "color.neutral"
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"hex": "#78716c",
|
|
140
|
-
"label": "color.stone"
|
|
141
|
-
}
|
|
142
|
-
]
|