@digital-alchemy/core 0.1.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 (303) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -0
  3. package/dist/automation/automation.module.d.ts +61 -0
  4. package/dist/automation/automation.module.js +70 -0
  5. package/dist/automation/automation.module.js.map +1 -0
  6. package/dist/automation/extensions/aggressive-scenes.extension.d.ts +22 -0
  7. package/dist/automation/extensions/aggressive-scenes.extension.js +125 -0
  8. package/dist/automation/extensions/aggressive-scenes.extension.js.map +1 -0
  9. package/dist/automation/extensions/circadian.extension.d.ts +11 -0
  10. package/dist/automation/extensions/circadian.extension.js +87 -0
  11. package/dist/automation/extensions/circadian.extension.js.map +1 -0
  12. package/dist/automation/extensions/index.d.ts +7 -0
  13. package/dist/automation/extensions/index.js +11 -0
  14. package/dist/automation/extensions/index.js.map +1 -0
  15. package/dist/automation/extensions/light-manager.extension.d.ts +26 -0
  16. package/dist/automation/extensions/light-manager.extension.js +260 -0
  17. package/dist/automation/extensions/light-manager.extension.js.map +1 -0
  18. package/dist/automation/extensions/managed-switch.extension.d.ts +3 -0
  19. package/dist/automation/extensions/managed-switch.extension.js +73 -0
  20. package/dist/automation/extensions/managed-switch.extension.js.map +1 -0
  21. package/dist/automation/extensions/room.extension.d.ts +11 -0
  22. package/dist/automation/extensions/room.extension.js +179 -0
  23. package/dist/automation/extensions/room.extension.js.map +1 -0
  24. package/dist/automation/extensions/sequence-matcher.extension.d.ts +3 -0
  25. package/dist/automation/extensions/sequence-matcher.extension.js +126 -0
  26. package/dist/automation/extensions/sequence-matcher.extension.js.map +1 -0
  27. package/dist/automation/extensions/solar-calc.extension.d.ts +20 -0
  28. package/dist/automation/extensions/solar-calc.extension.js +105 -0
  29. package/dist/automation/extensions/solar-calc.extension.js.map +1 -0
  30. package/dist/automation/helpers/events.helper.d.ts +33 -0
  31. package/dist/automation/helpers/events.helper.js +14 -0
  32. package/dist/automation/helpers/events.helper.js.map +1 -0
  33. package/dist/automation/helpers/index.d.ts +7 -0
  34. package/dist/automation/helpers/index.js +11 -0
  35. package/dist/automation/helpers/index.js.map +1 -0
  36. package/dist/automation/helpers/managed-switch.helper.d.ts +41 -0
  37. package/dist/automation/helpers/managed-switch.helper.js +3 -0
  38. package/dist/automation/helpers/managed-switch.helper.js.map +1 -0
  39. package/dist/automation/helpers/metrics.helper.d.ts +13 -0
  40. package/dist/automation/helpers/metrics.helper.js +30 -0
  41. package/dist/automation/helpers/metrics.helper.js.map +1 -0
  42. package/dist/automation/helpers/reftimes.helper.d.ts +54 -0
  43. package/dist/automation/helpers/reftimes.helper.js +33 -0
  44. package/dist/automation/helpers/reftimes.helper.js.map +1 -0
  45. package/dist/automation/helpers/scene.helper.d.ts +97 -0
  46. package/dist/automation/helpers/scene.helper.js +5 -0
  47. package/dist/automation/helpers/scene.helper.js.map +1 -0
  48. package/dist/automation/helpers/sequence.helper.d.ts +55 -0
  49. package/dist/automation/helpers/sequence.helper.js +3 -0
  50. package/dist/automation/helpers/sequence.helper.js.map +1 -0
  51. package/dist/automation/helpers/solar.helper.d.ts +3 -0
  52. package/dist/automation/helpers/solar.helper.js +262 -0
  53. package/dist/automation/helpers/solar.helper.js.map +1 -0
  54. package/dist/automation/index.d.ts +3 -0
  55. package/dist/automation/index.js +10 -0
  56. package/dist/automation/index.js.map +1 -0
  57. package/dist/boilerplate/extensions/cache.extension.d.ts +24 -0
  58. package/dist/boilerplate/extensions/cache.extension.js +96 -0
  59. package/dist/boilerplate/extensions/cache.extension.js.map +1 -0
  60. package/dist/boilerplate/extensions/configuration.extension.d.ts +23 -0
  61. package/dist/boilerplate/extensions/configuration.extension.js +98 -0
  62. package/dist/boilerplate/extensions/configuration.extension.js.map +1 -0
  63. package/dist/boilerplate/extensions/fetch.extension.d.ts +20 -0
  64. package/dist/boilerplate/extensions/fetch.extension.js +154 -0
  65. package/dist/boilerplate/extensions/fetch.extension.js.map +1 -0
  66. package/dist/boilerplate/extensions/index.d.ts +6 -0
  67. package/dist/boilerplate/extensions/index.js +10 -0
  68. package/dist/boilerplate/extensions/index.js.map +1 -0
  69. package/dist/boilerplate/extensions/logger.extension.d.ts +39 -0
  70. package/dist/boilerplate/extensions/logger.extension.js +159 -0
  71. package/dist/boilerplate/extensions/logger.extension.js.map +1 -0
  72. package/dist/boilerplate/extensions/scheduler.extension.d.ts +21 -0
  73. package/dist/boilerplate/extensions/scheduler.extension.js +117 -0
  74. package/dist/boilerplate/extensions/scheduler.extension.js.map +1 -0
  75. package/dist/boilerplate/extensions/wiring.extension.d.ts +101 -0
  76. package/dist/boilerplate/extensions/wiring.extension.js +452 -0
  77. package/dist/boilerplate/extensions/wiring.extension.js.map +1 -0
  78. package/dist/boilerplate/helpers/cache-memory.helper.d.ts +7 -0
  79. package/dist/boilerplate/helpers/cache-memory.helper.js +65 -0
  80. package/dist/boilerplate/helpers/cache-memory.helper.js.map +1 -0
  81. package/dist/boilerplate/helpers/cache-redis.helper.d.ts +7 -0
  82. package/dist/boilerplate/helpers/cache-redis.helper.js +69 -0
  83. package/dist/boilerplate/helpers/cache-redis.helper.js.map +1 -0
  84. package/dist/boilerplate/helpers/config-environment-loader.helper.d.ts +2 -0
  85. package/dist/boilerplate/helpers/config-environment-loader.helper.js +56 -0
  86. package/dist/boilerplate/helpers/config-environment-loader.helper.js.map +1 -0
  87. package/dist/boilerplate/helpers/config-file-loader.helper.d.ts +4 -0
  88. package/dist/boilerplate/helpers/config-file-loader.helper.js +87 -0
  89. package/dist/boilerplate/helpers/config-file-loader.helper.js.map +1 -0
  90. package/dist/boilerplate/helpers/config.helper.d.ts +102 -0
  91. package/dist/boilerplate/helpers/config.helper.js +32 -0
  92. package/dist/boilerplate/helpers/config.helper.js.map +1 -0
  93. package/dist/boilerplate/helpers/errors.helper.d.ts +39 -0
  94. package/dist/boilerplate/helpers/errors.helper.js +76 -0
  95. package/dist/boilerplate/helpers/errors.helper.js.map +1 -0
  96. package/dist/boilerplate/helpers/events.helper.d.ts +3 -0
  97. package/dist/boilerplate/helpers/events.helper.js +11 -0
  98. package/dist/boilerplate/helpers/events.helper.js.map +1 -0
  99. package/dist/boilerplate/helpers/fetch.helper.d.ts +170 -0
  100. package/dist/boilerplate/helpers/fetch.helper.js +173 -0
  101. package/dist/boilerplate/helpers/fetch.helper.js.map +1 -0
  102. package/dist/boilerplate/helpers/index.d.ts +12 -0
  103. package/dist/boilerplate/helpers/index.js +16 -0
  104. package/dist/boilerplate/helpers/index.js.map +1 -0
  105. package/dist/boilerplate/helpers/lifecycle.helper.d.ts +43 -0
  106. package/dist/boilerplate/helpers/lifecycle.helper.js +13 -0
  107. package/dist/boilerplate/helpers/lifecycle.helper.js.map +1 -0
  108. package/dist/boilerplate/helpers/metrics.helper.d.ts +73 -0
  109. package/dist/boilerplate/helpers/metrics.helper.js +141 -0
  110. package/dist/boilerplate/helpers/metrics.helper.js.map +1 -0
  111. package/dist/boilerplate/helpers/testing.helper.d.ts +13 -0
  112. package/dist/boilerplate/helpers/testing.helper.js +91 -0
  113. package/dist/boilerplate/helpers/testing.helper.js.map +1 -0
  114. package/dist/boilerplate/helpers/wiring.helper.d.ts +155 -0
  115. package/dist/boilerplate/helpers/wiring.helper.js +5 -0
  116. package/dist/boilerplate/helpers/wiring.helper.js.map +1 -0
  117. package/dist/boilerplate/index.d.ts +2 -0
  118. package/dist/boilerplate/index.js +6 -0
  119. package/dist/boilerplate/index.js.map +1 -0
  120. package/dist/gotify/extensions/application.extension.d.ts +13 -0
  121. package/dist/gotify/extensions/application.extension.js +52 -0
  122. package/dist/gotify/extensions/application.extension.js.map +1 -0
  123. package/dist/gotify/extensions/client.extension.d.ts +8 -0
  124. package/dist/gotify/extensions/client.extension.js +38 -0
  125. package/dist/gotify/extensions/client.extension.js.map +1 -0
  126. package/dist/gotify/extensions/fetch.extension.d.ts +2 -0
  127. package/dist/gotify/extensions/fetch.extension.js +14 -0
  128. package/dist/gotify/extensions/fetch.extension.js.map +1 -0
  129. package/dist/gotify/extensions/index.d.ts +4 -0
  130. package/dist/gotify/extensions/index.js +8 -0
  131. package/dist/gotify/extensions/index.js.map +1 -0
  132. package/dist/gotify/extensions/message.extension.d.ts +8 -0
  133. package/dist/gotify/extensions/message.extension.js +37 -0
  134. package/dist/gotify/extensions/message.extension.js.map +1 -0
  135. package/dist/gotify/gotify.module.d.ts +29 -0
  136. package/dist/gotify/gotify.module.js +33 -0
  137. package/dist/gotify/gotify.module.js.map +1 -0
  138. package/dist/gotify/helpers/api.d.ts +346 -0
  139. package/dist/gotify/helpers/api.js +14 -0
  140. package/dist/gotify/helpers/api.js.map +1 -0
  141. package/dist/gotify/helpers/events.helper.d.ts +6 -0
  142. package/dist/gotify/helpers/events.helper.js +5 -0
  143. package/dist/gotify/helpers/events.helper.js.map +1 -0
  144. package/dist/gotify/helpers/index.d.ts +2 -0
  145. package/dist/gotify/helpers/index.js +6 -0
  146. package/dist/gotify/helpers/index.js.map +1 -0
  147. package/dist/gotify/index.d.ts +3 -0
  148. package/dist/gotify/index.js +7 -0
  149. package/dist/gotify/index.js.map +1 -0
  150. package/dist/hass/dynamic.d.ts +1126 -0
  151. package/dist/hass/dynamic.js +153 -0
  152. package/dist/hass/dynamic.js.map +1 -0
  153. package/dist/hass/extensions/call-proxy.extension.d.ts +4 -0
  154. package/dist/hass/extensions/call-proxy.extension.js +88 -0
  155. package/dist/hass/extensions/call-proxy.extension.js.map +1 -0
  156. package/dist/hass/extensions/entity-manager.extension.d.ts +61 -0
  157. package/dist/hass/extensions/entity-manager.extension.js +214 -0
  158. package/dist/hass/extensions/entity-manager.extension.js.map +1 -0
  159. package/dist/hass/extensions/fetch-api.extension.d.ts +26 -0
  160. package/dist/hass/extensions/fetch-api.extension.js +166 -0
  161. package/dist/hass/extensions/fetch-api.extension.js.map +1 -0
  162. package/dist/hass/extensions/index.d.ts +5 -0
  163. package/dist/hass/extensions/index.js +9 -0
  164. package/dist/hass/extensions/index.js.map +1 -0
  165. package/dist/hass/extensions/utilities.extension.d.ts +9 -0
  166. package/dist/hass/extensions/utilities.extension.js +43 -0
  167. package/dist/hass/extensions/utilities.extension.js.map +1 -0
  168. package/dist/hass/extensions/websocket-api.extension.d.ts +39 -0
  169. package/dist/hass/extensions/websocket-api.extension.js +363 -0
  170. package/dist/hass/extensions/websocket-api.extension.js.map +1 -0
  171. package/dist/hass/hass.module.d.ts +53 -0
  172. package/dist/hass/hass.module.js +59 -0
  173. package/dist/hass/hass.module.js.map +1 -0
  174. package/dist/hass/helpers/backup.helper.d.ts +11 -0
  175. package/dist/hass/helpers/backup.helper.js +3 -0
  176. package/dist/hass/helpers/backup.helper.js.map +1 -0
  177. package/dist/hass/helpers/constants.helper.d.ts +54 -0
  178. package/dist/hass/helpers/constants.helper.js +63 -0
  179. package/dist/hass/helpers/constants.helper.js.map +1 -0
  180. package/dist/hass/helpers/entity-state.helper.d.ts +45 -0
  181. package/dist/hass/helpers/entity-state.helper.js +9 -0
  182. package/dist/hass/helpers/entity-state.helper.js.map +1 -0
  183. package/dist/hass/helpers/fetch/calendar.d.ts +54 -0
  184. package/dist/hass/helpers/fetch/calendar.js +3 -0
  185. package/dist/hass/helpers/fetch/calendar.js.map +1 -0
  186. package/dist/hass/helpers/fetch/configuration.d.ts +34 -0
  187. package/dist/hass/helpers/fetch/configuration.js +3 -0
  188. package/dist/hass/helpers/fetch/configuration.js.map +1 -0
  189. package/dist/hass/helpers/fetch/index.d.ts +4 -0
  190. package/dist/hass/helpers/fetch/index.js +8 -0
  191. package/dist/hass/helpers/fetch/index.js.map +1 -0
  192. package/dist/hass/helpers/fetch/server-log.d.ts +10 -0
  193. package/dist/hass/helpers/fetch/server-log.js +20 -0
  194. package/dist/hass/helpers/fetch/server-log.js.map +1 -0
  195. package/dist/hass/helpers/fetch/service-list.d.ts +51 -0
  196. package/dist/hass/helpers/fetch/service-list.js +3 -0
  197. package/dist/hass/helpers/fetch/service-list.js.map +1 -0
  198. package/dist/hass/helpers/index.d.ts +7 -0
  199. package/dist/hass/helpers/index.js +11 -0
  200. package/dist/hass/helpers/index.js.map +1 -0
  201. package/dist/hass/helpers/metrics.helper.d.ts +13 -0
  202. package/dist/hass/helpers/metrics.helper.js +30 -0
  203. package/dist/hass/helpers/metrics.helper.js.map +1 -0
  204. package/dist/hass/helpers/utility.helper.d.ts +57 -0
  205. package/dist/hass/helpers/utility.helper.js +34 -0
  206. package/dist/hass/helpers/utility.helper.js.map +1 -0
  207. package/dist/hass/helpers/websocket.helper.d.ts +129 -0
  208. package/dist/hass/helpers/websocket.helper.js +3 -0
  209. package/dist/hass/helpers/websocket.helper.js.map +1 -0
  210. package/dist/hass/index.d.ts +4 -0
  211. package/dist/hass/index.js +8 -0
  212. package/dist/hass/index.js.map +1 -0
  213. package/dist/index.d.ts +2 -0
  214. package/dist/index.js +8 -0
  215. package/dist/index.js.map +1 -0
  216. package/dist/nexus/entities.extension.d.ts +2 -0
  217. package/dist/nexus/entities.extension.js +51 -0
  218. package/dist/nexus/entities.extension.js.map +1 -0
  219. package/dist/nexus/main.d.ts +9 -0
  220. package/dist/nexus/main.js +28 -0
  221. package/dist/nexus/main.js.map +1 -0
  222. package/dist/synapse/extensions/binary-sensor.extension.d.ts +19 -0
  223. package/dist/synapse/extensions/binary-sensor.extension.js +84 -0
  224. package/dist/synapse/extensions/binary-sensor.extension.js.map +1 -0
  225. package/dist/synapse/extensions/button.extension.d.ts +10 -0
  226. package/dist/synapse/extensions/button.extension.js +46 -0
  227. package/dist/synapse/extensions/button.extension.js.map +1 -0
  228. package/dist/synapse/extensions/index.d.ts +6 -0
  229. package/dist/synapse/extensions/index.js +10 -0
  230. package/dist/synapse/extensions/index.js.map +1 -0
  231. package/dist/synapse/extensions/registry.extension.d.ts +21 -0
  232. package/dist/synapse/extensions/registry.extension.js +207 -0
  233. package/dist/synapse/extensions/registry.extension.js.map +1 -0
  234. package/dist/synapse/extensions/scene.extension.d.ts +9 -0
  235. package/dist/synapse/extensions/scene.extension.js +37 -0
  236. package/dist/synapse/extensions/scene.extension.js.map +1 -0
  237. package/dist/synapse/extensions/sensor.extension.d.ts +25 -0
  238. package/dist/synapse/extensions/sensor.extension.js +154 -0
  239. package/dist/synapse/extensions/sensor.extension.js.map +1 -0
  240. package/dist/synapse/extensions/switch.extension.d.ts +19 -0
  241. package/dist/synapse/extensions/switch.extension.js +95 -0
  242. package/dist/synapse/extensions/switch.extension.js.map +1 -0
  243. package/dist/synapse/helpers/device-class.helper.d.ts +323 -0
  244. package/dist/synapse/helpers/device-class.helper.js +241 -0
  245. package/dist/synapse/helpers/device-class.helper.js.map +1 -0
  246. package/dist/synapse/helpers/index.d.ts +3 -0
  247. package/dist/synapse/helpers/index.js +7 -0
  248. package/dist/synapse/helpers/index.js.map +1 -0
  249. package/dist/synapse/helpers/metrics.helper.d.ts +13 -0
  250. package/dist/synapse/helpers/metrics.helper.js +30 -0
  251. package/dist/synapse/helpers/metrics.helper.js.map +1 -0
  252. package/dist/synapse/helpers/utility.helper.d.ts +1 -0
  253. package/dist/synapse/helpers/utility.helper.js +3 -0
  254. package/dist/synapse/helpers/utility.helper.js.map +1 -0
  255. package/dist/synapse/index.d.ts +3 -0
  256. package/dist/synapse/index.js +7 -0
  257. package/dist/synapse/index.js.map +1 -0
  258. package/dist/synapse/synapse.module.d.ts +29 -0
  259. package/dist/synapse/synapse.module.js +41 -0
  260. package/dist/synapse/synapse.module.js.map +1 -0
  261. package/dist/type-writer/build.extension.d.ts +2 -0
  262. package/dist/type-writer/build.extension.js +53 -0
  263. package/dist/type-writer/build.extension.js.map +1 -0
  264. package/dist/type-writer/main.d.ts +17 -0
  265. package/dist/type-writer/main.js +36 -0
  266. package/dist/type-writer/main.js.map +1 -0
  267. package/dist/type-writer/type-writer.extension.d.ts +2 -0
  268. package/dist/type-writer/type-writer.extension.js +212 -0
  269. package/dist/type-writer/type-writer.extension.js.map +1 -0
  270. package/dist/utilities/extensions/index.d.ts +3 -0
  271. package/dist/utilities/extensions/index.js +7 -0
  272. package/dist/utilities/extensions/index.js.map +1 -0
  273. package/dist/utilities/extensions/is.extension.d.ts +38 -0
  274. package/dist/utilities/extensions/is.extension.js +104 -0
  275. package/dist/utilities/extensions/is.extension.js.map +1 -0
  276. package/dist/utilities/extensions/zcc-testing.extension.d.ts +4 -0
  277. package/dist/utilities/extensions/zcc-testing.extension.js +9 -0
  278. package/dist/utilities/extensions/zcc-testing.extension.js.map +1 -0
  279. package/dist/utilities/extensions/zcc.extension.d.ts +20 -0
  280. package/dist/utilities/extensions/zcc.extension.js +66 -0
  281. package/dist/utilities/extensions/zcc.extension.js.map +1 -0
  282. package/dist/utilities/helpers/async.helper.d.ts +2 -0
  283. package/dist/utilities/helpers/async.helper.js +26 -0
  284. package/dist/utilities/helpers/async.helper.js.map +1 -0
  285. package/dist/utilities/helpers/context.helper.d.ts +7 -0
  286. package/dist/utilities/helpers/context.helper.js +3 -0
  287. package/dist/utilities/helpers/context.helper.js.map +1 -0
  288. package/dist/utilities/helpers/cron.helper.d.ts +87 -0
  289. package/dist/utilities/helpers/cron.helper.js +92 -0
  290. package/dist/utilities/helpers/cron.helper.js.map +1 -0
  291. package/dist/utilities/helpers/extend.helper.d.ts +2 -0
  292. package/dist/utilities/helpers/extend.helper.js +68 -0
  293. package/dist/utilities/helpers/extend.helper.js.map +1 -0
  294. package/dist/utilities/helpers/index.d.ts +5 -0
  295. package/dist/utilities/helpers/index.js +9 -0
  296. package/dist/utilities/helpers/index.js.map +1 -0
  297. package/dist/utilities/helpers/utilities.helper.d.ts +63 -0
  298. package/dist/utilities/helpers/utilities.helper.js +93 -0
  299. package/dist/utilities/helpers/utilities.helper.js.map +1 -0
  300. package/dist/utilities/index.d.ts +2 -0
  301. package/dist/utilities/index.js +6 -0
  302. package/dist/utilities/index.js.map +1 -0
  303. package/package.json +101 -0
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SequenceWatcher = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const object_path_1 = tslib_1.__importDefault(require("object-path"));
6
+ const uuid_1 = require("uuid");
7
+ const utilities_1 = require("../../utilities");
8
+ const __1 = require("..");
9
+ // eslint-disable-next-line @typescript-eslint/unbound-method
10
+ const { get } = object_path_1.default;
11
+ function SequenceWatcher({ logger, hass, config }) {
12
+ const ACTIVE = new Map();
13
+ const WATCHED_EVENTS = new Map();
14
+ const EVENT_REMOVAL = new Map();
15
+ async function onMatch(data) {
16
+ await data.exec();
17
+ const reset = data.reset ?? "self";
18
+ if (reset === "self") {
19
+ ACTIVE.delete(data);
20
+ return;
21
+ }
22
+ if (!utilities_1.is.object(reset)) {
23
+ logger.error({ reset: data.reset }, `bad reset type`);
24
+ return;
25
+ }
26
+ const labels = new Set([reset.label].flat().filter(i => !utilities_1.is.empty(i)));
27
+ [...ACTIVE.keys()].forEach(key => {
28
+ const item = ACTIVE.get(key);
29
+ if (labels.has(item.label)) {
30
+ item.interrupt.kill("stop");
31
+ ACTIVE.delete(key);
32
+ }
33
+ });
34
+ }
35
+ function trigger(type, event_data) {
36
+ WATCHED_EVENTS.get(type).forEach(async (data) => {
37
+ const allowed = data.filter(event_data);
38
+ if (!allowed) {
39
+ return;
40
+ }
41
+ // * Identify if it is already being watched
42
+ const current = ACTIVE.get(data);
43
+ const match = [];
44
+ if (current) {
45
+ // if so, kill the current sleep so it doesn't gc early
46
+ current.interrupt.kill("stop");
47
+ // prepend the current matches in to the new list
48
+ match.push(...current.match);
49
+ }
50
+ // * Grab the new value from the event, and add it on the list
51
+ const value = get(event_data, data.path);
52
+ match.push(value);
53
+ // * If the sequence matches, fire the callback
54
+ if (utilities_1.is.equal(match, data.match)) {
55
+ await onMatch(data);
56
+ }
57
+ // * wait out the match timeout using a sleep that can be cancelled
58
+ const interrupt = (0, utilities_1.sleep)(config.automation.SEQUENCE_TIMEOUT);
59
+ ACTIVE.set(data, {
60
+ interrupt,
61
+ label: data.label,
62
+ match,
63
+ reset: data.reset,
64
+ });
65
+ await interrupt;
66
+ // * New event hasn't come in within time period. >>> GC
67
+ ACTIVE.delete(data);
68
+ });
69
+ }
70
+ function SequenceWatcher(data) {
71
+ const { exec, event_type, match, context, label, path, filter } = data;
72
+ logger.trace({ context }, `setting up sequence watcher`);
73
+ const id = (0, uuid_1.v4)();
74
+ // If this is the first watcher for this event, set up a listener
75
+ let watcher = WATCHED_EVENTS.get(event_type);
76
+ if (!watcher) {
77
+ watcher = [];
78
+ logger.trace({ event_type }, `listening for socket event`);
79
+ const remover = hass.socket.onEvent({
80
+ context,
81
+ event: event_type,
82
+ exec: eventData => trigger(event_type, eventData),
83
+ label,
84
+ });
85
+ EVENT_REMOVAL.set(event_type, remover);
86
+ }
87
+ // Append watcher to list
88
+ WATCHED_EVENTS.set(event_type, [
89
+ ...watcher,
90
+ {
91
+ context,
92
+ event_type,
93
+ exec: () => {
94
+ logger.trace({ context, label, match }, `sequence match trigger`);
95
+ setImmediate(async () => await utilities_1.ZCC.safeExec({
96
+ duration: __1.SEQUENCE_MATCHER_EXECUTION_TIME,
97
+ errors: __1.SEQUENCE_MATCHER_ERRORS,
98
+ exec: async () => await exec(),
99
+ executions: __1.SEQUENCE_MATCHER_EXECUTION_COUNT,
100
+ labels: { context, label },
101
+ }));
102
+ },
103
+ filter: filter,
104
+ id,
105
+ label,
106
+ match,
107
+ path,
108
+ },
109
+ ]);
110
+ // Return a removal function
111
+ return () => {
112
+ const watcher = WATCHED_EVENTS.get(event_type).filter(item => item.id !== id);
113
+ if (utilities_1.is.empty(watcher)) {
114
+ logger.debug({ event_type }, `last watcher for event removed, cleaning up socket event listener`);
115
+ WATCHED_EVENTS.delete(event_type);
116
+ EVENT_REMOVAL.get(event_type)();
117
+ EVENT_REMOVAL.delete(event_type);
118
+ return;
119
+ }
120
+ WATCHED_EVENTS.set(event_type, watcher);
121
+ };
122
+ }
123
+ return SequenceWatcher;
124
+ }
125
+ exports.SequenceWatcher = SequenceWatcher;
126
+ //# sourceMappingURL=sequence-matcher.extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequence-matcher.extension.js","sourceRoot":"","sources":["../../../src/automation/extensions/sequence-matcher.extension.ts"],"names":[],"mappings":";;;;AAAA,sEAA8B;AAC9B,+BAA0B;AAG1B,+CAAiD;AACjD,0BAQY;AAEZ,6DAA6D;AAC7D,MAAM,EAAE,GAAG,EAAE,GAAG,qBAAG,CAAC;AAEpB,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;IAEpD,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,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,cAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YA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AAE,EAAE,wBAAwB,CAAC,CAAC;oBAClE,YAAY,CACV,KAAK,IAAI,EAAE,CACT,MAAM,eAAG,CAAC,QAAQ,CAAC;wBACjB,QAAQ,EAAE,mCAA+B;wBACzC,MAAM,EAAE,2BAAuB;wBAC/B,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,IAAI,EAAE;wBAC9B,UAAU,EAAE,oCAAgC;wBAC5C,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;qBAC3B,CAAC,CACL,CAAC;gBACJ,CAAC;gBACD,MAAM,EAAE,MAAuB;gBAC/B,EAAE;gBACF,KAAK;gBACL,KAAK;gBACL,IAAI;aACL;SACF,CAAC,CAAC;QAEH,4BAA4B;QAC5B,OAAO,GAAG,EAAE;YACV,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,MAAM,CACnD,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CACvB,CAAC;YACF,IAAI,cAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gBACtB,MAAM,CAAC,KAAK,CACV,EAAE,UAAU,EAAE,EACd,mEAAmE,CACpE,CAAC;gBACF,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;gBAClC,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;AAxID,0CAwIC"}
@@ -0,0 +1,20 @@
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, context, 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 {};
@@ -0,0 +1,105 @@
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, context, 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
+ context,
54
+ exec: () => PopulateReferences(),
55
+ schedule: utilities_1.CronExpression.EVERY_HOUR,
56
+ });
57
+ async function updateLocation() {
58
+ config = await hass.fetch.getConfig();
59
+ await cache.set(CACHE_KEY, config);
60
+ PopulateReferences();
61
+ }
62
+ const solarReference = {};
63
+ async function PopulateReferences() {
64
+ solarReference.dawn = (0, dayjs_1.default)((0, __1.calcSunriseSet)(true, degreesBelowHorizon.twilight, config.latitude, config.longitude));
65
+ solarReference.sunriseEnd = (0, dayjs_1.default)((0, __1.calcSunriseSet)(true, degreesBelowHorizon.sunriseEnd, config.latitude, config.longitude));
66
+ solarReference.sunsetStart = (0, dayjs_1.default)((0, __1.calcSunriseSet)(false, degreesBelowHorizon.sunriseEnd, config.latitude, config.longitude));
67
+ solarReference.dusk = (0, dayjs_1.default)((0, __1.calcSunriseSet)(false, degreesBelowHorizon.twilight, config.latitude, config.longitude));
68
+ solarReference.nightStart = (0, dayjs_1.default)((0, __1.calcSunriseSet)(false, degreesBelowHorizon.night, config.latitude, config.longitude));
69
+ solarReference.nightEnd = (0, dayjs_1.default)((0, __1.calcSunriseSet)(true, degreesBelowHorizon.night, config.latitude, config.longitude));
70
+ solarReference.sunrise = (0, dayjs_1.default)((0, __1.calcSunriseSet)(true, degreesBelowHorizon.sunrise, config.latitude, config.longitude));
71
+ solarReference.sunset = (0, dayjs_1.default)((0, __1.calcSunriseSet)(false, degreesBelowHorizon.sunrise, config.latitude, config.longitude));
72
+ solarReference.solarNoon = (0, dayjs_1.default)((0, __1.calcSolNoon)(config.longitude));
73
+ solarReference.loaded = true;
74
+ const now = (0, dayjs_1.default)();
75
+ const today = now.format("YYYY-MM-DD");
76
+ if (lastEventAttachment !== today) {
77
+ lastEventAttachment = today;
78
+ solarEvents.forEach((i) => {
79
+ if (solarReference[i].isBefore(now)) {
80
+ return;
81
+ }
82
+ setTimeout(() => event.emit(i), Math.abs(now.diff(solarReference[i], "ms")));
83
+ });
84
+ }
85
+ }
86
+ solarReference.loaded = false;
87
+ solarReference.isBetween = (a, b) => {
88
+ const now = (0, dayjs_1.default)();
89
+ return now.isBetween(solarReference[a], solarReference[b]);
90
+ };
91
+ solarReference.onEvent = ({ context, eventName, label, exec, }) => {
92
+ event.on(eventName, async () => {
93
+ await utilities_1.ZCC.safeExec({
94
+ duration: undefined,
95
+ errors: undefined,
96
+ exec: async () => await exec(),
97
+ executions: undefined,
98
+ labels: { context, label },
99
+ });
100
+ });
101
+ };
102
+ return solarReference;
103
+ }
104
+ exports.SolarCalculator = SolarCalculator;
105
+ //# sourceMappingURL=solar-calc.extension.js.map
@@ -0,0 +1 @@
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,SAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,KAAK,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,SAAS,GACM;IACf,IAAI,MAAkB,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C,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,cAAgC,CAAC;AAC1C,CAAC;AA9JD,0CA8JC"}
@@ -0,0 +1,33 @@
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
+ };
@@ -0,0 +1,14 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,7 @@
1
+ export * from "./events.helper";
2
+ export * from "./managed-switch.helper";
3
+ export * from "./metrics.helper";
4
+ export * from "./reftimes.helper";
5
+ export * from "./scene.helper";
6
+ export * from "./sequence.helper";
7
+ export * from "./solar.helper";
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,41 @@
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 {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=managed-switch.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managed-switch.helper.js","sourceRoot":"","sources":["../../../src/automation/helpers/managed-switch.helper.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
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">;
@@ -0,0 +1,30 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,54 @@
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 {};
@@ -0,0 +1,33 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reftimes.helper.js","sourceRoot":"","sources":["../../../src/automation/helpers/reftimes.helper.ts"],"names":[],"mappings":";;;;AAAA,0DAAqC;AAErC,+CAAmD;AAEnD,SAAgB,QAAQ,CAAC,KAAmB;IAC1C,MAAM,KAAK,GAAG,IAAA,eAAK,GAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC3C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,eAAK,EAAC,GAAG,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,gBAAI,CAAC,CAAC,CAAC;AAClE,CAAC;AAHD,4BAGC;AA8ED,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;AACjC,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,eAAG,CAAC,OAAO,GAAG,QAAQ,CAAC;AAEvB,eAAG,CAAC,SAAS,GAAG,UAAU,KAAkB;IAC1C,MAAM,GAAG,GAAG,IAAA,eAAK,GAAE,CAAC;IACpB,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QACnB,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;YAChB,OAAO,GAAG,CAAC;QACb,CAAC;QACD,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC;YACrB,OAAO,IAAA,eAAK,EAAC,GAAG,KAAK,KAAK,CAAC,CAAC;QAC9B,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtD,MAAM,KAAK,IAAI,CAAC;QAChB,IAAI,CAAC,CAAC,MAAM,CAAC,iBAAK,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,EAAE,CAAC;YAC1C,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9C,CAAC;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"}
@@ -0,0 +1,97 @@
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 {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SCENE_ROOM_OPTIONS = void 0;
4
+ exports.SCENE_ROOM_OPTIONS = "scene-room";
5
+ //# sourceMappingURL=scene.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene.helper.js","sourceRoot":"","sources":["../../../src/automation/helpers/scene.helper.ts"],"names":[],"mappings":";;;AAyCa,QAAA,kBAAkB,GAAG,YAAY,CAAC"}