mqtt2matter 0.3.2 → 0.4.0
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/CHANGELOG.md +24 -0
- package/README.md +17 -0
- package/dist/engine/payload.d.ts +6 -3
- package/dist/engine/payload.js +8 -1
- package/dist/engine/payload.js.map +1 -1
- package/dist/engine/runtime.js +4 -0
- package/dist/engine/runtime.js.map +1 -1
- package/dist/engine/template.d.ts +1 -20
- package/dist/engine/template.js +4 -263
- package/dist/engine/template.js.map +1 -1
- package/dist/families/color.d.ts +3 -22
- package/dist/families/color.js +7 -144
- package/dist/families/color.js.map +1 -1
- package/dist/importers/ha/areas.d.ts +1 -6
- package/dist/importers/ha/areas.js +5 -278
- package/dist/importers/ha/areas.js.map +1 -1
- package/dist/importers/ha/source.d.ts +11 -9
- package/dist/importers/ha/source.js +22 -63
- package/dist/importers/ha/source.js.map +1 -1
- package/dist/importers/ha/templates.d.ts +3 -14
- package/dist/importers/ha/templates.js +7 -248
- package/dist/importers/ha/templates.js.map +1 -1
- package/dist/importers/ha/types.d.ts +2 -78
- package/dist/importers/ha/types.js +1 -472
- package/dist/importers/ha/types.js.map +1 -1
- package/dist/mqtt/client.d.ts +17 -3
- package/dist/mqtt/client.js +70 -13
- package/dist/mqtt/client.js.map +1 -1
- package/docs/config.md +1 -1
- package/docs/importers.md +2 -2
- package/package.json +2 -2
- package/ui/dist/licenses.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../../src/importers/ha/source.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../../src/importers/ha/source.ts"],"names":[],"mappings":"AAAA;;;;0CAI0C;AAE1C,OAAO,EAAC,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAGrF,OAAO,EAAiB,QAAQ,EAAC,MAAM,WAAW,CAAC;AAGnD,OAAO,EAAC,cAAc,EAAC,CAAC;AAgBxB,MAAM,OAAO,QAAQ;IACA,KAAK,CAAiB;IACvC,2FAA2F;IAC3F,IAAI,GAAG,KAAK,CAAC;IAEb,YAAY,SAAiB,cAAc;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,cAAc,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,qBAAqB;IACrB,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED,8BAA8B;IAC9B,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAa,EAAE,OAAwB;QAC1C,IAAI,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,SAAS,EAAE,CAAC;YACxD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,2FAA2F;IAC3F,IAAI,CAAC,KAAiB;QAClB,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YACpD,IAAI,CAAC;gBACD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAChD,CAAC;YAAC,MAAM,CAAC;gBACL,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,QAAQ;QACJ,OAAO,QAAQ,CAAC,EAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAC,CAAC,CAAC;IACnG,CAAC;CACJ"}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export declare const TESTS: Set<string>;
|
|
5
|
-
/** the functions the engine provides as globals */
|
|
6
|
-
export declare const FUNCTIONS: Set<string>;
|
|
7
|
-
/** the variables of a status half's template */
|
|
8
|
-
export declare const STATUS_VARIABLES: Set<string>;
|
|
1
|
+
import { type TemplateCheck } from 'mqtt-ha-entities';
|
|
2
|
+
export { FILTERS, TESTS, FUNCTIONS, STATUS_VARIABLES } from 'mqtt-ha-entities';
|
|
3
|
+
export type { TemplateCheck };
|
|
9
4
|
/** the variables of a command half's template: the value, an enum's member name, the families' fields */
|
|
10
5
|
export declare const COMMAND_VARIABLES: Set<string>;
|
|
11
|
-
export type TemplateCheck = {
|
|
12
|
-
ok: true;
|
|
13
|
-
} | {
|
|
14
|
-
ok: false;
|
|
15
|
-
reason: string;
|
|
16
|
-
};
|
|
17
6
|
/** can the engine render this template with the variables of that side? */
|
|
18
7
|
export declare function checkTemplate(source: string, side: 'status' | 'command', extra?: readonly string[]): TemplateCheck;
|
|
@@ -1,81 +1,13 @@
|
|
|
1
1
|
/* Can the payload engine run a Home Assistant template? The engine renders Jinja through
|
|
2
2
|
`@huggingface/jinja` with Home Assistant's filters added (docs/config.md, "Templates"); what it cannot
|
|
3
|
-
do — `states()`, `now()`, `this`, the time and regex helpers,
|
|
3
|
+
do — `states()`, `now()`, `this`, the time and regex helpers, macros — must not become a
|
|
4
4
|
mapping that fails at runtime. The importer parses the template with the same library and walks the
|
|
5
5
|
program: every filter, test, called function and free name has to be one the engine provides; a
|
|
6
|
-
`*_template` that is not leaves its mapping unadopted, listed with the template. The
|
|
7
|
-
the engine's
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/** the filters the engine renders: the library's built-ins plus the Home Assistant ones it adds */
|
|
12
|
-
export const FILTERS = new Set([
|
|
13
|
-
'abs',
|
|
14
|
-
'bool',
|
|
15
|
-
'capitalize',
|
|
16
|
-
'default',
|
|
17
|
-
'd',
|
|
18
|
-
'dictsort',
|
|
19
|
-
'first',
|
|
20
|
-
'float',
|
|
21
|
-
'iif',
|
|
22
|
-
'indent',
|
|
23
|
-
'int',
|
|
24
|
-
'is_defined',
|
|
25
|
-
'is_number',
|
|
26
|
-
'items',
|
|
27
|
-
'join',
|
|
28
|
-
'last',
|
|
29
|
-
'length',
|
|
30
|
-
'list',
|
|
31
|
-
'lower',
|
|
32
|
-
'map',
|
|
33
|
-
'max',
|
|
34
|
-
'min',
|
|
35
|
-
'multiply',
|
|
36
|
-
'rejectattr',
|
|
37
|
-
'replace',
|
|
38
|
-
'reverse',
|
|
39
|
-
'round',
|
|
40
|
-
'safe',
|
|
41
|
-
'selectattr',
|
|
42
|
-
'sort',
|
|
43
|
-
'string',
|
|
44
|
-
'strip',
|
|
45
|
-
'title',
|
|
46
|
-
'tojson',
|
|
47
|
-
'trim',
|
|
48
|
-
'unique',
|
|
49
|
-
'upper',
|
|
50
|
-
]);
|
|
51
|
-
/** the tests (`is …`) the library knows */
|
|
52
|
-
export const TESTS = new Set([
|
|
53
|
-
'boolean',
|
|
54
|
-
'callable',
|
|
55
|
-
'defined',
|
|
56
|
-
'eq',
|
|
57
|
-
'equalto',
|
|
58
|
-
'even',
|
|
59
|
-
'false',
|
|
60
|
-
'integer',
|
|
61
|
-
'iterable',
|
|
62
|
-
'lower',
|
|
63
|
-
'mapping',
|
|
64
|
-
'none',
|
|
65
|
-
'number',
|
|
66
|
-
'odd',
|
|
67
|
-
'sequence',
|
|
68
|
-
'string',
|
|
69
|
-
'true',
|
|
70
|
-
'undefined',
|
|
71
|
-
'upper',
|
|
72
|
-
]);
|
|
73
|
-
/** the functions the engine provides as globals */
|
|
74
|
-
export const FUNCTIONS = new Set(['float', 'iif', 'int', 'is_number', 'max', 'min']);
|
|
75
|
-
/** the names every template sees */
|
|
76
|
-
const GLOBALS = new Set(['true', 'false', 'none', 'True', 'False', 'None', 'loop', 'topic']);
|
|
77
|
-
/** the variables of a status half's template */
|
|
78
|
-
export const STATUS_VARIABLES = new Set(['value', 'value_json']);
|
|
6
|
+
`*_template` that is not leaves its mapping unadopted, listed with the template. The check is
|
|
7
|
+
mqtt-ha-entities' (the same names as its engine); what is mqtt2matter's own are the command side's
|
|
8
|
+
variables: the fields the families hand a command template. */
|
|
9
|
+
import { checkTemplate as check } from 'mqtt-ha-entities';
|
|
10
|
+
export { FILTERS, TESTS, FUNCTIONS, STATUS_VARIABLES } from 'mqtt-ha-entities';
|
|
79
11
|
/** the variables of a command half's template: the value, an enum's member name, the families' fields */
|
|
80
12
|
export const COMMAND_VARIABLES = new Set([
|
|
81
13
|
'value',
|
|
@@ -105,181 +37,8 @@ export const COMMAND_VARIABLES = new Set([
|
|
|
105
37
|
'speed',
|
|
106
38
|
'action',
|
|
107
39
|
]);
|
|
108
|
-
/** keyword arguments the engine's filters do not implement (a silent wrong result otherwise) */
|
|
109
|
-
const UNSUPPORTED_KEYWORDS = { int: ['base'], float: ['base'] };
|
|
110
|
-
function isNode(value) {
|
|
111
|
-
return typeof value === 'object' && value !== null && typeof value.type === 'string';
|
|
112
|
-
}
|
|
113
|
-
function identifierName(node) {
|
|
114
|
-
return isNode(node) && node.type === 'Identifier' ? node.value : undefined;
|
|
115
|
-
}
|
|
116
|
-
class Walker {
|
|
117
|
-
problems = [];
|
|
118
|
-
bound = new Set();
|
|
119
|
-
variables;
|
|
120
|
-
constructor(variables) {
|
|
121
|
-
this.variables = variables;
|
|
122
|
-
}
|
|
123
|
-
problem(text) {
|
|
124
|
-
if (!this.problems.includes(text)) {
|
|
125
|
-
this.problems.push(text);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
bind(node) {
|
|
129
|
-
const name = identifierName(node);
|
|
130
|
-
if (name !== undefined) {
|
|
131
|
-
this.bound.add(name);
|
|
132
|
-
}
|
|
133
|
-
else if (isNode(node) && node.type === 'TupleLiteral') {
|
|
134
|
-
for (const item of node.value) {
|
|
135
|
-
this.bind(item);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
walk(node) {
|
|
140
|
-
if (Array.isArray(node)) {
|
|
141
|
-
for (const item of node) {
|
|
142
|
-
this.walk(item);
|
|
143
|
-
}
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (!isNode(node)) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
switch (node.type) {
|
|
150
|
-
case 'Identifier': {
|
|
151
|
-
const name = node.value;
|
|
152
|
-
if (!this.variables.has(name) && !GLOBALS.has(name) && !this.bound.has(name) && !FUNCTIONS.has(name)) {
|
|
153
|
-
this.problem(`"${name}" is not available`);
|
|
154
|
-
}
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
case 'FilterExpression': {
|
|
158
|
-
this.walk(node.operand);
|
|
159
|
-
this.checkFilter(node.filter);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
case 'FilterStatement': {
|
|
163
|
-
this.checkFilter(node.filter);
|
|
164
|
-
this.walk(node.body);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
case 'TestExpression': {
|
|
168
|
-
this.walk(node.operand);
|
|
169
|
-
const test = identifierName(node.test);
|
|
170
|
-
if (test !== undefined && !TESTS.has(test)) {
|
|
171
|
-
this.problem(`the test "${test}" is not available`);
|
|
172
|
-
}
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
case 'CallExpression': {
|
|
176
|
-
const callee = node.callee;
|
|
177
|
-
const name = identifierName(callee);
|
|
178
|
-
if (name !== undefined) {
|
|
179
|
-
if (!FUNCTIONS.has(name) && !this.bound.has(name)) {
|
|
180
|
-
this.problem(`"${name}()" is not available`);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
// a method on a value (`value_json.get('x')`, `'a,b'.split(',')`): the library's business
|
|
185
|
-
this.walk(callee);
|
|
186
|
-
}
|
|
187
|
-
this.walk(node.args);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
case 'MemberExpression': {
|
|
191
|
-
this.walk(node.object);
|
|
192
|
-
if (node.computed === true) {
|
|
193
|
-
this.walk(node.property);
|
|
194
|
-
}
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
case 'Set': {
|
|
198
|
-
this.walk(node.value);
|
|
199
|
-
this.walk(node.body);
|
|
200
|
-
this.bind(node.assignee);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
case 'For': {
|
|
204
|
-
this.walk(node.iterable);
|
|
205
|
-
this.bind(node.loopvar);
|
|
206
|
-
this.walk(node.body);
|
|
207
|
-
this.walk(node.defaultBlock);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
case 'Macro':
|
|
211
|
-
case 'CallStatement': {
|
|
212
|
-
this.problem('macros are not available');
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
case 'BinaryExpression': {
|
|
216
|
-
// the operator is a token, not a name to look up
|
|
217
|
-
this.walk(node.left);
|
|
218
|
-
this.walk(node.right);
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
case 'UnaryExpression': {
|
|
222
|
-
this.walk(node.argument);
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
case 'ObjectLiteral': {
|
|
226
|
-
// the library renders dictionaries with string keys only
|
|
227
|
-
const entries = node.value instanceof Map ? [...node.value.entries()] : [];
|
|
228
|
-
for (const [key, value] of entries) {
|
|
229
|
-
if (isNode(key) && key.type !== 'StringLiteral') {
|
|
230
|
-
this.problem('a dictionary with non-string keys is not available');
|
|
231
|
-
}
|
|
232
|
-
this.walk(key);
|
|
233
|
-
this.walk(value);
|
|
234
|
-
}
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
default: {
|
|
238
|
-
for (const [key, value] of Object.entries(node)) {
|
|
239
|
-
if (key !== 'type') {
|
|
240
|
-
this.walk(value);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
checkFilter(filter) {
|
|
247
|
-
let name = identifierName(filter);
|
|
248
|
-
let args = [];
|
|
249
|
-
if (name === undefined && isNode(filter) && filter.type === 'CallExpression') {
|
|
250
|
-
name = identifierName(filter.callee);
|
|
251
|
-
args = filter.args;
|
|
252
|
-
}
|
|
253
|
-
if (name === undefined) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
if (!FILTERS.has(name)) {
|
|
257
|
-
this.problem(`the filter "${name}" is not available`);
|
|
258
|
-
}
|
|
259
|
-
const unsupported = UNSUPPORTED_KEYWORDS[name];
|
|
260
|
-
for (const arg of args) {
|
|
261
|
-
if (isNode(arg) && arg.type === 'KeywordArgumentExpression') {
|
|
262
|
-
const key = identifierName(arg.key);
|
|
263
|
-
if (key !== undefined && unsupported?.includes(key) === true) {
|
|
264
|
-
this.problem(`"${name}(${key}=…)" is not available`);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
this.walk(arg);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
40
|
/** can the engine render this template with the variables of that side? */
|
|
272
41
|
export function checkTemplate(source, side, extra = []) {
|
|
273
|
-
|
|
274
|
-
try {
|
|
275
|
-
program = jinja.parse(jinja.tokenize(source, { lstrip_blocks: true, trim_blocks: true }));
|
|
276
|
-
}
|
|
277
|
-
catch (error) {
|
|
278
|
-
return { ok: false, reason: `does not parse: ${error.message}` };
|
|
279
|
-
}
|
|
280
|
-
const variables = new Set([...(side === 'status' ? STATUS_VARIABLES : COMMAND_VARIABLES), ...extra]);
|
|
281
|
-
const walker = new Walker(variables);
|
|
282
|
-
walker.walk(program.body);
|
|
283
|
-
return walker.problems.length === 0 ? { ok: true } : { ok: false, reason: walker.problems.join('; ') };
|
|
42
|
+
return check(source, side, side === 'command' ? [...COMMAND_VARIABLES, ...extra] : extra);
|
|
284
43
|
}
|
|
285
44
|
//# sourceMappingURL=templates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/importers/ha/templates.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/importers/ha/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;iEAOiE;AAEjE,OAAO,EAAC,aAAa,IAAI,KAAK,EAAqB,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAG7E,yGAAyG;AACzG,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IACrC,OAAO;IACP,MAAM;IACN,OAAO;IACP,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,KAAK;IACL,YAAY;IACZ,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,KAAK;IACL,OAAO;IACP,MAAM;IACN,GAAG;IACH,GAAG;IACH,GAAG;IACH,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,MAAM;IACN,eAAe;IACf,MAAM;IACN,OAAO;IACP,QAAQ;CACX,CAAC,CAAC;AAEH,2EAA2E;AAC3E,MAAM,UAAU,aAAa,CACzB,MAAc,EACd,IAA0B,EAC1B,QAA2B,EAAE;IAE7B,OAAO,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,iBAAiB,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -1,78 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
/** the `device` block's abbreviations (`DEVICE_ABBREVIATIONS`) */
|
|
4
|
-
export declare const DEVICE_ABBREVIATIONS: Readonly<Record<string, string>>;
|
|
5
|
-
/** the `origin` block's abbreviations (`ORIGIN_ABBREVIATIONS`) */
|
|
6
|
-
export declare const ORIGIN_ABBREVIATIONS: Readonly<Record<string, string>>;
|
|
7
|
-
export interface DeviceInfo {
|
|
8
|
-
/** one identifier or a list; Home Assistant accepts both */
|
|
9
|
-
identifiers?: string | string[];
|
|
10
|
-
/** `[["mac", "02:5b:…"]]` */
|
|
11
|
-
connections?: [string, string][];
|
|
12
|
-
name?: string;
|
|
13
|
-
manufacturer?: string;
|
|
14
|
-
model?: string;
|
|
15
|
-
model_id?: string;
|
|
16
|
-
sw_version?: string;
|
|
17
|
-
hw_version?: string;
|
|
18
|
-
serial_number?: string;
|
|
19
|
-
suggested_area?: string;
|
|
20
|
-
via_device?: string;
|
|
21
|
-
configuration_url?: string;
|
|
22
|
-
[key: string]: unknown;
|
|
23
|
-
}
|
|
24
|
-
export interface Origin {
|
|
25
|
-
name?: string;
|
|
26
|
-
sw_version?: string;
|
|
27
|
-
support_url?: string;
|
|
28
|
-
[key: string]: unknown;
|
|
29
|
-
}
|
|
30
|
-
export interface AvailabilityEntry {
|
|
31
|
-
topic: string;
|
|
32
|
-
payload_available?: string;
|
|
33
|
-
payload_not_available?: string;
|
|
34
|
-
value_template?: string;
|
|
35
|
-
}
|
|
36
|
-
/** an entity's config with the long key names; the importer reads the fields it knows, keeps the rest */
|
|
37
|
-
export interface EntityConfig {
|
|
38
|
-
platform?: string;
|
|
39
|
-
name?: string | null;
|
|
40
|
-
unique_id?: string;
|
|
41
|
-
object_id?: string;
|
|
42
|
-
device?: DeviceInfo;
|
|
43
|
-
origin?: Origin;
|
|
44
|
-
availability?: AvailabilityEntry[];
|
|
45
|
-
availability_topic?: string;
|
|
46
|
-
availability_mode?: string;
|
|
47
|
-
availability_template?: string;
|
|
48
|
-
payload_available?: string;
|
|
49
|
-
payload_not_available?: string;
|
|
50
|
-
state_topic?: string;
|
|
51
|
-
command_topic?: string;
|
|
52
|
-
value_template?: string;
|
|
53
|
-
device_class?: string | null;
|
|
54
|
-
entity_category?: string | null;
|
|
55
|
-
enabled_by_default?: boolean;
|
|
56
|
-
expire_after?: number;
|
|
57
|
-
optimistic?: boolean;
|
|
58
|
-
unit_of_measurement?: string | null;
|
|
59
|
-
[key: string]: unknown;
|
|
60
|
-
}
|
|
61
|
-
/** every abbreviation expanded and `~` substituted, in the entity itself, its availability list, device and origin */
|
|
62
|
-
export declare function expandEntity(raw: Record<string, unknown>, inherited?: Record<string, unknown>): EntityConfig;
|
|
63
|
-
/** the device-based form: `components` each with a `platform`; returns the entities with the shared fields applied */
|
|
64
|
-
export declare function expandDevicePayload(raw: Record<string, unknown>): {
|
|
65
|
-
components: Record<string, EntityConfig>;
|
|
66
|
-
device?: DeviceInfo;
|
|
67
|
-
origin?: Origin;
|
|
68
|
-
};
|
|
69
|
-
export interface DiscoveryTopic {
|
|
70
|
-
/** the component, or `device` for the device-based form */
|
|
71
|
-
component: string;
|
|
72
|
-
nodeId?: string;
|
|
73
|
-
objectId: string;
|
|
74
|
-
}
|
|
75
|
-
/** `<prefix>/<component>/[<node_id>/]<object_id>/config`, or undefined for any other topic under the prefix */
|
|
76
|
-
export declare function parseDiscoveryTopic(prefix: string, topic: string): DiscoveryTopic | undefined;
|
|
77
|
-
/** the device key material: the first identifier, else the first connection (`mac:…`) */
|
|
78
|
-
export declare function deviceIdentity(device: DeviceInfo | undefined): string | undefined;
|
|
1
|
+
export { ABBREVIATIONS, DEVICE_ABBREVIATIONS, ORIGIN_ABBREVIATIONS, expandEntity, expandDevicePayload, parseDiscoveryTopic, deviceIdentity, } from 'mqtt-ha-entities';
|
|
2
|
+
export type { DeviceInfo, Origin, AvailabilityEntry, EntityConfig, DiscoveryTopic } from 'mqtt-ha-entities';
|