@ajclarkson/homerun 0.0.1-edge.db0717b → 0.0.1-edge.f1d8985

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.
@@ -51,7 +51,7 @@ export class ApiServer {
51
51
  id: a.id,
52
52
  location: a.location,
53
53
  subsystem: a.subsystem,
54
- triggerTypes: a.triggers.map((t) => t.type),
54
+ triggers: a.triggers.map(serializeTrigger),
55
55
  }));
56
56
  json(res, 200, automations);
57
57
  }
@@ -100,6 +100,12 @@ export class ApiServer {
100
100
  req.on('close', unsubscribe);
101
101
  }
102
102
  }
103
+ function serializeTrigger(trigger) {
104
+ if (trigger.type === 'state_changed' && trigger.entity instanceof RegExp) {
105
+ return { ...trigger, entity: trigger.entity.toString() };
106
+ }
107
+ return trigger;
108
+ }
103
109
  function json(res, status, body) {
104
110
  const payload = JSON.stringify(body);
105
111
  res.writeHead(status, { 'Content-Type': 'application/json' });
@@ -1,4 +1,4 @@
1
- const DOUBLE_PRESS_WINDOW_MS = 400;
1
+ const DOUBLE_PRESS_WINDOW_MS = 250;
2
2
  class ButtonGestureHandler {
3
3
  entityId;
4
4
  dispatch;
@@ -4,6 +4,8 @@ import type { HAContext } from './framework/ha-client.js';
4
4
  type TestStateEntry = {
5
5
  state: string;
6
6
  attributes?: Record<string, unknown>;
7
+ last_changed?: string;
8
+ last_updated?: string;
7
9
  };
8
10
  interface TestOptions {
9
11
  event: TriggerEvent;
@@ -9,8 +9,8 @@ export function testAutomation(automation, options) {
9
9
  entity_id: entityId,
10
10
  state: entry.state,
11
11
  attributes: entry.attributes ?? {},
12
- last_changed: '',
13
- last_updated: '',
12
+ last_changed: entry.last_changed ?? '',
13
+ last_updated: entry.last_updated ?? '',
14
14
  };
15
15
  };
16
16
  const haContext = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ajclarkson/homerun",
3
3
  "type": "module",
4
- "version": "0.0.1-edge.db0717b",
4
+ "version": "0.0.1-edge.f1d8985",
5
5
  "description": "TypeScript automation framework for Home Assistant",
6
6
  "files": [
7
7
  "dist"