@mp-consulting/homebridge-daikin-cloud 1.3.6 → 1.3.7
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 +39 -1
- package/README.md +3 -1
- package/dist/src/accessories/air-conditioning-accessory.d.ts +2 -2
- package/dist/src/accessories/air-conditioning-accessory.d.ts.map +1 -1
- package/dist/src/accessories/air-conditioning-accessory.js.map +1 -1
- package/dist/src/accessories/altherma-accessory.d.ts +2 -2
- package/dist/src/accessories/altherma-accessory.d.ts.map +1 -1
- package/dist/src/accessories/altherma-accessory.js.map +1 -1
- package/dist/src/accessories/base-accessory.d.ts +5 -5
- package/dist/src/accessories/base-accessory.d.ts.map +1 -1
- package/dist/src/accessories/base-accessory.js +7 -4
- package/dist/src/accessories/base-accessory.js.map +1 -1
- package/dist/src/api/daikin-api.d.ts +25 -25
- package/dist/src/api/daikin-api.d.ts.map +1 -1
- package/dist/src/api/daikin-api.js +41 -31
- package/dist/src/api/daikin-api.js.map +1 -1
- package/dist/src/api/daikin-cloud.repository.d.ts.map +1 -1
- package/dist/src/api/daikin-cloud.repository.js.map +1 -1
- package/dist/src/api/daikin-controller.d.ts +41 -42
- package/dist/src/api/daikin-controller.d.ts.map +1 -1
- package/dist/src/api/daikin-controller.js +39 -39
- package/dist/src/api/daikin-controller.js.map +1 -1
- package/dist/src/api/daikin-device.d.ts +33 -31
- package/dist/src/api/daikin-device.d.ts.map +1 -1
- package/dist/src/api/daikin-device.js +40 -29
- package/dist/src/api/daikin-device.js.map +1 -1
- package/dist/src/api/daikin-mobile-oauth.d.ts +16 -16
- package/dist/src/api/daikin-mobile-oauth.d.ts.map +1 -1
- package/dist/src/api/daikin-mobile-oauth.js +32 -22
- package/dist/src/api/daikin-mobile-oauth.js.map +1 -1
- package/dist/src/api/daikin-oauth.d.ts +29 -29
- package/dist/src/api/daikin-oauth.d.ts.map +1 -1
- package/dist/src/api/daikin-oauth.js +45 -35
- package/dist/src/api/daikin-oauth.js.map +1 -1
- package/dist/src/api/daikin-schemas.d.ts +4 -4
- package/dist/src/api/daikin-schemas.js +3 -3
- package/dist/src/api/daikin-schemas.js.map +1 -1
- package/dist/src/api/daikin-types.js.map +1 -1
- package/dist/src/api/daikin-websocket.d.ts +31 -32
- package/dist/src/api/daikin-websocket.d.ts.map +1 -1
- package/dist/src/api/daikin-websocket.js +30 -30
- package/dist/src/api/daikin-websocket.js.map +1 -1
- package/dist/src/api/index.d.ts +1 -1
- package/dist/src/api/index.d.ts.map +1 -1
- package/dist/src/api/index.js +2 -1
- package/dist/src/api/index.js.map +1 -1
- package/dist/src/api/token-storage.d.ts +1 -1
- package/dist/src/api/token-storage.d.ts.map +1 -1
- package/dist/src/api/token-storage.js +20 -11
- package/dist/src/api/token-storage.js.map +1 -1
- package/dist/src/config/config-manager.d.ts +33 -33
- package/dist/src/config/config-manager.d.ts.map +1 -1
- package/dist/src/config/config-manager.js +33 -33
- package/dist/src/config/config-manager.js.map +1 -1
- package/dist/src/constants/api.constants.js.map +1 -1
- package/dist/src/device/accessory-factory.d.ts +10 -10
- package/dist/src/device/accessory-factory.d.ts.map +1 -1
- package/dist/src/device/accessory-factory.js +6 -6
- package/dist/src/device/accessory-factory.js.map +1 -1
- package/dist/src/device/capability-detector.d.ts +8 -8
- package/dist/src/device/capability-detector.d.ts.map +1 -1
- package/dist/src/device/capability-detector.js +6 -6
- package/dist/src/device/capability-detector.js.map +1 -1
- package/dist/src/device/capability-docs.d.ts +1 -1
- package/dist/src/device/capability-docs.d.ts.map +1 -1
- package/dist/src/device/capability-docs.js +1 -2
- package/dist/src/device/capability-docs.js.map +1 -1
- package/dist/src/device/profiles/device-profile.d.ts +1 -1
- package/dist/src/device/profiles/device-profile.d.ts.map +1 -1
- package/dist/src/device/profiles/device-profile.js +4 -4
- package/dist/src/device/profiles/device-profile.js.map +1 -1
- package/dist/src/features/base-feature.d.ts +2 -2
- package/dist/src/features/base-feature.d.ts.map +1 -1
- package/dist/src/features/base-feature.js +2 -3
- package/dist/src/features/base-feature.js.map +1 -1
- package/dist/src/features/feature-manager.d.ts +8 -8
- package/dist/src/features/feature-manager.d.ts.map +1 -1
- package/dist/src/features/feature-manager.js +5 -5
- package/dist/src/features/feature-manager.js.map +1 -1
- package/dist/src/features/modes/dry-operation-mode.feature.d.ts +1 -1
- package/dist/src/features/modes/dry-operation-mode.feature.d.ts.map +1 -1
- package/dist/src/features/modes/dry-operation-mode.feature.js.map +1 -1
- package/dist/src/features/modes/econo-mode.feature.d.ts +1 -1
- package/dist/src/features/modes/econo-mode.feature.d.ts.map +1 -1
- package/dist/src/features/modes/econo-mode.feature.js.map +1 -1
- package/dist/src/features/modes/fan-only-operation-mode.feature.d.ts +1 -1
- package/dist/src/features/modes/fan-only-operation-mode.feature.d.ts.map +1 -1
- package/dist/src/features/modes/fan-only-operation-mode.feature.js.map +1 -1
- package/dist/src/features/modes/indoor-silent-mode.feature.d.ts +1 -1
- package/dist/src/features/modes/indoor-silent-mode.feature.d.ts.map +1 -1
- package/dist/src/features/modes/indoor-silent-mode.feature.js.map +1 -1
- package/dist/src/features/modes/outdoor-silent-mode.feature.d.ts +1 -1
- package/dist/src/features/modes/outdoor-silent-mode.feature.d.ts.map +1 -1
- package/dist/src/features/modes/outdoor-silent-mode.feature.js.map +1 -1
- package/dist/src/features/modes/powerful-mode.feature.d.ts +1 -1
- package/dist/src/features/modes/powerful-mode.feature.d.ts.map +1 -1
- package/dist/src/features/modes/powerful-mode.feature.js.map +1 -1
- package/dist/src/features/modes/streamer-mode.feature.d.ts +1 -1
- package/dist/src/features/modes/streamer-mode.feature.d.ts.map +1 -1
- package/dist/src/features/modes/streamer-mode.feature.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/platform.d.ts +6 -5
- package/dist/src/platform.d.ts.map +1 -1
- package/dist/src/platform.js +2 -2
- package/dist/src/platform.js.map +1 -1
- package/dist/src/services/climate-control.service.d.ts +8 -2
- package/dist/src/services/climate-control.service.d.ts.map +1 -1
- package/dist/src/services/climate-control.service.js +53 -59
- package/dist/src/services/climate-control.service.js.map +1 -1
- package/dist/src/services/hot-water-tank.service.d.ts +6 -2
- package/dist/src/services/hot-water-tank.service.d.ts.map +1 -1
- package/dist/src/services/hot-water-tank.service.js +31 -34
- package/dist/src/services/hot-water-tank.service.js.map +1 -1
- package/dist/src/types/daikin-enums.js +12 -12
- package/dist/src/types/daikin-enums.js.map +1 -1
- package/dist/src/types/device-capabilities.d.ts +1 -1
- package/dist/src/types/device-capabilities.d.ts.map +1 -1
- package/dist/src/utils/log-context.d.ts +23 -23
- package/dist/src/utils/log-context.d.ts.map +1 -1
- package/dist/src/utils/log-context.js +28 -28
- package/dist/src/utils/log-context.js.map +1 -1
- package/dist/src/utils/strings.d.ts.map +1 -1
- package/dist/src/utils/strings.js.map +1 -1
- package/dist/src/utils/update-mapper.d.ts +16 -16
- package/dist/src/utils/update-mapper.d.ts.map +1 -1
- package/dist/src/utils/update-mapper.js +14 -14
- package/dist/src/utils/update-mapper.js.map +1 -1
- package/homebridge-ui/public/script.js +956 -897
- package/homebridge-ui/server.js +739 -695
- package/package.json +27 -24
- package/.claude/settings.json +0 -3
- package/.claude/settings.local.json +0 -24
- package/CHANGELOG.md +0 -114
- package/CLAUDE.md +0 -269
- package/config.md +0 -2
- package/docs/ARCHITECTURE.md +0 -645
- package/docs/IMPLEMENTATION_GUIDE.md +0 -899
- package/docs/IMPROVEMENTS_SUMMARY.md +0 -415
- package/docs/NEXT_STEPS.md +0 -368
- package/docs/Screenshot 2024-07-04 at 18.41.28.png +0 -0
- package/docs/TROUBLESHOOTING.md +0 -475
- package/docs/api-response-for-BRP069A8x.json +0 -520
- package/docs/api-response-for-BRP069C4x-2.json +0 -881
- package/docs/api-response-for-BRP069C4x.json +0 -916
- package/docs/api-response-for-altherma.json +0 -759
- package/docs/api-response-for-altherma2.json +0 -2735
- package/docs/api-response-with-multiple-devices-incl-heatpump.json +0 -2544
- package/docs/cr-insance-altherma-id-0.json +0 -834
- package/docs/mock-air-to-air-dx23.json +0 -759
- package/docs/mock-air-to-air-dx4.json +0 -1134
- package/docs/mock-airpurifier-with-humidifier.json +0 -732
- package/docs/mock-airpurifier.json +0 -450
- package/docs/mock-altherma-air-to-water-lan.json +0 -845
- package/docs/mock-altherma-air-to-water-wlan.json +0 -845
- package/docs/mock-d2cnd-gas-boiler.json +0 -649
- package/docs/setpointmode-vs-controlmode-vs-setpoints-vs-sensorydata.txt +0 -6
- package/images/fan-speed.jpeg +0 -0
- package/images/homekit-controls.jpeg +0 -0
- package/images/homekit-settings.jpeg +0 -0
- package/images/swing-mode.png +0 -0
- package/jest.config.ts +0 -21
- package/test/fixtures/altherma-crSense-2.ts +0 -834
- package/test/fixtures/altherma-fraction.ts +0 -718
- package/test/fixtures/altherma-heat-pump-2.ts +0 -479
- package/test/fixtures/altherma-heat-pump.ts +0 -757
- package/test/fixtures/altherma-miladcerkic-off.ts +0 -524
- package/test/fixtures/altherma-miladcerkic.ts +0 -524
- package/test/fixtures/altherma-v1ckoeln.ts +0 -644
- package/test/fixtures/altherma-with-embedded-id-zero.ts +0 -834
- package/test/fixtures/dx23-airco-2.ts +0 -343
- package/test/fixtures/dx23-airco.ts +0 -518
- package/test/fixtures/dx4-airco.ts +0 -914
- package/test/fixtures/unknown-jan.ts +0 -488
- package/test/fixtures/unknown-kitchen-guests.ts +0 -488
- package/test/hbConfig/.daikin-mobile-tokenset +0 -8
- package/test/hbConfig/.uix-dashboard.json +0 -1
- package/test/hbConfig/.uix-secrets +0 -1
- package/test/hbConfig/accessories/.cachedAccessories.bak +0 -1
- package/test/hbConfig/accessories/cachedAccessories +0 -1
- package/test/hbConfig/accessories/uiAccessoriesLayout.json +0 -1
- package/test/hbConfig/auth.json +0 -10
- package/test/hbConfig/backups/config-backups/config.json.1767953686461 +0 -25
- package/test/hbConfig/backups/config-backups/config.json.1767953695236 +0 -29
- package/test/hbConfig/backups/config-backups/config.json.1767953814763 +0 -29
- package/test/hbConfig/backups/config-backups/config.json.1767953823101 +0 -29
- package/test/hbConfig/backups/config-backups/config.json.1767954822835 +0 -29
- package/test/hbConfig/backups/config-backups/config.json.1767954859218 +0 -29
- package/test/hbConfig/backups/config-backups/config.json.1767960145503 +0 -33
- package/test/hbConfig/backups/config-backups/config.json.1767960168068 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960170333 +0 -46
- package/test/hbConfig/backups/config-backups/config.json.1767960172731 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960179323 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960182114 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960189302 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960195194 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960197301 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960199151 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960199667 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960329839 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960334503 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960336208 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767960338537 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767963223953 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767963241753 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767963252785 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767963463944 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767963834475 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767963838474 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767963843066 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767965217715 +0 -44
- package/test/hbConfig/backups/config-backups/config.json.1767965419624 +0 -25
- package/test/hbConfig/backups/config-backups/config.json.1767965870934 +0 -32
- package/test/hbConfig/backups/config-backups/config.json.1767977675045 +0 -32
- package/test/hbConfig/backups/config-backups/config.json.1767977677222 +0 -33
- package/test/hbConfig/backups/config-backups/config.json.1767977710226 +0 -33
- package/test/hbConfig/backups/config-backups/config.json.1767977741397 +0 -33
- package/test/hbConfig/backups/config-backups/config.json.1767977977093 +0 -35
- package/test/hbConfig/backups/config-backups/config.json.1767977981773 +0 -35
- package/test/hbConfig/backups/config-backups/config.json.1767977986514 +0 -35
- package/test/hbConfig/backups/config-backups/config.json.1767977991174 +0 -35
- package/test/hbConfig/backups/config-backups/config.json.1767979424487 +0 -35
- package/test/hbConfig/backups/config-backups/config.json.1767979424987 +0 -35
- package/test/hbConfig/backups/config-backups/config.json.1767979432646 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767979433150 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767979436933 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767979437438 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767979441676 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767979442180 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767979466735 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767979903636 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767979904135 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767979906606 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767979907108 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988702341 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988702837 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988713159 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988713664 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988918139 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988918639 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988921120 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988921624 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988930307 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988935070 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767988935574 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767989710262 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767989710760 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767989729668 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767990295225 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767990479921 +0 -47
- package/test/hbConfig/backups/config-backups/config.json.1767990481702 +0 -49
- package/test/hbConfig/backups/instance-backups/homebridge-backup-1E4A432551BA.1768010187391.tar.gz +0 -0
- package/test/hbConfig/backups/instance-backups/homebridge-backup-1E4A432551BA.1768096587387.tar.gz +0 -0
- package/test/hbConfig/backups/instance-backups/homebridge-backup-1E4A432551BA.1768182987404.tar.gz +0 -0
- package/test/hbConfig/config.json +0 -47
- package/test/hbConfig/daikin-cloud-certs/server.crt +0 -22
- package/test/hbConfig/daikin-cloud-certs/server.key +0 -28
- package/test/hbConfig/persist/AccessoryInfo.1E4A432551BA.json +0 -1
- package/test/hbConfig/persist/IdentifierCache.1E4A432551BA.json +0 -1
- package/test/hbConfig/tmp/daikin_request/api.onecta.daikineurope.com_01-09-2026-23-29-52/request_14758 +0 -1
- package/test/hbConfig/tmp/daikin_request/api.onecta.daikineurope.com_01-09-2026-23-29-52/request_14759 +0 -1
- package/test/hbConfig/tmp/daikin_request/api.onecta.daikineurope.com_01-09-2026-23-29-52/request_14760 +0 -1
- package/test/hbConfig/tmp/daikin_request/api.onecta.daikineurope.com_01-09-2026-23-29-52/request_14761 +0 -1
- package/test/hbConfig/tmp/daikin_request/api.onecta.daikineurope.com_01-09-2026-23-29-52/request_14762 +0 -1
- package/test/hbConfig/tmp/daikin_request/api.onecta.daikineurope.com_01-09-2026-23-29-52/request_14764 +0 -1
- package/test/helpers/test-isolation.ts +0 -228
- package/test/integration/air-conditioning.test.ts +0 -396
- package/test/integration/altherma.test.ts +0 -279
- package/test/integration/platform.test.ts +0 -118
- package/test/mobile-tokens.json +0 -8
- package/test/mocks/index.ts +0 -27
- package/test/test-gigya-auth.js +0 -443
- package/test/test-mobile-oauth.js +0 -175
- package/test/test-websocket-mobile.js +0 -123
- package/test/test-websocket.js +0 -116
- package/test/unit/api/__snapshots__/daikinCloud.test.ts.snap +0 -1320
- package/test/unit/api/daikin-api.test.ts +0 -442
- package/test/unit/api/daikin-cloud-repository.test.ts +0 -107
- package/test/unit/api/daikin-oauth.test.ts +0 -214
- package/test/unit/api/daikinCloud.test.ts +0 -12
- package/test/unit/api/token-storage.test.ts +0 -90
- package/test/unit/config/config-manager.test.ts +0 -271
- package/test/unit/device/daikin-device.test.ts +0 -73
- package/test/unit/services/hot-water-tank.service.test.ts +0 -123
- package/test/unit/utils/log-context.test.ts +0 -271
- package/test/unit/utils/update-mapper.test.ts +0 -404
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebSocket Test Script - Mobile App Token
|
|
3
|
-
*
|
|
4
|
-
* Tests WebSocket with the mobile app token from mobile-tokens.json.
|
|
5
|
-
* Run test-gigya-auth.js first to generate the token.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const WebSocket = require('ws');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
|
|
11
|
-
// Load token from mobile-tokens.json
|
|
12
|
-
let tokens;
|
|
13
|
-
try {
|
|
14
|
-
tokens = JSON.parse(fs.readFileSync('mobile-tokens.json', 'utf8'));
|
|
15
|
-
} catch (e) {
|
|
16
|
-
console.error('Error: Could not load mobile-tokens.json');
|
|
17
|
-
console.error('Run test-gigya-auth.js first to generate the token.');
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const MOBILE_TOKEN = tokens.access_token;
|
|
22
|
-
const WEBSOCKET_URL = 'wss://wsapi.onecta.daikineurope.com';
|
|
23
|
-
|
|
24
|
-
console.log('=== Daikin WebSocket Test (Mobile App Token) ===\n');
|
|
25
|
-
|
|
26
|
-
// Decode token to check expiry
|
|
27
|
-
const payload = JSON.parse(Buffer.from(MOBILE_TOKEN.split('.')[1], 'base64').toString());
|
|
28
|
-
console.log('Token scope:', payload.scope);
|
|
29
|
-
console.log('Token expires at:', new Date(payload.exp * 1000).toISOString());
|
|
30
|
-
console.log('Current time:', new Date().toISOString());
|
|
31
|
-
|
|
32
|
-
const now = Math.floor(Date.now() / 1000);
|
|
33
|
-
if (payload.exp < now) {
|
|
34
|
-
console.log('\n⚠️ WARNING: Token is EXPIRED!\n');
|
|
35
|
-
console.log('Run test-gigya-auth.js to get a new token.');
|
|
36
|
-
process.exit(1);
|
|
37
|
-
} else {
|
|
38
|
-
console.log('Token valid for:', Math.round((payload.exp - now) / 60), 'minutes\n');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
console.log('Connecting to:', WEBSOCKET_URL);
|
|
42
|
-
console.log('---\n');
|
|
43
|
-
|
|
44
|
-
const ws = new WebSocket(WEBSOCKET_URL, {
|
|
45
|
-
headers: {
|
|
46
|
-
'Authorization': 'Bearer ' + MOBILE_TOKEN,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
let messageCount = 0;
|
|
51
|
-
const deviceUpdates = new Map();
|
|
52
|
-
|
|
53
|
-
ws.on('open', function() {
|
|
54
|
-
console.log('✅ CONNECTED!\n');
|
|
55
|
-
console.log('Listening for device updates... (press Ctrl+C to stop)\n');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
ws.on('message', function(data) {
|
|
59
|
-
try {
|
|
60
|
-
const message = JSON.parse(data.toString());
|
|
61
|
-
|
|
62
|
-
if (message.message === 'Internal server error') {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
messageCount++;
|
|
67
|
-
|
|
68
|
-
if (message.event === 'gateway:managementpoint:characteristic') {
|
|
69
|
-
const deviceId = message.gatewayDeviceId;
|
|
70
|
-
const characteristic = message.data.name;
|
|
71
|
-
const value = message.data.value;
|
|
72
|
-
|
|
73
|
-
if (!deviceUpdates.has(deviceId)) {
|
|
74
|
-
deviceUpdates.set(deviceId, new Set());
|
|
75
|
-
console.log('📱 New device discovered:', deviceId.substring(0, 8) + '...');
|
|
76
|
-
}
|
|
77
|
-
deviceUpdates.get(deviceId).add(characteristic);
|
|
78
|
-
|
|
79
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
80
|
-
console.log('[' + timestamp + '] Device ' + characteristic + ':', JSON.stringify(value).substring(0, 100));
|
|
81
|
-
} else if (message.event === 'group:characteristic') {
|
|
82
|
-
const characteristic = message.data.name;
|
|
83
|
-
const value = message.data.value;
|
|
84
|
-
|
|
85
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
86
|
-
console.log('[' + timestamp + '] Group ' + characteristic + ':', JSON.stringify(value).substring(0, 100));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
} catch (e) {
|
|
90
|
-
// Ignore parse errors
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
ws.on('error', function(err) {
|
|
95
|
-
console.log('❌ ERROR:', err.message);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
ws.on('close', function(code, reason) {
|
|
99
|
-
console.log('\n--- Connection closed ---');
|
|
100
|
-
console.log('Code:', code);
|
|
101
|
-
console.log('Reason:', reason.toString() || 'none');
|
|
102
|
-
console.log('\nTotal messages received:', messageCount);
|
|
103
|
-
console.log('Unique devices:', deviceUpdates.size);
|
|
104
|
-
|
|
105
|
-
if (deviceUpdates.size > 0) {
|
|
106
|
-
console.log('\nDevice characteristics received:');
|
|
107
|
-
deviceUpdates.forEach(function(chars, deviceId) {
|
|
108
|
-
console.log(' ' + deviceId.substring(0, 8) + '...:', Array.from(chars).join(', '));
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
process.exit(0);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
process.on('SIGINT', function() {
|
|
116
|
-
console.log('\n\nShutting down...');
|
|
117
|
-
ws.close();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
setTimeout(function() {
|
|
121
|
-
console.log('\n\n⏱️ Test timeout (30s) - closing connection');
|
|
122
|
-
ws.close();
|
|
123
|
-
}, 30000);
|
package/test/test-websocket.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebSocket Test Script
|
|
3
|
-
*
|
|
4
|
-
* Tests the DaikinWebSocket implementation with a real token.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const WebSocket = require('ws');
|
|
8
|
-
|
|
9
|
-
// Read token from file
|
|
10
|
-
const fs = require('fs');
|
|
11
|
-
const tokenData = JSON.parse(
|
|
12
|
-
fs.readFileSync('./hbConfig/.daikin-controller-cloud-tokenset', 'utf8')
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const WEBSOCKET_URL = 'wss://wsapi.onecta.daikineurope.com';
|
|
16
|
-
|
|
17
|
-
console.log('=== Daikin WebSocket Test ===\n');
|
|
18
|
-
console.log('Token expires at:', new Date(tokenData.expires_at * 1000).toISOString());
|
|
19
|
-
console.log('Current time:', new Date().toISOString());
|
|
20
|
-
|
|
21
|
-
const now = Math.floor(Date.now() / 1000);
|
|
22
|
-
if (tokenData.expires_at < now) {
|
|
23
|
-
console.log('\n⚠️ WARNING: Token is EXPIRED! You may need to refresh it.\n');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
console.log('\nConnecting to:', WEBSOCKET_URL);
|
|
27
|
-
console.log('---\n');
|
|
28
|
-
|
|
29
|
-
const ws = new WebSocket(WEBSOCKET_URL, {
|
|
30
|
-
headers: {
|
|
31
|
-
'Authorization': 'Bearer ' + tokenData.access_token,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
let messageCount = 0;
|
|
36
|
-
const deviceUpdates = new Map();
|
|
37
|
-
|
|
38
|
-
ws.on('open', function() {
|
|
39
|
-
console.log('✅ CONNECTED!\n');
|
|
40
|
-
console.log('Listening for device updates... (press Ctrl+C to stop)\n');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
ws.on('message', function(data) {
|
|
44
|
-
try {
|
|
45
|
-
const message = JSON.parse(data.toString());
|
|
46
|
-
|
|
47
|
-
// Skip internal server errors (from invalid message formats)
|
|
48
|
-
if (message.message === 'Internal server error') {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
messageCount++;
|
|
53
|
-
|
|
54
|
-
if (message.event === 'gateway:managementpoint:characteristic') {
|
|
55
|
-
const deviceId = message.gatewayDeviceId;
|
|
56
|
-
const characteristic = message.data.name;
|
|
57
|
-
const value = message.data.value;
|
|
58
|
-
|
|
59
|
-
// Track unique devices
|
|
60
|
-
if (!deviceUpdates.has(deviceId)) {
|
|
61
|
-
deviceUpdates.set(deviceId, new Set());
|
|
62
|
-
console.log('📱 New device discovered:', deviceId.substring(0, 8) + '...');
|
|
63
|
-
}
|
|
64
|
-
deviceUpdates.get(deviceId).add(characteristic);
|
|
65
|
-
|
|
66
|
-
// Log the update
|
|
67
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
68
|
-
console.log('[' + timestamp + '] Device: ' + deviceId.substring(0, 8) + '... | ' + characteristic + ':', JSON.stringify(value).substring(0, 80));
|
|
69
|
-
} else if (message.event === 'group:characteristic') {
|
|
70
|
-
const groupId = message.groupId;
|
|
71
|
-
const characteristic = message.data.name;
|
|
72
|
-
const value = message.data.value;
|
|
73
|
-
|
|
74
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
75
|
-
console.log('[' + timestamp + '] Group: ' + groupId.substring(0, 8) + '... | ' + characteristic + ':', JSON.stringify(value).substring(0, 80));
|
|
76
|
-
} else {
|
|
77
|
-
console.log('Unknown event type:', message.event || 'N/A');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
} catch (e) {
|
|
81
|
-
// Ignore parse errors
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
ws.on('error', function(err) {
|
|
86
|
-
console.log('❌ ERROR:', err.message);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
ws.on('close', function(code, reason) {
|
|
90
|
-
console.log('\n--- Connection closed ---');
|
|
91
|
-
console.log('Code:', code);
|
|
92
|
-
console.log('Reason:', reason.toString() || 'none');
|
|
93
|
-
console.log('\nTotal messages received:', messageCount);
|
|
94
|
-
console.log('Unique devices:', deviceUpdates.size);
|
|
95
|
-
|
|
96
|
-
if (deviceUpdates.size > 0) {
|
|
97
|
-
console.log('\nDevice characteristics received:');
|
|
98
|
-
deviceUpdates.forEach(function(chars, deviceId) {
|
|
99
|
-
console.log(' ' + deviceId.substring(0, 8) + '...:', Array.from(chars).join(', '));
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
process.exit(0);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Handle Ctrl+C gracefully
|
|
107
|
-
process.on('SIGINT', function() {
|
|
108
|
-
console.log('\n\nShutting down...');
|
|
109
|
-
ws.close();
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// Keep running for 60 seconds max
|
|
113
|
-
setTimeout(function() {
|
|
114
|
-
console.log('\n\n⏱️ Test timeout (60s) - closing connection');
|
|
115
|
-
ws.close();
|
|
116
|
-
}, 60000);
|