@digital-alchemy/hass 24.7.1 → 24.7.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/dynamic.d.ts +30 -4
- package/dist/extensions/events.extension.d.ts +11 -0
- package/dist/extensions/events.extension.js +15 -0
- package/dist/extensions/events.extension.js.map +1 -0
- package/dist/extensions/index.d.ts +1 -0
- package/dist/extensions/index.js +1 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/zone.extension.d.ts +1 -1
- package/dist/extensions/zone.extension.js +8 -4
- package/dist/extensions/zone.extension.js.map +1 -1
- package/dist/hass.module.d.ts +5 -1
- package/dist/hass.module.js +4 -0
- package/dist/hass.module.js.map +1 -1
- package/dist/helpers/constants.helper.d.ts +1 -0
- package/dist/helpers/constants.helper.js +2 -1
- package/dist/helpers/constants.helper.js.map +1 -1
- package/dist/testing/events.spec.d.ts +1 -0
- package/dist/testing/events.spec.js +89 -0
- package/dist/testing/events.spec.js.map +1 -0
- package/dist/testing/zone.spec.d.ts +1 -0
- package/dist/testing/zone.spec.js +121 -0
- package/dist/testing/zone.spec.js.map +1 -0
- package/package.json +4 -4
package/dist/dynamic.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { ActionableNotification, AndroidActionableNotification, AppleActionableNotification, PICK_ENTITY } from "./helpers";
|
|
2
2
|
type PICK_FROM_PLATFORM<ID extends TPlatformId, DOMAIN extends TRawDomains = TRawDomains> = Extract<REGISTRY_SETUP["platform"][`_${ID}`], PICK_ENTITY<DOMAIN>>;
|
|
3
3
|
export type ENTITY_SETUP = {
|
|
4
|
+
"button.example": {
|
|
5
|
+
state: string;
|
|
6
|
+
entity_id: "button.example";
|
|
7
|
+
attributes: {
|
|
8
|
+
friendly_name: "Example button";
|
|
9
|
+
};
|
|
10
|
+
};
|
|
4
11
|
"binary_sensor.hass_e2e_online": {
|
|
5
12
|
attributes: {
|
|
6
13
|
friendly_name: "hass_e2e online";
|
|
@@ -2277,6 +2284,24 @@ export type iCallService = {
|
|
|
2277
2284
|
*/
|
|
2278
2285
|
set_level(service_data: {}): Promise<void>;
|
|
2279
2286
|
};
|
|
2287
|
+
button: {
|
|
2288
|
+
/**
|
|
2289
|
+
* ### Press
|
|
2290
|
+
*
|
|
2291
|
+
* > Press the button entity.
|
|
2292
|
+
*/
|
|
2293
|
+
press(service_data: {
|
|
2294
|
+
/**
|
|
2295
|
+
* Assisted definition
|
|
2296
|
+
* > ```yaml
|
|
2297
|
+
* > entity:
|
|
2298
|
+
* > - domain:
|
|
2299
|
+
* > - button
|
|
2300
|
+
* > ```
|
|
2301
|
+
*/
|
|
2302
|
+
entity_id: PICK_ENTITY<"button"> | PICK_ENTITY<"button">[];
|
|
2303
|
+
}): Promise<void>;
|
|
2304
|
+
};
|
|
2280
2305
|
notify: {
|
|
2281
2306
|
/**
|
|
2282
2307
|
* ### Send a notification with notify
|
|
@@ -3684,7 +3709,7 @@ export type REGISTRY_SETUP = {
|
|
|
3684
3709
|
_person: "person.digital_alchemy";
|
|
3685
3710
|
_shopping_list: "todo.shopping_list";
|
|
3686
3711
|
_google_translate: "tts.google_en_com";
|
|
3687
|
-
_synapse: "binary_sensor.hass_e2e_online" | "sensor.magic" | "binary_sensor.toggles" | "switch.bedroom_lamp" | "switch.kitchen_cabinets" | "switch.living_room_mood_lights" | "switch.porch_light";
|
|
3712
|
+
_synapse: "binary_sensor.hass_e2e_online" | "sensor.magic" | "button.example" | "binary_sensor.toggles" | "switch.bedroom_lamp" | "switch.kitchen_cabinets" | "switch.living_room_mood_lights" | "switch.porch_light";
|
|
3688
3713
|
_holiday: "calendar.united_states_tx";
|
|
3689
3714
|
};
|
|
3690
3715
|
label: {
|
|
@@ -3696,7 +3721,7 @@ export type REGISTRY_SETUP = {
|
|
|
3696
3721
|
_upstairs: "switch.bedroom_lamp";
|
|
3697
3722
|
};
|
|
3698
3723
|
device: {
|
|
3699
|
-
_308e39cf50a9fc6c30b4110724ed1f2e: "sensor.sun_next_dawn" | "sensor.sun_next_dusk" | "sensor.sun_next_midnight" | "sensor.sun_next_noon" | "sensor.sun_next_rising" | "sensor.sun_next_setting" | "sensor.sun_solar_elevation" | "sensor.sun_solar_azimuth" | "sensor.sun_solar_rising";
|
|
3724
|
+
_308e39cf50a9fc6c30b4110724ed1f2e: "sensor.sun_next_dawn" | "sensor.sun_next_dusk" | "sensor.sun_next_midnight" | "sensor.sun_next_noon" | "sensor.sun_next_rising" | "sensor.sun_next_setting" | "button.example" | "sensor.sun_solar_elevation" | "sensor.sun_solar_azimuth" | "sensor.sun_solar_rising";
|
|
3700
3725
|
_e58841e47cf86097b310316e55d6bb12: "calendar.united_states_tx";
|
|
3701
3726
|
};
|
|
3702
3727
|
};
|
|
@@ -3705,9 +3730,9 @@ export type TDeviceId = "308e39cf50a9fc6c30b4110724ed1f2e" | "e58841e47cf86097b3
|
|
|
3705
3730
|
export type TFloorId = "downstairs" | "upstairs";
|
|
3706
3731
|
export type TLabelId = "synapse" | "test";
|
|
3707
3732
|
export type TZoneId = string;
|
|
3708
|
-
export type TRawEntityIds = "person.digital_alchemy" | "zone.home" | "sun.sun" | "sensor.sun_next_dawn" | "sensor.sun_next_dusk" | "sensor.sun_next_midnight" | "sensor.sun_next_noon" | "light.bedroom_ceiling_fan" | "scene.games_room_auto" | "sensor.sun_next_rising" | "sensor.sun_next_setting" | "todo.shopping_list" | "tts.google_en_com" | "binary_sensor.hass_e2e_online" | "sensor.magic" | "binary_sensor.toggles" | "switch.bedroom_lamp" | "switch.kitchen_cabinets" | "switch.living_room_mood_lights" | "switch.porch_light" | "calendar.united_states_tx";
|
|
3733
|
+
export type TRawEntityIds = "person.digital_alchemy" | "zone.home" | "sun.sun" | "sensor.sun_next_dawn" | "sensor.sun_next_dusk" | "button.example" | "sensor.sun_next_midnight" | "sensor.sun_next_noon" | "light.bedroom_ceiling_fan" | "scene.games_room_auto" | "sensor.sun_next_rising" | "sensor.sun_next_setting" | "todo.shopping_list" | "tts.google_en_com" | "binary_sensor.hass_e2e_online" | "sensor.magic" | "binary_sensor.toggles" | "switch.bedroom_lamp" | "switch.kitchen_cabinets" | "switch.living_room_mood_lights" | "switch.porch_light" | "calendar.united_states_tx";
|
|
3709
3734
|
export type TPlatformId = "sun" | "person" | "shopping_list" | "google_translate" | "synapse" | "holiday";
|
|
3710
|
-
export type TRawDomains = "person" | "zone" | "sun" | "light" | "scene" | "sensor" | "todo" | "tts" | "binary_sensor" | "switch" | "calendar";
|
|
3735
|
+
export type TRawDomains = "person" | "zone" | "sun" | "light" | "scene" | "button" | "sensor" | "todo" | "tts" | "binary_sensor" | "switch" | "calendar";
|
|
3711
3736
|
export type TUniqueIDMapping = {
|
|
3712
3737
|
"5622d76001a335e3ea893c4d60d31b3d-next_dawn": "sensor.sun_next_dawn";
|
|
3713
3738
|
"5622d76001a335e3ea893c4d60d31b3d-next_dusk": "sensor.sun_next_dusk";
|
|
@@ -3716,6 +3741,7 @@ export type TUniqueIDMapping = {
|
|
|
3716
3741
|
"5622d76001a335e3ea893c4d60d31b3d-next_rising": "sensor.sun_next_rising";
|
|
3717
3742
|
"5622d76001a335e3ea893c4d60d31b3d-next_setting": "sensor.sun_next_setting";
|
|
3718
3743
|
"5622d76001a335e3ea893c4d60d31b3d-solar_elevation": "sensor.sun_solar_elevation";
|
|
3744
|
+
"6d8acf36200c5ff8d2d9bb1b1f1dbe00c7eb5b7540103fd90c9a035f82967431": "button.start_white_noise";
|
|
3719
3745
|
"5622d76001a335e3ea893c4d60d31b3d-solar_azimuth": "sensor.sun_solar_azimuth";
|
|
3720
3746
|
"5622d76001a335e3ea893c4d60d31b3d-solar_rising": "sensor.sun_solar_rising";
|
|
3721
3747
|
digital_alchemy: "person.digital_alchemy";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TBlackHole, TServiceParams } from "@digital-alchemy/core";
|
|
2
|
+
type SimpleCallback = () => TBlackHole;
|
|
3
|
+
export declare function Events({ event }: TServiceParams): {
|
|
4
|
+
onAreaRegistryUpdate: (callback: SimpleCallback) => import("events")<[never]>;
|
|
5
|
+
onDeviceRegistryUpdate: (callback: SimpleCallback) => import("events")<[never]>;
|
|
6
|
+
onEntityRegistryUpdate: (callback: SimpleCallback) => import("events")<[never]>;
|
|
7
|
+
onFloorRegistryUpdate: (callback: SimpleCallback) => import("events")<[never]>;
|
|
8
|
+
onLabelRegistryUpdate: (callback: SimpleCallback) => import("events")<[never]>;
|
|
9
|
+
onZoneRegistryUpdate: (callback: SimpleCallback) => import("events")<[never]>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Events = Events;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
function Events({ event }) {
|
|
6
|
+
return {
|
|
7
|
+
onAreaRegistryUpdate: (callback) => event.on(helpers_1.AREA_REGISTRY_UPDATED, callback),
|
|
8
|
+
onDeviceRegistryUpdate: (callback) => event.on(helpers_1.DEVICE_REGISTRY_UPDATED, callback),
|
|
9
|
+
onEntityRegistryUpdate: (callback) => event.on(helpers_1.ENTITY_REGISTRY_UPDATED, callback),
|
|
10
|
+
onFloorRegistryUpdate: (callback) => event.on(helpers_1.FLOOR_REGISTRY_UPDATED, callback),
|
|
11
|
+
onLabelRegistryUpdate: (callback) => event.on(helpers_1.LABEL_REGISTRY_UPDATED, callback),
|
|
12
|
+
onZoneRegistryUpdate: (callback) => event.on(helpers_1.ZONE_REGISTRY_UPDATED, callback),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=events.extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.extension.js","sourceRoot":"","sources":["../../src/extensions/events.extension.ts"],"names":[],"mappings":";;AAaA,wBAeC;AA1BD,wCAOoB;AAIpB,SAAgB,MAAM,CAAC,EAAE,KAAK,EAAkB;IAC9C,OAAO;QACL,oBAAoB,EAAE,CAAC,QAAwB,EAAE,EAAE,CACjD,KAAK,CAAC,EAAE,CAAC,+BAAqB,EAAE,QAAQ,CAAC;QAC3C,sBAAsB,EAAE,CAAC,QAAwB,EAAE,EAAE,CACnD,KAAK,CAAC,EAAE,CAAC,iCAAuB,EAAE,QAAQ,CAAC;QAC7C,sBAAsB,EAAE,CAAC,QAAwB,EAAE,EAAE,CACnD,KAAK,CAAC,EAAE,CAAC,iCAAuB,EAAE,QAAQ,CAAC;QAC7C,qBAAqB,EAAE,CAAC,QAAwB,EAAE,EAAE,CAClD,KAAK,CAAC,EAAE,CAAC,gCAAsB,EAAE,QAAQ,CAAC;QAC5C,qBAAqB,EAAE,CAAC,QAAwB,EAAE,EAAE,CAClD,KAAK,CAAC,EAAE,CAAC,gCAAsB,EAAE,QAAQ,CAAC;QAC5C,oBAAoB,EAAE,CAAC,QAAwB,EAAE,EAAE,CACjD,KAAK,CAAC,EAAE,CAAC,+BAAqB,EAAE,QAAQ,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -4,6 +4,7 @@ export * from "./call-proxy.extension";
|
|
|
4
4
|
export * from "./config.extension";
|
|
5
5
|
export * from "./device.extension";
|
|
6
6
|
export * from "./entity.extension";
|
|
7
|
+
export * from "./events.extension";
|
|
7
8
|
export * from "./fetch-api.extension";
|
|
8
9
|
export * from "./floor.extension";
|
|
9
10
|
export * from "./id-by.extension";
|
package/dist/extensions/index.js
CHANGED
|
@@ -7,6 +7,7 @@ tslib_1.__exportStar(require("./call-proxy.extension"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./config.extension"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./device.extension"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./entity.extension"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./events.extension"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./fetch-api.extension"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./floor.extension"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./id-by.extension"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,6DAAmC;AACnC,iEAAuC;AACvC,6DAAmC;AACnC,6DAAmC;AACnC,6DAAmC;AACnC,gEAAsC;AACtC,4DAAkC;AAClC,4DAAkC;AAClC,4DAAkC;AAClC,gEAAsC;AACtC,+DAAqC;AACrC,oEAA0C;AAC1C,2DAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,6DAAmC;AACnC,iEAAuC;AACvC,6DAAmC;AACnC,6DAAmC;AACnC,6DAAmC;AACnC,6DAAmC;AACnC,gEAAsC;AACtC,4DAAkC;AAClC,4DAAkC;AAClC,4DAAkC;AAClC,gEAAsC;AACtC,+DAAqC;AACrC,oEAA0C;AAC1C,2DAAiC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TServiceParams } from "@digital-alchemy/core";
|
|
2
2
|
import { ZoneDetails, ZoneOptions } from "../helpers";
|
|
3
|
-
export declare function Zone({ config, hass, logger, context, lifecycle, }: TServiceParams): {
|
|
3
|
+
export declare function Zone({ config, hass, event, logger, context, lifecycle, }: TServiceParams): {
|
|
4
4
|
create: (options: ZoneOptions) => Promise<void>;
|
|
5
5
|
current: ZoneDetails[];
|
|
6
6
|
list: () => Promise<ZoneDetails[]>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Zone = Zone;
|
|
4
4
|
const helpers_1 = require("../helpers");
|
|
5
|
-
function Zone({ config, hass, logger, context, lifecycle, }) {
|
|
5
|
+
function Zone({ config, hass, event, logger, context, lifecycle, }) {
|
|
6
6
|
hass.socket.onConnect(async () => {
|
|
7
7
|
if (!config.hass.AUTO_CONNECT_SOCKET || !config.hass.MANAGE_REGISTRY) {
|
|
8
8
|
return;
|
|
@@ -20,12 +20,16 @@ function Zone({ config, hass, logger, context, lifecycle, }) {
|
|
|
20
20
|
async exec() {
|
|
21
21
|
hass.zone.current = await hass.zone.list();
|
|
22
22
|
logger.debug(`zone registry updated`);
|
|
23
|
+
event.emit(helpers_1.ZONE_REGISTRY_UPDATED);
|
|
23
24
|
},
|
|
24
25
|
});
|
|
25
26
|
async function ZoneCreate(options) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
return new Promise(async (done) => {
|
|
28
|
+
event.once(helpers_1.ZONE_REGISTRY_UPDATED, done);
|
|
29
|
+
await hass.socket.sendMessage({
|
|
30
|
+
...options,
|
|
31
|
+
type: "zone/create",
|
|
32
|
+
});
|
|
29
33
|
});
|
|
30
34
|
}
|
|
31
35
|
async function ZoneUpdate(zone_id, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zone.extension.js","sourceRoot":"","sources":["../../src/extensions/zone.extension.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"zone.extension.js","sourceRoot":"","sources":["../../src/extensions/zone.extension.ts"],"names":[],"mappings":";;AAUA,oBA2DC;AAnED,wCAMoB;AAEpB,SAAgB,IAAI,CAAC,EACnB,MAAM,EACN,IAAI,EACJ,KAAK,EACL,MAAM,EACN,OAAO,EACP,SAAS,GACM;IACf,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC/B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACrE,OAAO;QACT,CAAC;QACD,IAAI,OAAO,GAAG,IAAI,OAAO,CAAO,KAAK,EAAC,IAAI,EAAC,EAAE;YAC3C,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,CAAC,IAA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,EAAE,EAAmB;QAC5B,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,UAAU;KACnB,CAAC;AACJ,CAAC"}
|
package/dist/hass.module.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StringConfig } from "@digital-alchemy/core";
|
|
2
|
-
import { Area, Backup, CallProxy, Configure, Device, EntityManager, FetchAPI, Floor, Label, Registry, WebsocketAPI, Zone } from "./extensions";
|
|
2
|
+
import { Area, Backup, CallProxy, Configure, Device, EntityManager, Events, FetchAPI, Floor, Label, Registry, WebsocketAPI, Zone } from "./extensions";
|
|
3
3
|
import { IDByExtension } from "./extensions/id-by.extension";
|
|
4
4
|
import { ReferenceExtension } from "./extensions/reference.extension";
|
|
5
5
|
type AllowRestOptions = "prefer" | "allow" | "forbid";
|
|
@@ -19,6 +19,10 @@ export declare const LIB_HASS: import("@digital-alchemy/core").LibraryDefinition
|
|
|
19
19
|
* retrieve and interact with home assistant entities
|
|
20
20
|
*/
|
|
21
21
|
entity: typeof EntityManager;
|
|
22
|
+
/**
|
|
23
|
+
* Named event attachments
|
|
24
|
+
*/
|
|
25
|
+
events: typeof Events;
|
|
22
26
|
/**
|
|
23
27
|
* rest api commands
|
|
24
28
|
*/
|
package/dist/hass.module.js
CHANGED
|
@@ -108,6 +108,10 @@ exports.LIB_HASS = (0, core_1.CreateLibrary)({
|
|
|
108
108
|
* retrieve and interact with home assistant entities
|
|
109
109
|
*/
|
|
110
110
|
entity: extensions_1.EntityManager,
|
|
111
|
+
/**
|
|
112
|
+
* Named event attachments
|
|
113
|
+
*/
|
|
114
|
+
events: extensions_1.Events,
|
|
111
115
|
/**
|
|
112
116
|
* rest api commands
|
|
113
117
|
*/
|
package/dist/hass.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hass.module.js","sourceRoot":"","sources":["../src/hass.module.ts"],"names":[],"mappings":";;;AAAA,gDAAoE;AAEpE,
|
|
1
|
+
{"version":3,"file":"hass.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GISTRY_UPDATED = "LABEL_REGISTRY_UPDATED";
|
|
18
18
|
export declare const FLOOR_REGISTRY_UPDATED = "FLOOR_REGISTRY_UPDATED";
|
|
19
19
|
export declare const DEVICE_REGISTRY_UPDATED = "DEVICE_REGISTRY_UPDATED";
|
|
20
|
+
export declare const ZONE_REGISTRY_UPDATED = "ZONE_REGISTRY_UPDATED";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEVICE_REGISTRY_UPDATED = exports.FLOOR_REGISTRY_UPDATED = exports.LABEL_REGISTRY_UPDATED = exports.AREA_REGISTRY_UPDATED = exports.ENTITY_REGISTRY_UPDATED = exports.EARLY_ON_READY = exports.HOME_ASSISTANT_MODULE_CONFIGURATION = exports.HassSocketMessageTypes = exports.SOCKET_READY = exports.ALL_ENTITIES_UPDATED = exports.HASS_ENTITY_GROUP = exports.HASS_ENTITY = void 0;
|
|
3
|
+
exports.ZONE_REGISTRY_UPDATED = exports.DEVICE_REGISTRY_UPDATED = exports.FLOOR_REGISTRY_UPDATED = exports.LABEL_REGISTRY_UPDATED = exports.AREA_REGISTRY_UPDATED = exports.ENTITY_REGISTRY_UPDATED = exports.EARLY_ON_READY = exports.HOME_ASSISTANT_MODULE_CONFIGURATION = exports.HassSocketMessageTypes = exports.SOCKET_READY = exports.ALL_ENTITIES_UPDATED = exports.HASS_ENTITY_GROUP = exports.HASS_ENTITY = void 0;
|
|
4
4
|
exports.HASS_ENTITY = "HASS_ENTITY";
|
|
5
5
|
exports.HASS_ENTITY_GROUP = "HASS_ENTITY_GROUP";
|
|
6
6
|
exports.ALL_ENTITIES_UPDATED = "ALL_ENTITIES_UPDATED";
|
|
@@ -21,4 +21,5 @@ exports.AREA_REGISTRY_UPDATED = "AREA_REGISTRY_UPDATED";
|
|
|
21
21
|
exports.LABEL_REGISTRY_UPDATED = "LABEL_REGISTRY_UPDATED";
|
|
22
22
|
exports.FLOOR_REGISTRY_UPDATED = "FLOOR_REGISTRY_UPDATED";
|
|
23
23
|
exports.DEVICE_REGISTRY_UPDATED = "DEVICE_REGISTRY_UPDATED";
|
|
24
|
+
exports.ZONE_REGISTRY_UPDATED = "ZONE_REGISTRY_UPDATED";
|
|
24
25
|
//# sourceMappingURL=constants.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.helper.js","sourceRoot":"","sources":["../../src/helpers/constants.helper.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,aAAa,CAAC;AAC5B,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,YAAY,GAAG,cAAc,CAAC;AAE3C,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,yDAA+B,CAAA;IAC/B,6CAAmB,CAAA;IACnB,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,uCAAa,CAAA;IACb,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,sCAAtB,sBAAsB,QAOjC;AAEY,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAE3B,QAAA,cAAc,GAAG,CAAC,CAAC;AACnB,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AACpD,QAAA,qBAAqB,GAAG,uBAAuB,CAAC;AAChD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,uBAAuB,GAAG,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.helper.js","sourceRoot":"","sources":["../../src/helpers/constants.helper.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,aAAa,CAAC;AAC5B,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,YAAY,GAAG,cAAc,CAAC;AAE3C,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,yDAA+B,CAAA;IAC/B,6CAAmB,CAAA;IACnB,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,uCAAa,CAAA;IACb,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,sCAAtB,sBAAsB,QAOjC;AAEY,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAE3B,QAAA,cAAc,GAAG,CAAC,CAAC;AACnB,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AACpD,QAAA,qBAAqB,GAAG,uBAAuB,CAAC;AAChD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AACpD,QAAA,qBAAqB,GAAG,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpers_1 = require("../helpers");
|
|
4
|
+
const mock_assistant_1 = require("../mock_assistant");
|
|
5
|
+
describe("Events", () => {
|
|
6
|
+
let application;
|
|
7
|
+
afterEach(async () => {
|
|
8
|
+
if (application) {
|
|
9
|
+
await application.teardown();
|
|
10
|
+
application = undefined;
|
|
11
|
+
}
|
|
12
|
+
jest.restoreAllMocks();
|
|
13
|
+
});
|
|
14
|
+
describe("Event Callbacks", () => {
|
|
15
|
+
it("should register callback for AREA_REGISTRY_UPDATED", async () => {
|
|
16
|
+
expect.assertions(1);
|
|
17
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
18
|
+
Test({ event, hass }) {
|
|
19
|
+
const spy = jest.spyOn(event, "on");
|
|
20
|
+
const callback = jest.fn();
|
|
21
|
+
hass.events.onAreaRegistryUpdate(callback);
|
|
22
|
+
expect(spy).toHaveBeenCalledWith(helpers_1.AREA_REGISTRY_UPDATED, callback);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
26
|
+
});
|
|
27
|
+
it("should register callback for DEVICE_REGISTRY_UPDATED", async () => {
|
|
28
|
+
expect.assertions(1);
|
|
29
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
30
|
+
Test({ event, hass }) {
|
|
31
|
+
const spy = jest.spyOn(event, "on");
|
|
32
|
+
const callback = jest.fn();
|
|
33
|
+
hass.events.onDeviceRegistryUpdate(callback);
|
|
34
|
+
expect(spy).toHaveBeenCalledWith(helpers_1.DEVICE_REGISTRY_UPDATED, callback);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
38
|
+
});
|
|
39
|
+
it("should register callback for ENTITY_REGISTRY_UPDATED", async () => {
|
|
40
|
+
expect.assertions(1);
|
|
41
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
42
|
+
Test({ event, hass }) {
|
|
43
|
+
const spy = jest.spyOn(event, "on");
|
|
44
|
+
const callback = jest.fn();
|
|
45
|
+
hass.events.onEntityRegistryUpdate(callback);
|
|
46
|
+
expect(spy).toHaveBeenCalledWith(helpers_1.ENTITY_REGISTRY_UPDATED, callback);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
50
|
+
});
|
|
51
|
+
it("should register callback for FLOOR_REGISTRY_UPDATED", async () => {
|
|
52
|
+
expect.assertions(1);
|
|
53
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
54
|
+
Test({ event, hass }) {
|
|
55
|
+
const spy = jest.spyOn(event, "on");
|
|
56
|
+
const callback = jest.fn();
|
|
57
|
+
hass.events.onFloorRegistryUpdate(callback);
|
|
58
|
+
expect(spy).toHaveBeenCalledWith(helpers_1.FLOOR_REGISTRY_UPDATED, callback);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
62
|
+
});
|
|
63
|
+
it("should register callback for LABEL_REGISTRY_UPDATED", async () => {
|
|
64
|
+
expect.assertions(1);
|
|
65
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
66
|
+
Test({ event, hass }) {
|
|
67
|
+
const spy = jest.spyOn(event, "on");
|
|
68
|
+
const callback = jest.fn();
|
|
69
|
+
hass.events.onLabelRegistryUpdate(callback);
|
|
70
|
+
expect(spy).toHaveBeenCalledWith(helpers_1.LABEL_REGISTRY_UPDATED, callback);
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
74
|
+
});
|
|
75
|
+
it("should register callback for ZONE_REGISTRY_UPDATED", async () => {
|
|
76
|
+
expect.assertions(1);
|
|
77
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
78
|
+
Test({ event, hass }) {
|
|
79
|
+
const spy = jest.spyOn(event, "on");
|
|
80
|
+
const callback = jest.fn();
|
|
81
|
+
hass.events.onZoneRegistryUpdate(callback);
|
|
82
|
+
expect(spy).toHaveBeenCalledWith(helpers_1.ZONE_REGISTRY_UPDATED, callback);
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=events.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.spec.js","sourceRoot":"","sources":["../../src/testing/events.spec.ts"],"names":[],"mappings":";;AAOA,wCAOoB;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AAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;YAClE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACrB,WAAW,GAAG,IAAA,yCAAwB,EAAC;gBACrC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAkB;oBAClC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBAC3B,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;oBAC3C,MAAM,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,+BAAqB,EAAE,QAAQ,CAAC,CAAC;gBACpE,CAAC;aACF,CAAC,CAAC;YACH,MAAM,WAAW,CAAC,SAAS,CACzB,IAAA,4BAAW,EAAC,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CACnD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpers_1 = require("../helpers");
|
|
4
|
+
const mock_assistant_1 = require("../mock_assistant");
|
|
5
|
+
describe("Zone", () => {
|
|
6
|
+
let application;
|
|
7
|
+
const EXAMPLE_ZONE = {
|
|
8
|
+
icon: "",
|
|
9
|
+
latitude: 0,
|
|
10
|
+
longitude: 0,
|
|
11
|
+
name: "Test",
|
|
12
|
+
passive: true,
|
|
13
|
+
};
|
|
14
|
+
afterEach(async () => {
|
|
15
|
+
if (application) {
|
|
16
|
+
await application.teardown();
|
|
17
|
+
application = undefined;
|
|
18
|
+
}
|
|
19
|
+
jest.restoreAllMocks();
|
|
20
|
+
});
|
|
21
|
+
describe("Lifecycle", () => {
|
|
22
|
+
it("should force values to be available before ready", async () => {
|
|
23
|
+
expect.assertions(1);
|
|
24
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
25
|
+
Test({ lifecycle, hass }) {
|
|
26
|
+
const spy = jest
|
|
27
|
+
.spyOn(hass.socket, "sendMessage")
|
|
28
|
+
.mockImplementation(async () => [EXAMPLE_ZONE]);
|
|
29
|
+
lifecycle.onReady(async () => {
|
|
30
|
+
await hass.zone.list();
|
|
31
|
+
expect(spy).toHaveBeenCalledWith(expect.objectContaining({ type: "zone/list" }));
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({
|
|
36
|
+
hass: {
|
|
37
|
+
AUTO_CONNECT_SOCKET: false,
|
|
38
|
+
AUTO_SCAN_CALL_PROXY: false,
|
|
39
|
+
},
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe("API", () => {
|
|
44
|
+
describe("Formatting", () => {
|
|
45
|
+
it("should call list properly", async () => {
|
|
46
|
+
expect.assertions(1);
|
|
47
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
48
|
+
Test({ lifecycle, hass }) {
|
|
49
|
+
const spy = jest
|
|
50
|
+
.spyOn(hass.socket, "sendMessage")
|
|
51
|
+
.mockImplementation(async () => []);
|
|
52
|
+
lifecycle.onReady(async () => {
|
|
53
|
+
await hass.zone.list();
|
|
54
|
+
expect(spy).toHaveBeenCalledWith(expect.objectContaining({ type: "zone/list" }));
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({
|
|
59
|
+
hass: {
|
|
60
|
+
AUTO_CONNECT_SOCKET: false,
|
|
61
|
+
AUTO_SCAN_CALL_PROXY: false,
|
|
62
|
+
},
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
it("should call create properly", async () => {
|
|
66
|
+
expect.assertions(1);
|
|
67
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
68
|
+
Test({ lifecycle, hass, event }) {
|
|
69
|
+
const spy = jest
|
|
70
|
+
.spyOn(hass.socket, "sendMessage")
|
|
71
|
+
.mockImplementation(async () => undefined);
|
|
72
|
+
lifecycle.onReady(async () => {
|
|
73
|
+
setImmediate(() => event.emit(helpers_1.ZONE_REGISTRY_UPDATED));
|
|
74
|
+
await hass.zone.create(EXAMPLE_ZONE);
|
|
75
|
+
expect(spy).toHaveBeenCalledWith({
|
|
76
|
+
type: "zone/create",
|
|
77
|
+
...EXAMPLE_ZONE,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({
|
|
83
|
+
hass: {
|
|
84
|
+
AUTO_CONNECT_SOCKET: false,
|
|
85
|
+
AUTO_SCAN_CALL_PROXY: false,
|
|
86
|
+
},
|
|
87
|
+
}));
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
describe("Order of operations", () => {
|
|
91
|
+
it("should wait for an update before returning when creating", async () => {
|
|
92
|
+
expect.assertions(1);
|
|
93
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
94
|
+
Test({ lifecycle, hass, event }) {
|
|
95
|
+
jest
|
|
96
|
+
.spyOn(hass.socket, "sendMessage")
|
|
97
|
+
.mockImplementation(async () => undefined);
|
|
98
|
+
lifecycle.onReady(async () => {
|
|
99
|
+
const response = hass.zone.create(EXAMPLE_ZONE);
|
|
100
|
+
let order = "";
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
order += "a";
|
|
103
|
+
event.emit(helpers_1.ZONE_REGISTRY_UPDATED);
|
|
104
|
+
}, 5);
|
|
105
|
+
await response;
|
|
106
|
+
order += "b";
|
|
107
|
+
expect(order).toEqual("ab");
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({
|
|
112
|
+
hass: {
|
|
113
|
+
AUTO_CONNECT_SOCKET: false,
|
|
114
|
+
AUTO_SCAN_CALL_PROXY: false,
|
|
115
|
+
},
|
|
116
|
+
}));
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=zone.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zone.spec.js","sourceRoot":"","sources":["../../src/testing/zone.spec.ts"],"names":[],"mappings":";;AAOA,wCAAgE;AAChE,sDAA0E;AAE1E,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,IAAI,WAGH,CAAC;IACF,MAAM,YAAY,GAAG;QACnB,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,IAAI;KACC,CAAC;IAEjB,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC7B,WAAW,GAAG,SAAS,CAAC;QAC1B,CAAC;QACD,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;YAChE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACrB,WAAW,GAAG,IAAA,yCAAwB,EAAC;gBACrC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAkB;oBACtC,MAAM,GAAG,GAAG,IAAI;yBACb,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC;yBACjC,kBAAkB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,Y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AAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBACrB,WAAW,GAAG,IAAA,yCAAwB,EAAC;oBACrC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAkB;wBAC7C,IAAI;6BACD,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC;6BACjC,kBAAkB,CAAC,KAAK,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC;wBAC7C,SAAS,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;4BAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;4BAChD,IAAI,KAAK,GAAG,EAAE,CAAC;4BACf,UAAU,CAAC,GAAG,EAAE;gCACd,KAAK,IAAI,GAAG,CAAC;gCACb,KAAK,CAAC,IAAI,CAAC,+BAAqB,CAAC,CAAC;4BACpC,CAAC,EAAE,CAAC,CAAC,CAAC;4BACN,MAAM,QAAQ,CAAC;4BACf,KAAK,IAAI,GAAG,CAAC;4BACb,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;wBAC9B,CAAC,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC,CAAC;gBACH,MAAM,WAAW,CAAC,SAAS,CACzB,IAAA,4BAAW,EAAC;oBACV,IAAI,EAAE;wBACJ,mBAAmB,EAAE,KAAK;wBAC1B,oBAAoB,EAAE,KAAK;qBAC5B;iBACF,CAAC,CACH,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@digital-alchemy/hass",
|
|
3
3
|
"repository": "https://github.com/Digital-Alchemy-TS/hass",
|
|
4
4
|
"homepage": "https://docs.digital-alchemy.app",
|
|
5
|
-
"version": "24.7.
|
|
5
|
+
"version": "24.7.2",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rm -rf dist/; tsc",
|
|
8
8
|
"lint": "eslint src",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@cspell/eslint-plugin": "^8.8.4",
|
|
39
|
-
"@digital-alchemy/core": "^24.6.
|
|
40
|
-
"@digital-alchemy/synapse": "^24.6.
|
|
41
|
-
"@digital-alchemy/type-writer": "^24.6.
|
|
39
|
+
"@digital-alchemy/core": "^24.6.6",
|
|
40
|
+
"@digital-alchemy/synapse": "^24.6.6",
|
|
41
|
+
"@digital-alchemy/type-writer": "^24.6.6",
|
|
42
42
|
"@types/figlet": "^1.5.8",
|
|
43
43
|
"@types/jest": "^29.5.12",
|
|
44
44
|
"@types/js-yaml": "^4.0.9",
|