@digital-alchemy/hass 25.2.2 → 25.3.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/dist/dev/index.d.mts +3 -0
- package/dist/dev/index.mjs +4 -0
- package/dist/dev/index.mjs.map +1 -0
- package/dist/dev/mappings.d.mts +70 -0
- package/dist/dev/mappings.mjs +2 -0
- package/dist/dev/mappings.mjs.map +1 -0
- package/dist/dev/registry.d.mts +328 -0
- package/dist/dev/registry.mjs +2 -0
- package/dist/dev/registry.mjs.map +1 -0
- package/dist/dev/services.d.mts +2431 -0
- package/dist/dev/services.mjs +5 -0
- package/dist/dev/services.mjs.map +1 -0
- package/dist/helpers/device.d.mts +1 -1
- package/dist/helpers/entity-state.d.mts +2 -2
- package/dist/helpers/fetch/calendar.d.mts +1 -1
- package/dist/helpers/fetch/configuration.d.mts +1 -1
- package/dist/helpers/fetch/service-list.d.mts +28 -3
- package/dist/helpers/id-by.d.mts +2 -3
- package/dist/helpers/interfaces.d.mts +4 -5
- package/dist/helpers/interfaces.mjs.map +1 -1
- package/dist/helpers/registry.d.mts +1 -2
- package/dist/helpers/registry.mjs.map +1 -1
- package/dist/helpers/utility.d.mts +5 -21
- package/dist/helpers/utility.mjs +0 -5
- package/dist/helpers/utility.mjs.map +1 -1
- package/dist/helpers/websocket.d.mts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/mock_assistant/helpers/fixtures.d.mts +2 -1
- package/dist/mock_assistant/services/device.service.mjs.map +1 -1
- package/dist/mock_assistant/services/entity-registry.service.d.mts +1 -1
- package/dist/mock_assistant/services/entity.service.d.mts +2 -2
- package/dist/mock_assistant/services/events.service.d.mts +2 -1
- package/dist/mock_assistant/services/events.service.mjs.map +1 -1
- package/dist/mock_assistant/services/fixtures.service.d.mts +3 -2
- package/dist/mock_assistant/services/fixtures.service.mjs.map +1 -1
- package/dist/mock_assistant/services/zone.service.mjs +1 -1
- package/dist/mock_assistant/services/zone.service.mjs.map +1 -1
- package/dist/services/area.service.d.mts +1 -1
- package/dist/services/area.service.mjs +1 -1
- package/dist/services/area.service.mjs.map +1 -1
- package/dist/services/call-proxy.service.d.mts +1 -1
- package/dist/services/call-proxy.service.mjs.map +1 -1
- package/dist/services/config.service.mjs.map +1 -1
- package/dist/services/entity.service.d.mts +1 -1
- package/dist/services/entity.service.mjs +1 -1
- package/dist/services/entity.service.mjs.map +1 -1
- package/dist/services/fetch-api.service.d.mts +3 -2
- package/dist/services/fetch-api.service.mjs.map +1 -1
- package/dist/services/floor.service.mjs.map +1 -1
- package/dist/services/id-by.service.d.mts +1 -1
- package/dist/services/id-by.service.mjs +28 -3
- package/dist/services/id-by.service.mjs.map +1 -1
- package/dist/services/label.service.mjs.map +1 -1
- package/dist/services/reference.service.mjs +4 -3
- package/dist/services/reference.service.mjs.map +1 -1
- package/dist/services/websocket-api.service.mjs +2 -2
- package/dist/services/websocket-api.service.mjs.map +1 -1
- package/dist/testing/area.spec.mjs.map +1 -1
- package/dist/testing/entity.spec.mjs.map +1 -1
- package/dist/testing/floor.spec.mjs.map +1 -1
- package/dist/testing/id-by.spec.mjs.map +1 -1
- package/dist/testing/label.spec.mjs.map +1 -1
- package/dist/testing/ref-by.spec.mjs.map +1 -1
- package/dist/user.d.mts +43 -0
- package/dist/user.mjs +4 -0
- package/dist/user.mjs.map +1 -0
- package/package.json +18 -17
- package/src/dev/index.mts +3 -0
- package/src/dev/mappings.mts +121 -0
- package/src/dev/registry.mts +330 -0
- package/src/dev/services.mts +2759 -0
- package/src/helpers/device.mts +1 -1
- package/src/helpers/entity-state.mts +6 -9
- package/src/helpers/fetch/calendar.mts +1 -1
- package/src/helpers/fetch/configuration.mts +1 -1
- package/src/helpers/fetch/service-list.mts +23 -3
- package/src/helpers/id-by.mts +11 -13
- package/src/helpers/interfaces.mts +14 -18
- package/src/helpers/registry.mts +9 -2
- package/src/helpers/utility.mts +13 -67
- package/src/helpers/websocket.mts +2 -1
- package/src/index.mts +2 -1
- package/src/mock_assistant/helpers/fixtures.mts +1 -1
- package/src/mock_assistant/services/area.service.mts +1 -1
- package/src/mock_assistant/services/device.service.mts +1 -1
- package/src/mock_assistant/services/entity-registry.service.mts +1 -1
- package/src/mock_assistant/services/entity.service.mts +2 -2
- package/src/mock_assistant/services/events.service.mts +2 -1
- package/src/mock_assistant/services/fixtures.service.mts +2 -1
- package/src/mock_assistant/services/floor.service.mts +1 -1
- package/src/mock_assistant/services/label.service.mts +1 -1
- package/src/mock_assistant/services/zone.service.mts +13 -10
- package/src/services/area.service.mts +2 -3
- package/src/services/call-proxy.service.mts +2 -2
- package/src/services/config.service.mts +1 -1
- package/src/services/entity.service.mts +2 -4
- package/src/services/fetch-api.service.mts +1 -1
- package/src/services/floor.service.mts +1 -1
- package/src/services/id-by.service.mts +47 -19
- package/src/services/label.service.mts +1 -1
- package/src/services/reference.service.mts +19 -18
- package/src/services/websocket-api.service.mts +2 -2
- package/src/testing/area.spec.mts +1 -1
- package/src/testing/entity.spec.mts +2 -1
- package/src/testing/floor.spec.mts +1 -1
- package/src/testing/id-by.spec.mts +1 -1
- package/src/testing/label.spec.mts +1 -1
- package/src/testing/ref-by.spec.mts +2 -1
- package/src/user.mts +97 -0
- package/dist/dynamic.d.mts +0 -3764
- package/dist/dynamic.mjs +0 -7
- package/dist/dynamic.mjs.map +0 -1
- package/src/dynamic.mts +0 -4302
package/src/helpers/device.mts
CHANGED
|
@@ -3,22 +3,19 @@ import { Dayjs } from "dayjs";
|
|
|
3
3
|
import { Except } from "type-fest";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
+
ALL_DOMAINS,
|
|
7
|
+
ANY_ENTITY,
|
|
8
|
+
GetDomain,
|
|
6
9
|
iCallService,
|
|
10
|
+
PICK_ENTITY,
|
|
7
11
|
TAreaId,
|
|
8
12
|
TDeviceId,
|
|
9
13
|
TLabelId,
|
|
10
14
|
TPlatformId,
|
|
11
15
|
TRawDomains,
|
|
12
|
-
} from "../
|
|
16
|
+
} from "../user.mts";
|
|
13
17
|
import { SensorUnitOfMeasurement } from "./registry.mts";
|
|
14
|
-
import {
|
|
15
|
-
ALL_DOMAINS,
|
|
16
|
-
ALL_SERVICE_DOMAINS,
|
|
17
|
-
ANY_ENTITY,
|
|
18
|
-
ENTITY_STATE,
|
|
19
|
-
GetDomain,
|
|
20
|
-
PICK_ENTITY,
|
|
21
|
-
} from "./utility.mts";
|
|
18
|
+
import { ALL_SERVICE_DOMAINS, ENTITY_STATE } from "./utility.mts";
|
|
22
19
|
|
|
23
20
|
export interface HassEntityContext {
|
|
24
21
|
id: string | null;
|
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { LiteralUnion } from "type-fest";
|
|
2
|
+
|
|
3
|
+
import { ALL_DOMAINS, TPlatformId } from "../../user.mts";
|
|
4
|
+
import { ColorMode } from "../features.mts";
|
|
3
5
|
|
|
4
6
|
export interface ServiceListSelectorTarget {
|
|
5
7
|
domain?: ALL_DOMAINS;
|
|
6
8
|
integration?: TPlatformId;
|
|
7
9
|
multiple?: boolean;
|
|
8
10
|
}
|
|
11
|
+
|
|
9
12
|
export interface ServiceListSelector {
|
|
13
|
+
addon?: null;
|
|
14
|
+
backup_location?: null;
|
|
10
15
|
boolean?: null;
|
|
16
|
+
color_rgb?: null;
|
|
17
|
+
color_temp?: { unit: "kelvin"; min: number; max: number };
|
|
18
|
+
conversation_agent?: null;
|
|
19
|
+
date?: null;
|
|
20
|
+
datetime?: null;
|
|
11
21
|
entity?: ServiceListSelectorTarget;
|
|
22
|
+
icon?: null;
|
|
12
23
|
number?: {
|
|
13
24
|
max: number;
|
|
14
25
|
min: number;
|
|
@@ -18,17 +29,26 @@ export interface ServiceListSelector {
|
|
|
18
29
|
};
|
|
19
30
|
object?: null;
|
|
20
31
|
select?: {
|
|
32
|
+
custom_value?: boolean;
|
|
33
|
+
multiple?: boolean;
|
|
21
34
|
options: Record<"label" | "value", string>[] | string[];
|
|
22
35
|
};
|
|
23
|
-
text?: null;
|
|
36
|
+
text?: null | { type: "password" };
|
|
37
|
+
theme?: { include_defaults?: boolean };
|
|
24
38
|
time?: null;
|
|
25
39
|
}
|
|
26
40
|
|
|
41
|
+
export interface ServiceListFilter {
|
|
42
|
+
supported_features?: number[];
|
|
43
|
+
supported_color_modes?: LiteralUnion<`${ColorMode}`, string>[];
|
|
44
|
+
}
|
|
45
|
+
|
|
27
46
|
export interface ServiceListFieldDescription {
|
|
28
47
|
advanced?: boolean;
|
|
29
48
|
default?: unknown;
|
|
30
49
|
description?: string;
|
|
31
50
|
example?: string | number;
|
|
51
|
+
filter?: ServiceListFilter;
|
|
32
52
|
name?: string;
|
|
33
53
|
required?: boolean;
|
|
34
54
|
selector?: ServiceListSelector;
|
package/src/helpers/id-by.mts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TAreaId,
|
|
3
|
-
TDeviceId,
|
|
4
|
-
TFloorId,
|
|
5
|
-
TLabelId,
|
|
6
|
-
TPlatformId,
|
|
7
|
-
TRawEntityIds,
|
|
8
|
-
TUniqueId,
|
|
9
|
-
TUniqueIDMapping,
|
|
10
|
-
} from "../dynamic.mts";
|
|
11
1
|
import {
|
|
12
2
|
ALL_DOMAINS,
|
|
13
3
|
ANY_ENTITY,
|
|
4
|
+
HassUniqueIdMapping,
|
|
14
5
|
PICK_ENTITY,
|
|
15
6
|
PICK_FROM_AREA,
|
|
16
7
|
PICK_FROM_DEVICE,
|
|
17
8
|
PICK_FROM_FLOOR,
|
|
18
9
|
PICK_FROM_LABEL,
|
|
19
10
|
PICK_FROM_PLATFORM,
|
|
20
|
-
|
|
11
|
+
TAreaId,
|
|
12
|
+
TDeviceId,
|
|
13
|
+
TFloorId,
|
|
14
|
+
TLabelId,
|
|
15
|
+
TPlatformId,
|
|
16
|
+
TRawEntityIds,
|
|
17
|
+
TUniqueId,
|
|
18
|
+
} from "../user.mts";
|
|
21
19
|
|
|
22
20
|
export type IDByInterface = {
|
|
23
21
|
area: <AREA extends TAreaId, DOMAIN extends ALL_DOMAINS>(
|
|
@@ -43,8 +41,8 @@ export type IDByInterface = {
|
|
|
43
41
|
) => PICK_FROM_PLATFORM<PLATFORM, DOMAIN>[];
|
|
44
42
|
unique_id: <
|
|
45
43
|
UNIQUE_ID extends TUniqueId,
|
|
46
|
-
ENTITY_ID extends Extract<
|
|
47
|
-
|
|
44
|
+
ENTITY_ID extends Extract<HassUniqueIdMapping[UNIQUE_ID], ANY_ENTITY> = Extract<
|
|
45
|
+
HassUniqueIdMapping[UNIQUE_ID],
|
|
48
46
|
TRawEntityIds
|
|
49
47
|
>,
|
|
50
48
|
>(
|
|
@@ -3,7 +3,16 @@ import EventEmitter from "events";
|
|
|
3
3
|
import WS from "ws";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
+
ALL_DOMAINS,
|
|
7
|
+
ANY_ENTITY,
|
|
8
|
+
HassUniqueIdMapping,
|
|
6
9
|
iCallService,
|
|
10
|
+
PICK_ENTITY,
|
|
11
|
+
PICK_FROM_AREA,
|
|
12
|
+
PICK_FROM_DEVICE,
|
|
13
|
+
PICK_FROM_FLOOR,
|
|
14
|
+
PICK_FROM_LABEL,
|
|
15
|
+
PICK_FROM_PLATFORM,
|
|
7
16
|
TAreaId,
|
|
8
17
|
TDeviceId,
|
|
9
18
|
TFloorId,
|
|
@@ -12,13 +21,11 @@ import {
|
|
|
12
21
|
TRawDomains,
|
|
13
22
|
TRawEntityIds,
|
|
14
23
|
TUniqueId,
|
|
15
|
-
|
|
16
|
-
} from "../dynamic.mts";
|
|
24
|
+
} from "../user.mts";
|
|
17
25
|
import { BackupResponse, HomeAssistantBackup } from "./backup.mts";
|
|
18
26
|
import { DeviceDetails } from "./device.mts";
|
|
19
27
|
import { ByIdProxy } from "./entity-state.mts";
|
|
20
|
-
import { AreaCreate, AreaDetails, ConfigEntry, HassConfig } from "./
|
|
21
|
-
import { HassServiceDTO } from "./fetch/service-list.mts";
|
|
28
|
+
import { AreaCreate, AreaDetails, ConfigEntry, HassConfig, HassServiceDTO } from "./index.mts";
|
|
22
29
|
import {
|
|
23
30
|
EditAliasOptions,
|
|
24
31
|
EditLabelOptions,
|
|
@@ -33,18 +40,7 @@ import {
|
|
|
33
40
|
ZoneDetails,
|
|
34
41
|
ZoneOptions,
|
|
35
42
|
} from "./registry.mts";
|
|
36
|
-
import {
|
|
37
|
-
ALL_DOMAINS,
|
|
38
|
-
ALL_SERVICE_DOMAINS,
|
|
39
|
-
ANY_ENTITY,
|
|
40
|
-
ENTITY_STATE,
|
|
41
|
-
PICK_ENTITY,
|
|
42
|
-
PICK_FROM_AREA,
|
|
43
|
-
PICK_FROM_DEVICE,
|
|
44
|
-
PICK_FROM_FLOOR,
|
|
45
|
-
PICK_FROM_LABEL,
|
|
46
|
-
PICK_FROM_PLATFORM,
|
|
47
|
-
} from "./utility.mts";
|
|
43
|
+
import { ALL_SERVICE_DOMAINS, ENTITY_STATE } from "./utility.mts";
|
|
48
44
|
import {
|
|
49
45
|
EntityHistoryDTO,
|
|
50
46
|
EntityHistoryResult,
|
|
@@ -324,8 +320,8 @@ export type HassReferenceService = {
|
|
|
324
320
|
) => ByIdProxy<PICK_FROM_PLATFORM<PLATFORM, DOMAINS>>[];
|
|
325
321
|
unique_id: <
|
|
326
322
|
UNIQUE_ID extends TUniqueId,
|
|
327
|
-
ENTITY_ID extends Extract<
|
|
328
|
-
|
|
323
|
+
ENTITY_ID extends Extract<HassUniqueIdMapping[UNIQUE_ID], ANY_ENTITY> = Extract<
|
|
324
|
+
HassUniqueIdMapping[UNIQUE_ID],
|
|
329
325
|
ANY_ENTITY
|
|
330
326
|
>,
|
|
331
327
|
>(
|
package/src/helpers/registry.mts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ANY_ENTITY,
|
|
3
|
+
TAreaId,
|
|
4
|
+
TDeviceId,
|
|
5
|
+
TFloorId,
|
|
6
|
+
TLabelId,
|
|
7
|
+
TPlatformId,
|
|
8
|
+
TZoneId,
|
|
9
|
+
} from "../user.mts";
|
|
3
10
|
|
|
4
11
|
export type LabelOptions = {
|
|
5
12
|
name: string;
|
package/src/helpers/utility.mts
CHANGED
|
@@ -3,31 +3,18 @@ import { Dayjs } from "dayjs";
|
|
|
3
3
|
import { Get } from "type-fest";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
ALL_DOMAINS,
|
|
7
|
+
ANY_ENTITY,
|
|
8
|
+
HassEntitySetupMapping,
|
|
7
9
|
iCallService,
|
|
8
|
-
|
|
9
|
-
TAreaId,
|
|
10
|
-
TDeviceId,
|
|
11
|
-
TFloorId,
|
|
12
|
-
TLabelId,
|
|
13
|
-
TPlatformId,
|
|
14
|
-
TRawDomains,
|
|
10
|
+
PICK_ENTITY,
|
|
15
11
|
TRawEntityIds,
|
|
16
|
-
} from "../
|
|
12
|
+
} from "../user.mts";
|
|
17
13
|
import { HassEntityContext } from "./entity-state.mts";
|
|
18
14
|
|
|
19
|
-
export type ANY_ENTITY = TRawEntityIds;
|
|
20
|
-
|
|
21
15
|
// ? Casting by domain turns things from "equiv to ANY_ENTITY" to "scene.*" type generics
|
|
22
16
|
// These are no longer valid comparisons against ANY_ENTITY though
|
|
23
17
|
// ? The extract converts those generic types back into real entity ids to make types valid again
|
|
24
|
-
/**
|
|
25
|
-
* Pick any valid entity, optionally limiting by domain
|
|
26
|
-
*/
|
|
27
|
-
export type PICK_ENTITY<DOMAIN extends ALL_DOMAINS = ALL_DOMAINS> = Extract<
|
|
28
|
-
ANY_ENTITY,
|
|
29
|
-
`${DOMAIN}.${string}`
|
|
30
|
-
>;
|
|
31
18
|
|
|
32
19
|
/**
|
|
33
20
|
* Pick any valid service call, optionally limiting by domain
|
|
@@ -62,41 +49,32 @@ export function domain(entity: { entity_id: ANY_ENTITY } | ANY_ENTITY): ALL_DOMA
|
|
|
62
49
|
return entity_split(entity).shift() as ALL_DOMAINS;
|
|
63
50
|
}
|
|
64
51
|
|
|
65
|
-
export type ENTITY_PROP<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
export type ENTITY_PROP<
|
|
53
|
+
ENTITY_ID extends PICK_ENTITY,
|
|
54
|
+
PROP extends "state" | "attributes",
|
|
55
|
+
> = HassEntitySetupMapping[ENTITY_ID][PROP];
|
|
69
56
|
|
|
70
57
|
/**
|
|
71
58
|
* Type definitions to match a specific entity.
|
|
72
59
|
*/
|
|
73
|
-
export type ENTITY_STATE<ENTITY_ID extends
|
|
74
|
-
|
|
60
|
+
export type ENTITY_STATE<ENTITY_ID extends TRawEntityIds> = Omit<
|
|
61
|
+
HassEntitySetupMapping[ENTITY_ID],
|
|
75
62
|
"state" | "context" | "last_changed" | "last_updated" | "entity_id" | "attributes"
|
|
76
63
|
> & {
|
|
77
64
|
last_reported: Dayjs;
|
|
78
65
|
last_changed: Dayjs;
|
|
79
66
|
last_updated: Dayjs;
|
|
80
|
-
attributes:
|
|
67
|
+
attributes: ENTITY_PROP<ENTITY_ID, "attributes">;
|
|
81
68
|
entity_id: ENTITY_ID;
|
|
82
|
-
state:
|
|
69
|
+
state: ENTITY_PROP<ENTITY_ID, "state">;
|
|
83
70
|
context: HassEntityContext;
|
|
84
71
|
};
|
|
85
72
|
|
|
86
|
-
/**
|
|
87
|
-
* Union of all domains that contain entities
|
|
88
|
-
*/
|
|
89
|
-
export type ALL_DOMAINS = TRawDomains;
|
|
90
|
-
|
|
91
73
|
/**
|
|
92
74
|
* Union of all services with callable methods
|
|
93
75
|
*/
|
|
94
76
|
export type ALL_SERVICE_DOMAINS = keyof iCallService;
|
|
95
77
|
|
|
96
|
-
export type GetDomain<ENTITY extends ANY_ENTITY> = ENTITY extends `${infer domain}.${string}`
|
|
97
|
-
? domain
|
|
98
|
-
: never;
|
|
99
|
-
|
|
100
78
|
export function isDomain<DOMAIN extends ALL_DOMAINS>(
|
|
101
79
|
entity: string,
|
|
102
80
|
domain: DOMAIN | DOMAIN[],
|
|
@@ -105,12 +83,6 @@ export function isDomain<DOMAIN extends ALL_DOMAINS>(
|
|
|
105
83
|
return [domain].flat().includes(test);
|
|
106
84
|
}
|
|
107
85
|
|
|
108
|
-
is.removeFn = (remove: () => void) => {
|
|
109
|
-
const out = remove as RemoveCallback;
|
|
110
|
-
out.remove = remove;
|
|
111
|
-
return out;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
86
|
export type RemoveCallback = { remove: () => void; (): void };
|
|
115
87
|
|
|
116
88
|
declare module "@digital-alchemy/core" {
|
|
@@ -119,7 +91,6 @@ declare module "@digital-alchemy/core" {
|
|
|
119
91
|
* Check to see if an entity matches
|
|
120
92
|
*/
|
|
121
93
|
domain: typeof isDomain;
|
|
122
|
-
removeFn: (remove: () => void) => RemoveCallback;
|
|
123
94
|
}
|
|
124
95
|
}
|
|
125
96
|
|
|
@@ -127,28 +98,3 @@ export const PostConfigPriorities = {
|
|
|
127
98
|
FETCH: 1,
|
|
128
99
|
VALIDATE: -1,
|
|
129
100
|
} as const;
|
|
130
|
-
|
|
131
|
-
export type PICK_FROM_AREA<ID extends TAreaId, DOMAIN extends ALL_DOMAINS = ALL_DOMAINS> = Extract<
|
|
132
|
-
REGISTRY_SETUP["area"][`_${ID}`],
|
|
133
|
-
PICK_ENTITY<DOMAIN>
|
|
134
|
-
>;
|
|
135
|
-
|
|
136
|
-
export type PICK_FROM_LABEL<
|
|
137
|
-
ID extends TLabelId,
|
|
138
|
-
DOMAIN extends ALL_DOMAINS = ALL_DOMAINS,
|
|
139
|
-
> = Extract<REGISTRY_SETUP["label"][`_${ID}`], PICK_ENTITY<DOMAIN>>;
|
|
140
|
-
|
|
141
|
-
export type PICK_FROM_FLOOR<
|
|
142
|
-
ID extends TFloorId,
|
|
143
|
-
DOMAIN extends ALL_DOMAINS = ALL_DOMAINS,
|
|
144
|
-
> = Extract<REGISTRY_SETUP["floor"][`_${ID}`], PICK_ENTITY<DOMAIN>>;
|
|
145
|
-
|
|
146
|
-
export type PICK_FROM_DEVICE<
|
|
147
|
-
ID extends TDeviceId,
|
|
148
|
-
DOMAIN extends ALL_DOMAINS = ALL_DOMAINS,
|
|
149
|
-
> = Extract<REGISTRY_SETUP["device"][`_${ID}`], PICK_ENTITY<DOMAIN>>;
|
|
150
|
-
|
|
151
|
-
export type PICK_FROM_PLATFORM<
|
|
152
|
-
ID extends TPlatformId,
|
|
153
|
-
DOMAIN extends ALL_DOMAINS = ALL_DOMAINS,
|
|
154
|
-
> = Extract<REGISTRY_SETUP["platform"][`_${ID}`], PICK_ENTITY<DOMAIN>>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { TBlackHole, TContext } from "@digital-alchemy/core";
|
|
2
2
|
import { Dayjs } from "dayjs";
|
|
3
3
|
|
|
4
|
+
import { ALL_DOMAINS, ANY_ENTITY, PICK_ENTITY } from "../user.mts";
|
|
4
5
|
import { HassSocketMessageTypes } from "./constants.mts";
|
|
5
6
|
import { EntityUpdateEvent } from "./entity-state.mts";
|
|
6
|
-
import {
|
|
7
|
+
import { ENTITY_STATE } from "./utility.mts";
|
|
7
8
|
|
|
8
9
|
export interface SignRequestResponse {
|
|
9
10
|
path: string;
|
package/src/index.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ANY_ENTITY,
|
|
3
2
|
AreaDetails,
|
|
4
3
|
DeviceDetails,
|
|
5
4
|
ENTITY_STATE,
|
|
@@ -9,6 +8,7 @@ import {
|
|
|
9
8
|
HassServiceDTO as HassServiceDefinition,
|
|
10
9
|
LabelDefinition,
|
|
11
10
|
} from "../../helpers/index.mts";
|
|
11
|
+
import { ANY_ENTITY } from "../../user.mts";
|
|
12
12
|
|
|
13
13
|
export type ScannerCacheData = {
|
|
14
14
|
areas: AreaDetails[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import { TAreaId } from "../../dynamic.mts";
|
|
4
3
|
import { AreaDetails } from "../../helpers/index.mts";
|
|
4
|
+
import { TAreaId } from "../../user.mts";
|
|
5
5
|
|
|
6
6
|
export function MockAreaExtension({ mock_assistant }: TServiceParams) {
|
|
7
7
|
let areas = new Map<TAreaId, AreaDetails>();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import { TDeviceId } from "../../dynamic.mts";
|
|
4
3
|
import { DEVICE_REGISTRY_UPDATED, DeviceDetails } from "../../helpers/index.mts";
|
|
4
|
+
import { TDeviceId } from "../../user.mts";
|
|
5
5
|
|
|
6
6
|
export function MockDeviceExtension({ mock_assistant }: TServiceParams) {
|
|
7
7
|
let devices = new Map<TDeviceId, DeviceDetails>();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import { TRawEntityIds } from "../../dynamic.mts";
|
|
4
3
|
import { EntityRegistryItem } from "../../helpers/index.mts";
|
|
4
|
+
import { TRawEntityIds } from "../../user.mts";
|
|
5
5
|
|
|
6
6
|
export function MockEntityRegistryExtension({ mock_assistant, hass }: TServiceParams) {
|
|
7
7
|
let entityRegistry = new Map<TRawEntityIds, EntityRegistryItem<TRawEntityIds>>();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deepExtend, InternalError, sleep, TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { ENTITY_STATE } from "../../index.mts";
|
|
4
|
+
import { PICK_ENTITY, TRawEntityIds } from "../../user.mts";
|
|
5
5
|
|
|
6
6
|
export function MockEntityExtension({
|
|
7
7
|
hass,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { sleep, TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ENTITY_STATE, EntityUpdateEvent } from "../../index.mts";
|
|
4
|
+
import { ANY_ENTITY } from "../../user.mts";
|
|
4
5
|
|
|
5
6
|
const SUPER_SHORT = 1;
|
|
6
7
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BootstrapException, TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
import { existsSync, readFileSync } from "fs";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { ENTITY_STATE } from "../../index.mts";
|
|
5
|
+
import { ANY_ENTITY } from "../../user.mts";
|
|
5
6
|
import { ScannerCacheData } from "../helpers/index.mts";
|
|
6
7
|
|
|
7
8
|
type StateOptions = Partial<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import { TFloorId } from "../../dynamic.mts";
|
|
4
3
|
import { FloorDetails } from "../../helpers/index.mts";
|
|
4
|
+
import { TFloorId } from "../../user.mts";
|
|
5
5
|
|
|
6
6
|
export function MockFloorExtension({ mock_assistant }: TServiceParams) {
|
|
7
7
|
let floors = new Map<TFloorId, FloorDetails>();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import { TLabelId } from "../../dynamic.mts";
|
|
4
3
|
import { LabelDefinition } from "../../helpers/index.mts";
|
|
4
|
+
import { TLabelId } from "../../user.mts";
|
|
5
5
|
|
|
6
6
|
export function MockLabelExtension({ mock_assistant }: TServiceParams) {
|
|
7
7
|
let labels = new Map<TLabelId, LabelDefinition>();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import { TZoneId } from "../../dynamic.mts";
|
|
4
3
|
import { ZoneDetails } from "../../helpers/index.mts";
|
|
4
|
+
import { TZoneId } from "../../user.mts";
|
|
5
5
|
|
|
6
6
|
export function MockZoneExtension({ mock_assistant }: TServiceParams) {
|
|
7
7
|
let zones = new Map<TZoneId, ZoneDetails>();
|
|
@@ -38,15 +38,18 @@ export function MockZoneExtension({ mock_assistant }: TServiceParams) {
|
|
|
38
38
|
},
|
|
39
39
|
);
|
|
40
40
|
|
|
41
|
-
mock_assistant.socket.onMessage<ZoneDetails>(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
mock_assistant.socket.onMessage<ZoneDetails>(
|
|
42
|
+
"config/zone_registry/update",
|
|
43
|
+
(message: ZoneDetails) => {
|
|
44
|
+
zones.set(message.id as TZoneId, message);
|
|
45
|
+
sendUpdate();
|
|
46
|
+
mock_assistant.socket.sendMessage({
|
|
47
|
+
id: message.id,
|
|
48
|
+
result: null,
|
|
49
|
+
type: "result",
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
);
|
|
50
53
|
|
|
51
54
|
const sendUpdate = () =>
|
|
52
55
|
mock_assistant.socket.sendMessage({
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { debounce, eachSeries, InternalError, TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import { TAreaId } from "../dynamic.mts";
|
|
4
3
|
import {
|
|
5
|
-
ANY_ENTITY,
|
|
6
4
|
AREA_REGISTRY_UPDATED,
|
|
7
5
|
AreaCreate,
|
|
8
6
|
AreaDetails,
|
|
9
7
|
EARLY_ON_READY,
|
|
10
8
|
ENTITY_REGISTRY_UPDATED,
|
|
11
9
|
HassAreaService,
|
|
12
|
-
} from "../
|
|
10
|
+
} from "../index.mts";
|
|
11
|
+
import { ANY_ENTITY, TAreaId } from "../user.mts";
|
|
13
12
|
|
|
14
13
|
export function Area({
|
|
15
14
|
hass,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import { iCallService } from "../dynamic.mts";
|
|
4
3
|
import { ALL_SERVICE_DOMAINS, PICK_SERVICE, PICK_SERVICE_PARAMETERS } from "../helpers/index.mts";
|
|
4
|
+
import { iCallService } from "../user.mts";
|
|
5
5
|
|
|
6
6
|
export function CallProxy({
|
|
7
7
|
logger,
|
|
@@ -86,7 +86,7 @@ export function CallProxy({
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function buildCallProxy(): iCallService {
|
|
89
|
-
return new Proxy(rawProxy as iCallService, {
|
|
89
|
+
return new Proxy(rawProxy as unknown as iCallService, {
|
|
90
90
|
get: (_, domain: ALL_SERVICE_DOMAINS) => {
|
|
91
91
|
// oddities in the way proxies work
|
|
92
92
|
// this situation isn't testable afaik
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { asyncNoop, INCREMENT, SECOND, sleep, START, TServiceParams } from "@digital-alchemy/core";
|
|
3
3
|
import { env } from "process";
|
|
4
4
|
|
|
5
|
-
import { iCallService } from "../dynamic.mts";
|
|
6
5
|
import {
|
|
7
6
|
ALL_SERVICE_DOMAINS,
|
|
8
7
|
HassConfigService,
|
|
9
8
|
HassServiceDTO,
|
|
10
9
|
PostConfigPriorities,
|
|
11
10
|
} from "../helpers/index.mts";
|
|
11
|
+
import { iCallService } from "../user.mts";
|
|
12
12
|
|
|
13
13
|
const MAX_ATTEMPTS = 50;
|
|
14
14
|
const FAILED = 1;
|
|
@@ -11,8 +11,6 @@ import {
|
|
|
11
11
|
import dayjs, { Dayjs } from "dayjs";
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
|
-
ALL_DOMAINS,
|
|
15
|
-
ANY_ENTITY,
|
|
16
14
|
EditLabelOptions,
|
|
17
15
|
ENTITY_REGISTRY_UPDATED,
|
|
18
16
|
ENTITY_STATE,
|
|
@@ -21,9 +19,9 @@ import {
|
|
|
21
19
|
EntityHistoryResult,
|
|
22
20
|
EntityRegistryItem,
|
|
23
21
|
HassEntityManager,
|
|
24
|
-
PICK_ENTITY,
|
|
25
22
|
TMasterState,
|
|
26
|
-
} from "../
|
|
23
|
+
} from "../index.mts";
|
|
24
|
+
import { ALL_DOMAINS, ANY_ENTITY, PICK_ENTITY } from "../user.mts";
|
|
27
25
|
|
|
28
26
|
const MAX_ATTEMPTS = 10;
|
|
29
27
|
const RECENT = 5;
|
|
@@ -6,7 +6,6 @@ import { MIN_SUPPORTED_HASS_VERSION } from "../helpers/constants.mts";
|
|
|
6
6
|
import { FetchArguments, FilteredFetchArguments, TFetchBody } from "../helpers/fetch.mts";
|
|
7
7
|
import {
|
|
8
8
|
ALL_SERVICE_DOMAINS,
|
|
9
|
-
ANY_ENTITY,
|
|
10
9
|
CalendarEvent,
|
|
11
10
|
CalendarFetchOptions,
|
|
12
11
|
CheckConfigResult,
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
PostConfigPriorities,
|
|
20
19
|
RawCalendarEvent,
|
|
21
20
|
} from "../helpers/index.mts";
|
|
21
|
+
import { ANY_ENTITY } from "../user.mts";
|
|
22
22
|
|
|
23
23
|
type SendBody<STATE extends string | number = string, ATTRIBUTES extends object = object> = {
|
|
24
24
|
attributes?: ATTRIBUTES;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { debounce, TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
|
|
3
|
-
import { TFloorId } from "../dynamic.mts";
|
|
4
3
|
import {
|
|
5
4
|
EARLY_ON_READY,
|
|
6
5
|
FLOOR_REGISTRY_UPDATED,
|
|
@@ -8,6 +7,7 @@ import {
|
|
|
8
7
|
FloorDetails,
|
|
9
8
|
HassFloorService,
|
|
10
9
|
} from "../helpers/index.mts";
|
|
10
|
+
import { TFloorId } from "../user.mts";
|
|
11
11
|
|
|
12
12
|
export function Floor({
|
|
13
13
|
hass,
|