homebridge-dyson-solarcycle-morph 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 (57) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/LICENSE +22 -0
  3. package/README.md +259 -0
  4. package/config.schema.json +118 -0
  5. package/dist/accessory.d.ts +41 -0
  6. package/dist/accessory.js +129 -0
  7. package/dist/accessory.js.map +1 -0
  8. package/dist/cli/pair.d.ts +2 -0
  9. package/dist/cli/pair.js +144 -0
  10. package/dist/cli/pair.js.map +1 -0
  11. package/dist/config.d.ts +51 -0
  12. package/dist/config.js +32 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/dyson/cloud.d.ts +67 -0
  15. package/dist/dyson/cloud.js +147 -0
  16. package/dist/dyson/cloud.js.map +1 -0
  17. package/dist/dyson/credentials.d.ts +32 -0
  18. package/dist/dyson/credentials.js +73 -0
  19. package/dist/dyson/credentials.js.map +1 -0
  20. package/dist/dyson/crypto.d.ts +38 -0
  21. package/dist/dyson/crypto.js +98 -0
  22. package/dist/dyson/crypto.js.map +1 -0
  23. package/dist/dyson/debounce.d.ts +33 -0
  24. package/dist/dyson/debounce.js +59 -0
  25. package/dist/dyson/debounce.js.map +1 -0
  26. package/dist/dyson/lamp.d.ts +193 -0
  27. package/dist/dyson/lamp.js +692 -0
  28. package/dist/dyson/lamp.js.map +1 -0
  29. package/dist/dyson/protocol.d.ts +91 -0
  30. package/dist/dyson/protocol.js +156 -0
  31. package/dist/dyson/protocol.js.map +1 -0
  32. package/dist/dyson/queue.d.ts +24 -0
  33. package/dist/dyson/queue.js +51 -0
  34. package/dist/dyson/queue.js.map +1 -0
  35. package/dist/dyson/reconcile.d.ts +38 -0
  36. package/dist/dyson/reconcile.js +30 -0
  37. package/dist/dyson/reconcile.js.map +1 -0
  38. package/dist/dyson/settle.d.ts +30 -0
  39. package/dist/dyson/settle.js +56 -0
  40. package/dist/dyson/settle.js.map +1 -0
  41. package/dist/errors.d.ts +8 -0
  42. package/dist/errors.js +20 -0
  43. package/dist/errors.js.map +1 -0
  44. package/dist/index.d.ts +4 -0
  45. package/dist/index.js +7 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/platform.d.ts +27 -0
  48. package/dist/platform.js +106 -0
  49. package/dist/platform.js.map +1 -0
  50. package/dist/settings.d.ts +4 -0
  51. package/dist/settings.js +5 -0
  52. package/dist/settings.js.map +1 -0
  53. package/docs/PROTOCOL.md +153 -0
  54. package/homebridge-ui/public/index.html +396 -0
  55. package/homebridge-ui/server.js +297 -0
  56. package/package.json +68 -0
  57. package/tools/ble-probe.js +132 -0
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "homebridge-dyson-solarcycle-morph",
3
+ "displayName": "Dyson Solarcycle Morph",
4
+ "version": "0.1.0",
5
+ "description": "Homebridge plugin for the Bluetooth LE controlled Dyson Solarcycle/Lightcycle Morph task light",
6
+ "license": "MIT",
7
+ "author": "Oliver Rummeyer",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/rummeyer/homebridge-dyson-solarcycle-morph.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/rummeyer/homebridge-dyson-solarcycle-morph/issues"
14
+ },
15
+ "main": "dist/index.js",
16
+ "bin": {
17
+ "dyson-morph-pair": "dist/cli/pair.js"
18
+ },
19
+ "engines": {
20
+ "node": "^22.18.0 || ^24.0.0 || ^26.0.0",
21
+ "homebridge": "^2.0.0"
22
+ },
23
+ "keywords": [
24
+ "homebridge-plugin",
25
+ "dyson",
26
+ "solarcycle",
27
+ "lightcycle",
28
+ "morph",
29
+ "cd06",
30
+ "bluetooth",
31
+ "ble",
32
+ "light",
33
+ "homekit"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsc && chmod +x dist/cli/pair.js",
37
+ "watch": "tsc --watch",
38
+ "clean": "rm -rf dist",
39
+ "test": "npm run build && node --test test/*.test.ts",
40
+ "prepublishOnly": "npm run clean && npm test",
41
+ "prepare": "npm run build"
42
+ },
43
+ "dependencies": {
44
+ "@homebridge/plugin-ui-utils": "^2.2.6",
45
+ "dbus-next": "^0.10.2",
46
+ "node-ble": "^1.13.0",
47
+ "node-persist": "^4.0.4"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "^22.20.0",
51
+ "@types/node-persist": "^3.1.8",
52
+ "homebridge": "^2.4.0",
53
+ "typescript": "^5.9.3"
54
+ },
55
+ "files": [
56
+ "dist",
57
+ "homebridge-ui",
58
+ "tools",
59
+ "docs",
60
+ "config.schema.json",
61
+ "README.md",
62
+ "CHANGELOG.md",
63
+ "LICENSE"
64
+ ],
65
+ "homepage": "https://github.com/rummeyer/homebridge-dyson-solarcycle-morph#readme",
66
+ "funding": "https://github.com/sponsors/rummeyer",
67
+ "type": "module"
68
+ }
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Standalone GATT probe. Plain JavaScript so it runs on the Raspberry Pi with
4
+ * nothing but `npm install node-ble` — no build step, no plugin install.
5
+ *
6
+ * node tools/ble-probe.js AA:BB:CC:DD:EE:FF
7
+ *
8
+ * Dumps every service and characteristic the lamp exposes, reads what it can,
9
+ * and watches for notifications. Use this to confirm the documented UUIDs
10
+ * before trusting them, and to see whether unauthenticated reads are allowed.
11
+ */
12
+ import { createBluetooth } from 'node-ble';
13
+
14
+ const MAC = (process.argv[2] || '').toUpperCase();
15
+ const WATCH_SECONDS = Number(process.argv[3] || 20);
16
+
17
+ if (!/^([0-9A-F]{2}:){5}[0-9A-F]{2}$/.test(MAC)) {
18
+ console.error('Usage: node tools/ble-probe.js <MAC> [seconds-to-watch]');
19
+ process.exit(1);
20
+ }
21
+
22
+ /** UUIDs we expect, from the reverse-engineered Lightcycle/Solarcycle protocol. */
23
+ const KNOWN = {
24
+ '2dd10010-1c37-452d-8979-d1b4a787d0a4': 'Dyson service',
25
+ '2dd10011-1c37-452d-8979-d1b4a787d0a4': 'auth channel',
26
+ '2dd10013-1c37-452d-8979-d1b4a787d0a4': 'RSSI',
27
+ '2dd10021-1c37-452d-8979-d1b4a787d0a4': 'attribute write',
28
+ '2dd11000-1c37-452d-8979-d1b4a787d0a4': 'brightness %',
29
+ '2dd11001-1c37-452d-8979-d1b4a787d0a4': 'colour temp (K, uint16 LE)',
30
+ '2dd11005-1c37-452d-8979-d1b4a787d0a4': 'power (0/1)',
31
+ '2dd11006-1c37-452d-8979-d1b4a787d0a4': 'runtime flags',
32
+ '2dd11007-1c37-452d-8979-d1b4a787d0a4': 'ambient sensor',
33
+ '2dd11008-1c37-452d-8979-d1b4a787d0a4': 'motion',
34
+ '2dd11009-1c37-452d-8979-d1b4a787d0a4': 'brightness (lm, uint16 LE)',
35
+ };
36
+
37
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
38
+
39
+ /** Render a value as hex plus the interpretations that are plausible for it. */
40
+ function describeValue(buf) {
41
+ const parts = [`hex=${buf.toString('hex') || '(empty)'}`];
42
+ if (buf.length === 1) {
43
+ parts.push(`u8=${buf[0]}`);
44
+ }
45
+ if (buf.length === 2) {
46
+ parts.push(`u16le=${buf.readUInt16LE(0)}`);
47
+ }
48
+ return parts.join(' ');
49
+ }
50
+
51
+ async function main() {
52
+ const { bluetooth, destroy } = createBluetooth();
53
+ const adapter = await bluetooth.defaultAdapter();
54
+
55
+ if (!(await adapter.isPowered())) {
56
+ throw new Error('Bluetooth adapter is powered off — run: bluetoothctl power on');
57
+ }
58
+ if (!(await adapter.isDiscovering())) {
59
+ await adapter.startDiscovery();
60
+ }
61
+
62
+ console.log(`Waiting for ${MAC} …`);
63
+ const device = await adapter.waitDevice(MAC, 60_000);
64
+
65
+ for (const [label, fn] of [
66
+ ['name', 'getName'],
67
+ ['alias', 'getAlias'],
68
+ ['RSSI', 'getRSSI'],
69
+ ['paired', 'isPaired'],
70
+ ]) {
71
+ try {
72
+ console.log(` ${label}: ${await device[fn]()}`);
73
+ } catch (e) {
74
+ console.log(` ${label}: (unavailable)`);
75
+ }
76
+ }
77
+
78
+ console.log('Connecting …');
79
+ await device.connect();
80
+ const gatt = await device.gatt();
81
+
82
+ const notifying = [];
83
+
84
+ for (const serviceUuid of await gatt.services()) {
85
+ const service = await gatt.getPrimaryService(serviceUuid);
86
+ console.log(`\nService ${serviceUuid} ${KNOWN[serviceUuid] ? `(${KNOWN[serviceUuid]})` : ''}`);
87
+
88
+ for (const charUuid of await service.characteristics()) {
89
+ const characteristic = await service.getCharacteristic(charUuid);
90
+ const flags = await characteristic.getFlags();
91
+ const label = KNOWN[charUuid] ? ` ← ${KNOWN[charUuid]}` : '';
92
+ console.log(` ${charUuid} [${flags.join(', ')}]${label}`);
93
+
94
+ if (flags.includes('read')) {
95
+ try {
96
+ console.log(` read: ${describeValue(await characteristic.readValue())}`);
97
+ } catch (e) {
98
+ // A permission error here is the interesting case: it tells us the
99
+ // lamp gates this characteristic behind the auth handshake.
100
+ console.log(` read failed: ${e.message}`);
101
+ }
102
+ }
103
+
104
+ if (flags.includes('notify')) {
105
+ try {
106
+ characteristic.on('valuechanged', (buf) => {
107
+ console.log(` [notify] ${charUuid} ${describeValue(buf)}`);
108
+ });
109
+ await characteristic.startNotifications();
110
+ notifying.push(characteristic);
111
+ } catch (e) {
112
+ console.log(` notify failed: ${e.message}`);
113
+ }
114
+ }
115
+ }
116
+ }
117
+
118
+ console.log(`\nWatching notifications for ${WATCH_SECONDS}s — touch the lamp or wave at it now.`);
119
+ await sleep(WATCH_SECONDS * 1000);
120
+
121
+ for (const characteristic of notifying) {
122
+ await characteristic.stopNotifications().catch(() => {});
123
+ }
124
+ await device.disconnect().catch(() => {});
125
+ destroy();
126
+ console.log('Done.');
127
+ }
128
+
129
+ main().catch((e) => {
130
+ console.error(`\nProbe failed: ${e.message}`);
131
+ process.exit(1);
132
+ });