@glasshome/sync-layer 0.7.1 → 0.8.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/index.d.ts +1291 -54
- package/dist/index.js +215 -308
- package/dist/service-C8H42I-Q.d.ts +459 -0
- package/dist/solid/index.d.ts +119 -6
- package/dist/solid/index.js +20 -15
- package/dist/{statistics-CtRfIF6D.js → statistics-DyCCTwv2.js} +83 -95
- package/dist/worker/worker-main.d.ts +11 -8
- package/dist/worker/worker-main.js +2 -3
- package/dist/{worker-main-C-3QM4di.js → worker-main-D_wyGAIG.js} +47 -157
- package/package.json +3 -3
- package/dist/calendar/track.d.ts +0 -19
- package/dist/calendar/types.d.ts +0 -32
- package/dist/camera/fetch.d.ts +0 -16
- package/dist/camera/query.d.ts +0 -15
- package/dist/camera/types.d.ts +0 -85
- package/dist/camera/webrtc.d.ts +0 -31
- package/dist/commands/service.d.ts +0 -53
- package/dist/commands/types.d.ts +0 -113
- package/dist/connection/adapter.d.ts +0 -48
- package/dist/connection/auth.d.ts +0 -126
- package/dist/connection/bridged.d.ts +0 -16
- package/dist/connection/manager.d.ts +0 -51
- package/dist/connection/subscription-manager.d.ts +0 -48
- package/dist/connection/subscriptions.d.ts +0 -31
- package/dist/connection/types.d.ts +0 -151
- package/dist/core/privileged-conn.d.ts +0 -29
- package/dist/core/reducers.d.ts +0 -99
- package/dist/core/store.d.ts +0 -100
- package/dist/core/types.d.ts +0 -339
- package/dist/demo/demo-data.d.ts +0 -24
- package/dist/demo/demo-provider.d.ts +0 -40
- package/dist/demo/energy-sim.d.ts +0 -112
- package/dist/energy/prefs.d.ts +0 -56
- package/dist/entities/area-views.d.ts +0 -32
- package/dist/entities/index.d.ts +0 -54
- package/dist/entities/views.d.ts +0 -35
- package/dist/history/constants.d.ts +0 -16
- package/dist/history/fetch.d.ts +0 -19
- package/dist/history/query.d.ts +0 -27
- package/dist/history/statistics.d.ts +0 -55
- package/dist/history/types.d.ts +0 -146
- package/dist/host-api.d.ts +0 -50
- package/dist/media/url.d.ts +0 -14
- package/dist/query/area-builder.d.ts +0 -25
- package/dist/query/builder.d.ts +0 -18
- package/dist/query/helpers.d.ts +0 -21
- package/dist/query/memoization.d.ts +0 -18
- package/dist/query/projections.d.ts +0 -74
- package/dist/query/types.d.ts +0 -260
- package/dist/solid/hooks.d.ts +0 -119
- package/dist/solid/indices.d.ts +0 -15
- package/dist/weather/fetch.d.ts +0 -19
- package/dist/weather/query.d.ts +0 -23
- package/dist/weather/types.d.ts +0 -126
- package/dist/worker/bridge-client.d.ts +0 -47
- package/dist/worker/enforcement.d.ts +0 -53
- package/dist/worker/protocol.d.ts +0 -129
- package/dist/worker/token-store.d.ts +0 -3
package/dist/core/reducers.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* State update reducers
|
|
3
|
-
*
|
|
4
|
-
* These functions handle state updates in response to events from
|
|
5
|
-
* Home Assistant. They use SolidJS store's produce() for safe mutations.
|
|
6
|
-
*
|
|
7
|
-
* NOTE: All index maintenance code has been stripped.
|
|
8
|
-
* Indices are derived reactively in Plan 03.
|
|
9
|
-
*
|
|
10
|
-
* @packageDocumentation
|
|
11
|
-
*/
|
|
12
|
-
import type { EntityRegistryEntry } from "@glasshome/ha-types";
|
|
13
|
-
import type { AreaRegistryEntry, DeviceRegistryEntry, EntityId, FloorRegistryEntry, HassEntity, LabelRegistryEntry, StatisticData, StatisticMetadata } from "./types";
|
|
14
|
-
/**
|
|
15
|
-
* Bulk update multiple entities
|
|
16
|
-
*
|
|
17
|
-
* Used during initial load or bulk sync operations.
|
|
18
|
-
*
|
|
19
|
-
* @param entities - Array of entity states
|
|
20
|
-
*/
|
|
21
|
-
export declare function bulkUpdateEntities(entities: HassEntity[]): void;
|
|
22
|
-
/**
|
|
23
|
-
* Update entity registry entry
|
|
24
|
-
*
|
|
25
|
-
* @param entry - Entity registry entry
|
|
26
|
-
*/
|
|
27
|
-
export declare function updateEntityRegistry(entry: EntityRegistryEntry): void;
|
|
28
|
-
/**
|
|
29
|
-
* Remove entity registry entry
|
|
30
|
-
*
|
|
31
|
-
* @param entityId - Entity ID to remove
|
|
32
|
-
*/
|
|
33
|
-
export declare function removeEntityRegistry(entityId: EntityId): void;
|
|
34
|
-
/**
|
|
35
|
-
* Bulk update entity registry
|
|
36
|
-
*
|
|
37
|
-
* @param entries - Array of registry entries
|
|
38
|
-
*/
|
|
39
|
-
export declare function bulkUpdateEntityRegistry(entries: EntityRegistryEntry[]): void;
|
|
40
|
-
/**
|
|
41
|
-
* Update device registry entry
|
|
42
|
-
*
|
|
43
|
-
* @param device - Device registry entry
|
|
44
|
-
*/
|
|
45
|
-
export declare function updateDevice(device: DeviceRegistryEntry): void;
|
|
46
|
-
/**
|
|
47
|
-
* Remove device registry entry
|
|
48
|
-
*
|
|
49
|
-
* @param deviceId - Device ID to remove
|
|
50
|
-
*/
|
|
51
|
-
export declare function removeDevice(deviceId: string): void;
|
|
52
|
-
/**
|
|
53
|
-
* Update area registry entry
|
|
54
|
-
*
|
|
55
|
-
* @param area - Area registry entry
|
|
56
|
-
*/
|
|
57
|
-
export declare function updateArea(area: AreaRegistryEntry): void;
|
|
58
|
-
/**
|
|
59
|
-
* Remove area registry entry
|
|
60
|
-
*
|
|
61
|
-
* @param areaId - Area ID to remove
|
|
62
|
-
*/
|
|
63
|
-
export declare function removeArea(areaId: string): void;
|
|
64
|
-
/**
|
|
65
|
-
* Update floor registry entry
|
|
66
|
-
*
|
|
67
|
-
* @param floor - Floor registry entry
|
|
68
|
-
*/
|
|
69
|
-
export declare function updateFloor(floor: FloorRegistryEntry): void;
|
|
70
|
-
/**
|
|
71
|
-
* Remove floor registry entry
|
|
72
|
-
*
|
|
73
|
-
* @param floorId - Floor ID to remove
|
|
74
|
-
*/
|
|
75
|
-
export declare function removeFloor(floorId: string): void;
|
|
76
|
-
/**
|
|
77
|
-
* Update label registry entry
|
|
78
|
-
*
|
|
79
|
-
* @param label - Label registry entry
|
|
80
|
-
*/
|
|
81
|
-
export declare function updateLabel(label: LabelRegistryEntry): void;
|
|
82
|
-
/**
|
|
83
|
-
* Remove label registry entry
|
|
84
|
-
*
|
|
85
|
-
* @param labelId - Label ID to remove
|
|
86
|
-
*/
|
|
87
|
-
export declare function removeLabel(labelId: string): void;
|
|
88
|
-
/**
|
|
89
|
-
* Update statistics metadata
|
|
90
|
-
*
|
|
91
|
-
* @param metadata - Statistics metadata
|
|
92
|
-
*/
|
|
93
|
-
export declare function updateStatisticsMetadata(metadata: StatisticMetadata[]): void;
|
|
94
|
-
/**
|
|
95
|
-
* Update statistics data
|
|
96
|
-
*
|
|
97
|
-
* @param data - Statistics data points
|
|
98
|
-
*/
|
|
99
|
-
export declare function updateStatisticsData(data: StatisticData[]): void;
|
package/dist/core/store.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/** Central reactive state store for sync-layer using SolidJS createStore. */
|
|
2
|
-
import type { SetStoreFunction, Store } from "solid-js/store";
|
|
3
|
-
import type { CalendarEventsData } from "../calendar/types";
|
|
4
|
-
import type { CameraStreamData } from "../camera/types";
|
|
5
|
-
import type { EntityHistoryData } from "../history/types";
|
|
6
|
-
import type { WeatherForecastsData } from "../weather/types";
|
|
7
|
-
import type { AreaId, AreaRegistryEntry, ConnectionState, DeviceId, DeviceRegistryEntry, EntityId, FloorId, FloorRegistryEntry, HassEntity, LabelId, LabelRegistryEntry, StatisticData, StatisticMetadata } from "./types";
|
|
8
|
-
/**
|
|
9
|
-
* Complete state shape for the sync-layer store
|
|
10
|
-
*
|
|
11
|
-
* All updates use SolidJS store's produce() for mutations
|
|
12
|
-
* or reconcile() for bulk replacements.
|
|
13
|
-
*
|
|
14
|
-
* NOTE: No EntityIndices field -- indices are derived reactively in Plan 03.
|
|
15
|
-
* NOTE: No _activeSubscriptions -- managed externally.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* The structural surface every conn consumer actually uses. Satisfied by a
|
|
19
|
-
* real home-assistant-js-websocket Connection, the bridge facade (traffic
|
|
20
|
-
* tunneled through the HA worker), and mock connections.
|
|
21
|
-
*/
|
|
22
|
-
export interface HaLink {
|
|
23
|
-
sendMessagePromise<T>(message: unknown): Promise<T>;
|
|
24
|
-
subscribeMessage<T>(callback: (message: T) => void, message: unknown): Promise<() => Promise<void>>;
|
|
25
|
-
subscribeEvents(callback: (event: unknown) => void, eventType?: string): Promise<() => void | Promise<void>>;
|
|
26
|
-
}
|
|
27
|
-
export interface GlassHomeState {
|
|
28
|
-
/** Current connection state */
|
|
29
|
-
connectionState: ConnectionState;
|
|
30
|
-
/** Connection error (if any) */
|
|
31
|
-
connectionError: Error | null;
|
|
32
|
-
/** Home Assistant base URL */
|
|
33
|
-
hassUrl: string | null;
|
|
34
|
-
/** Same-origin prefix for the HA media proxy (e.g. "/ha-proxy/media"), or null
|
|
35
|
-
* to resolve media directly against hassUrl. Set by the host at connect. */
|
|
36
|
-
mediaProxyBase: string | null;
|
|
37
|
-
/** Home Assistant core config (unit system, locale, currency); null until loaded */
|
|
38
|
-
config: import("@glasshome/ha-types").HassConfig | null;
|
|
39
|
-
/** Live entity state (keyed by entity_id) */
|
|
40
|
-
entities: Record<EntityId, HassEntity>;
|
|
41
|
-
/** Entity registry entries (keyed by entity_id) */
|
|
42
|
-
entityRegistry: Record<EntityId, import("@glasshome/ha-types").EntityRegistryEntry>;
|
|
43
|
-
/** Device registry entries (keyed by device ID) */
|
|
44
|
-
devices: Record<DeviceId, DeviceRegistryEntry>;
|
|
45
|
-
/** Area registry entries (keyed by area ID) */
|
|
46
|
-
areas: Record<AreaId, AreaRegistryEntry>;
|
|
47
|
-
/** Floor registry entries (keyed by floor ID) */
|
|
48
|
-
floors: Record<FloorId, FloorRegistryEntry>;
|
|
49
|
-
/** Label registry entries (keyed by label ID) */
|
|
50
|
-
labels: Record<LabelId, LabelRegistryEntry>;
|
|
51
|
-
/** Statistics data (keyed by statistic_id) */
|
|
52
|
-
statistics: Record<string, StatisticData[]>;
|
|
53
|
-
/** Statistics metadata (keyed by statistic_id) */
|
|
54
|
-
statisticsMetadata: Record<string, StatisticMetadata>;
|
|
55
|
-
/** Entity history data (keyed by entity ID) */
|
|
56
|
-
history: Record<EntityId, EntityHistoryData>;
|
|
57
|
-
/** Weather forecasts data (keyed by entity ID) */
|
|
58
|
-
forecasts: Record<EntityId, WeatherForecastsData>;
|
|
59
|
-
/** Live calendar events (keyed by entity ID), maintained by calendar/track */
|
|
60
|
-
calendars: Record<EntityId, CalendarEventsData>;
|
|
61
|
-
/** Camera stream data (keyed by entity ID) */
|
|
62
|
-
streams: Record<EntityId, CameraStreamData>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Module-level SolidJS createStore singleton
|
|
66
|
-
*
|
|
67
|
-
* `state` is a read-only reactive proxy.
|
|
68
|
-
* `setState` is used for mutations via produce() or direct path setting.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* import { state, setState } from '@glasshome/sync-layer/core/store';
|
|
73
|
-
*
|
|
74
|
-
* // Read state (auto-tracked in SolidJS reactive contexts)
|
|
75
|
-
* const entities = state.entities;
|
|
76
|
-
*
|
|
77
|
-
* // Mutate via produce
|
|
78
|
-
* setState(produce((s) => {
|
|
79
|
-
* s.entities['light.living_room'] = newEntity;
|
|
80
|
-
* }));
|
|
81
|
-
*
|
|
82
|
-
* // Bulk replace
|
|
83
|
-
* setState("entities", reconcile(newEntities));
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
declare global {
|
|
87
|
-
var __GH_SYNC_LAYER_STORE__: boolean | undefined;
|
|
88
|
-
}
|
|
89
|
-
export declare const state: Store<GlassHomeState>;
|
|
90
|
-
export declare const setState: SetStoreFunction<GlassHomeState>;
|
|
91
|
-
/**
|
|
92
|
-
* Reset store to initial state
|
|
93
|
-
*/
|
|
94
|
-
export declare function resetStore(): void;
|
|
95
|
-
/**
|
|
96
|
-
* Factory for testing isolation
|
|
97
|
-
*
|
|
98
|
-
* Creates a new, independent store instance for test isolation.
|
|
99
|
-
*/
|
|
100
|
-
export declare function createStoreInstance(): [GlassHomeState, SetStoreFunction<GlassHomeState>];
|
package/dist/core/types.d.ts
DELETED
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core type definitions for @glasshome/sync-layer
|
|
3
|
-
*
|
|
4
|
-
* This file defines types that are:
|
|
5
|
-
* 1. **Used from ha-types**: WebSocket commands, events, registry entries
|
|
6
|
-
* 2. **Runtime data structures**: Entity states, device/area/floor/label registries
|
|
7
|
-
* (These should eventually be moved to ha-types but are defined here for now
|
|
8
|
-
* as ha-types currently only has WebSocket command types)
|
|
9
|
-
* 3. **Sync-layer specific**: EntityView, views
|
|
10
|
-
*
|
|
11
|
-
* @packageDocumentation
|
|
12
|
-
*/
|
|
13
|
-
import type { AreaEntry, DeviceEntry, EntityCategory, EntityRegistryEntry } from "@glasshome/ha-types";
|
|
14
|
-
/**
|
|
15
|
-
* Unique entity identifier (e.g., "light.living_room")
|
|
16
|
-
*/
|
|
17
|
-
export type EntityId = string;
|
|
18
|
-
/**
|
|
19
|
-
* Domain extracted from entity_id (e.g., "light")
|
|
20
|
-
*/
|
|
21
|
-
export type EntityDomain = string;
|
|
22
|
-
/**
|
|
23
|
-
* Unique device identifier (UUID)
|
|
24
|
-
*/
|
|
25
|
-
export type DeviceId = string;
|
|
26
|
-
/**
|
|
27
|
-
* Unique area identifier
|
|
28
|
-
*/
|
|
29
|
-
export type AreaId = string;
|
|
30
|
-
/**
|
|
31
|
-
* Floor identifier
|
|
32
|
-
*/
|
|
33
|
-
export type FloorId = string;
|
|
34
|
-
/**
|
|
35
|
-
* Label identifier
|
|
36
|
-
*/
|
|
37
|
-
export type LabelId = string;
|
|
38
|
-
/**
|
|
39
|
-
* Runtime entity state from Home Assistant
|
|
40
|
-
*
|
|
41
|
-
* This represents the live state of an entity as received
|
|
42
|
-
* from the WebSocket API's `get_states` command or `subscribe_entities` subscription.
|
|
43
|
-
*/
|
|
44
|
-
export interface HassEntity {
|
|
45
|
-
/** Unique entity identifier */
|
|
46
|
-
entity_id: EntityId;
|
|
47
|
-
/** Current state value (e.g., "on", "off", "23.5") */
|
|
48
|
-
state: string;
|
|
49
|
-
/** Entity attributes (brightness, temperature, etc.) */
|
|
50
|
-
attributes: Record<string, any>;
|
|
51
|
-
/** ISO 8601 timestamp of last state change */
|
|
52
|
-
last_changed: string;
|
|
53
|
-
/** ISO 8601 timestamp of last update */
|
|
54
|
-
last_updated: string;
|
|
55
|
-
/** Event context */
|
|
56
|
-
context: {
|
|
57
|
-
/** Context ID */
|
|
58
|
-
id: string;
|
|
59
|
-
/** Parent context ID */
|
|
60
|
-
parent_id: string | null;
|
|
61
|
-
/** User ID that triggered the change */
|
|
62
|
-
user_id: string | null;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Device registry entry
|
|
67
|
-
*
|
|
68
|
-
* @alias DeviceEntry
|
|
69
|
-
*/
|
|
70
|
-
export type DeviceRegistryEntry = DeviceEntry;
|
|
71
|
-
/**
|
|
72
|
-
* Area registry entry
|
|
73
|
-
*
|
|
74
|
-
* @alias AreaEntry
|
|
75
|
-
* @note AreaEntry uses 'id' field, not 'area_id'
|
|
76
|
-
*/
|
|
77
|
-
export type AreaRegistryEntry = AreaEntry;
|
|
78
|
-
/**
|
|
79
|
-
* Floor registry entry
|
|
80
|
-
*
|
|
81
|
-
* Response structure from `config/floor_registry/list`
|
|
82
|
-
*/
|
|
83
|
-
export interface FloorRegistryEntry {
|
|
84
|
-
/** Unique floor identifier */
|
|
85
|
-
floor_id: FloorId;
|
|
86
|
-
/** Floor name */
|
|
87
|
-
name: string;
|
|
88
|
-
/** Floor level (integer, 0 = ground floor) */
|
|
89
|
-
level: number;
|
|
90
|
-
/** Floor icon */
|
|
91
|
-
icon: string | null;
|
|
92
|
-
/** Floor aliases */
|
|
93
|
-
aliases: string[];
|
|
94
|
-
/** Created timestamp */
|
|
95
|
-
created_at: string;
|
|
96
|
-
/** Modified timestamp */
|
|
97
|
-
modified_at: string;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Label registry entry
|
|
101
|
-
*
|
|
102
|
-
* Response structure from `config/label_registry/list`
|
|
103
|
-
*/
|
|
104
|
-
export interface LabelRegistryEntry {
|
|
105
|
-
/** Unique label identifier */
|
|
106
|
-
label_id: LabelId;
|
|
107
|
-
/** Label name */
|
|
108
|
-
name: string;
|
|
109
|
-
/** Label color (hex) */
|
|
110
|
-
color: string | null;
|
|
111
|
-
/** Label icon */
|
|
112
|
-
icon: string | null;
|
|
113
|
-
/** Label description */
|
|
114
|
-
description: string | null;
|
|
115
|
-
/** Created timestamp */
|
|
116
|
-
created_at: string;
|
|
117
|
-
/** Modified timestamp */
|
|
118
|
-
modified_at: string;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Statistics metadata
|
|
122
|
-
*
|
|
123
|
-
* Response structure from `recorder/get_statistics_metadata`
|
|
124
|
-
*/
|
|
125
|
-
export interface StatisticMetadata {
|
|
126
|
-
/** Statistic ID */
|
|
127
|
-
statistic_id: string;
|
|
128
|
-
/** Data source */
|
|
129
|
-
source: string;
|
|
130
|
-
/** Unit of measurement */
|
|
131
|
-
unit_of_measurement: string | null;
|
|
132
|
-
/** Whether statistic has mean values */
|
|
133
|
-
has_mean: boolean;
|
|
134
|
-
/** Whether statistic has sum values */
|
|
135
|
-
has_sum: boolean;
|
|
136
|
-
/** Display name */
|
|
137
|
-
name: string | null;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Statistics data point
|
|
141
|
-
*
|
|
142
|
-
* Response structure from `recorder/statistics_during_period`
|
|
143
|
-
*/
|
|
144
|
-
export interface StatisticData {
|
|
145
|
-
/** Statistic ID */
|
|
146
|
-
statistic_id: string;
|
|
147
|
-
/** Period start (ISO 8601) */
|
|
148
|
-
start: string;
|
|
149
|
-
/** Period end (ISO 8601) */
|
|
150
|
-
end: string;
|
|
151
|
-
/** Mean value */
|
|
152
|
-
mean?: number;
|
|
153
|
-
/** Minimum value */
|
|
154
|
-
min?: number;
|
|
155
|
-
/** Maximum value */
|
|
156
|
-
max?: number;
|
|
157
|
-
/** Last reset timestamp */
|
|
158
|
-
last_reset?: string;
|
|
159
|
-
/** State value */
|
|
160
|
-
state?: number;
|
|
161
|
-
/** Sum value */
|
|
162
|
-
sum?: number;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Unified entity view combining runtime state and registry metadata
|
|
166
|
-
*
|
|
167
|
-
* This is the primary interface for working with entities in the sync-layer.
|
|
168
|
-
* It combines live state data with registry metadata to provide a complete
|
|
169
|
-
* view of an entity.
|
|
170
|
-
*/
|
|
171
|
-
export interface EntityView {
|
|
172
|
-
/** Unique entity identifier */
|
|
173
|
-
id: EntityId;
|
|
174
|
-
/** Entity domain (e.g., "light", "sensor") */
|
|
175
|
-
domain: EntityDomain;
|
|
176
|
-
/** Current state value */
|
|
177
|
-
state: string;
|
|
178
|
-
/**
|
|
179
|
-
* Entity attributes from Home Assistant, excluding keys that are
|
|
180
|
-
* surfaced as canonical resolved fields elsewhere on EntityView
|
|
181
|
-
* (`deviceClass`, `unitOfMeasurement`, `friendlyName`, `icon`).
|
|
182
|
-
* Use those fields instead of reaching into `attributes`.
|
|
183
|
-
*/
|
|
184
|
-
attributes: Omit<Record<string, any>, "device_class" | "unit_of_measurement" | "friendly_name" | "icon">;
|
|
185
|
-
lastChanged: Date;
|
|
186
|
-
lastUpdated: Date;
|
|
187
|
-
/** Event context */
|
|
188
|
-
context: {
|
|
189
|
-
id: string;
|
|
190
|
-
parentId: string | null;
|
|
191
|
-
userId: string | null;
|
|
192
|
-
};
|
|
193
|
-
/** Entity name (from registry or friendly_name) */
|
|
194
|
-
name: string;
|
|
195
|
-
/** Friendly display name */
|
|
196
|
-
friendlyName: string;
|
|
197
|
-
/** Area ID where entity is located */
|
|
198
|
-
areaId: AreaId | null;
|
|
199
|
-
/** Device ID this entity belongs to */
|
|
200
|
-
deviceId: DeviceId | null;
|
|
201
|
-
/** Platform/integration that provides this entity */
|
|
202
|
-
platform: string;
|
|
203
|
-
/** Unique ID from integration */
|
|
204
|
-
uniqueId: string | null;
|
|
205
|
-
/** Whether entity is disabled */
|
|
206
|
-
isDisabled: boolean;
|
|
207
|
-
/** Whether entity is hidden */
|
|
208
|
-
isHidden: boolean;
|
|
209
|
-
/** Resolved icon (registry icon, attribute icon, or domain default) */
|
|
210
|
-
icon: string | null;
|
|
211
|
-
/** Icon source (registry, attribute, or default) */
|
|
212
|
-
iconSource: "registry" | "attribute" | "default";
|
|
213
|
-
/** Entity category (config, diagnostic, or null) */
|
|
214
|
-
entityCategory: EntityCategory | null;
|
|
215
|
-
/** Labels applied to this entity */
|
|
216
|
-
labels: LabelId[];
|
|
217
|
-
/** Entity aliases */
|
|
218
|
-
aliases: string[];
|
|
219
|
-
/** Device class (e.g., "temperature", "humidity") */
|
|
220
|
-
deviceClass?: string | null;
|
|
221
|
-
/** Unit of measurement */
|
|
222
|
-
unitOfMeasurement?: string | null;
|
|
223
|
-
/** Supported features bitmask */
|
|
224
|
-
supportedFeatures?: number;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Device view combining registry data with computed properties
|
|
228
|
-
*/
|
|
229
|
-
export interface DeviceView {
|
|
230
|
-
/** Unique device identifier */
|
|
231
|
-
id: DeviceId;
|
|
232
|
-
/** Device name */
|
|
233
|
-
name: string;
|
|
234
|
-
/** User-friendly name */
|
|
235
|
-
nameByUser: string | null;
|
|
236
|
-
/** Manufacturer */
|
|
237
|
-
manufacturer: string | null;
|
|
238
|
-
/** Model */
|
|
239
|
-
model: string | null;
|
|
240
|
-
/** Software version */
|
|
241
|
-
swVersion: string | null;
|
|
242
|
-
/** Area ID where device is located */
|
|
243
|
-
areaId: AreaId | null;
|
|
244
|
-
/** Configuration entry IDs */
|
|
245
|
-
configEntries: string[];
|
|
246
|
-
/** Device connections */
|
|
247
|
-
connections: Array<[string, string]>;
|
|
248
|
-
/** Device identifiers */
|
|
249
|
-
identifiers: Array<[string, string]>;
|
|
250
|
-
/** Whether device is disabled */
|
|
251
|
-
disabledBy: string | null;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Area view combining registry data with computed entities and devices
|
|
255
|
-
*/
|
|
256
|
-
export interface AreaView {
|
|
257
|
-
/** Unique area identifier */
|
|
258
|
-
id: AreaId;
|
|
259
|
-
/** Area name */
|
|
260
|
-
name: string;
|
|
261
|
-
/** Normalized area name (for searching) */
|
|
262
|
-
normalizedName: string;
|
|
263
|
-
/** Area aliases */
|
|
264
|
-
aliases: string[];
|
|
265
|
-
/** Floor ID this area belongs to */
|
|
266
|
-
floorId: FloorId | null;
|
|
267
|
-
/** Area icon */
|
|
268
|
-
icon: string | null;
|
|
269
|
-
/** Area picture */
|
|
270
|
-
picture: string | null;
|
|
271
|
-
/** Labels applied to this area */
|
|
272
|
-
labels: LabelId[];
|
|
273
|
-
/** Temperature entity ID for this area */
|
|
274
|
-
temperatureEntityId: EntityId | null;
|
|
275
|
-
/** Humidity entity ID for this area */
|
|
276
|
-
humidityEntityId: EntityId | null;
|
|
277
|
-
/** Created timestamp */
|
|
278
|
-
createdAt: string;
|
|
279
|
-
/** Last modified timestamp */
|
|
280
|
-
modifiedAt: string;
|
|
281
|
-
/** Entities in this area (direct + via devices) - uses query engine */
|
|
282
|
-
entities: EntityView[];
|
|
283
|
-
/** Devices in this area */
|
|
284
|
-
devices: DeviceView[];
|
|
285
|
-
/** Entity IDs for fast lookups */
|
|
286
|
-
entityIds: EntityId[];
|
|
287
|
-
/** Device IDs for fast lookups */
|
|
288
|
-
deviceIds: DeviceId[];
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* WebSocket connection state
|
|
292
|
-
*/
|
|
293
|
-
export type ConnectionState = "connecting" | "connected" | "disconnected" | "reconnecting" | "error";
|
|
294
|
-
/**
|
|
295
|
-
* Unsubscribe function returned by subscriptions
|
|
296
|
-
*/
|
|
297
|
-
export type UnsubscribeFunc = () => void;
|
|
298
|
-
/**
|
|
299
|
-
* Generic callback type
|
|
300
|
-
*/
|
|
301
|
-
export type Callback<T> = (data: T) => void;
|
|
302
|
-
/**
|
|
303
|
-
* Predicate function for filtering
|
|
304
|
-
*/
|
|
305
|
-
export type PredicateFunc<T> = (item: T) => boolean;
|
|
306
|
-
/**
|
|
307
|
-
* Comparison function for sorting
|
|
308
|
-
*/
|
|
309
|
-
export type CompareFunc<T> = (a: T, b: T) => number;
|
|
310
|
-
/**
|
|
311
|
-
* Mapping function for transformations
|
|
312
|
-
*/
|
|
313
|
-
export type MapFunc<T, R> = (item: T) => R;
|
|
314
|
-
/**
|
|
315
|
-
* Registry update event data
|
|
316
|
-
*/
|
|
317
|
-
export interface RegistryUpdateEvent {
|
|
318
|
-
action: "create" | "update" | "remove";
|
|
319
|
-
entity_id: EntityId;
|
|
320
|
-
entity?: EntityRegistryEntry;
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Statistics update event data
|
|
324
|
-
*/
|
|
325
|
-
export interface StatisticsUpdateEvent {
|
|
326
|
-
statistic_ids: string[];
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Check if a value is a valid EntityId
|
|
330
|
-
*/
|
|
331
|
-
export declare function isEntityId(value: unknown): value is EntityId;
|
|
332
|
-
/**
|
|
333
|
-
* Extract domain from entity ID
|
|
334
|
-
*/
|
|
335
|
-
export declare function extractDomain(entityId: EntityId): EntityDomain;
|
|
336
|
-
/**
|
|
337
|
-
* Check if entity is in a specific domain
|
|
338
|
-
*/
|
|
339
|
-
export declare function isDomain(entityId: EntityId, domain: EntityDomain): boolean;
|
package/dist/demo/demo-data.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Demo Mode Fixtures
|
|
3
|
-
*
|
|
4
|
-
* ~30 curated apartment entities for showcasing the dashboard without
|
|
5
|
-
* a real Home Assistant instance. Covers all widget-relevant domains.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
import type { EntityRegistryEntry } from "@glasshome/ha-types";
|
|
10
|
-
import type { AreaRegistryEntry, DeviceRegistryEntry, HassEntity } from "../core/types";
|
|
11
|
-
export interface DemoFixtures {
|
|
12
|
-
entities: Record<string, HassEntity>;
|
|
13
|
-
entityRegistry: Record<string, EntityRegistryEntry>;
|
|
14
|
-
areas: Record<string, AreaRegistryEntry>;
|
|
15
|
-
devices: Record<string, DeviceRegistryEntry>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Create ~30 curated apartment entity fixtures.
|
|
19
|
-
*
|
|
20
|
-
* Entities span lights, sensors, binary sensors, climate, covers,
|
|
21
|
-
* locks, switches, media player, weather, camera, scenes, and buttons
|
|
22
|
-
* across 6 areas: living_room, bedroom, kitchen, entry, utility, garage.
|
|
23
|
-
*/
|
|
24
|
-
export declare function createDemoFixtures(): DemoFixtures;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Demo Mode Provider
|
|
3
|
-
*
|
|
4
|
-
* Loads demo fixtures into the SolidJS store and provides
|
|
5
|
-
* optimistic local state updates for service calls (toggle, turnOn, turnOff).
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Whether demo mode is currently active.
|
|
11
|
-
*/
|
|
12
|
-
export declare function isDemoMode(): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Load demo fixtures into the SolidJS store.
|
|
15
|
-
*
|
|
16
|
-
* Populates entities, entity registry, areas, and devices.
|
|
17
|
-
* Sets connection state to "connected" (pretend connected).
|
|
18
|
-
*/
|
|
19
|
-
export declare function loadDemoData(): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Unload demo data and reset to disconnected state.
|
|
22
|
-
*/
|
|
23
|
-
export declare function unloadDemoData(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Start the demo energy ticker. Updates the energy sensors and `sun.sun`
|
|
26
|
-
* every 5 seconds. Idempotent: clears any prior interval first. SSR-safe.
|
|
27
|
-
*/
|
|
28
|
-
export declare function startDemoEnergyTicker(): void;
|
|
29
|
-
/** Stop the demo energy ticker if running. */
|
|
30
|
-
export declare function stopDemoEnergyTicker(): void;
|
|
31
|
-
/**
|
|
32
|
-
* Apply an optimistic state update for demo mode.
|
|
33
|
-
*
|
|
34
|
-
* When a service call is made in demo mode, this updates the entity
|
|
35
|
-
* state locally (no WebSocket message sent). State resets on page refresh.
|
|
36
|
-
*/
|
|
37
|
-
export declare function applyDemoServiceCall(_domain: string, service: string, _serviceData?: Record<string, any>, target?: {
|
|
38
|
-
entity_id?: string | string[];
|
|
39
|
-
}): void;
|
|
40
|
-
export { createDemoFixtures } from "./demo-data";
|