@digital-alchemy/core 0.1.17 → 0.2.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/dist/{boilerplate/extensions → extensions}/cache.extension.d.ts +3 -3
- package/dist/{boilerplate/extensions → extensions}/cache.extension.js +16 -16
- package/dist/extensions/cache.extension.js.map +1 -0
- package/dist/{boilerplate/extensions → extensions}/configuration.extension.d.ts +3 -3
- package/dist/{boilerplate/extensions → extensions}/configuration.extension.js +8 -8
- package/dist/extensions/configuration.extension.js.map +1 -0
- package/dist/{boilerplate/extensions → extensions}/fetch.extension.d.ts +2 -2
- package/dist/{boilerplate/extensions → extensions}/fetch.extension.js +22 -22
- package/dist/extensions/fetch.extension.js.map +1 -0
- package/dist/{boilerplate/extensions → extensions}/index.d.ts +2 -0
- package/dist/{boilerplate/extensions → extensions}/index.js +2 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/{utilities/extensions/zcc.extension.d.ts → extensions/internal.extension.d.ts} +4 -4
- package/dist/{utilities/extensions/zcc.extension.js → extensions/internal.extension.js} +8 -8
- package/dist/extensions/internal.extension.js.map +1 -0
- package/dist/extensions/is.extension.js.map +1 -0
- package/dist/{boilerplate/extensions → extensions}/logger.extension.d.ts +3 -3
- package/dist/{boilerplate/extensions → extensions}/logger.extension.js +1 -1
- package/dist/extensions/logger.extension.js.map +1 -0
- package/dist/{boilerplate/extensions → extensions}/scheduler.extension.d.ts +1 -1
- package/dist/{boilerplate/extensions → extensions}/scheduler.extension.js +1 -1
- package/dist/extensions/scheduler.extension.js.map +1 -0
- package/dist/{boilerplate/extensions → extensions}/wiring.extension.d.ts +3 -30
- package/dist/{boilerplate/extensions → extensions}/wiring.extension.js +43 -59
- package/dist/extensions/wiring.extension.js.map +1 -0
- package/dist/helpers/async.helper.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/cache-memory.helper.js +1 -1
- package/dist/helpers/cache-memory.helper.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/cache-redis.helper.js +1 -1
- package/dist/helpers/cache-redis.helper.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/config-environment-loader.helper.js +1 -1
- package/dist/helpers/config-environment-loader.helper.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/config-file-loader.helper.js +2 -2
- package/dist/helpers/config-file-loader.helper.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/config.helper.d.ts +1 -1
- package/dist/{boilerplate/helpers → helpers}/config.helper.js +1 -1
- package/dist/helpers/config.helper.js.map +1 -0
- package/dist/helpers/context.helper.js.map +1 -0
- package/dist/helpers/cron.helper.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/errors.helper.d.ts +1 -1
- package/dist/helpers/errors.helper.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/events.helper.js +1 -1
- package/dist/helpers/events.helper.js.map +1 -0
- package/dist/helpers/extend.helper.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/fetch.helper.d.ts +1 -1
- package/dist/{boilerplate/helpers → helpers}/fetch.helper.js +1 -1
- package/dist/helpers/fetch.helper.js.map +1 -0
- package/dist/{utilities/helpers/index.js → helpers/index copy.js } +1 -1
- package/dist/helpers/index copy.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/index.d.ts +5 -0
- package/dist/{boilerplate/helpers → helpers}/index.js +5 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/lifecycle.helper.d.ts +1 -1
- package/dist/helpers/lifecycle.helper.js.map +1 -0
- package/dist/helpers/metrics.helper.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/testing.helper.d.ts +0 -5
- package/dist/{boilerplate/helpers → helpers}/testing.helper.js +3 -3
- package/dist/helpers/testing.helper.js.map +1 -0
- package/dist/helpers/utilities.helper.js.map +1 -0
- package/dist/{boilerplate/helpers → helpers}/wiring.helper.d.ts +3 -3
- package/dist/helpers/wiring.helper.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/package.json +7 -21
- package/dist/automation/automation.module.d.ts +0 -96
- package/dist/automation/automation.module.js +0 -105
- package/dist/automation/automation.module.js.map +0 -1
- package/dist/automation/extensions/aggressive-scenes.extension.d.ts +0 -12
- package/dist/automation/extensions/aggressive-scenes.extension.js +0 -114
- package/dist/automation/extensions/aggressive-scenes.extension.js.map +0 -1
- package/dist/automation/extensions/circadian.extension.d.ts +0 -6
- package/dist/automation/extensions/circadian.extension.js +0 -81
- package/dist/automation/extensions/circadian.extension.js.map +0 -1
- package/dist/automation/extensions/index.d.ts +0 -7
- package/dist/automation/extensions/index.js +0 -11
- package/dist/automation/extensions/index.js.map +0 -1
- package/dist/automation/extensions/light-manager.extension.d.ts +0 -26
- package/dist/automation/extensions/light-manager.extension.js +0 -258
- package/dist/automation/extensions/light-manager.extension.js.map +0 -1
- package/dist/automation/extensions/managed-switch.extension.d.ts +0 -3
- package/dist/automation/extensions/managed-switch.extension.js +0 -73
- package/dist/automation/extensions/managed-switch.extension.js.map +0 -1
- package/dist/automation/extensions/room.extension.d.ts +0 -11
- package/dist/automation/extensions/room.extension.js +0 -177
- package/dist/automation/extensions/room.extension.js.map +0 -1
- package/dist/automation/extensions/sequence-matcher.extension.d.ts +0 -3
- package/dist/automation/extensions/sequence-matcher.extension.js +0 -123
- package/dist/automation/extensions/sequence-matcher.extension.js.map +0 -1
- package/dist/automation/extensions/solar-calc.extension.d.ts +0 -20
- package/dist/automation/extensions/solar-calc.extension.js +0 -104
- package/dist/automation/extensions/solar-calc.extension.js.map +0 -1
- package/dist/automation/helpers/events.helper.d.ts +0 -33
- package/dist/automation/helpers/events.helper.js +0 -14
- package/dist/automation/helpers/events.helper.js.map +0 -1
- package/dist/automation/helpers/index.d.ts +0 -7
- package/dist/automation/helpers/index.js +0 -11
- package/dist/automation/helpers/index.js.map +0 -1
- package/dist/automation/helpers/managed-switch.helper.d.ts +0 -41
- package/dist/automation/helpers/managed-switch.helper.js +0 -3
- package/dist/automation/helpers/managed-switch.helper.js.map +0 -1
- package/dist/automation/helpers/metrics.helper.d.ts +0 -13
- package/dist/automation/helpers/metrics.helper.js +0 -30
- package/dist/automation/helpers/metrics.helper.js.map +0 -1
- package/dist/automation/helpers/reftimes.helper.d.ts +0 -54
- package/dist/automation/helpers/reftimes.helper.js +0 -33
- package/dist/automation/helpers/reftimes.helper.js.map +0 -1
- package/dist/automation/helpers/scene.helper.d.ts +0 -97
- package/dist/automation/helpers/scene.helper.js +0 -5
- package/dist/automation/helpers/scene.helper.js.map +0 -1
- package/dist/automation/helpers/sequence.helper.d.ts +0 -55
- package/dist/automation/helpers/sequence.helper.js +0 -3
- package/dist/automation/helpers/sequence.helper.js.map +0 -1
- package/dist/automation/helpers/solar.helper.d.ts +0 -3
- package/dist/automation/helpers/solar.helper.js +0 -262
- package/dist/automation/helpers/solar.helper.js.map +0 -1
- package/dist/automation/index.d.ts +0 -3
- package/dist/automation/index.js +0 -10
- package/dist/automation/index.js.map +0 -1
- package/dist/boilerplate/extensions/cache.extension.js.map +0 -1
- package/dist/boilerplate/extensions/configuration.extension.js.map +0 -1
- package/dist/boilerplate/extensions/fetch.extension.js.map +0 -1
- package/dist/boilerplate/extensions/index.js.map +0 -1
- package/dist/boilerplate/extensions/logger.extension.js.map +0 -1
- package/dist/boilerplate/extensions/scheduler.extension.js.map +0 -1
- package/dist/boilerplate/extensions/wiring.extension.js.map +0 -1
- package/dist/boilerplate/helpers/cache-memory.helper.js.map +0 -1
- package/dist/boilerplate/helpers/cache-redis.helper.js.map +0 -1
- package/dist/boilerplate/helpers/config-environment-loader.helper.js.map +0 -1
- package/dist/boilerplate/helpers/config-file-loader.helper.js.map +0 -1
- package/dist/boilerplate/helpers/config.helper.js.map +0 -1
- package/dist/boilerplate/helpers/errors.helper.js.map +0 -1
- package/dist/boilerplate/helpers/events.helper.js.map +0 -1
- package/dist/boilerplate/helpers/fetch.helper.js.map +0 -1
- package/dist/boilerplate/helpers/index.js.map +0 -1
- package/dist/boilerplate/helpers/lifecycle.helper.js.map +0 -1
- package/dist/boilerplate/helpers/metrics.helper.js.map +0 -1
- package/dist/boilerplate/helpers/testing.helper.js.map +0 -1
- package/dist/boilerplate/helpers/wiring.helper.js.map +0 -1
- package/dist/boilerplate/index.d.ts +0 -2
- package/dist/boilerplate/index.js +0 -6
- package/dist/boilerplate/index.js.map +0 -1
- package/dist/gotify/extensions/application.extension.d.ts +0 -13
- package/dist/gotify/extensions/application.extension.js +0 -52
- package/dist/gotify/extensions/application.extension.js.map +0 -1
- package/dist/gotify/extensions/client.extension.d.ts +0 -8
- package/dist/gotify/extensions/client.extension.js +0 -38
- package/dist/gotify/extensions/client.extension.js.map +0 -1
- package/dist/gotify/extensions/fetch.extension.d.ts +0 -2
- package/dist/gotify/extensions/fetch.extension.js +0 -13
- package/dist/gotify/extensions/fetch.extension.js.map +0 -1
- package/dist/gotify/extensions/index.d.ts +0 -4
- package/dist/gotify/extensions/index.js +0 -8
- package/dist/gotify/extensions/index.js.map +0 -1
- package/dist/gotify/extensions/message.extension.d.ts +0 -8
- package/dist/gotify/extensions/message.extension.js +0 -37
- package/dist/gotify/extensions/message.extension.js.map +0 -1
- package/dist/gotify/gotify.module.d.ts +0 -34
- package/dist/gotify/gotify.module.js +0 -33
- package/dist/gotify/gotify.module.js.map +0 -1
- package/dist/gotify/helpers/api.d.ts +0 -346
- package/dist/gotify/helpers/api.js +0 -14
- package/dist/gotify/helpers/api.js.map +0 -1
- package/dist/gotify/helpers/events.helper.d.ts +0 -6
- package/dist/gotify/helpers/events.helper.js +0 -5
- package/dist/gotify/helpers/events.helper.js.map +0 -1
- package/dist/gotify/helpers/index.d.ts +0 -2
- package/dist/gotify/helpers/index.js +0 -6
- package/dist/gotify/helpers/index.js.map +0 -1
- package/dist/gotify/index.d.ts +0 -3
- package/dist/gotify/index.js +0 -7
- package/dist/gotify/index.js.map +0 -1
- package/dist/hass/dynamic.d.ts +0 -1126
- package/dist/hass/dynamic.js +0 -153
- package/dist/hass/dynamic.js.map +0 -1
- package/dist/hass/extensions/call-proxy.extension.d.ts +0 -4
- package/dist/hass/extensions/call-proxy.extension.js +0 -88
- package/dist/hass/extensions/call-proxy.extension.js.map +0 -1
- package/dist/hass/extensions/config.extension.d.ts +0 -2
- package/dist/hass/extensions/config.extension.js +0 -53
- package/dist/hass/extensions/config.extension.js.map +0 -1
- package/dist/hass/extensions/entity-manager.extension.d.ts +0 -61
- package/dist/hass/extensions/entity-manager.extension.js +0 -211
- package/dist/hass/extensions/entity-manager.extension.js.map +0 -1
- package/dist/hass/extensions/fetch-api.extension.d.ts +0 -29
- package/dist/hass/extensions/fetch-api.extension.js +0 -174
- package/dist/hass/extensions/fetch-api.extension.js.map +0 -1
- package/dist/hass/extensions/index.d.ts +0 -6
- package/dist/hass/extensions/index.js +0 -10
- package/dist/hass/extensions/index.js.map +0 -1
- package/dist/hass/extensions/utilities.extension.d.ts +0 -9
- package/dist/hass/extensions/utilities.extension.js +0 -43
- package/dist/hass/extensions/utilities.extension.js.map +0 -1
- package/dist/hass/extensions/websocket-api.extension.d.ts +0 -39
- package/dist/hass/extensions/websocket-api.extension.js +0 -363
- package/dist/hass/extensions/websocket-api.extension.js.map +0 -1
- package/dist/hass/hass.module.d.ts +0 -80
- package/dist/hass/hass.module.js +0 -83
- package/dist/hass/hass.module.js.map +0 -1
- package/dist/hass/helpers/backup.helper.d.ts +0 -11
- package/dist/hass/helpers/backup.helper.js +0 -3
- package/dist/hass/helpers/backup.helper.js.map +0 -1
- package/dist/hass/helpers/constants.helper.d.ts +0 -54
- package/dist/hass/helpers/constants.helper.js +0 -63
- package/dist/hass/helpers/constants.helper.js.map +0 -1
- package/dist/hass/helpers/entity-state.helper.d.ts +0 -45
- package/dist/hass/helpers/entity-state.helper.js +0 -9
- package/dist/hass/helpers/entity-state.helper.js.map +0 -1
- package/dist/hass/helpers/fetch/calendar.d.ts +0 -54
- package/dist/hass/helpers/fetch/calendar.js +0 -3
- package/dist/hass/helpers/fetch/calendar.js.map +0 -1
- package/dist/hass/helpers/fetch/configuration.d.ts +0 -34
- package/dist/hass/helpers/fetch/configuration.js +0 -3
- package/dist/hass/helpers/fetch/configuration.js.map +0 -1
- package/dist/hass/helpers/fetch/index.d.ts +0 -4
- package/dist/hass/helpers/fetch/index.js +0 -8
- package/dist/hass/helpers/fetch/index.js.map +0 -1
- package/dist/hass/helpers/fetch/server-log.d.ts +0 -10
- package/dist/hass/helpers/fetch/server-log.js +0 -20
- package/dist/hass/helpers/fetch/server-log.js.map +0 -1
- package/dist/hass/helpers/fetch/service-list.d.ts +0 -51
- package/dist/hass/helpers/fetch/service-list.js +0 -3
- package/dist/hass/helpers/fetch/service-list.js.map +0 -1
- package/dist/hass/helpers/index.d.ts +0 -7
- package/dist/hass/helpers/index.js +0 -11
- package/dist/hass/helpers/index.js.map +0 -1
- package/dist/hass/helpers/metrics.helper.d.ts +0 -13
- package/dist/hass/helpers/metrics.helper.js +0 -30
- package/dist/hass/helpers/metrics.helper.js.map +0 -1
- package/dist/hass/helpers/utility.helper.d.ts +0 -61
- package/dist/hass/helpers/utility.helper.js +0 -38
- package/dist/hass/helpers/utility.helper.js.map +0 -1
- package/dist/hass/helpers/websocket.helper.d.ts +0 -129
- package/dist/hass/helpers/websocket.helper.js +0 -3
- package/dist/hass/helpers/websocket.helper.js.map +0 -1
- package/dist/hass/index.d.ts +0 -4
- package/dist/hass/index.js +0 -8
- package/dist/hass/index.js.map +0 -1
- package/dist/nexus/entities.extension.d.ts +0 -2
- package/dist/nexus/entities.extension.js +0 -50
- package/dist/nexus/entities.extension.js.map +0 -1
- package/dist/nexus/main.d.ts +0 -9
- package/dist/nexus/main.js +0 -28
- package/dist/nexus/main.js.map +0 -1
- package/dist/purge/main.d.ts +0 -34
- package/dist/purge/main.js +0 -50
- package/dist/purge/main.js.map +0 -1
- package/dist/purge/purge.extension.d.ts +0 -2
- package/dist/purge/purge.extension.js +0 -49
- package/dist/purge/purge.extension.js.map +0 -1
- package/dist/synapse/extensions/binary-sensor.extension.d.ts +0 -19
- package/dist/synapse/extensions/binary-sensor.extension.js +0 -84
- package/dist/synapse/extensions/binary-sensor.extension.js.map +0 -1
- package/dist/synapse/extensions/button.extension.d.ts +0 -10
- package/dist/synapse/extensions/button.extension.js +0 -46
- package/dist/synapse/extensions/button.extension.js.map +0 -1
- package/dist/synapse/extensions/index.d.ts +0 -6
- package/dist/synapse/extensions/index.js +0 -10
- package/dist/synapse/extensions/index.js.map +0 -1
- package/dist/synapse/extensions/registry.extension.d.ts +0 -21
- package/dist/synapse/extensions/registry.extension.js +0 -223
- package/dist/synapse/extensions/registry.extension.js.map +0 -1
- package/dist/synapse/extensions/scene.extension.d.ts +0 -9
- package/dist/synapse/extensions/scene.extension.js +0 -37
- package/dist/synapse/extensions/scene.extension.js.map +0 -1
- package/dist/synapse/extensions/sensor.extension.d.ts +0 -25
- package/dist/synapse/extensions/sensor.extension.js +0 -154
- package/dist/synapse/extensions/sensor.extension.js.map +0 -1
- package/dist/synapse/extensions/switch.extension.d.ts +0 -19
- package/dist/synapse/extensions/switch.extension.js +0 -95
- package/dist/synapse/extensions/switch.extension.js.map +0 -1
- package/dist/synapse/helpers/device-class.helper.d.ts +0 -323
- package/dist/synapse/helpers/device-class.helper.js +0 -241
- package/dist/synapse/helpers/device-class.helper.js.map +0 -1
- package/dist/synapse/helpers/index.d.ts +0 -3
- package/dist/synapse/helpers/index.js +0 -7
- package/dist/synapse/helpers/index.js.map +0 -1
- package/dist/synapse/helpers/metrics.helper.d.ts +0 -13
- package/dist/synapse/helpers/metrics.helper.js +0 -30
- package/dist/synapse/helpers/metrics.helper.js.map +0 -1
- package/dist/synapse/helpers/utility.helper.d.ts +0 -1
- package/dist/synapse/helpers/utility.helper.js +0 -3
- package/dist/synapse/helpers/utility.helper.js.map +0 -1
- package/dist/synapse/index.d.ts +0 -3
- package/dist/synapse/index.js +0 -7
- package/dist/synapse/index.js.map +0 -1
- package/dist/synapse/synapse.module.d.ts +0 -54
- package/dist/synapse/synapse.module.js +0 -65
- package/dist/synapse/synapse.module.js.map +0 -1
- package/dist/type-writer/build.extension.d.ts +0 -2
- package/dist/type-writer/build.extension.js +0 -52
- package/dist/type-writer/build.extension.js.map +0 -1
- package/dist/type-writer/main.d.ts +0 -17
- package/dist/type-writer/main.js +0 -36
- package/dist/type-writer/main.js.map +0 -1
- package/dist/type-writer/type-writer.extension.d.ts +0 -2
- package/dist/type-writer/type-writer.extension.js +0 -214
- package/dist/type-writer/type-writer.extension.js.map +0 -1
- package/dist/utilities/extensions/index.d.ts +0 -3
- package/dist/utilities/extensions/index.js +0 -7
- package/dist/utilities/extensions/index.js.map +0 -1
- package/dist/utilities/extensions/is.extension.js.map +0 -1
- package/dist/utilities/extensions/zcc-testing.extension.d.ts +0 -4
- package/dist/utilities/extensions/zcc-testing.extension.js +0 -9
- package/dist/utilities/extensions/zcc-testing.extension.js.map +0 -1
- package/dist/utilities/extensions/zcc.extension.js.map +0 -1
- package/dist/utilities/helpers/async.helper.js.map +0 -1
- package/dist/utilities/helpers/context.helper.js.map +0 -1
- package/dist/utilities/helpers/cron.helper.js.map +0 -1
- package/dist/utilities/helpers/extend.helper.js.map +0 -1
- package/dist/utilities/helpers/index.js.map +0 -1
- package/dist/utilities/helpers/utilities.helper.js.map +0 -1
- package/dist/utilities/index.d.ts +0 -2
- package/dist/utilities/index.js +0 -6
- package/dist/utilities/index.js.map +0 -1
- /package/dist/{utilities/extensions → extensions}/is.extension.d.ts +0 -0
- /package/dist/{utilities/extensions → extensions}/is.extension.js +0 -0
- /package/dist/{utilities/helpers → helpers}/async.helper.d.ts +0 -0
- /package/dist/{utilities/helpers → helpers}/async.helper.js +0 -0
- /package/dist/{boilerplate/helpers → helpers}/cache-memory.helper.d.ts +0 -0
- /package/dist/{boilerplate/helpers → helpers}/cache-redis.helper.d.ts +0 -0
- /package/dist/{boilerplate/helpers → helpers}/config-environment-loader.helper.d.ts +0 -0
- /package/dist/{boilerplate/helpers → helpers}/config-file-loader.helper.d.ts +0 -0
- /package/dist/{utilities/helpers → helpers}/context.helper.d.ts +0 -0
- /package/dist/{utilities/helpers → helpers}/context.helper.js +0 -0
- /package/dist/{utilities/helpers → helpers}/cron.helper.d.ts +0 -0
- /package/dist/{utilities/helpers → helpers}/cron.helper.js +0 -0
- /package/dist/{boilerplate/helpers → helpers}/errors.helper.js +0 -0
- /package/dist/{boilerplate/helpers → helpers}/events.helper.d.ts +0 -0
- /package/dist/{utilities/helpers → helpers}/extend.helper.d.ts +0 -0
- /package/dist/{utilities/helpers → helpers}/extend.helper.js +0 -0
- /package/dist/{utilities/helpers/index.d.ts → helpers/index copy.d.ts} +0 -0
- /package/dist/{boilerplate/helpers → helpers}/lifecycle.helper.js +0 -0
- /package/dist/{boilerplate/helpers → helpers}/metrics.helper.d.ts +0 -0
- /package/dist/{boilerplate/helpers → helpers}/metrics.helper.js +0 -0
- /package/dist/{utilities/helpers → helpers}/utilities.helper.d.ts +0 -0
- /package/dist/{utilities/helpers → helpers}/utilities.helper.js +0 -0
- /package/dist/{boilerplate/helpers → helpers}/wiring.helper.js +0 -0
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SequenceWatcher = void 0;
|
|
4
|
-
const utilities_1 = require("../../utilities");
|
|
5
|
-
const __1 = require("..");
|
|
6
|
-
function SequenceWatcher({ logger, hass, config }) {
|
|
7
|
-
const ACTIVE = new Map();
|
|
8
|
-
const WATCHED_EVENTS = new Map();
|
|
9
|
-
const EVENT_REMOVAL = new Map();
|
|
10
|
-
let counter = utilities_1.START;
|
|
11
|
-
async function onMatch(data) {
|
|
12
|
-
await data.exec();
|
|
13
|
-
const reset = data.reset ?? "self";
|
|
14
|
-
if (reset === "self") {
|
|
15
|
-
ACTIVE.delete(data);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (!utilities_1.is.object(reset)) {
|
|
19
|
-
logger.error({ reset: data.reset }, `bad reset type`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const labels = new Set([reset.label].flat().filter((i) => !utilities_1.is.empty(i)));
|
|
23
|
-
[...ACTIVE.keys()].forEach((key) => {
|
|
24
|
-
const item = ACTIVE.get(key);
|
|
25
|
-
if (labels.has(item.label)) {
|
|
26
|
-
item.interrupt.kill("stop");
|
|
27
|
-
ACTIVE.delete(key);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function trigger(type, event_data) {
|
|
32
|
-
WATCHED_EVENTS.get(type).forEach(async (data) => {
|
|
33
|
-
const allowed = data.filter(event_data);
|
|
34
|
-
if (!allowed) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
// * Identify if it is already being watched
|
|
38
|
-
const current = ACTIVE.get(data);
|
|
39
|
-
const match = [];
|
|
40
|
-
if (current) {
|
|
41
|
-
// if so, kill the current sleep so it doesn't gc early
|
|
42
|
-
current.interrupt.kill("stop");
|
|
43
|
-
// prepend the current matches in to the new list
|
|
44
|
-
match.push(...current.match);
|
|
45
|
-
}
|
|
46
|
-
// * Grab the new value from the event, and add it on the list
|
|
47
|
-
const value = utilities_1.ZCC.utils.object.get(event_data, data.path);
|
|
48
|
-
match.push(value);
|
|
49
|
-
// * If the sequence matches, fire the callback
|
|
50
|
-
if (utilities_1.is.equal(match, data.match)) {
|
|
51
|
-
await onMatch(data);
|
|
52
|
-
}
|
|
53
|
-
// * wait out the match timeout using a sleep that can be cancelled
|
|
54
|
-
const interrupt = (0, utilities_1.sleep)(config.automation.SEQUENCE_TIMEOUT);
|
|
55
|
-
ACTIVE.set(data, {
|
|
56
|
-
interrupt,
|
|
57
|
-
label: data.label,
|
|
58
|
-
match,
|
|
59
|
-
reset: data.reset,
|
|
60
|
-
});
|
|
61
|
-
await interrupt;
|
|
62
|
-
// * New event hasn't come in within time period. >>> GC
|
|
63
|
-
ACTIVE.delete(data);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function SequenceWatcher(data) {
|
|
67
|
-
const { exec, event_type, match, context, label, path, filter } = data;
|
|
68
|
-
logger.trace({ context }, `setting up sequence watcher`);
|
|
69
|
-
const id = counter.toString();
|
|
70
|
-
counter++;
|
|
71
|
-
// If this is the first watcher for this event, set up a listener
|
|
72
|
-
let watcher = WATCHED_EVENTS.get(event_type);
|
|
73
|
-
if (!watcher) {
|
|
74
|
-
watcher = [];
|
|
75
|
-
logger.trace({ event_type }, `listening for socket event`);
|
|
76
|
-
const remover = hass.socket.onEvent({
|
|
77
|
-
context,
|
|
78
|
-
event: event_type,
|
|
79
|
-
exec: (eventData) => trigger(event_type, eventData),
|
|
80
|
-
label,
|
|
81
|
-
});
|
|
82
|
-
EVENT_REMOVAL.set(event_type, remover);
|
|
83
|
-
}
|
|
84
|
-
// Append watcher to list
|
|
85
|
-
WATCHED_EVENTS.set(event_type, [
|
|
86
|
-
...watcher,
|
|
87
|
-
{
|
|
88
|
-
context,
|
|
89
|
-
event_type,
|
|
90
|
-
exec: () => {
|
|
91
|
-
logger.trace({ context, label, match }, `sequence match trigger`);
|
|
92
|
-
setImmediate(async () => await utilities_1.ZCC.safeExec({
|
|
93
|
-
duration: __1.SEQUENCE_MATCHER_EXECUTION_TIME,
|
|
94
|
-
errors: __1.SEQUENCE_MATCHER_ERRORS,
|
|
95
|
-
exec: async () => await exec(),
|
|
96
|
-
executions: __1.SEQUENCE_MATCHER_EXECUTION_COUNT,
|
|
97
|
-
labels: { context, label },
|
|
98
|
-
}));
|
|
99
|
-
},
|
|
100
|
-
filter: filter,
|
|
101
|
-
id,
|
|
102
|
-
label,
|
|
103
|
-
match,
|
|
104
|
-
path,
|
|
105
|
-
},
|
|
106
|
-
]);
|
|
107
|
-
// Return a removal function
|
|
108
|
-
return () => {
|
|
109
|
-
const watcher = WATCHED_EVENTS.get(event_type).filter((item) => item.id !== id);
|
|
110
|
-
if (utilities_1.is.empty(watcher)) {
|
|
111
|
-
logger.debug({ event_type }, `last watcher for event removed, cleaning up socket event listener`);
|
|
112
|
-
WATCHED_EVENTS.delete(event_type);
|
|
113
|
-
EVENT_REMOVAL.get(event_type)();
|
|
114
|
-
EVENT_REMOVAL.delete(event_type);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
WATCHED_EVENTS.set(event_type, watcher);
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
return SequenceWatcher;
|
|
121
|
-
}
|
|
122
|
-
exports.SequenceWatcher = SequenceWatcher;
|
|
123
|
-
//# sourceMappingURL=sequence-matcher.extension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sequence-matcher.extension.js","sourceRoot":"","sources":["../../../src/automation/extensions/sequence-matcher.extension.ts"],"names":[],"mappings":";;;AACA,+CAAwD;AACxD,0BAQY;AAEZ,SAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAkB;IACtE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAChD,MAAM,cAAc,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC3D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAsB,CAAC;IACpD,IAAI,OAAO,GAAG,iBAAK,CAAC;IAEpB,KAAK,UAAU,OAAO,CAAC,IAA0B;QAC/C,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QACnC,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACrB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,cAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,gBAAgB,CAAC,CAAC;YACtD,OAAO;QACT,CAAC;QACD,MAAM,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,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBAChC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;gBACjC,OAAO;YACT,CAAC;YACD,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AA1ID,0CA0IC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Dayjs } from "dayjs";
|
|
2
|
-
import { TServiceParams } from "../../boilerplate";
|
|
3
|
-
import { TBlackHole, TContext } from "../../utilities";
|
|
4
|
-
export type SolarEvents = "dawn" | "dusk" | "solarNoon" | "sunrise" | "nightStart" | "nightEnd" | "sunset" | "sunriseEnd" | "sunsetStart";
|
|
5
|
-
/**
|
|
6
|
-
* Benefits from a persistent cache, like Redis
|
|
7
|
-
*/
|
|
8
|
-
export declare function SolarCalculator({ logger, cache, scheduler, hass, lifecycle, }: TServiceParams): SolarReference;
|
|
9
|
-
type OnSolarEvent = {
|
|
10
|
-
context: TContext;
|
|
11
|
-
label?: string;
|
|
12
|
-
eventName: SolarEvents;
|
|
13
|
-
exec: () => TBlackHole;
|
|
14
|
-
};
|
|
15
|
-
type SolarReference = Record<SolarEvents, Dayjs> & {
|
|
16
|
-
isBetween: (a: SolarEvents, b: SolarEvents) => boolean;
|
|
17
|
-
loaded: boolean;
|
|
18
|
-
onEvent: (options: OnSolarEvent) => TBlackHole;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SolarCalculator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
6
|
-
const node_cache_1 = require("node-cache");
|
|
7
|
-
const utilities_1 = require("../../utilities");
|
|
8
|
-
const __1 = require("..");
|
|
9
|
-
const solarEvents = [
|
|
10
|
-
"dawn",
|
|
11
|
-
"sunriseEnd",
|
|
12
|
-
"sunsetStart",
|
|
13
|
-
"dusk",
|
|
14
|
-
"nightStart",
|
|
15
|
-
"nightEnd",
|
|
16
|
-
"sunrise",
|
|
17
|
-
"sunset",
|
|
18
|
-
"solarNoon",
|
|
19
|
-
];
|
|
20
|
-
const CACHE_KEY = "SOLAR_CALC_CONFIG_CACHE";
|
|
21
|
-
const degreesBelowHorizon = {
|
|
22
|
-
goldenHour: -6,
|
|
23
|
-
nauticalTwilight: 12,
|
|
24
|
-
night: 18,
|
|
25
|
-
sunrise: 0.833,
|
|
26
|
-
sunriseEnd: 0.3,
|
|
27
|
-
twilight: 6,
|
|
28
|
-
};
|
|
29
|
-
const UNLIMITED = 0;
|
|
30
|
-
/**
|
|
31
|
-
* Benefits from a persistent cache, like Redis
|
|
32
|
-
*/
|
|
33
|
-
function SolarCalculator({ logger, cache, scheduler, hass, lifecycle, }) {
|
|
34
|
-
let config;
|
|
35
|
-
const event = new node_cache_1.EventEmitter();
|
|
36
|
-
event.setMaxListeners(UNLIMITED);
|
|
37
|
-
let lastEventAttachment;
|
|
38
|
-
lifecycle.onBootstrap(async () => {
|
|
39
|
-
config = await cache.get(CACHE_KEY);
|
|
40
|
-
if (!config) {
|
|
41
|
-
// Hold up bootstrapping for it
|
|
42
|
-
logger.info(`no lat/long on hand, fetching from Home Assistant`);
|
|
43
|
-
await updateLocation();
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
// Background update, just in case
|
|
47
|
-
// Not expecting it to change, so it can be done in
|
|
48
|
-
setImmediate(async () => await updateLocation());
|
|
49
|
-
});
|
|
50
|
-
// Rebuild references hourly
|
|
51
|
-
//
|
|
52
|
-
scheduler.cron({
|
|
53
|
-
exec: () => PopulateReferences(),
|
|
54
|
-
schedule: utilities_1.CronExpression.EVERY_HOUR,
|
|
55
|
-
});
|
|
56
|
-
async function updateLocation() {
|
|
57
|
-
config = await hass.fetch.getConfig();
|
|
58
|
-
await cache.set(CACHE_KEY, config);
|
|
59
|
-
PopulateReferences();
|
|
60
|
-
}
|
|
61
|
-
const solarReference = {};
|
|
62
|
-
async function PopulateReferences() {
|
|
63
|
-
solarReference.dawn = (0, dayjs_1.default)((0, __1.calcSunriseSet)(true, degreesBelowHorizon.twilight, config.latitude, config.longitude));
|
|
64
|
-
solarReference.sunriseEnd = (0, dayjs_1.default)((0, __1.calcSunriseSet)(true, degreesBelowHorizon.sunriseEnd, config.latitude, config.longitude));
|
|
65
|
-
solarReference.sunsetStart = (0, dayjs_1.default)((0, __1.calcSunriseSet)(false, degreesBelowHorizon.sunriseEnd, config.latitude, config.longitude));
|
|
66
|
-
solarReference.dusk = (0, dayjs_1.default)((0, __1.calcSunriseSet)(false, degreesBelowHorizon.twilight, config.latitude, config.longitude));
|
|
67
|
-
solarReference.nightStart = (0, dayjs_1.default)((0, __1.calcSunriseSet)(false, degreesBelowHorizon.night, config.latitude, config.longitude));
|
|
68
|
-
solarReference.nightEnd = (0, dayjs_1.default)((0, __1.calcSunriseSet)(true, degreesBelowHorizon.night, config.latitude, config.longitude));
|
|
69
|
-
solarReference.sunrise = (0, dayjs_1.default)((0, __1.calcSunriseSet)(true, degreesBelowHorizon.sunrise, config.latitude, config.longitude));
|
|
70
|
-
solarReference.sunset = (0, dayjs_1.default)((0, __1.calcSunriseSet)(false, degreesBelowHorizon.sunrise, config.latitude, config.longitude));
|
|
71
|
-
solarReference.solarNoon = (0, dayjs_1.default)((0, __1.calcSolNoon)(config.longitude));
|
|
72
|
-
solarReference.loaded = true;
|
|
73
|
-
const now = (0, dayjs_1.default)();
|
|
74
|
-
const today = now.format("YYYY-MM-DD");
|
|
75
|
-
if (lastEventAttachment !== today) {
|
|
76
|
-
lastEventAttachment = today;
|
|
77
|
-
solarEvents.forEach((i) => {
|
|
78
|
-
if (solarReference[i].isBefore(now)) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
setTimeout(() => event.emit(i), Math.abs(now.diff(solarReference[i], "ms")));
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
solarReference.loaded = false;
|
|
86
|
-
solarReference.isBetween = (a, b) => {
|
|
87
|
-
const now = (0, dayjs_1.default)();
|
|
88
|
-
return now.isBetween(solarReference[a], solarReference[b]);
|
|
89
|
-
};
|
|
90
|
-
solarReference.onEvent = ({ context, eventName, label, exec, }) => {
|
|
91
|
-
event.on(eventName, async () => {
|
|
92
|
-
await utilities_1.ZCC.safeExec({
|
|
93
|
-
duration: undefined,
|
|
94
|
-
errors: undefined,
|
|
95
|
-
exec: async () => await exec(),
|
|
96
|
-
executions: undefined,
|
|
97
|
-
labels: { context, label },
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
return solarReference;
|
|
102
|
-
}
|
|
103
|
-
exports.SolarCalculator = SolarCalculator;
|
|
104
|
-
//# sourceMappingURL=solar-calc.extension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solar-calc.extension.js","sourceRoot":"","sources":["../../../src/automation/extensions/solar-calc.extension.ts"],"names":[],"mappings":";;;;AAAA,0DAAqC;AACrC,2CAA0C;AAI1C,+CAA4E;AAC5E,0BAAiD;AAajD,MAAM,WAAW,GAAG;IAClB,MAAM;IACN,YAAY;IACZ,aAAa;IACb,MAAM;IACN,YAAY;IACZ,UAAU;IACV,SAAS;IACT,QAAQ;IACR,WAAW;CACK,CAAC;AAEnB,MAAM,SAAS,GAAG,yBAAyB,CAAC;AAE5C,MAAM,mBAAmB,GAAG;IAC1B,UAAU,EAAE,CAAC,CAAC;IACd,gBAAgB,EAAE,EAAE;IACpB,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,GAAG;IACf,QAAQ,EAAE,CAAC;CACZ,CAAC;AACF,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB;;GAEG;AACH,SAAg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AC9B,UAAU,EAAE,SAAS;gBACrB,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;aAC3B,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,cAAgC,CAAC;AAC1C,CAAC;AA5JD,0CA4JC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { PICK_ENTITY } from "../../hass";
|
|
2
|
-
import { TContext } from "../../utilities";
|
|
3
|
-
export declare const LOCATION_UPDATED = "LOCATION_UPDATED";
|
|
4
|
-
export declare const SCENE_CHANGE: <T extends string = string>(room: T) => string;
|
|
5
|
-
export declare const SCENE_SET_ENTITY = "SCENE_SET_ENTITY";
|
|
6
|
-
export declare const ANIMATION_INTERRUPT = "ANIMATION_INTERRUPT";
|
|
7
|
-
export declare const DETERMINISTIC_SWITCH_CHANGED = "DETERMINISTIC_SWITCH_CHANGED";
|
|
8
|
-
export type DeterministicSwitchChangedData = {
|
|
9
|
-
entity_id: PICK_ENTITY<"switch"> | PICK_ENTITY<"switch">[];
|
|
10
|
-
state: "on" | "off";
|
|
11
|
-
};
|
|
12
|
-
export declare const AGGRESSIVE_SCENES_ADJUSTMENT = "AGGRESSIVE_SCENES_ADJUSTMENT";
|
|
13
|
-
export type AggressiveScenesAdjustmentTypes = "light_brightness" | "light_color" | "light_temperature" | "light_on_off" | "switch_on_off";
|
|
14
|
-
export type AggressiveScenesAdjustmentData = {
|
|
15
|
-
entity_id: PICK_ENTITY<"switch" | "light">;
|
|
16
|
-
type: AggressiveScenesAdjustmentTypes;
|
|
17
|
-
};
|
|
18
|
-
export declare const ROOM_SET_SCENE = "ROOM_SET_SCENE";
|
|
19
|
-
export type RoomSetSceneData = {
|
|
20
|
-
room: string;
|
|
21
|
-
scene: string;
|
|
22
|
-
};
|
|
23
|
-
export declare const SEQUENCE_WATCHER_TRIGGER = "SEQUENCE_WATCHER_TRIGGER";
|
|
24
|
-
export type SequenceWatcherTriggerData = {
|
|
25
|
-
context: TContext;
|
|
26
|
-
label?: string;
|
|
27
|
-
time: number;
|
|
28
|
-
};
|
|
29
|
-
export declare const SOLAR_EVENT_TRIGGER = "SOLAR_EVENT_TRIGGER";
|
|
30
|
-
export type SolarEventTriggerData = {
|
|
31
|
-
context: TContext;
|
|
32
|
-
event: string;
|
|
33
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SOLAR_EVENT_TRIGGER = exports.SEQUENCE_WATCHER_TRIGGER = exports.ROOM_SET_SCENE = exports.AGGRESSIVE_SCENES_ADJUSTMENT = exports.DETERMINISTIC_SWITCH_CHANGED = exports.ANIMATION_INTERRUPT = exports.SCENE_SET_ENTITY = exports.SCENE_CHANGE = exports.LOCATION_UPDATED = void 0;
|
|
4
|
-
exports.LOCATION_UPDATED = "LOCATION_UPDATED";
|
|
5
|
-
const SCENE_CHANGE = (room) => `SCENE_CHANGE:${room}`;
|
|
6
|
-
exports.SCENE_CHANGE = SCENE_CHANGE;
|
|
7
|
-
exports.SCENE_SET_ENTITY = "SCENE_SET_ENTITY";
|
|
8
|
-
exports.ANIMATION_INTERRUPT = "ANIMATION_INTERRUPT";
|
|
9
|
-
exports.DETERMINISTIC_SWITCH_CHANGED = "DETERMINISTIC_SWITCH_CHANGED";
|
|
10
|
-
exports.AGGRESSIVE_SCENES_ADJUSTMENT = "AGGRESSIVE_SCENES_ADJUSTMENT";
|
|
11
|
-
exports.ROOM_SET_SCENE = "ROOM_SET_SCENE";
|
|
12
|
-
exports.SEQUENCE_WATCHER_TRIGGER = "SEQUENCE_WATCHER_TRIGGER";
|
|
13
|
-
exports.SOLAR_EVENT_TRIGGER = "SOLAR_EVENT_TRIGGER";
|
|
14
|
-
//# sourceMappingURL=events.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.helper.js","sourceRoot":"","sources":["../../../src/automation/helpers/events.helper.ts"],"names":[],"mappings":";;;AAGa,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C,MAAM,YAAY,GAAG,CAA4B,IAAO,EAAE,EAAE,CACjE,gBAAgB,IAAI,EAAE,CAAC;AADZ,QAAA,YAAY,gBACA;AACZ,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACtC,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAC5C,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAM9D,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAY9D,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAMlC,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AAOtD,QAAA,mBAAmB,GAAG,qBAAqB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./events.helper"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./managed-switch.helper"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./metrics.helper"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./reftimes.helper"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./scene.helper"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./sequence.helper"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./solar.helper"), exports);
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/automation/helpers/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,kEAAwC;AACxC,2DAAiC;AACjC,4DAAkC;AAClC,yDAA+B;AAC/B,4DAAkC;AAClC,yDAA+B"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { PICK_ENTITY } from "../../hass";
|
|
2
|
-
import { CronExpression, TBlackHole, TContext } from "../../utilities";
|
|
3
|
-
export type PickASwitch = PICK_ENTITY<"switch"> | {
|
|
4
|
-
entity_id: PICK_ENTITY<"switch">;
|
|
5
|
-
};
|
|
6
|
-
type EntityUpdate = PICK_ENTITY | {
|
|
7
|
-
entity_id: PICK_ENTITY;
|
|
8
|
-
} | {
|
|
9
|
-
onUpdate: (callback: () => TBlackHole) => void;
|
|
10
|
-
state: unknown;
|
|
11
|
-
name: string;
|
|
12
|
-
};
|
|
13
|
-
export interface ManagedSwitchOptions {
|
|
14
|
-
/**
|
|
15
|
-
* Logging context
|
|
16
|
-
*/
|
|
17
|
-
context: TContext;
|
|
18
|
-
/**
|
|
19
|
-
* Set the state of this switch
|
|
20
|
-
*/
|
|
21
|
-
entity_id: PickASwitch | PickASwitch[];
|
|
22
|
-
/**
|
|
23
|
-
* cron compatible expression
|
|
24
|
-
*
|
|
25
|
-
* Default: EVERY_10_MINUTES
|
|
26
|
-
*/
|
|
27
|
-
schedule?: CronExpression | `${CronExpression}` | string;
|
|
28
|
-
/**
|
|
29
|
-
* Check on update of this entity
|
|
30
|
-
*/
|
|
31
|
-
onUpdate?: EntityUpdate | EntityUpdate[];
|
|
32
|
-
/**
|
|
33
|
-
* - return true for on
|
|
34
|
-
* - return false for off
|
|
35
|
-
* - return undefined for no change
|
|
36
|
-
*
|
|
37
|
-
* Cannot be a promise
|
|
38
|
-
*/
|
|
39
|
-
shouldBeOn: () => boolean | undefined;
|
|
40
|
-
}
|
|
41
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"managed-switch.helper.js","sourceRoot":"","sources":["../../../src/automation/helpers/managed-switch.helper.ts"],"names":[],"mappings":""}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Counter, Summary } from "prom-client";
|
|
2
|
-
/**
|
|
3
|
-
* Tracks the number of times a sequence matcher callback has been executed.
|
|
4
|
-
*/
|
|
5
|
-
export declare const SEQUENCE_MATCHER_EXECUTION_COUNT: Counter<"context" | "label">;
|
|
6
|
-
/**
|
|
7
|
-
* Counts the number of errors occurred during sequence matcher callback executions.
|
|
8
|
-
*/
|
|
9
|
-
export declare const SEQUENCE_MATCHER_ERRORS: Counter<"context" | "label">;
|
|
10
|
-
/**
|
|
11
|
-
* Summary for Execution Time
|
|
12
|
-
*/
|
|
13
|
-
export declare const SEQUENCE_MATCHER_EXECUTION_TIME: Summary<"context" | "label">;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SEQUENCE_MATCHER_EXECUTION_TIME = exports.SEQUENCE_MATCHER_ERRORS = exports.SEQUENCE_MATCHER_EXECUTION_COUNT = void 0;
|
|
4
|
-
const prom_client_1 = require("prom-client");
|
|
5
|
-
/**
|
|
6
|
-
* Tracks the number of times a sequence matcher callback has been executed.
|
|
7
|
-
*/
|
|
8
|
-
exports.SEQUENCE_MATCHER_EXECUTION_COUNT = new prom_client_1.Counter({
|
|
9
|
-
help: "Counts the number of times a sequence matcher callback has been executed",
|
|
10
|
-
labelNames: ["context", "label"],
|
|
11
|
-
name: "digital_alchemy_automation_logic_sequence_matcher_callback_execution_count",
|
|
12
|
-
});
|
|
13
|
-
/**
|
|
14
|
-
* Counts the number of errors occurred during sequence matcher callback executions.
|
|
15
|
-
*/
|
|
16
|
-
exports.SEQUENCE_MATCHER_ERRORS = new prom_client_1.Counter({
|
|
17
|
-
help: "Counts the number of errors during sequence matcher callback executions",
|
|
18
|
-
labelNames: ["context", "label"],
|
|
19
|
-
name: "digital_alchemy_automation_logic_sequence_matcher_callback_errors",
|
|
20
|
-
});
|
|
21
|
-
/**
|
|
22
|
-
* Summary for Execution Time
|
|
23
|
-
*/
|
|
24
|
-
exports.SEQUENCE_MATCHER_EXECUTION_TIME = new prom_client_1.Summary({
|
|
25
|
-
help: "Measures the duration of each cron job or interval execution",
|
|
26
|
-
labelNames: ["context", "label"],
|
|
27
|
-
name: "digital_alchemy_automation_logic_sequence_matcher_callback_execution_time",
|
|
28
|
-
percentiles: [0.5, 0.9, 0.99],
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=metrics.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.helper.js","sourceRoot":"","sources":["../../../src/automation/helpers/metrics.helper.ts"],"names":[],"mappings":";;;AAAA,6CAA+C;AAE/C;;GAEG;AACU,QAAA,gCAAgC,GAAG,IAAI,qBAAO,CAAC;IAC1D,IAAI,EAAE,0EAA0E;IAChF,UAAU,EAAE,CAAC,SAAS,EAAE,OAAO,CAAU;IACzC,IAAI,EAAE,4EAA4E;CACnF,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,uBAAuB,GAAG,IAAI,qBAAO,CAAC;IACjD,IAAI,EAAE,yEAAyE;IAC/E,UAAU,EAAE,CAAC,SAAS,EAAE,OAAO,CAAU;IACzC,IAAI,EAAE,mEAAmE;CAC1E,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,+BAA+B,GAAG,IAAI,qBAAO,CAAC;IACzD,IAAI,EAAE,8DAA8D;IACpE,UAAU,EAAE,CAAC,SAAS,EAAE,OAAO,CAAU;IACzC,IAAI,EAAE,2EAA2E;IACjF,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC;CAC9B,CAAC,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Dayjs } from "dayjs";
|
|
2
|
-
export declare function refTimes(times: TimeString[]): Dayjs[];
|
|
3
|
-
type Digit = `${number}`;
|
|
4
|
-
type TimeString = Digit | `${Digit}:${Digit}` | `${Digit}:${Digit}:${Digit}`;
|
|
5
|
-
declare module "../../utilities" {
|
|
6
|
-
interface ZCCDefinition {
|
|
7
|
-
/**
|
|
8
|
-
* Quickly calculate reference points in time.
|
|
9
|
-
* Times are in reference to 12AM/midnight this morning, and input in 24 hour format.
|
|
10
|
-
* Values are input from left to right
|
|
11
|
-
*
|
|
12
|
-
* > HH[:mm[:ss]]
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* ## Usage Example
|
|
16
|
-
*
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const [AM830, PM3, TOMORROW] = is.refTimes(["8:30", "15", "24"]);
|
|
19
|
-
* const now = dayjs();
|
|
20
|
-
* if (!now.isBetween(AM830, PM3)) {
|
|
21
|
-
* console.log(
|
|
22
|
-
* `${Math.abs(now.diff(TOMORROW, "minute"))} minutes until tomorrow`,
|
|
23
|
-
* );
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
refTime(times: TimeString[]): Dayjs[];
|
|
28
|
-
/**
|
|
29
|
-
* Quickly calculate reference points in time.
|
|
30
|
-
* Times are in reference to 12AM/midnight this morning.
|
|
31
|
-
*
|
|
32
|
-
* > (AM|PM)[H]H[:(00|15|30|45)]
|
|
33
|
-
*
|
|
34
|
-
* Intended for readability and covering 90% of use cases. Use `refTime` for more configurable interface
|
|
35
|
-
*
|
|
36
|
-
* ## Usage Example
|
|
37
|
-
*
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const [NOW, AM830, PM3] = is.shortTime(["NOW", "AM8:30", "PM3", "24"]);
|
|
40
|
-
* if (!NOW.isBetween(AM830, PM3)) {
|
|
41
|
-
* console.log(
|
|
42
|
-
* `Not in range`,
|
|
43
|
-
* );
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
shortTime(times: ShortTime[]): Dayjs[];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
type ShortTime = `${AmPm}${ShortDigits}${ShortSuffix}` | "NOW" | "TOMORROW";
|
|
51
|
-
type ShortDigits = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12";
|
|
52
|
-
type AmPm = "AM" | "PM";
|
|
53
|
-
type ShortSuffix = "" | ":00" | ":15" | ":30" | ":45";
|
|
54
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.refTimes = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
6
|
-
const utilities_1 = require("../../utilities");
|
|
7
|
-
function refTimes(times) {
|
|
8
|
-
const today = (0, dayjs_1.default)().format("YYYY-MM-DD");
|
|
9
|
-
return times.map((i) => (0, dayjs_1.default)(`${today} ${i}`).millisecond(utilities_1.NONE));
|
|
10
|
-
}
|
|
11
|
-
exports.refTimes = refTimes;
|
|
12
|
-
const SLICE_LENGTH = "AM".length;
|
|
13
|
-
const ROLLOVER = 12;
|
|
14
|
-
utilities_1.ZCC.refTime = refTimes;
|
|
15
|
-
utilities_1.ZCC.shortTime = function (times) {
|
|
16
|
-
const now = (0, dayjs_1.default)();
|
|
17
|
-
const today = now.format("YYYY-MM-DD");
|
|
18
|
-
return times.map((i) => {
|
|
19
|
-
if (i === "NOW") {
|
|
20
|
-
return now;
|
|
21
|
-
}
|
|
22
|
-
if (i === "TOMORROW") {
|
|
23
|
-
return (0, dayjs_1.default)(`${today} 24`);
|
|
24
|
-
}
|
|
25
|
-
let [hour, minute] = i.slice(SLICE_LENGTH).split(":");
|
|
26
|
-
minute ??= "00";
|
|
27
|
-
if (i.charAt(utilities_1.START).toLowerCase() === "p") {
|
|
28
|
-
hour = (Number(hour) + ROLLOVER).toString();
|
|
29
|
-
}
|
|
30
|
-
return (0, dayjs_1.default)(`${today} ${hour}:${minute}`).millisecond(utilities_1.NONE);
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=reftimes.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reftimes.helper.js","sourceRoot":"","sources":["../../../src/automation/helpers/reftimes.helper.ts"],"names":[],"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QACD,OAAO,IAAA,eAAK,EAAC,GAAG,KAAK,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,gBAAI,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { ALL_DOMAINS, GetDomain, PICK_ENTITY } from "../../hass";
|
|
2
|
-
import { TContext } from "../../utilities";
|
|
3
|
-
type SceneAwareDomains = "switch" | "light";
|
|
4
|
-
type RGB = [r: number, g: number, b: number];
|
|
5
|
-
export type LightOff = {
|
|
6
|
-
state: "off";
|
|
7
|
-
};
|
|
8
|
-
export type LightOn = {
|
|
9
|
-
brightness?: number;
|
|
10
|
-
kelvin?: number;
|
|
11
|
-
rgb_color?: RGB;
|
|
12
|
-
state?: "on";
|
|
13
|
-
};
|
|
14
|
-
type EntitySceneType<DOMAIN extends SceneAwareDomains> = {
|
|
15
|
-
light: LightOff | LightOn;
|
|
16
|
-
switch: {
|
|
17
|
-
state: "on" | "off";
|
|
18
|
-
};
|
|
19
|
-
}[DOMAIN];
|
|
20
|
-
export type tSceneType<ENTITY extends PICK_ENTITY<SceneAwareDomains>> = EntitySceneType<GetDomain<ENTITY>>;
|
|
21
|
-
export type tScene = {
|
|
22
|
-
[key in PICK_ENTITY<SceneAwareDomains>]: tSceneType<key>;
|
|
23
|
-
};
|
|
24
|
-
export type SceneDescription<RoomNames extends string = string> = {
|
|
25
|
-
global: string[];
|
|
26
|
-
rooms: Partial<Record<RoomNames, string[]>>;
|
|
27
|
-
};
|
|
28
|
-
export interface AutomationLogicModuleConfiguration {
|
|
29
|
-
global_scenes?: Record<string, boolean>;
|
|
30
|
-
room_configuration?: Record<string, RoomConfiguration<string>>;
|
|
31
|
-
}
|
|
32
|
-
export type AllowedSceneDomains = Extract<ALL_DOMAINS, "switch" | "light" | "fan">;
|
|
33
|
-
export declare const SCENE_ROOM_OPTIONS = "scene-room";
|
|
34
|
-
export type SceneSwitchState = {
|
|
35
|
-
state: "on" | "off";
|
|
36
|
-
};
|
|
37
|
-
export type SceneLightStateOn = {
|
|
38
|
-
/**
|
|
39
|
-
* Light will probably restore previous value
|
|
40
|
-
*/
|
|
41
|
-
brightness: number;
|
|
42
|
-
/**
|
|
43
|
-
* If not provided, light will attempt to use color temp if possible
|
|
44
|
-
*/
|
|
45
|
-
rgb_color?: {
|
|
46
|
-
b: number;
|
|
47
|
-
g: number;
|
|
48
|
-
r: number;
|
|
49
|
-
};
|
|
50
|
-
state: "on";
|
|
51
|
-
};
|
|
52
|
-
export type SceneLightState = {
|
|
53
|
-
state: "off";
|
|
54
|
-
} | SceneLightStateOn;
|
|
55
|
-
type MappedDomains = {
|
|
56
|
-
light: SceneLightState;
|
|
57
|
-
switch: SceneSwitchState;
|
|
58
|
-
};
|
|
59
|
-
export type SceneDefinition = Partial<{
|
|
60
|
-
[entity_id in PICK_ENTITY<keyof MappedDomains>]: MappedDomains[GetDomain<entity_id>];
|
|
61
|
-
}>;
|
|
62
|
-
export type SceneList<SCENES extends string> = Record<SCENES, Partial<Record<PICK_ENTITY<AllowedSceneDomains>, SceneDefinition>>>;
|
|
63
|
-
export type RoomConfiguration<SCENES extends string> = {
|
|
64
|
-
context: TContext;
|
|
65
|
-
/**
|
|
66
|
-
* Friendly name
|
|
67
|
-
*/
|
|
68
|
-
name?: string;
|
|
69
|
-
/**
|
|
70
|
-
* Global scenes are required to be declared within the room
|
|
71
|
-
*/
|
|
72
|
-
scenes: Record<SCENES, RoomScene>;
|
|
73
|
-
};
|
|
74
|
-
export type RoomScene<DEFINITION extends SceneDefinition = SceneDefinition> = {
|
|
75
|
-
/**
|
|
76
|
-
* Ensure entities are maintained as the scene says they should be
|
|
77
|
-
*
|
|
78
|
-
* - Automatically revert changes made by pesky humans
|
|
79
|
-
* - how dare they?!
|
|
80
|
-
*
|
|
81
|
-
* - Ensure lights match the brightness / color the scene says they should be
|
|
82
|
-
* - sometimes things don't fully make brightness transitions, this will fix
|
|
83
|
-
*
|
|
84
|
-
* default: `true` (controlled by config)
|
|
85
|
-
*/
|
|
86
|
-
aggressive?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Human understandable description of this scene (long form)
|
|
89
|
-
*/
|
|
90
|
-
description?: string;
|
|
91
|
-
/**
|
|
92
|
-
* Human understandable description of this scene (short form)
|
|
93
|
-
*/
|
|
94
|
-
friendly_name?: string;
|
|
95
|
-
definition: DEFINITION;
|
|
96
|
-
};
|
|
97
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scene.helper.js","sourceRoot":"","sources":["../../../src/automation/helpers/scene.helper.ts"],"names":[],"mappings":";;;AAyCa,QAAA,kBAAkB,GAAG,YAAY,CAAC"}
|