@glasshome/sync-layer 0.3.2 → 0.4.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.
|
@@ -53,18 +53,18 @@ export interface OAuthOptions {
|
|
|
53
53
|
* Authenticate using OAuth flow
|
|
54
54
|
*
|
|
55
55
|
* This function uses `getAuth` from `home-assistant-js-websocket` which:
|
|
56
|
-
* 1.
|
|
56
|
+
* 1. Redirects the whole page to the Home Assistant authorization page
|
|
57
57
|
* 2. Waits for user authorization
|
|
58
|
-
* 3.
|
|
59
|
-
* 4.
|
|
58
|
+
* 3. On return, HA redirects back to the app URL with `?auth_callback=1&code=…`
|
|
59
|
+
* 4. Exchanges the authorization code for tokens and returns an Auth object
|
|
60
60
|
*
|
|
61
61
|
* Note: For a complete OAuth flow, you typically need to:
|
|
62
62
|
* - Set up a redirect URI endpoint in your app
|
|
63
63
|
* - Handle the OAuth callback with the authorization code
|
|
64
64
|
* - Use `getAuthCode` callback to provide the code
|
|
65
65
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
66
|
+
* In browser environments `getAuth` handles this automatically via a full-page
|
|
67
|
+
* redirect (not a popup); native platforms supply `getAuthCode` instead.
|
|
68
68
|
*
|
|
69
69
|
* @param options - OAuth options
|
|
70
70
|
* @returns Authenticated Auth object
|
|
@@ -869,6 +869,26 @@ function createDemoFixtures() {
|
|
|
869
869
|
area_id: "entry",
|
|
870
870
|
supported_features: 1
|
|
871
871
|
});
|
|
872
|
+
add(makeEntity("light.studio_rgb", "on", {
|
|
873
|
+
brightness: 205,
|
|
874
|
+
hs_color: [265, 66],
|
|
875
|
+
color_mode: "hs",
|
|
876
|
+
supported_color_modes: ["hs", "color_temp"]
|
|
877
|
+
}), {
|
|
878
|
+
device_id: "studio_lights",
|
|
879
|
+
area_id: "living_room",
|
|
880
|
+
supported_features: 44
|
|
881
|
+
});
|
|
882
|
+
add(makeEntity("light.desk_rgb", "on", {
|
|
883
|
+
brightness: 200,
|
|
884
|
+
hs_color: [172, 79],
|
|
885
|
+
color_mode: "hs",
|
|
886
|
+
supported_color_modes: ["hs", "color_temp"]
|
|
887
|
+
}), {
|
|
888
|
+
device_id: "desk_lights",
|
|
889
|
+
area_id: "bedroom",
|
|
890
|
+
supported_features: 44
|
|
891
|
+
});
|
|
872
892
|
add(makeEntity("sensor.temperature_living", "22.5", {
|
|
873
893
|
unit_of_measurement: "°C",
|
|
874
894
|
device_class: "temperature",
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ENERGY_ENTITY_IDS, createDemoFixtures, demoEnergyPreferences, energyEntityValue, formatEnergyState, isEnergyEntity, isSunUp, resetStore, setState, simulateEnergy, state, sunEvents, synthesizeEnergyHistory, synthesizeEnergyStatistics } from "./demo-data-
|
|
1
|
+
import { ENERGY_ENTITY_IDS, createDemoFixtures, demoEnergyPreferences, energyEntityValue, formatEnergyState, isEnergyEntity, isSunUp, resetStore, setState, simulateEnergy, state, sunEvents, synthesizeEnergyHistory, synthesizeEnergyStatistics } from "./demo-data-CcG2efdQ.js";
|
|
2
2
|
import { runHaBridgeWorker } from "./worker-main-DTbzEKor.js";
|
|
3
3
|
import { createConnection, createLongLivedTokenAuth, getAuth } from "home-assistant-js-websocket";
|
|
4
4
|
import { produce, reconcile } from "solid-js/store";
|
|
@@ -247,18 +247,18 @@ function updateStatisticsMetadata(metadata) {
|
|
|
247
247
|
* Authenticate using OAuth flow
|
|
248
248
|
*
|
|
249
249
|
* This function uses `getAuth` from `home-assistant-js-websocket` which:
|
|
250
|
-
* 1.
|
|
250
|
+
* 1. Redirects the whole page to the Home Assistant authorization page
|
|
251
251
|
* 2. Waits for user authorization
|
|
252
|
-
* 3.
|
|
253
|
-
* 4.
|
|
252
|
+
* 3. On return, HA redirects back to the app URL with `?auth_callback=1&code=…`
|
|
253
|
+
* 4. Exchanges the authorization code for tokens and returns an Auth object
|
|
254
254
|
*
|
|
255
255
|
* Note: For a complete OAuth flow, you typically need to:
|
|
256
256
|
* - Set up a redirect URI endpoint in your app
|
|
257
257
|
* - Handle the OAuth callback with the authorization code
|
|
258
258
|
* - Use `getAuthCode` callback to provide the code
|
|
259
259
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
260
|
+
* In browser environments `getAuth` handles this automatically via a full-page
|
|
261
|
+
* redirect (not a popup); native platforms supply `getAuthCode` instead.
|
|
262
262
|
*
|
|
263
263
|
* @param options - OAuth options
|
|
264
264
|
* @returns Authenticated Auth object
|
|
@@ -1491,10 +1491,11 @@ function resolveIcon(entity$1, registry) {
|
|
|
1491
1491
|
*/
|
|
1492
1492
|
function buildEntityView(entity$1, registry) {
|
|
1493
1493
|
const domain = extractDomain(entity$1.entity_id);
|
|
1494
|
-
const
|
|
1494
|
+
const attributes = entity$1.attributes ?? {};
|
|
1495
|
+
const friendlyName = attributes.friendly_name ?? registry?.name ?? entity$1.entity_id;
|
|
1495
1496
|
const name = registry?.name ?? friendlyName;
|
|
1496
1497
|
const iconResolution = resolveIcon(entity$1, registry);
|
|
1497
|
-
const { device_class: _dc, unit_of_measurement: _uom, friendly_name: _fn, icon: _icon,...restAttributes } =
|
|
1498
|
+
const { device_class: _dc, unit_of_measurement: _uom, friendly_name: _fn, icon: _icon,...restAttributes } = attributes;
|
|
1498
1499
|
let areaId = registry?.area_id ?? null;
|
|
1499
1500
|
if (areaId === null && registry?.device_id) {
|
|
1500
1501
|
const device = state.devices[registry.device_id];
|
|
@@ -1508,9 +1509,9 @@ function buildEntityView(entity$1, registry) {
|
|
|
1508
1509
|
lastChanged: new Date(entity$1.last_changed),
|
|
1509
1510
|
lastUpdated: new Date(entity$1.last_updated),
|
|
1510
1511
|
context: {
|
|
1511
|
-
id: entity$1.context
|
|
1512
|
-
parentId: entity$1.context
|
|
1513
|
-
userId: entity$1.context
|
|
1512
|
+
id: entity$1.context?.id ?? "",
|
|
1513
|
+
parentId: entity$1.context?.parent_id ?? null,
|
|
1514
|
+
userId: entity$1.context?.user_id ?? null
|
|
1514
1515
|
},
|
|
1515
1516
|
name,
|
|
1516
1517
|
friendlyName,
|
|
@@ -1525,9 +1526,9 @@ function buildEntityView(entity$1, registry) {
|
|
|
1525
1526
|
entityCategory: registry?.entity_category ?? null,
|
|
1526
1527
|
labels: registry?.labels ?? [],
|
|
1527
1528
|
aliases: registry?.aliases ?? [],
|
|
1528
|
-
deviceClass: registry?.device_class ??
|
|
1529
|
-
unitOfMeasurement: registry?.unit_of_measurement ??
|
|
1530
|
-
supportedFeatures: registry?.supported_features ??
|
|
1529
|
+
deviceClass: registry?.device_class ?? attributes.device_class ?? null,
|
|
1530
|
+
unitOfMeasurement: registry?.unit_of_measurement ?? attributes.unit_of_measurement ?? null,
|
|
1531
|
+
supportedFeatures: registry?.supported_features ?? attributes.supported_features
|
|
1531
1532
|
};
|
|
1532
1533
|
}
|
|
1533
1534
|
/**
|
package/dist/testing/index.js
CHANGED