@digital-alchemy/hass 25.8.21 → 25.10.19-beta.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.
Files changed (150) hide show
  1. package/dist/dev/services.d.mts +1 -1
  2. package/dist/helpers/device.d.mts +1 -1
  3. package/dist/helpers/entity-state.d.mts +6 -6
  4. package/dist/helpers/fetch/calendar.d.mts +2 -2
  5. package/dist/helpers/fetch/configuration.d.mts +1 -1
  6. package/dist/helpers/fetch/service-list.d.mts +3 -3
  7. package/dist/helpers/fetch.d.mts +2 -2
  8. package/dist/helpers/fetch.mjs.map +1 -1
  9. package/dist/helpers/id-by.d.mts +1 -1
  10. package/dist/helpers/interfaces.d.mts +22 -13
  11. package/dist/helpers/interfaces.mjs.map +1 -1
  12. package/dist/helpers/registry.d.mts +1 -1
  13. package/dist/helpers/utility.d.mts +5 -5
  14. package/dist/helpers/utility.mjs.map +1 -1
  15. package/dist/helpers/websocket.d.mts +9 -8
  16. package/dist/merge.d.mts +1 -1
  17. package/dist/mock_assistant/helpers/fixtures.d.mts +2 -2
  18. package/dist/mock_assistant/main.mjs.map +1 -1
  19. package/dist/mock_assistant/services/area.service.d.mts +2 -2
  20. package/dist/mock_assistant/services/config.service.d.mts +2 -2
  21. package/dist/mock_assistant/services/config.service.mjs.map +1 -1
  22. package/dist/mock_assistant/services/device.service.d.mts +2 -2
  23. package/dist/mock_assistant/services/device.service.mjs.map +1 -1
  24. package/dist/mock_assistant/services/entity-registry.service.d.mts +3 -3
  25. package/dist/mock_assistant/services/entity.service.d.mts +3 -3
  26. package/dist/mock_assistant/services/entity.service.mjs.map +1 -1
  27. package/dist/mock_assistant/services/events.service.d.mts +3 -3
  28. package/dist/mock_assistant/services/events.service.mjs.map +1 -1
  29. package/dist/mock_assistant/services/fixtures.service.d.mts +4 -4
  30. package/dist/mock_assistant/services/fixtures.service.mjs.map +1 -1
  31. package/dist/mock_assistant/services/floor.service.d.mts +2 -2
  32. package/dist/mock_assistant/services/label.service.d.mts +2 -2
  33. package/dist/mock_assistant/services/services.service.d.mts +2 -2
  34. package/dist/mock_assistant/services/websocket-api.service.d.mts +4 -4
  35. package/dist/mock_assistant/services/websocket-api.service.mjs.map +1 -1
  36. package/dist/mock_assistant/services/zone.service.d.mts +2 -2
  37. package/dist/quickboot.module.d.mts +1 -1
  38. package/dist/quickboot.module.mjs.map +1 -1
  39. package/dist/services/area.service.d.mts +2 -2
  40. package/dist/services/area.service.mjs +1 -1
  41. package/dist/services/area.service.mjs.map +1 -1
  42. package/dist/services/backup.service.d.mts +2 -2
  43. package/dist/services/backup.service.mjs.map +1 -1
  44. package/dist/services/call-proxy.service.d.mts +2 -2
  45. package/dist/services/call-proxy.service.mjs +1 -1
  46. package/dist/services/call-proxy.service.mjs.map +1 -1
  47. package/dist/services/config.service.d.mts +2 -2
  48. package/dist/services/config.service.mjs +1 -2
  49. package/dist/services/config.service.mjs.map +1 -1
  50. package/dist/services/conversation.service.d.mts +2 -2
  51. package/dist/services/conversation.service.mjs +1 -1
  52. package/dist/services/conversation.service.mjs.map +1 -1
  53. package/dist/services/device.service.d.mts +2 -2
  54. package/dist/services/device.service.mjs +1 -1
  55. package/dist/services/device.service.mjs.map +1 -1
  56. package/dist/services/diagnostics.service.d.mts +1 -1
  57. package/dist/services/entity.service.d.mts +2 -2
  58. package/dist/services/entity.service.mjs +2 -2
  59. package/dist/services/entity.service.mjs.map +1 -1
  60. package/dist/services/events.service.d.mts +2 -2
  61. package/dist/services/events.service.mjs.map +1 -1
  62. package/dist/services/fetch-api.service.d.mts +5 -5
  63. package/dist/services/fetch-api.service.mjs +1 -1
  64. package/dist/services/fetch-api.service.mjs.map +1 -1
  65. package/dist/services/floor.service.d.mts +2 -2
  66. package/dist/services/floor.service.mjs +1 -1
  67. package/dist/services/floor.service.mjs.map +1 -1
  68. package/dist/services/id-by.service.d.mts +2 -2
  69. package/dist/services/id-by.service.mjs.map +1 -1
  70. package/dist/services/internal.service.d.mts +2 -2
  71. package/dist/services/internal.service.mjs +1 -1
  72. package/dist/services/internal.service.mjs.map +1 -1
  73. package/dist/services/label.service.d.mts +2 -2
  74. package/dist/services/label.service.mjs +1 -1
  75. package/dist/services/label.service.mjs.map +1 -1
  76. package/dist/services/reference.service.d.mts +2 -2
  77. package/dist/services/reference.service.mjs +1 -1
  78. package/dist/services/reference.service.mjs.map +1 -1
  79. package/dist/services/registry.service.d.mts +2 -2
  80. package/dist/services/websocket-api.service.d.mts +2 -2
  81. package/dist/services/websocket-api.service.mjs +53 -39
  82. package/dist/services/websocket-api.service.mjs.map +1 -1
  83. package/dist/services/zone.service.d.mts +2 -2
  84. package/dist/services/zone.service.mjs +1 -1
  85. package/dist/services/zone.service.mjs.map +1 -1
  86. package/dist/testing/area.spec.mjs.map +1 -1
  87. package/dist/testing/floor.spec.mjs.map +1 -1
  88. package/dist/testing/label.spec.mjs.map +1 -1
  89. package/dist/testing/websocket.spec.mjs +125 -0
  90. package/dist/testing/websocket.spec.mjs.map +1 -1
  91. package/dist/testing/zone.spec.mjs.map +1 -1
  92. package/package.json +28 -28
  93. package/src/dev/services.mts +1 -1
  94. package/src/helpers/device.mts +1 -1
  95. package/src/helpers/entity-state.mts +6 -6
  96. package/src/helpers/fetch/calendar.mts +2 -2
  97. package/src/helpers/fetch/configuration.mts +1 -1
  98. package/src/helpers/fetch/service-list.mts +3 -3
  99. package/src/helpers/fetch.mts +3 -2
  100. package/src/helpers/id-by.mts +1 -1
  101. package/src/helpers/interfaces.mts +22 -15
  102. package/src/helpers/registry.mts +1 -1
  103. package/src/helpers/utility.mts +6 -5
  104. package/src/helpers/websocket.mts +12 -8
  105. package/src/merge.mts +1 -1
  106. package/src/mock_assistant/helpers/fixtures.mts +2 -2
  107. package/src/mock_assistant/main.mts +3 -2
  108. package/src/mock_assistant/services/area.service.mts +3 -3
  109. package/src/mock_assistant/services/config.service.mts +3 -2
  110. package/src/mock_assistant/services/device.service.mts +4 -3
  111. package/src/mock_assistant/services/entity-registry.service.mts +3 -3
  112. package/src/mock_assistant/services/entity.service.mts +4 -3
  113. package/src/mock_assistant/services/events.service.mts +4 -3
  114. package/src/mock_assistant/services/fixtures.service.mts +5 -4
  115. package/src/mock_assistant/services/floor.service.mts +3 -3
  116. package/src/mock_assistant/services/label.service.mts +3 -3
  117. package/src/mock_assistant/services/services.service.mts +2 -2
  118. package/src/mock_assistant/services/websocket-api.service.mts +5 -4
  119. package/src/mock_assistant/services/zone.service.mts +3 -3
  120. package/src/quickboot.module.mts +2 -1
  121. package/src/services/area.service.mts +5 -11
  122. package/src/services/backup.service.mts +3 -2
  123. package/src/services/call-proxy.service.mts +4 -4
  124. package/src/services/config.service.mts +5 -8
  125. package/src/services/conversation.service.mts +3 -7
  126. package/src/services/device.service.mts +4 -8
  127. package/src/services/diagnostics.service.mts +1 -1
  128. package/src/services/entity.service.mts +7 -15
  129. package/src/services/events.service.mts +2 -3
  130. package/src/services/fetch-api.service.mts +8 -7
  131. package/src/services/floor.service.mts +5 -10
  132. package/src/services/id-by.service.mts +5 -3
  133. package/src/services/internal.service.mts +4 -4
  134. package/src/services/label.service.mts +5 -10
  135. package/src/services/reference.service.mts +8 -7
  136. package/src/services/registry.service.mts +2 -2
  137. package/src/services/websocket-api.service.mts +74 -60
  138. package/src/services/zone.service.mts +4 -10
  139. package/src/testing/area.spec.mts +3 -2
  140. package/src/testing/backup.spec.mts +1 -1
  141. package/src/testing/config.spec.mts +1 -1
  142. package/src/testing/device.spec.mts +1 -1
  143. package/src/testing/entity.spec.mts +2 -2
  144. package/src/testing/fetch-api.spec.mts +2 -2
  145. package/src/testing/floor.spec.mts +3 -2
  146. package/src/testing/id-by.spec.mts +1 -1
  147. package/src/testing/label.spec.mts +3 -2
  148. package/src/testing/ref-by.spec.mts +2 -2
  149. package/src/testing/websocket.spec.mts +156 -0
  150. package/src/testing/zone.spec.mts +2 -1
@@ -1,8 +1,9 @@
1
- import { RemoveCallback, TBlackHole } from "@digital-alchemy/core";
2
- import EventEmitter from "events";
3
- import WS from "ws";
1
+ import type { RemoveCallback, TBlackHole } from "@digital-alchemy/core";
2
+ import type EventEmitter from "events";
3
+ import type { EmptyObject } from "type-fest";
4
+ import type WS from "ws";
4
5
 
5
- import {
6
+ import type {
6
7
  ALL_DOMAINS,
7
8
  ANY_ENTITY,
8
9
  HassUniqueIdMapping,
@@ -22,11 +23,11 @@ import {
22
23
  TRawEntityIds,
23
24
  TUniqueId,
24
25
  } from "../user.mts";
25
- import { BackupResponse, HomeAssistantBackup } from "./backup.mts";
26
- import { DeviceDetails } from "./device.mts";
27
- import { ByIdProxy } from "./entity-state.mts";
28
- import { AreaCreate, AreaDetails, ConfigEntry, HassConfig, HassServiceDTO } from "./index.mts";
29
- import {
26
+ import type { BackupResponse, HomeAssistantBackup } from "./backup.mts";
27
+ import type { DeviceDetails } from "./device.mts";
28
+ import type { ByIdProxy } from "./entity-state.mts";
29
+ import type { AreaCreate, AreaDetails, ConfigEntry, HassConfig, HassServiceDTO } from "./index.mts";
30
+ import type {
30
31
  EditAliasOptions,
31
32
  EditLabelOptions,
32
33
  EntityRegistryItem,
@@ -40,12 +41,11 @@ import {
40
41
  ZoneDetails,
41
42
  ZoneOptions,
42
43
  } from "./registry.mts";
43
- import { ALL_SERVICE_DOMAINS, ENTITY_STATE } from "./utility.mts";
44
- import {
44
+ import type { ALL_SERVICE_DOMAINS, ENTITY_STATE } from "./utility.mts";
45
+ import type {
45
46
  EntityHistoryDTO,
46
47
  EntityHistoryResult,
47
48
  OnHassEventOptions,
48
- SocketMessageDTO,
49
49
  SocketSubscribeOptions,
50
50
  } from "./websocket.mts";
51
51
 
@@ -138,7 +138,7 @@ export type HassWebsocketAPI = {
138
138
  *
139
139
  * for unit testing
140
140
  */
141
- onMessage: (message: SocketMessageDTO) => Promise<void>;
141
+ onMessage: <T extends { type: string }>(message: T) => Promise<void>;
142
142
  /**
143
143
  * when true:
144
144
  * - outgoing socket messages are blocked
@@ -163,6 +163,13 @@ export type HassWebsocketAPI = {
163
163
  * internal
164
164
  */
165
165
  setConnectionState: (state: ConnectionState) => void;
166
+ /**
167
+ * Register a handler for incoming websocket messages by type
168
+ */
169
+ registerMessageHandler: <T extends { type: string }>(
170
+ type: string,
171
+ callback: (message: T) => TBlackHole,
172
+ ) => void;
166
173
  /**
167
174
  * internal
168
175
  */
@@ -172,11 +179,11 @@ export type HassWebsocketAPI = {
172
179
  *
173
180
  * Not the same as `onEvent` (you probably want that)
174
181
  */
175
- subscribe: <EVENT extends string>({
182
+ subscribe: <EVENT extends string, PAYLOAD extends Record<string, unknown> = EmptyObject>({
176
183
  event_type,
177
184
  context,
178
185
  exec,
179
- }: SocketSubscribeOptions<EVENT>) => Promise<RemoveCallback>;
186
+ }: SocketSubscribeOptions<EVENT, PAYLOAD>) => Promise<RemoveCallback>;
180
187
  /**
181
188
  * remove the current socket connection to home assistant
182
189
  *
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  ANY_ENTITY,
3
3
  TAreaId,
4
4
  TDeviceId,
@@ -1,8 +1,9 @@
1
- import { is, TBlackHole } from "@digital-alchemy/core";
2
- import { Dayjs } from "dayjs";
3
- import { Get } from "type-fest";
1
+ import type { TBlackHole } from "@digital-alchemy/core";
2
+ import { is } from "@digital-alchemy/core";
3
+ import type { Dayjs } from "dayjs";
4
+ import type { Get } from "type-fest";
4
5
 
5
- import {
6
+ import type {
6
7
  ALL_DOMAINS,
7
8
  ANY_ENTITY,
8
9
  HassEntitySetupMapping,
@@ -10,7 +11,7 @@ import {
10
11
  PICK_ENTITY,
11
12
  TRawEntityIds,
12
13
  } from "../user.mts";
13
- import { HassEntityContext } from "./entity-state.mts";
14
+ import type { HassEntityContext } from "./entity-state.mts";
14
15
 
15
16
  // ? Casting by domain turns things from "equiv to ANY_ENTITY" to "scene.*" type generics
16
17
  // These are no longer valid comparisons against ANY_ENTITY though
@@ -1,10 +1,11 @@
1
- import { TBlackHole, TContext } from "@digital-alchemy/core";
2
- import { Dayjs } from "dayjs";
1
+ import type { TBlackHole, TContext } from "@digital-alchemy/core";
2
+ import type { Dayjs } from "dayjs";
3
+ import type { EmptyObject } from "type-fest";
3
4
 
4
- import { ALL_DOMAINS, ANY_ENTITY, PICK_ENTITY } from "../user.mts";
5
- import { HassSocketMessageTypes } from "./constants.mts";
6
- import { EntityUpdateEvent } from "./entity-state.mts";
7
- import { ENTITY_STATE } from "./utility.mts";
5
+ import type { ALL_DOMAINS, ANY_ENTITY, PICK_ENTITY } from "../user.mts";
6
+ import type { HassSocketMessageTypes } from "./constants.mts";
7
+ import type { EntityUpdateEvent } from "./entity-state.mts";
8
+ import type { ENTITY_STATE } from "./utility.mts";
8
9
 
9
10
  export interface SignRequestResponse {
10
11
  path: string;
@@ -19,10 +20,13 @@ export interface SocketMessageDTO {
19
20
  type: `${HassSocketMessageTypes}`;
20
21
  }
21
22
 
22
- export type SocketSubscribeOptions<EVENT extends string> = {
23
+ export type SocketSubscribeOptions<
24
+ EVENT extends string,
25
+ PAYLOAD extends Record<string, unknown> = EmptyObject,
26
+ > = {
23
27
  event_type: EVENT;
24
28
  context: TContext;
25
- exec: (data: SocketSubscribeData<EVENT>) => TBlackHole;
29
+ exec: (data: PAYLOAD & SocketSubscribeData<EVENT>) => TBlackHole;
26
30
  };
27
31
 
28
32
  export type SocketSubscribeData<EVENT extends string> = {
package/src/merge.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { PICK_ENTITY } from "./index.mts";
1
+ import type { PICK_ENTITY } from "./index.mts";
2
2
 
3
3
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
4
4
  export interface EntityMergeAttributes {}
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  AreaDetails,
3
3
  DeviceDetails,
4
4
  ENTITY_STATE,
@@ -8,7 +8,7 @@ import {
8
8
  HassServiceDTO as HassServiceDefinition,
9
9
  LabelDefinition,
10
10
  } from "../../helpers/index.mts";
11
- import { ANY_ENTITY } from "../../user.mts";
11
+ import type { ANY_ENTITY } from "../../user.mts";
12
12
 
13
13
  export type ScannerCacheData = {
14
14
  areas: AreaDetails[];
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { CreateApplication, TServiceParams } from "@digital-alchemy/core";
2
+ import type { TServiceParams } from "@digital-alchemy/core";
3
+ import { CreateApplication } from "@digital-alchemy/core";
3
4
  import { writeFileSync } from "fs";
4
5
  import { join } from "path";
5
6
  import { cwd } from "process";
6
7
 
7
8
  import { LIB_HASS } from "../index.mts";
8
- import { ScannerCacheData } from "./helpers/index.mts";
9
+ import type { ScannerCacheData } from "./helpers/index.mts";
9
10
 
10
11
  const writeFixtures = CreateApplication({
11
12
  configuration: {
@@ -1,7 +1,7 @@
1
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
 
3
- import { AreaDetails } from "../../helpers/index.mts";
4
- import { TAreaId } from "../../user.mts";
3
+ import type { AreaDetails } from "../../helpers/index.mts";
4
+ import type { TAreaId } from "../../user.mts";
5
5
 
6
6
  export function MockAreaExtension({ mock_assistant }: TServiceParams) {
7
7
  let areas = new Map<TAreaId, AreaDetails>();
@@ -1,6 +1,7 @@
1
- import { deepExtend, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { deepExtend } from "@digital-alchemy/core";
2
3
 
3
- import { HassConfig } from "../../helpers/index.mts";
4
+ import type { HassConfig } from "../../helpers/index.mts";
4
5
 
5
6
  export function MockConfig({ hass }: TServiceParams) {
6
7
  let config = { components: ["synapse"], version: "2024.4.1" } as HassConfig;
@@ -1,7 +1,8 @@
1
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
 
3
- import { DEVICE_REGISTRY_UPDATED, DeviceDetails } from "../../helpers/index.mts";
4
- import { TDeviceId } from "../../user.mts";
3
+ import type { DeviceDetails } from "../../helpers/index.mts";
4
+ import { DEVICE_REGISTRY_UPDATED } from "../../helpers/index.mts";
5
+ import type { TDeviceId } from "../../user.mts";
5
6
 
6
7
  export function MockDeviceExtension({ mock_assistant }: TServiceParams) {
7
8
  let devices = new Map<TDeviceId, DeviceDetails>();
@@ -1,7 +1,7 @@
1
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
 
3
- import { EntityRegistryItem } from "../../helpers/index.mts";
4
- import { TRawEntityIds } from "../../user.mts";
3
+ import type { EntityRegistryItem } from "../../helpers/index.mts";
4
+ import type { 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,8 @@
1
- import { deepExtend, InternalError, sleep, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { deepExtend, InternalError, sleep } from "@digital-alchemy/core";
2
3
 
3
- import { ENTITY_STATE } from "../../index.mts";
4
- import { PICK_ENTITY, TRawEntityIds } from "../../user.mts";
4
+ import type { ENTITY_STATE } from "../../index.mts";
5
+ import type { PICK_ENTITY, TRawEntityIds } from "../../user.mts";
5
6
 
6
7
  export function MockEntityExtension({
7
8
  hass,
@@ -1,7 +1,8 @@
1
- import { sleep, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { sleep } from "@digital-alchemy/core";
2
3
 
3
- import { ENTITY_STATE, EntityUpdateEvent } from "../../index.mts";
4
- import { ANY_ENTITY } from "../../user.mts";
4
+ import type { ENTITY_STATE, EntityUpdateEvent } from "../../index.mts";
5
+ import type { ANY_ENTITY } from "../../user.mts";
5
6
 
6
7
  const SUPER_SHORT = 1;
7
8
 
@@ -1,9 +1,10 @@
1
- import { BootstrapException, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { BootstrapException } from "@digital-alchemy/core";
2
3
  import { existsSync, readFileSync } from "fs";
3
4
 
4
- import { ENTITY_STATE } from "../../index.mts";
5
- import { ANY_ENTITY } from "../../user.mts";
6
- import { ScannerCacheData } from "../helpers/index.mts";
5
+ import type { ENTITY_STATE } from "../../index.mts";
6
+ import type { ANY_ENTITY } from "../../user.mts";
7
+ import type { ScannerCacheData } from "../helpers/index.mts";
7
8
 
8
9
  type StateOptions = Partial<{
9
10
  [entity in ANY_ENTITY]: Partial<ENTITY_STATE<entity>>;
@@ -1,7 +1,7 @@
1
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
 
3
- import { FloorDetails } from "../../helpers/index.mts";
4
- import { TFloorId } from "../../user.mts";
3
+ import type { FloorDetails } from "../../helpers/index.mts";
4
+ import type { 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
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
 
3
- import { LabelDefinition } from "../../helpers/index.mts";
4
- import { TLabelId } from "../../user.mts";
3
+ import type { LabelDefinition } from "../../helpers/index.mts";
4
+ import type { TLabelId } from "../../user.mts";
5
5
 
6
6
  export function MockLabelExtension({ mock_assistant }: TServiceParams) {
7
7
  let labels = new Map<TLabelId, LabelDefinition>();
@@ -1,6 +1,6 @@
1
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
 
3
- import { HassServiceDTO } from "../../helpers/index.mts";
3
+ import type { HassServiceDTO } from "../../helpers/index.mts";
4
4
 
5
5
  export function MockServices({ hass }: TServiceParams) {
6
6
  let services: HassServiceDTO[];
@@ -1,9 +1,10 @@
1
- import { START, TBlackHole, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TBlackHole, TServiceParams } from "@digital-alchemy/core";
2
+ import { START } from "@digital-alchemy/core";
2
3
  import EventEmitter from "events";
3
- import { PartialDeep, WritableDeep } from "type-fest";
4
- import WS from "ws";
4
+ import type { PartialDeep, WritableDeep } from "type-fest";
5
+ import type WS from "ws";
5
6
 
6
- import { SocketMessageDTO } from "../../helpers/index.mts";
7
+ import type { SocketMessageDTO } from "../../helpers/index.mts";
7
8
 
8
9
  const CONNECTION_CLOSED = 0;
9
10
  // const CONNECTION_OPEN = 1;
@@ -1,7 +1,7 @@
1
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
 
3
- import { ZoneDetails } from "../../helpers/index.mts";
4
- import { TZoneId } from "../../user.mts";
3
+ import type { ZoneDetails } from "../../helpers/index.mts";
4
+ import type { TZoneId } from "../../user.mts";
5
5
 
6
6
  export function MockZoneExtension({ mock_assistant }: TServiceParams) {
7
7
  let zones = new Map<TZoneId, ZoneDetails>();
@@ -1,4 +1,5 @@
1
- import { CreateApplication, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { CreateApplication } from "@digital-alchemy/core";
2
3
 
3
4
  import { LIB_HASS } from "./index.mts";
4
5
 
@@ -1,15 +1,9 @@
1
- import { debounce, eachSeries, InternalError, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { debounce, eachSeries, InternalError } from "@digital-alchemy/core";
2
3
 
3
- import {
4
- AREA_REGISTRY_UPDATED,
5
- AreaCreate,
6
- AreaDetails,
7
- EARLY_ON_READY,
8
- ENTITY_REGISTRY_UPDATED,
9
- HassAreaService,
10
- perf,
11
- } from "../index.mts";
12
- import { ANY_ENTITY, TAreaId } from "../user.mts";
4
+ import type { AreaCreate, AreaDetails, HassAreaService } from "../index.mts";
5
+ import { AREA_REGISTRY_UPDATED, EARLY_ON_READY, ENTITY_REGISTRY_UPDATED, perf } from "../index.mts";
6
+ import type { ANY_ENTITY, TAreaId } from "../user.mts";
13
7
 
14
8
  export function Area({
15
9
  hass,
@@ -1,6 +1,7 @@
1
- import { SECOND, sleep, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { SECOND, sleep } from "@digital-alchemy/core";
2
3
 
3
- import {
4
+ import type {
4
5
  BackupResponse,
5
6
  HassBackupService,
6
7
  HomeAssistantBackup,
@@ -1,12 +1,12 @@
1
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
 
3
- import {
3
+ import type {
4
4
  ALL_SERVICE_DOMAINS,
5
- perf,
6
5
  PICK_SERVICE,
7
6
  PICK_SERVICE_PARAMETERS,
8
7
  } from "../helpers/index.mts";
9
- import { iCallService } from "../user.mts";
8
+ import { perf } from "../helpers/index.mts";
9
+ import type { iCallService } from "../user.mts";
10
10
 
11
11
  export function CallProxy({
12
12
  logger,
@@ -1,14 +1,11 @@
1
1
  /* eslint-disable @typescript-eslint/no-magic-numbers */
2
- import { asyncNoop, INCREMENT, SECOND, sleep, START, TServiceParams } from "@digital-alchemy/core";
2
+ import type { TServiceParams } from "@digital-alchemy/core";
3
+ import { asyncNoop, INCREMENT, SECOND, sleep, START } from "@digital-alchemy/core";
3
4
  import { env } from "process";
4
5
 
5
- import {
6
- ALL_SERVICE_DOMAINS,
7
- HassConfigService,
8
- HassServiceDTO,
9
- PostConfigPriorities,
10
- } from "../helpers/index.mts";
11
- import { iCallService } from "../user.mts";
6
+ import type { ALL_SERVICE_DOMAINS, HassConfigService, HassServiceDTO } from "../helpers/index.mts";
7
+ import { PostConfigPriorities } from "../helpers/index.mts";
8
+ import type { iCallService } from "../user.mts";
12
9
 
13
10
  const MAX_ATTEMPTS = 50;
14
11
  const FAILED = 1;
@@ -1,11 +1,7 @@
1
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
 
3
- import {
4
- EditAliasOptions,
5
- HassConversationService,
6
- ToggleExpose,
7
- UPDATE_REGISTRY,
8
- } from "../helpers/index.mts";
3
+ import type { EditAliasOptions, HassConversationService, ToggleExpose } from "../helpers/index.mts";
4
+ import { UPDATE_REGISTRY } from "../helpers/index.mts";
9
5
 
10
6
  export function Conversation({ hass, logger }: TServiceParams): HassConversationService {
11
7
  async function addAlias({ entity, alias }: EditAliasOptions) {
@@ -1,12 +1,8 @@
1
- import { debounce, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { debounce } from "@digital-alchemy/core";
2
3
 
3
- import {
4
- DEVICE_REGISTRY_UPDATED,
5
- DeviceDetails,
6
- EARLY_ON_READY,
7
- HassDeviceService,
8
- perf,
9
- } from "../helpers/index.mts";
4
+ import type { DeviceDetails, HassDeviceService } from "../helpers/index.mts";
5
+ import { DEVICE_REGISTRY_UPDATED, EARLY_ON_READY, perf } from "../helpers/index.mts";
10
6
 
11
7
  export function Device({
12
8
  hass,
@@ -1,4 +1,4 @@
1
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
  import { channel } from "diagnostics_channel";
3
3
 
4
4
  function createDiagnostics<CHANNEL extends string>(context: string, channels: CHANNEL[]) {
@@ -1,28 +1,20 @@
1
- import {
2
- debounce,
3
- each,
4
- eachSeries,
5
- INCREMENT,
6
- SECOND,
7
- sleep,
8
- START,
9
- TServiceParams,
10
- } from "@digital-alchemy/core";
11
- import dayjs, { Dayjs } from "dayjs";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { debounce, each, eachSeries, INCREMENT, SECOND, sleep, START } from "@digital-alchemy/core";
3
+ import type { Dayjs } from "dayjs";
4
+ import dayjs from "dayjs";
12
5
 
13
- import {
6
+ import type {
14
7
  EditLabelOptions,
15
- ENTITY_REGISTRY_UPDATED,
16
8
  ENTITY_STATE,
17
9
  EntityHistoryDTO,
18
10
  EntityHistoryItem,
19
11
  EntityHistoryResult,
20
12
  EntityRegistryItem,
21
13
  HassEntityManager,
22
- perf,
23
14
  TMasterState,
24
15
  } from "../index.mts";
25
- import { ALL_DOMAINS, ANY_ENTITY, PICK_ENTITY } from "../user.mts";
16
+ import { ENTITY_REGISTRY_UPDATED, perf } from "../index.mts";
17
+ import type { ALL_DOMAINS, ANY_ENTITY, PICK_ENTITY } from "../user.mts";
26
18
 
27
19
  const MAX_ATTEMPTS = 10;
28
20
  const RECENT = 5;
@@ -1,13 +1,12 @@
1
- import { TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
2
 
3
+ import type { HassEventsService, SimpleCallback } from "../helpers/index.mts";
3
4
  import {
4
5
  AREA_REGISTRY_UPDATED,
5
6
  DEVICE_REGISTRY_UPDATED,
6
7
  ENTITY_REGISTRY_UPDATED,
7
8
  FLOOR_REGISTRY_UPDATED,
8
- HassEventsService,
9
9
  LABEL_REGISTRY_UPDATED,
10
- SimpleCallback,
11
10
  ZONE_REGISTRY_UPDATED,
12
11
  } from "../helpers/index.mts";
13
12
 
@@ -1,8 +1,10 @@
1
- import { DOWN, NO_CHANGE, SECOND, TServiceParams, UP } from "@digital-alchemy/core";
2
- import dayjs, { Dayjs } from "dayjs";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { DOWN, NO_CHANGE, SECOND, UP } from "@digital-alchemy/core";
3
+ import type { Dayjs } from "dayjs";
4
+ import dayjs from "dayjs";
3
5
 
4
- import { FetchArguments, FilteredFetchArguments, TFetchBody } from "../helpers/fetch.mts";
5
- import {
6
+ import type { FetchArguments, FilteredFetchArguments, TFetchBody } from "../helpers/fetch.mts";
7
+ import type {
6
8
  ALL_SERVICE_DOMAINS,
7
9
  CalendarEvent,
8
10
  CalendarFetchOptions,
@@ -11,13 +13,12 @@ import {
11
13
  HassConfig,
12
14
  HassServiceDTO,
13
15
  HomeAssistantServerLogItem,
14
- perf,
15
16
  PICK_SERVICE,
16
17
  PICK_SERVICE_PARAMETERS,
17
- PostConfigPriorities,
18
18
  RawCalendarEvent,
19
19
  } from "../helpers/index.mts";
20
- import { ANY_ENTITY } from "../user.mts";
20
+ import { perf, PostConfigPriorities } from "../helpers/index.mts";
21
+ import type { ANY_ENTITY } from "../user.mts";
21
22
 
22
23
  type SendBody<STATE extends string | number = string, ATTRIBUTES extends object = object> = {
23
24
  attributes?: ATTRIBUTES;
@@ -1,14 +1,9 @@
1
- import { debounce, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { debounce } from "@digital-alchemy/core";
2
3
 
3
- import {
4
- EARLY_ON_READY,
5
- FLOOR_REGISTRY_UPDATED,
6
- FloorCreate,
7
- FloorDetails,
8
- HassFloorService,
9
- perf,
10
- } from "../helpers/index.mts";
11
- import { TFloorId } from "../user.mts";
4
+ import type { FloorCreate, FloorDetails, HassFloorService } from "../helpers/index.mts";
5
+ import { EARLY_ON_READY, FLOOR_REGISTRY_UPDATED, perf } from "../helpers/index.mts";
6
+ import type { TFloorId } from "../user.mts";
12
7
 
13
8
  export function Floor({
14
9
  hass,
@@ -1,7 +1,9 @@
1
- import { FIRST, SINGLE, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { FIRST, SINGLE } from "@digital-alchemy/core";
2
3
 
3
- import { domain, EntityRegistryItem, IDByInterface } from "../index.mts";
4
- import {
4
+ import type { EntityRegistryItem, IDByInterface } from "../index.mts";
5
+ import { domain } from "../index.mts";
6
+ import type {
5
7
  ALL_DOMAINS,
6
8
  ANY_ENTITY,
7
9
  HassUniqueIdMapping,
@@ -1,19 +1,19 @@
1
- import { FIRST, InternalError, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { FIRST, InternalError } from "@digital-alchemy/core";
2
3
  import { createWriteStream } from "fs";
3
4
  import { pipeline } from "stream";
4
5
  import { promisify } from "util";
5
6
 
6
- import {
7
- buildFilterString,
7
+ import type {
8
8
  DownloadOptions,
9
9
  FetchArguments,
10
10
  FetcherOptions,
11
11
  FetchProcessTypes,
12
12
  FetchWith,
13
- isDomain,
14
13
  MaybeHttpError,
15
14
  TFetchBody,
16
15
  } from "../helpers/index.mts";
16
+ import { buildFilterString, isDomain } from "../helpers/index.mts";
17
17
 
18
18
  const streamPipeline = promisify(pipeline);
19
19
 
@@ -1,14 +1,9 @@
1
- import { debounce, TServiceParams } from "@digital-alchemy/core";
1
+ import type { TServiceParams } from "@digital-alchemy/core";
2
+ import { debounce } from "@digital-alchemy/core";
2
3
 
3
- import {
4
- EARLY_ON_READY,
5
- HassLabelService,
6
- LABEL_REGISTRY_UPDATED,
7
- LabelDefinition,
8
- LabelOptions,
9
- perf,
10
- } from "../helpers/index.mts";
11
- import { TLabelId } from "../user.mts";
4
+ import type { HassLabelService, LabelDefinition, LabelOptions } from "../helpers/index.mts";
5
+ import { EARLY_ON_READY, LABEL_REGISTRY_UPDATED, perf } from "../helpers/index.mts";
6
+ import type { TLabelId } from "../user.mts";
12
7
 
13
8
  export function Label({
14
9
  hass,