@glasshome/sync-layer 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.
- package/LICENSE +21 -0
- package/README.md +120 -0
- package/dist/area-views-B-m8vwce.js +321 -0
- package/dist/camera/fetch.d.ts +15 -0
- package/dist/camera/query.d.ts +15 -0
- package/dist/camera/types.d.ts +85 -0
- package/dist/camera/webrtc.d.ts +31 -0
- package/dist/commands/service.d.ts +53 -0
- package/dist/commands/types.d.ts +113 -0
- package/dist/connection/adapter.d.ts +48 -0
- package/dist/connection/auth.d.ts +126 -0
- package/dist/connection/manager.d.ts +42 -0
- package/dist/connection/subscriptions.d.ts +25 -0
- package/dist/connection/types.d.ts +161 -0
- package/dist/core/reducers.d.ts +99 -0
- package/dist/core/store.d.ts +64 -0
- package/dist/core/types.d.ts +336 -0
- package/dist/demo/demo-data.d.ts +24 -0
- package/dist/demo/demo-provider.d.ts +33 -0
- package/dist/demo/demo-provider.js +103 -0
- package/dist/demo-data-D8JXWRpw.js +419 -0
- package/dist/entities/area-views.d.ts +25 -0
- package/dist/entities/index.d.ts +54 -0
- package/dist/entities/views.d.ts +30 -0
- package/dist/history/constants.d.ts +16 -0
- package/dist/history/fetch.d.ts +19 -0
- package/dist/history/query.d.ts +13 -0
- package/dist/history/types.d.ts +146 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +1747 -0
- package/dist/query/area-builder.d.ts +25 -0
- package/dist/query/builder.d.ts +18 -0
- package/dist/query/helpers.d.ts +21 -0
- package/dist/query/memoization.d.ts +18 -0
- package/dist/query/projections.d.ts +74 -0
- package/dist/query/types.d.ts +260 -0
- package/dist/solid/hooks.d.ts +88 -0
- package/dist/solid/index.d.ts +10 -0
- package/dist/solid/index.js +176 -0
- package/dist/solid/indices.d.ts +14 -0
- package/dist/store-B1sbyexX.js +54 -0
- package/dist/testing/fixtures.d.ts +161 -0
- package/dist/testing/helpers.d.ts +160 -0
- package/dist/testing/index.d.ts +13 -0
- package/dist/testing/index.js +2047 -0
- package/dist/testing/mock-behaviors/base.d.ts +73 -0
- package/dist/testing/mock-behaviors/climate.d.ts +22 -0
- package/dist/testing/mock-behaviors/cover.d.ts +22 -0
- package/dist/testing/mock-behaviors/index.d.ts +11 -0
- package/dist/testing/mock-behaviors/light.d.ts +20 -0
- package/dist/testing/mock-behaviors/lock.d.ts +20 -0
- package/dist/testing/mock-behaviors/media_player.d.ts +42 -0
- package/dist/testing/mock-behaviors/registry.d.ts +55 -0
- package/dist/testing/mock-behaviors/switch.d.ts +17 -0
- package/dist/testing/mock.d.ts +191 -0
- package/dist/testing/types.d.ts +87 -0
- package/dist/types-Csog0nqk.js +10 -0
- package/dist/weather/fetch.d.ts +19 -0
- package/dist/weather/query.d.ts +23 -0
- package/dist/weather/types.d.ts +126 -0
- package/package.json +85 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
//#region src/demo/demo-data.ts
|
|
2
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3
|
+
let contextCounter = 0;
|
|
4
|
+
function ctx() {
|
|
5
|
+
return {
|
|
6
|
+
id: `demo-${++contextCounter}`,
|
|
7
|
+
parent_id: null,
|
|
8
|
+
user_id: null
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function makeEntity(entity_id, state, attributes = {}) {
|
|
12
|
+
return {
|
|
13
|
+
entity_id,
|
|
14
|
+
state,
|
|
15
|
+
attributes: {
|
|
16
|
+
friendly_name: friendlyName(entity_id),
|
|
17
|
+
...attributes
|
|
18
|
+
},
|
|
19
|
+
last_changed: now,
|
|
20
|
+
last_updated: now,
|
|
21
|
+
context: ctx()
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function friendlyName(entityId) {
|
|
25
|
+
const objectId = entityId.split(".")[1] ?? entityId;
|
|
26
|
+
return objectId.split("_").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
27
|
+
}
|
|
28
|
+
function makeRegistryEntry(entity_id, overrides = {}) {
|
|
29
|
+
const domain = entity_id.split(".")[0] ?? "";
|
|
30
|
+
return {
|
|
31
|
+
aliases: [],
|
|
32
|
+
area_id: null,
|
|
33
|
+
capabilities: null,
|
|
34
|
+
categories: {},
|
|
35
|
+
config_entry_id: "demo_config",
|
|
36
|
+
config_subentry_id: null,
|
|
37
|
+
created_at: now,
|
|
38
|
+
device_class: null,
|
|
39
|
+
device_id: null,
|
|
40
|
+
disabled_by: null,
|
|
41
|
+
entity_category: null,
|
|
42
|
+
entity_id,
|
|
43
|
+
has_entity_name: false,
|
|
44
|
+
hidden_by: null,
|
|
45
|
+
icon: null,
|
|
46
|
+
id: `reg-${entity_id.replace(".", "-")}`,
|
|
47
|
+
labels: [],
|
|
48
|
+
modified_at: now,
|
|
49
|
+
name: null,
|
|
50
|
+
options: {},
|
|
51
|
+
original_device_class: null,
|
|
52
|
+
original_icon: null,
|
|
53
|
+
original_name: null,
|
|
54
|
+
platform: domain === "weather" ? "met" : "demo",
|
|
55
|
+
previous_unique_id: null,
|
|
56
|
+
suggested_object_id: null,
|
|
57
|
+
supported_features: 0,
|
|
58
|
+
translation_key: null,
|
|
59
|
+
unique_id: `demo_${entity_id.replace(".", "_")}`,
|
|
60
|
+
unit_of_measurement: null,
|
|
61
|
+
...overrides
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function makeDevice(id, name, areaId, manufacturer = "Demo", model = "Virtual") {
|
|
65
|
+
return {
|
|
66
|
+
id,
|
|
67
|
+
name,
|
|
68
|
+
name_by_user: null,
|
|
69
|
+
manufacturer,
|
|
70
|
+
model,
|
|
71
|
+
model_id: null,
|
|
72
|
+
sw_version: "1.0.0",
|
|
73
|
+
hw_version: null,
|
|
74
|
+
area_id: areaId,
|
|
75
|
+
config_entries: ["demo_config"],
|
|
76
|
+
config_entries_subentries: {},
|
|
77
|
+
configuration_url: null,
|
|
78
|
+
connections: [],
|
|
79
|
+
created_at: now,
|
|
80
|
+
disabled_by: null,
|
|
81
|
+
entry_type: null,
|
|
82
|
+
identifiers: [["demo", id]],
|
|
83
|
+
labels: [],
|
|
84
|
+
modified_at: now,
|
|
85
|
+
primary_config_entry: "demo_config",
|
|
86
|
+
serial_number: null,
|
|
87
|
+
via_device_id: null
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function makeArea(id, name, floorId = "ground_floor") {
|
|
91
|
+
return {
|
|
92
|
+
id,
|
|
93
|
+
name,
|
|
94
|
+
normalized_name: name.toLowerCase().replace(/\s+/g, "_"),
|
|
95
|
+
created_at: now,
|
|
96
|
+
modified_at: now,
|
|
97
|
+
aliases: [],
|
|
98
|
+
floor_id: floorId,
|
|
99
|
+
humidity_entity_id: null,
|
|
100
|
+
icon: null,
|
|
101
|
+
labels: [],
|
|
102
|
+
picture: null,
|
|
103
|
+
temperature_entity_id: null
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create ~30 curated apartment entity fixtures.
|
|
108
|
+
*
|
|
109
|
+
* Entities span lights, sensors, binary sensors, climate, covers,
|
|
110
|
+
* locks, switches, media player, weather, camera, scenes, and buttons
|
|
111
|
+
* across 4 areas: living_room, bedroom, kitchen, entry.
|
|
112
|
+
*/
|
|
113
|
+
function createDemoFixtures() {
|
|
114
|
+
contextCounter = 0;
|
|
115
|
+
const areas = {
|
|
116
|
+
living_room: makeArea("living_room", "Living Room"),
|
|
117
|
+
bedroom: makeArea("bedroom", "Bedroom"),
|
|
118
|
+
kitchen: makeArea("kitchen", "Kitchen"),
|
|
119
|
+
entry: makeArea("entry", "Entry")
|
|
120
|
+
};
|
|
121
|
+
areas.living_room.temperature_entity_id = "sensor.temperature_living";
|
|
122
|
+
areas.living_room.humidity_entity_id = "sensor.humidity_living";
|
|
123
|
+
const devices = {
|
|
124
|
+
living_room_lights: makeDevice("living_room_lights", "Living Room Lights", "living_room", "Philips", "Hue"),
|
|
125
|
+
kitchen_lights: makeDevice("kitchen_lights", "Kitchen Lights", "kitchen", "IKEA", "Tradfri"),
|
|
126
|
+
bedroom_lights: makeDevice("bedroom_lights", "Bedroom Lights", "bedroom", "Philips", "Hue"),
|
|
127
|
+
hallway_lights: makeDevice("hallway_lights", "Hallway Lights", "entry", "IKEA", "Tradfri"),
|
|
128
|
+
bathroom_lights: makeDevice("bathroom_lights", "Bathroom Lights", null),
|
|
129
|
+
thermostat_lr: makeDevice("thermostat_lr", "Living Room Thermostat", "living_room", "Nest", "Learning Thermostat"),
|
|
130
|
+
thermostat_br: makeDevice("thermostat_br", "Bedroom AC", "bedroom", "Daikin", "Split AC"),
|
|
131
|
+
blinds_lr: makeDevice("blinds_lr", "Living Room Blinds", "living_room", "Somfy", "Roller Shade"),
|
|
132
|
+
curtains_br: makeDevice("curtains_br", "Bedroom Curtains", "bedroom", "IKEA", "Fyrtur"),
|
|
133
|
+
lock_front: makeDevice("lock_front", "Front Door Lock", "entry", "Yale", "Assure Lock 2"),
|
|
134
|
+
lock_back: makeDevice("lock_back", "Back Door Lock", "entry", "August", "Smart Lock Pro"),
|
|
135
|
+
speaker_lr: makeDevice("speaker_lr", "Living Room Speaker", "living_room", "Sonos", "One"),
|
|
136
|
+
camera_front: makeDevice("camera_front", "Front Door Camera", "entry", "Ring", "Video Doorbell"),
|
|
137
|
+
door_sensor: makeDevice("door_sensor", "Front Door Sensor", "entry", "Aqara", "Door Sensor"),
|
|
138
|
+
motion_sensor: makeDevice("motion_sensor", "Hallway Motion Sensor", "entry", "Aqara", "Motion Sensor")
|
|
139
|
+
};
|
|
140
|
+
const entities = {};
|
|
141
|
+
const entityRegistry = {};
|
|
142
|
+
function add(e, regOverrides = {}) {
|
|
143
|
+
entities[e.entity_id] = e;
|
|
144
|
+
entityRegistry[e.entity_id] = makeRegistryEntry(e.entity_id, regOverrides);
|
|
145
|
+
}
|
|
146
|
+
add(makeEntity("light.living_room_main", "on", {
|
|
147
|
+
brightness: 179,
|
|
148
|
+
color_temp_kelvin: 3e3,
|
|
149
|
+
color_mode: "color_temp",
|
|
150
|
+
supported_color_modes: ["color_temp", "xy"]
|
|
151
|
+
}), {
|
|
152
|
+
device_id: "living_room_lights",
|
|
153
|
+
area_id: "living_room",
|
|
154
|
+
supported_features: 44
|
|
155
|
+
});
|
|
156
|
+
add(makeEntity("light.kitchen_counter", "off", { supported_color_modes: ["brightness"] }), {
|
|
157
|
+
device_id: "kitchen_lights",
|
|
158
|
+
area_id: "kitchen",
|
|
159
|
+
supported_features: 1
|
|
160
|
+
});
|
|
161
|
+
add(makeEntity("light.bedroom_ceiling", "on", {
|
|
162
|
+
brightness: 77,
|
|
163
|
+
color_temp_kelvin: 2700,
|
|
164
|
+
color_mode: "color_temp",
|
|
165
|
+
supported_color_modes: ["color_temp"]
|
|
166
|
+
}), {
|
|
167
|
+
device_id: "bedroom_lights",
|
|
168
|
+
area_id: "bedroom",
|
|
169
|
+
supported_features: 44
|
|
170
|
+
});
|
|
171
|
+
add(makeEntity("light.bathroom", "off", { supported_color_modes: ["brightness"] }), { device_id: "bathroom_lights" });
|
|
172
|
+
add(makeEntity("light.hallway", "on", {
|
|
173
|
+
brightness: 128,
|
|
174
|
+
color_mode: "brightness",
|
|
175
|
+
supported_color_modes: ["brightness"]
|
|
176
|
+
}), {
|
|
177
|
+
device_id: "hallway_lights",
|
|
178
|
+
area_id: "entry",
|
|
179
|
+
supported_features: 1
|
|
180
|
+
});
|
|
181
|
+
add(makeEntity("sensor.temperature_living", "22.5", {
|
|
182
|
+
unit_of_measurement: "°C",
|
|
183
|
+
device_class: "temperature",
|
|
184
|
+
state_class: "measurement"
|
|
185
|
+
}), {
|
|
186
|
+
area_id: "living_room",
|
|
187
|
+
device_class: "temperature",
|
|
188
|
+
unit_of_measurement: "°C"
|
|
189
|
+
});
|
|
190
|
+
add(makeEntity("sensor.humidity_living", "45", {
|
|
191
|
+
unit_of_measurement: "%",
|
|
192
|
+
device_class: "humidity",
|
|
193
|
+
state_class: "measurement"
|
|
194
|
+
}), {
|
|
195
|
+
area_id: "living_room",
|
|
196
|
+
device_class: "humidity",
|
|
197
|
+
unit_of_measurement: "%"
|
|
198
|
+
});
|
|
199
|
+
add(makeEntity("sensor.temperature_outdoor", "-2", {
|
|
200
|
+
unit_of_measurement: "°C",
|
|
201
|
+
device_class: "temperature",
|
|
202
|
+
state_class: "measurement"
|
|
203
|
+
}), {
|
|
204
|
+
device_class: "temperature",
|
|
205
|
+
unit_of_measurement: "°C"
|
|
206
|
+
});
|
|
207
|
+
add(makeEntity("sensor.power_consumption", "1.2", {
|
|
208
|
+
unit_of_measurement: "kW",
|
|
209
|
+
device_class: "power",
|
|
210
|
+
state_class: "measurement"
|
|
211
|
+
}), {
|
|
212
|
+
device_class: "power",
|
|
213
|
+
unit_of_measurement: "kW"
|
|
214
|
+
});
|
|
215
|
+
add(makeEntity("sensor.battery_door_sensor", "87", {
|
|
216
|
+
unit_of_measurement: "%",
|
|
217
|
+
device_class: "battery",
|
|
218
|
+
state_class: "measurement"
|
|
219
|
+
}), {
|
|
220
|
+
device_id: "door_sensor",
|
|
221
|
+
area_id: "entry",
|
|
222
|
+
device_class: "battery",
|
|
223
|
+
unit_of_measurement: "%"
|
|
224
|
+
});
|
|
225
|
+
add(makeEntity("binary_sensor.front_door", "off", { device_class: "door" }), {
|
|
226
|
+
device_id: "door_sensor",
|
|
227
|
+
area_id: "entry",
|
|
228
|
+
device_class: "door"
|
|
229
|
+
});
|
|
230
|
+
add(makeEntity("binary_sensor.motion_hallway", "off", { device_class: "motion" }), {
|
|
231
|
+
device_id: "motion_sensor",
|
|
232
|
+
area_id: "entry",
|
|
233
|
+
device_class: "motion"
|
|
234
|
+
});
|
|
235
|
+
add(makeEntity("binary_sensor.window_bedroom", "off", { device_class: "window" }), {
|
|
236
|
+
area_id: "bedroom",
|
|
237
|
+
device_class: "window"
|
|
238
|
+
});
|
|
239
|
+
add(makeEntity("climate.living_room_thermostat", "heat", {
|
|
240
|
+
temperature: 22,
|
|
241
|
+
current_temperature: 21.8,
|
|
242
|
+
hvac_modes: [
|
|
243
|
+
"off",
|
|
244
|
+
"heat",
|
|
245
|
+
"cool",
|
|
246
|
+
"auto"
|
|
247
|
+
],
|
|
248
|
+
hvac_action: "heating",
|
|
249
|
+
min_temp: 7,
|
|
250
|
+
max_temp: 35
|
|
251
|
+
}), {
|
|
252
|
+
device_id: "thermostat_lr",
|
|
253
|
+
area_id: "living_room",
|
|
254
|
+
supported_features: 385
|
|
255
|
+
});
|
|
256
|
+
add(makeEntity("climate.bedroom_ac", "off", {
|
|
257
|
+
temperature: 20,
|
|
258
|
+
current_temperature: 22.1,
|
|
259
|
+
hvac_modes: [
|
|
260
|
+
"off",
|
|
261
|
+
"cool",
|
|
262
|
+
"heat",
|
|
263
|
+
"dry",
|
|
264
|
+
"fan_only"
|
|
265
|
+
],
|
|
266
|
+
hvac_action: "idle",
|
|
267
|
+
min_temp: 16,
|
|
268
|
+
max_temp: 30
|
|
269
|
+
}), {
|
|
270
|
+
device_id: "thermostat_br",
|
|
271
|
+
area_id: "bedroom",
|
|
272
|
+
supported_features: 385
|
|
273
|
+
});
|
|
274
|
+
add(makeEntity("cover.living_room_blinds", "open", {
|
|
275
|
+
current_position: 80,
|
|
276
|
+
device_class: "shade"
|
|
277
|
+
}), {
|
|
278
|
+
device_id: "blinds_lr",
|
|
279
|
+
area_id: "living_room",
|
|
280
|
+
device_class: "shade",
|
|
281
|
+
supported_features: 15
|
|
282
|
+
});
|
|
283
|
+
add(makeEntity("cover.bedroom_curtains", "closed", {
|
|
284
|
+
current_position: 0,
|
|
285
|
+
device_class: "curtain"
|
|
286
|
+
}), {
|
|
287
|
+
device_id: "curtains_br",
|
|
288
|
+
area_id: "bedroom",
|
|
289
|
+
device_class: "curtain",
|
|
290
|
+
supported_features: 15
|
|
291
|
+
});
|
|
292
|
+
add(makeEntity("lock.front_door_lock", "locked", {}), {
|
|
293
|
+
device_id: "lock_front",
|
|
294
|
+
area_id: "entry",
|
|
295
|
+
supported_features: 1
|
|
296
|
+
});
|
|
297
|
+
add(makeEntity("lock.back_door_lock", "locked", {}), {
|
|
298
|
+
device_id: "lock_back",
|
|
299
|
+
area_id: "entry",
|
|
300
|
+
supported_features: 1
|
|
301
|
+
});
|
|
302
|
+
add(makeEntity("switch.coffee_machine", "off", { device_class: "outlet" }), {
|
|
303
|
+
area_id: "kitchen",
|
|
304
|
+
device_class: "outlet"
|
|
305
|
+
});
|
|
306
|
+
add(makeEntity("switch.fan_living_room", "on", { device_class: "switch" }), {
|
|
307
|
+
area_id: "living_room",
|
|
308
|
+
device_class: "switch"
|
|
309
|
+
});
|
|
310
|
+
add(makeEntity("media_player.living_room_speaker", "playing", {
|
|
311
|
+
media_title: "Lo-fi Beats",
|
|
312
|
+
media_artist: "Chill Station",
|
|
313
|
+
media_content_type: "music",
|
|
314
|
+
volume_level: .4,
|
|
315
|
+
is_volume_muted: false,
|
|
316
|
+
supported_features: 152461
|
|
317
|
+
}), {
|
|
318
|
+
device_id: "speaker_lr",
|
|
319
|
+
area_id: "living_room",
|
|
320
|
+
supported_features: 152461
|
|
321
|
+
});
|
|
322
|
+
add(makeEntity("weather.home_forecast", "partlycloudy", {
|
|
323
|
+
temperature: 3,
|
|
324
|
+
temperature_unit: "°C",
|
|
325
|
+
humidity: 72,
|
|
326
|
+
pressure: 1013,
|
|
327
|
+
pressure_unit: "hPa",
|
|
328
|
+
wind_speed: 12,
|
|
329
|
+
wind_speed_unit: "km/h",
|
|
330
|
+
wind_bearing: 220,
|
|
331
|
+
forecast: [
|
|
332
|
+
{
|
|
333
|
+
datetime: "2026-03-07T00:00:00Z",
|
|
334
|
+
condition: "cloudy",
|
|
335
|
+
temperature: 4,
|
|
336
|
+
templow: -1
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
datetime: "2026-03-08T00:00:00Z",
|
|
340
|
+
condition: "sunny",
|
|
341
|
+
temperature: 7,
|
|
342
|
+
templow: 1
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
datetime: "2026-03-09T00:00:00Z",
|
|
346
|
+
condition: "rainy",
|
|
347
|
+
temperature: 5,
|
|
348
|
+
templow: 2
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
datetime: "2026-03-10T00:00:00Z",
|
|
352
|
+
condition: "partlycloudy",
|
|
353
|
+
temperature: 6,
|
|
354
|
+
templow: 0
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
datetime: "2026-03-11T00:00:00Z",
|
|
358
|
+
condition: "snowy",
|
|
359
|
+
temperature: 1,
|
|
360
|
+
templow: -3
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
}), { platform: "met" });
|
|
364
|
+
add(makeEntity("camera.front_door_camera", "streaming", {
|
|
365
|
+
entity_picture: "/api/camera_proxy/camera.front_door_camera",
|
|
366
|
+
frontend_stream_type: "hls"
|
|
367
|
+
}), {
|
|
368
|
+
device_id: "camera_front",
|
|
369
|
+
area_id: "entry",
|
|
370
|
+
supported_features: 2
|
|
371
|
+
});
|
|
372
|
+
add(makeEntity("scene.movie_night", "scening", { entity_id: [
|
|
373
|
+
"light.living_room_main",
|
|
374
|
+
"cover.living_room_blinds",
|
|
375
|
+
"media_player.living_room_speaker"
|
|
376
|
+
] }), { area_id: "living_room" });
|
|
377
|
+
add(makeEntity("scene.good_morning", "scening", { entity_id: [
|
|
378
|
+
"light.bedroom_ceiling",
|
|
379
|
+
"cover.bedroom_curtains",
|
|
380
|
+
"switch.coffee_machine"
|
|
381
|
+
] }), {});
|
|
382
|
+
add(makeEntity("button.restart_home_assistant", "unknown", { device_class: "restart" }), {
|
|
383
|
+
entity_category: "config",
|
|
384
|
+
device_class: "restart"
|
|
385
|
+
});
|
|
386
|
+
add(makeEntity("button.update_firmware", "unknown", { device_class: "update" }), {
|
|
387
|
+
entity_category: "config",
|
|
388
|
+
device_class: "update"
|
|
389
|
+
});
|
|
390
|
+
add(makeEntity("sensor.door_lock_battery", "92", {
|
|
391
|
+
unit_of_measurement: "%",
|
|
392
|
+
device_class: "battery",
|
|
393
|
+
state_class: "measurement"
|
|
394
|
+
}), {
|
|
395
|
+
device_id: "lock_front",
|
|
396
|
+
area_id: "entry",
|
|
397
|
+
device_class: "battery",
|
|
398
|
+
unit_of_measurement: "%"
|
|
399
|
+
});
|
|
400
|
+
add(makeEntity("sensor.motion_sensor_battery", "65", {
|
|
401
|
+
unit_of_measurement: "%",
|
|
402
|
+
device_class: "battery",
|
|
403
|
+
state_class: "measurement"
|
|
404
|
+
}), {
|
|
405
|
+
device_id: "motion_sensor",
|
|
406
|
+
area_id: "entry",
|
|
407
|
+
device_class: "battery",
|
|
408
|
+
unit_of_measurement: "%"
|
|
409
|
+
});
|
|
410
|
+
return {
|
|
411
|
+
entities,
|
|
412
|
+
entityRegistry,
|
|
413
|
+
areas,
|
|
414
|
+
devices
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
//#endregion
|
|
419
|
+
export { createDemoFixtures };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Area View Builder
|
|
3
|
+
*
|
|
4
|
+
* Constructs unified AreaView objects by combining registry data
|
|
5
|
+
* with computed entities and devices using the query engine.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { AreaId, AreaView, DeviceRegistryEntry, DeviceView } from "../core/types";
|
|
10
|
+
/**
|
|
11
|
+
* Build a DeviceView from registry data
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildDeviceView(device: DeviceRegistryEntry): DeviceView;
|
|
14
|
+
/**
|
|
15
|
+
* Build an AreaView from registry data using query engine
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildAreaView(areaId: AreaId): AreaView;
|
|
18
|
+
/**
|
|
19
|
+
* Get all area views
|
|
20
|
+
*/
|
|
21
|
+
export declare function getAreaViews(): AreaView[];
|
|
22
|
+
/**
|
|
23
|
+
* Get area view
|
|
24
|
+
*/
|
|
25
|
+
export declare function getAreaView(areaId: AreaId): AreaView | undefined;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entity Index Queries
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for querying entities by various criteria.
|
|
5
|
+
* In the SolidJS port, indices are NOT stored in state -- they are
|
|
6
|
+
* computed on the fly here (and will be derived reactively in Plan 03).
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import type { AreaId, DeviceId, EntityDomain, EntityId, FloorId, LabelId } from "../core/types";
|
|
11
|
+
/**
|
|
12
|
+
* Get all entity IDs
|
|
13
|
+
*/
|
|
14
|
+
export declare function getAllEntityIds(): EntityId[];
|
|
15
|
+
/**
|
|
16
|
+
* Get entities by domain
|
|
17
|
+
*/
|
|
18
|
+
export declare function getEntitiesByDomain(domain: EntityDomain): EntityId[];
|
|
19
|
+
/**
|
|
20
|
+
* Get entities via devices in area
|
|
21
|
+
*
|
|
22
|
+
* Only includes entities that inherit area from device (entity.area_id is null).
|
|
23
|
+
*/
|
|
24
|
+
export declare function getEntitiesViaDevices(areaId: AreaId): EntityId[];
|
|
25
|
+
/**
|
|
26
|
+
* Get entities by area
|
|
27
|
+
*
|
|
28
|
+
* Returns entities with direct area_id assignments and entities that inherit their area from devices.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getEntitiesByArea(areaId: AreaId): EntityId[];
|
|
31
|
+
/**
|
|
32
|
+
* Get entities by device
|
|
33
|
+
*/
|
|
34
|
+
export declare function getEntitiesByDevice(deviceId: DeviceId): EntityId[];
|
|
35
|
+
/**
|
|
36
|
+
* Get entities by floor
|
|
37
|
+
*/
|
|
38
|
+
export declare function getEntitiesByFloor(floorId: FloorId): EntityId[];
|
|
39
|
+
/**
|
|
40
|
+
* Get entities by label
|
|
41
|
+
*/
|
|
42
|
+
export declare function getEntitiesByLabel(labelId: LabelId): EntityId[];
|
|
43
|
+
/**
|
|
44
|
+
* Get domain statistics
|
|
45
|
+
*/
|
|
46
|
+
export declare function getDomainStats(): Record<EntityDomain, number>;
|
|
47
|
+
/**
|
|
48
|
+
* Get area statistics
|
|
49
|
+
*/
|
|
50
|
+
export declare function getAreaStats(): Record<AreaId, number>;
|
|
51
|
+
/**
|
|
52
|
+
* Get total entity count
|
|
53
|
+
*/
|
|
54
|
+
export declare function getEntityCount(): number;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entity View Builder
|
|
3
|
+
*
|
|
4
|
+
* Constructs unified EntityView objects by combining runtime state
|
|
5
|
+
* with registry metadata.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { EntityRegistryEntry } from "@glasshome/ha-types";
|
|
10
|
+
import type { EntityId, EntityView, HassEntity } from "../core/types";
|
|
11
|
+
/**
|
|
12
|
+
* Build an EntityView from runtime state and registry metadata
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildEntityView(entity: HassEntity, registry: EntityRegistryEntry | undefined): EntityView;
|
|
15
|
+
/**
|
|
16
|
+
* Get or build an EntityView
|
|
17
|
+
*/
|
|
18
|
+
export declare function getEntityView(entityId: EntityId): EntityView | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Get multiple entity views
|
|
21
|
+
*/
|
|
22
|
+
export declare function getEntityViews(entityIds: EntityId[]): EntityView[];
|
|
23
|
+
/**
|
|
24
|
+
* Get all entity views
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAllEntityViews(): EntityView[];
|
|
27
|
+
/**
|
|
28
|
+
* Rebuild entity view
|
|
29
|
+
*/
|
|
30
|
+
export declare function rebuildEntityView(entityId: EntityId): EntityView | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History Constants
|
|
3
|
+
*
|
|
4
|
+
* Constants and utilities for history fetching and processing.
|
|
5
|
+
* Based on Home Assistant frontend implementation.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { EntityId } from "../core/types";
|
|
10
|
+
export declare const DOMAINS_USE_LAST_UPDATED: readonly ["climate", "humidifier", "water_heater"];
|
|
11
|
+
export declare const NEED_ATTRIBUTE_DOMAINS: readonly ["climate", "humidifier", "input_datetime", "water_heater", "person", "device_tracker"];
|
|
12
|
+
export declare const LINE_ATTRIBUTES_TO_KEEP: readonly ["temperature", "current_temperature", "target_temp_low", "target_temp_high", "hvac_action", "humidity", "mode", "action", "current_humidity"];
|
|
13
|
+
/**
|
|
14
|
+
* Check if an entity needs attributes in history response
|
|
15
|
+
*/
|
|
16
|
+
export declare function entityIdHistoryNeedsAttributes(entityId: EntityId): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History Fetching
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { EntityId } from "../core/types";
|
|
7
|
+
import type { EntityHistoryData, EntityHistoryQueryOptions, EntityHistoryState, HistoryQueryOptions, TimelineState } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* Fetch history for entities during a time period
|
|
10
|
+
*/
|
|
11
|
+
export declare function fetchHistory(options: HistoryQueryOptions): Promise<Record<EntityId, EntityHistoryState[]>>;
|
|
12
|
+
/**
|
|
13
|
+
* Fetch history for a single entity
|
|
14
|
+
*/
|
|
15
|
+
export declare function fetchEntityHistory(entityId: EntityId, options: EntityHistoryQueryOptions): Promise<EntityHistoryData>;
|
|
16
|
+
/**
|
|
17
|
+
* Convert compressed history state to timeline state
|
|
18
|
+
*/
|
|
19
|
+
export declare function historyStateToTimeline(s: EntityHistoryState): TimelineState;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EntityId } from "../core/types";
|
|
2
|
+
import type { EntityHistoryData, EntityHistoryQueryOptions } from "./types";
|
|
3
|
+
/** Check if an entity has active history tracking. */
|
|
4
|
+
export declare function isHistoryTracked(entityId: EntityId): boolean;
|
|
5
|
+
/** Start tracking history for an entity. Fetches initial backfill. */
|
|
6
|
+
export declare function trackEntityHistory(entityId: EntityId, options: EntityHistoryQueryOptions): Promise<EntityHistoryData>;
|
|
7
|
+
/** Stop tracking history for an entity and clear its data. */
|
|
8
|
+
export declare function untrackEntityHistory(entityId: EntityId): void;
|
|
9
|
+
/**
|
|
10
|
+
* Append a state change to an entity's history.
|
|
11
|
+
* Called by the entity subscription handler when a tracked entity changes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function appendHistoryPoint(entityId: EntityId, stateValue: string, attributes: Record<string, unknown>, lastUpdated: number, lastChanged?: number): void;
|