@mp-consulting/homebridge-daikin-cloud 1.3.5 → 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 +5 -3
- 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 +6 -6
- package/dist/src/accessories/base-accessory.d.ts.map +1 -1
- package/dist/src/accessories/base-accessory.js +15 -15
- package/dist/src/accessories/base-accessory.js.map +1 -1
- package/dist/src/api/daikin-api.d.ts +26 -26
- package/dist/src/api/daikin-api.d.ts.map +1 -1
- package/dist/src/api/daikin-api.js +68 -42
- 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 +22 -14
- package/dist/src/api/daikin-cloud.repository.js.map +1 -1
- package/dist/src/api/daikin-controller.d.ts +41 -47
- package/dist/src/api/daikin-controller.d.ts.map +1 -1
- package/dist/src/api/daikin-controller.js +40 -64
- package/dist/src/api/daikin-controller.js.map +1 -1
- package/dist/src/api/daikin-device.d.ts +36 -31
- package/dist/src/api/daikin-device.d.ts.map +1 -1
- package/dist/src/api/daikin-device.js +45 -31
- package/dist/src/api/daikin-device.js.map +1 -1
- package/dist/src/api/daikin-mobile-oauth.d.ts +20 -20
- package/dist/src/api/daikin-mobile-oauth.d.ts.map +1 -1
- package/dist/src/api/daikin-mobile-oauth.js +49 -44
- package/dist/src/api/daikin-mobile-oauth.js.map +1 -1
- package/dist/src/api/daikin-oauth.d.ts +32 -32
- package/dist/src/api/daikin-oauth.d.ts.map +1 -1
- package/dist/src/api/daikin-oauth.js +64 -56
- package/dist/src/api/daikin-oauth.js.map +1 -1
- package/dist/src/api/daikin-schemas.d.ts +476 -351
- package/dist/src/api/daikin-schemas.d.ts.map +1 -1
- package/dist/src/api/daikin-schemas.js +11 -42
- package/dist/src/api/daikin-schemas.js.map +1 -1
- package/dist/src/api/daikin-types.d.ts +5 -1
- package/dist/src/api/daikin-types.d.ts.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 +55 -35
- package/dist/src/api/daikin-websocket.js.map +1 -1
- package/dist/src/api/index.d.ts +2 -1
- package/dist/src/api/index.d.ts.map +1 -1
- package/dist/src/api/index.js +3 -1
- package/dist/src/api/index.js.map +1 -1
- package/dist/src/api/token-storage.d.ts +21 -0
- package/dist/src/api/token-storage.d.ts.map +1 -0
- package/dist/src/api/token-storage.js +90 -0
- package/dist/src/api/token-storage.js.map +1 -0
- 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.d.ts +4 -0
- package/dist/src/constants/api.constants.d.ts.map +1 -1
- package/dist/src/constants/api.constants.js +5 -1
- package/dist/src/constants/api.constants.js.map +1 -1
- package/dist/src/constants/device.constants.d.ts +4 -0
- package/dist/src/constants/device.constants.d.ts.map +1 -1
- package/dist/src/constants/device.constants.js +5 -1
- package/dist/src/constants/device.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 +7 -7
- 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 -9
- package/dist/src/device/capability-docs.d.ts.map +1 -1
- package/dist/src/device/capability-docs.js +19 -73
- 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 -16
- package/dist/src/features/feature-manager.d.ts.map +1 -1
- package/dist/src/features/feature-manager.js +5 -17
- 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 +11 -8
- package/dist/src/platform.d.ts.map +1 -1
- package/dist/src/platform.js +64 -15
- 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 +59 -58
- 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 +33 -31
- 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/index.html +2 -2
- package/homebridge-ui/public/script.js +957 -898
- package/homebridge-ui/server.js +746 -678
- package/package.json +29 -27
- package/.claude/settings.json +0 -3
- package/.claude/settings.local.json +0 -29
- package/CHANGELOG.md +0 -103
- package/CLAUDE.md +0 -269
- package/config.md +0 -2
- package/dist/src/api/daikin-device-tracker.d.ts +0 -97
- package/dist/src/api/daikin-device-tracker.d.ts.map +0 -1
- package/dist/src/api/daikin-device-tracker.js +0 -136
- package/dist/src/api/daikin-device-tracker.js.map +0 -1
- package/dist/src/api/http-interceptor.d.ts +0 -99
- package/dist/src/api/http-interceptor.d.ts.map +0 -1
- package/dist/src/api/http-interceptor.js +0 -177
- package/dist/src/api/http-interceptor.js.map +0 -1
- package/dist/src/di/service-container.d.ts +0 -92
- package/dist/src/di/service-container.d.ts.map +0 -1
- package/dist/src/di/service-container.js +0 -156
- package/dist/src/di/service-container.js.map +0 -1
- package/dist/src/features/feature-registry.d.ts +0 -100
- package/dist/src/features/feature-registry.d.ts.map +0 -1
- package/dist/src/features/feature-registry.js +0 -142
- package/dist/src/features/feature-registry.js.map +0 -1
- package/dist/src/services/service-factory.d.ts +0 -46
- package/dist/src/services/service-factory.d.ts.map +0 -1
- package/dist/src/services/service-factory.js +0 -72
- package/dist/src/services/service-factory.js.map +0 -1
- package/dist/src/utils/error-handler.d.ts +0 -101
- package/dist/src/utils/error-handler.d.ts.map +0 -1
- package/dist/src/utils/error-handler.js +0 -251
- package/dist/src/utils/error-handler.js.map +0 -1
- package/dist/src/utils/retry.d.ts +0 -42
- package/dist/src/utils/retry.d.ts.map +0 -1
- package/dist/src/utils/retry.js +0 -70
- package/dist/src/utils/retry.js.map +0 -1
- 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 -13
- 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/helpers/test-isolation.ts +0 -228
- package/test/integration/air-conditioning.test.ts +0 -410
- package/test/integration/altherma.test.ts +0 -289
- package/test/integration/platform.test.ts +0 -118
- 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 -384
- package/test/unit/api/daikin-oauth.test.ts +0 -214
- package/test/unit/api/daikinCloud.test.ts +0 -12
- package/test/unit/config/config-manager.test.ts +0 -271
- package/test/unit/device/daikin-device.test.ts +0 -79
- package/test/unit/services/hot-water-tank.service.test.ts +0 -123
- package/test/unit/utils/error-handler.test.ts +0 -274
- package/test/unit/utils/log-context.test.ts +0 -271
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import {PlatformAccessory} from 'homebridge/lib/platformAccessory';
|
|
2
|
-
import {DaikinCloudAccessoryContext, DaikinCloudPlatform} from '../../src/platform';
|
|
3
|
-
import {MockPlatformConfig} from '../mocks';
|
|
4
|
-
import {AlthermaAccessory} from '../../src/accessories';
|
|
5
|
-
import {DaikinCloudDevice, DaikinCloudController, DaikinApi} from '../../src/api';
|
|
6
|
-
import {althermaV1ckoeln} from '../fixtures/altherma-v1ckoeln';
|
|
7
|
-
import {althermaCrSense2} from '../fixtures/altherma-crSense-2';
|
|
8
|
-
import {althermaWithEmbeddedIdZero} from '../fixtures/altherma-with-embedded-id-zero';
|
|
9
|
-
import {althermaHeatPump} from '../fixtures/altherma-heat-pump';
|
|
10
|
-
import {althermaHeatPump2} from '../fixtures/altherma-heat-pump-2';
|
|
11
|
-
import {althermaFraction} from '../fixtures/altherma-fraction';
|
|
12
|
-
import {althermaMiladcerkic} from '../fixtures/altherma-miladcerkic';
|
|
13
|
-
|
|
14
|
-
import {HomebridgeAPI} from 'homebridge/lib/api.js';
|
|
15
|
-
import { Logger } from 'homebridge/lib/logger.js';
|
|
16
|
-
|
|
17
|
-
type DeviceState = {
|
|
18
|
-
activeState: boolean;
|
|
19
|
-
currentTemperature: number;
|
|
20
|
-
targetHeaterCoolerState: string;
|
|
21
|
-
coolingThresholdTemperature: number;
|
|
22
|
-
heatingThresholdTemperature: number;
|
|
23
|
-
hotWaterTankCurrentHeatingCoolingState: number;
|
|
24
|
-
hotWaterTankCurrentTemperature: number;
|
|
25
|
-
hotWaterTankHeatingTargetTemperature: number;
|
|
26
|
-
hotWaterTankTargetHeaterCoolerState: number;
|
|
27
|
-
powerfulMode: number;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
test.each<Array<string | string | any | DeviceState>>([
|
|
31
|
-
[
|
|
32
|
-
'altherma',
|
|
33
|
-
'climateControlMainZone',
|
|
34
|
-
althermaHeatPump,
|
|
35
|
-
{
|
|
36
|
-
activeState: true,
|
|
37
|
-
currentTemperature: 22.4,
|
|
38
|
-
targetHeaterCoolerState: 1,
|
|
39
|
-
coolingThresholdTemperature: undefined,
|
|
40
|
-
heatingThresholdTemperature: 22,
|
|
41
|
-
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
42
|
-
hotWaterTankCurrentTemperature: 48,
|
|
43
|
-
hotWaterTankHeatingTargetTemperature: 48,
|
|
44
|
-
hotWaterTankTargetHeaterCoolerState: 1,
|
|
45
|
-
powerfulMode: false,
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
[
|
|
50
|
-
'altherma',
|
|
51
|
-
'climateControlMainZone',
|
|
52
|
-
althermaHeatPump2,
|
|
53
|
-
{
|
|
54
|
-
activeState: false,
|
|
55
|
-
currentTemperature: 33,
|
|
56
|
-
targetHeaterCoolerState: 1,
|
|
57
|
-
coolingThresholdTemperature: 0,
|
|
58
|
-
heatingThresholdTemperature: 0,
|
|
59
|
-
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
60
|
-
hotWaterTankCurrentTemperature: 50,
|
|
61
|
-
hotWaterTankHeatingTargetTemperature: 50,
|
|
62
|
-
hotWaterTankTargetHeaterCoolerState: 1,
|
|
63
|
-
powerfulMode: false,
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
[
|
|
68
|
-
'altherma2',
|
|
69
|
-
'1',
|
|
70
|
-
althermaWithEmbeddedIdZero,
|
|
71
|
-
{
|
|
72
|
-
activeState: false,
|
|
73
|
-
currentTemperature: 27.7,
|
|
74
|
-
targetHeaterCoolerState: 1,
|
|
75
|
-
coolingThresholdTemperature: 20,
|
|
76
|
-
heatingThresholdTemperature: 21,
|
|
77
|
-
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
78
|
-
hotWaterTankCurrentTemperature: 42,
|
|
79
|
-
hotWaterTankHeatingTargetTemperature: 45,
|
|
80
|
-
hotWaterTankTargetHeaterCoolerState: 1,
|
|
81
|
-
powerfulMode: false,
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
[
|
|
86
|
-
'altherma3',
|
|
87
|
-
'1',
|
|
88
|
-
althermaCrSense2,
|
|
89
|
-
{
|
|
90
|
-
activeState: false,
|
|
91
|
-
currentTemperature: 27.8,
|
|
92
|
-
targetHeaterCoolerState: 1,
|
|
93
|
-
coolingThresholdTemperature: 20,
|
|
94
|
-
heatingThresholdTemperature: 21,
|
|
95
|
-
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
96
|
-
hotWaterTankCurrentTemperature: 45,
|
|
97
|
-
hotWaterTankHeatingTargetTemperature: 45,
|
|
98
|
-
hotWaterTankTargetHeaterCoolerState: 1,
|
|
99
|
-
powerfulMode: false,
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
[
|
|
104
|
-
'altherma4',
|
|
105
|
-
'climateControlMainZone',
|
|
106
|
-
althermaV1ckoeln,
|
|
107
|
-
{
|
|
108
|
-
activeState: false,
|
|
109
|
-
currentTemperature: 34, // or should we always show the roomTemperature here which is 27.5
|
|
110
|
-
targetHeaterCoolerState: 1,
|
|
111
|
-
coolingThresholdTemperature: 20,
|
|
112
|
-
heatingThresholdTemperature: 0,
|
|
113
|
-
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
114
|
-
hotWaterTankCurrentTemperature: 42,
|
|
115
|
-
hotWaterTankHeatingTargetTemperature: 46,
|
|
116
|
-
hotWaterTankTargetHeaterCoolerState: 1,
|
|
117
|
-
powerfulMode: false,
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
[
|
|
122
|
-
'althermaFraction',
|
|
123
|
-
'climateControlMainZone',
|
|
124
|
-
althermaFraction,
|
|
125
|
-
{
|
|
126
|
-
activeState: true,
|
|
127
|
-
currentTemperature: 35, // has no roomTemperature :(
|
|
128
|
-
targetHeaterCoolerState: 1,
|
|
129
|
-
coolingThresholdTemperature: 0,
|
|
130
|
-
heatingThresholdTemperature: 0,
|
|
131
|
-
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
132
|
-
hotWaterTankCurrentTemperature: 45,
|
|
133
|
-
hotWaterTankHeatingTargetTemperature: 47,
|
|
134
|
-
hotWaterTankTargetHeaterCoolerState: 1,
|
|
135
|
-
powerfulMode: false,
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
[
|
|
140
|
-
'althermaMiladcerkic',
|
|
141
|
-
'climateControlMainZone',
|
|
142
|
-
althermaMiladcerkic,
|
|
143
|
-
{
|
|
144
|
-
activeState: true,
|
|
145
|
-
currentTemperature: 45,
|
|
146
|
-
targetHeaterCoolerState: 1,
|
|
147
|
-
coolingThresholdTemperature: 20,
|
|
148
|
-
heatingThresholdTemperature: 45,
|
|
149
|
-
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
150
|
-
hotWaterTankCurrentTemperature: 49,
|
|
151
|
-
hotWaterTankHeatingTargetTemperature: 50,
|
|
152
|
-
hotWaterTankTargetHeaterCoolerState: 1,
|
|
153
|
-
powerfulMode: false,
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
])('Create DaikinCloudThermostatAccessory with %s device', async (name, climateControlEmbeddedId, deviceJson, state) => {
|
|
157
|
-
const mockApi = { updateDevice: jest.fn().mockResolvedValue(undefined) } as unknown as DaikinApi;
|
|
158
|
-
const device = new DaikinCloudDevice(deviceJson as any, mockApi);
|
|
159
|
-
|
|
160
|
-
jest.spyOn(DaikinCloudController.prototype, 'getCloudDevices').mockImplementation(async () => {
|
|
161
|
-
return [device];
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
const config = new MockPlatformConfig(true);
|
|
165
|
-
const api = new HomebridgeAPI();
|
|
166
|
-
|
|
167
|
-
const uuid = api.hap.uuid.generate(device.getId());
|
|
168
|
-
const accessory = new api.platformAccessory("NAME_FOR_TEST", uuid);
|
|
169
|
-
accessory.context['device'] = device;
|
|
170
|
-
|
|
171
|
-
expect(() => {
|
|
172
|
-
new AlthermaAccessory(new DaikinCloudPlatform(new Logger(), config, api), accessory as unknown as PlatformAccessory<DaikinCloudAccessoryContext>);
|
|
173
|
-
}).not.toThrow();
|
|
174
|
-
|
|
175
|
-
const homebridgeAccessory = new AlthermaAccessory(new DaikinCloudPlatform(new Logger(), config, api), accessory as unknown as PlatformAccessory<DaikinCloudAccessoryContext>);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (typeof state.activeState !== 'undefined') {
|
|
179
|
-
expect(await homebridgeAccessory.service?.handleActiveStateGet()).toBe(state.activeState);
|
|
180
|
-
expect(async () => {
|
|
181
|
-
await homebridgeAccessory.service?.handleActiveStateSet(1);
|
|
182
|
-
}).not.toThrow();
|
|
183
|
-
expect(async () => {
|
|
184
|
-
await homebridgeAccessory.service?.handleActiveStateSet(0);
|
|
185
|
-
}).not.toThrow();
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
expect(await homebridgeAccessory.service?.handleCurrentTemperatureGet()).toBe(state.currentTemperature);
|
|
189
|
-
|
|
190
|
-
if (typeof state.coolingThresholdTemperature !== 'undefined') {
|
|
191
|
-
expect(await homebridgeAccessory.service?.handleCoolingThresholdTemperatureGet()).toBe(state.coolingThresholdTemperature);
|
|
192
|
-
expect(async () => {
|
|
193
|
-
await homebridgeAccessory.service?.handleCoolingThresholdTemperatureSet(21);
|
|
194
|
-
}).not.toThrow();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (typeof state.heatingThresholdTemperature !== 'undefined') {
|
|
198
|
-
expect(await homebridgeAccessory.service?.handleHeatingThresholdTemperatureGet()).toBe(state.heatingThresholdTemperature);
|
|
199
|
-
expect(async () => {
|
|
200
|
-
await homebridgeAccessory.service?.handleHeatingThresholdTemperatureSet(25);
|
|
201
|
-
}).not.toThrow();
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (typeof state.targetHeaterCoolerState !== 'undefined') {
|
|
205
|
-
expect(await homebridgeAccessory.service?.handleTargetHeaterCoolerStateGet()).toBe(state.targetHeaterCoolerState);
|
|
206
|
-
expect(async () => {
|
|
207
|
-
await homebridgeAccessory.service?.handleTargetHeaterCoolerStateSet(1);
|
|
208
|
-
}).not.toThrow();
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (typeof state.hotWaterTankCurrentHeatingCoolingState !== 'undefined') {
|
|
213
|
-
expect(await homebridgeAccessory.hotWaterTankService?.handleHotWaterTankCurrentHeatingCoolingStateGet()).toBe(state.hotWaterTankCurrentHeatingCoolingState);
|
|
214
|
-
}
|
|
215
|
-
if (typeof state.hotWaterTankCurrentTemperature !== 'undefined') {
|
|
216
|
-
expect(await homebridgeAccessory.hotWaterTankService?.handleHotWaterTankCurrentTemperatureGet()).toBe(state.hotWaterTankCurrentTemperature);
|
|
217
|
-
}
|
|
218
|
-
if (typeof state.hotWaterTankHeatingTargetTemperature !== 'undefined') {
|
|
219
|
-
expect(await homebridgeAccessory.hotWaterTankService?.handleHotWaterTankHeatingTargetTemperatureGet()).toBe(state.hotWaterTankHeatingTargetTemperature);
|
|
220
|
-
}
|
|
221
|
-
if (typeof state.hotWaterTankTargetHeaterCoolerState !== 'undefined') {
|
|
222
|
-
expect(await homebridgeAccessory.hotWaterTankService?.handleHotWaterTankTargetHeatingCoolingStateGet()).toBe(state.hotWaterTankTargetHeaterCoolerState);
|
|
223
|
-
}
|
|
224
|
-
if (typeof state.powerfulMode !== 'undefined') {
|
|
225
|
-
expect(await homebridgeAccessory.hotWaterTankService?.handlePowerfulModeGet()).toBe(state.powerfulMode);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
test('DaikinCloudAirConditioningAccessory Getters', async () => {
|
|
231
|
-
const mockApi = { updateDevice: jest.fn().mockResolvedValue(undefined) } as unknown as DaikinApi;
|
|
232
|
-
const device = new DaikinCloudDevice(althermaHeatPump as any, mockApi);
|
|
233
|
-
|
|
234
|
-
jest.spyOn(DaikinCloudController.prototype, 'getCloudDevices').mockImplementation(async () => {
|
|
235
|
-
return [device];
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
const config = new MockPlatformConfig(false);
|
|
239
|
-
const api = new HomebridgeAPI();
|
|
240
|
-
|
|
241
|
-
const uuid = api.hap.uuid.generate(device.getId());
|
|
242
|
-
const accessory = new api.platformAccessory(device.getData('climateControlMainZone', 'name', undefined).value as string, uuid);
|
|
243
|
-
accessory.context['device'] = device;
|
|
244
|
-
|
|
245
|
-
const homebridgeAccessory = new AlthermaAccessory(new DaikinCloudPlatform(new Logger(), config, api), accessory as unknown as PlatformAccessory<DaikinCloudAccessoryContext>);
|
|
246
|
-
|
|
247
|
-
expect(await homebridgeAccessory.service?.handleActiveStateGet()).toEqual(true);
|
|
248
|
-
expect(await homebridgeAccessory.service?.handleCurrentTemperatureGet()).toEqual(22.4);
|
|
249
|
-
expect(await homebridgeAccessory.service?.handleHeatingThresholdTemperatureGet()).toEqual(22);
|
|
250
|
-
expect(await homebridgeAccessory.service?.handleTargetHeaterCoolerStateGet()).toEqual(1);
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
test('DaikinCloudAirConditioningAccessory Setters', async () => {
|
|
254
|
-
const mockApi = { updateDevice: jest.fn().mockResolvedValue(undefined) } as unknown as DaikinApi;
|
|
255
|
-
const device = new DaikinCloudDevice(althermaHeatPump as any, mockApi);
|
|
256
|
-
|
|
257
|
-
jest.spyOn(DaikinCloudController.prototype, 'getCloudDevices').mockImplementation(async () => {
|
|
258
|
-
return [device];
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
const setDataSpy = jest.spyOn(DaikinCloudDevice.prototype, 'setData').mockImplementation();
|
|
262
|
-
|
|
263
|
-
const config = new MockPlatformConfig(false);
|
|
264
|
-
const api = new HomebridgeAPI();
|
|
265
|
-
|
|
266
|
-
const uuid = api.hap.uuid.generate(device.getId());
|
|
267
|
-
const accessory = new api.platformAccessory(device.getData('climateControlMainZone', 'name', undefined).value as string, uuid);
|
|
268
|
-
accessory.context['device'] = device;
|
|
269
|
-
|
|
270
|
-
const homebridgeAccessory = new AlthermaAccessory(new DaikinCloudPlatform(new Logger(), config, api), accessory as unknown as PlatformAccessory<DaikinCloudAccessoryContext>);
|
|
271
|
-
|
|
272
|
-
await homebridgeAccessory.service?.handleActiveStateSet(1);
|
|
273
|
-
expect(setDataSpy).toHaveBeenNthCalledWith(1, 'climateControlMainZone', 'onOffMode', 'on', undefined);
|
|
274
|
-
|
|
275
|
-
await homebridgeAccessory.service?.handleActiveStateSet(0);
|
|
276
|
-
expect(setDataSpy).toHaveBeenNthCalledWith(2, 'climateControlMainZone', 'onOffMode', 'off', undefined);
|
|
277
|
-
|
|
278
|
-
await homebridgeAccessory.service?.handleCoolingThresholdTemperatureSet(21);
|
|
279
|
-
expect(setDataSpy).toHaveBeenNthCalledWith(3, 'climateControlMainZone', 'temperatureControl', '/operationModes/cooling/setpoints/roomTemperature', 21);
|
|
280
|
-
|
|
281
|
-
await homebridgeAccessory.service?.handleHeatingThresholdTemperatureSet(25);
|
|
282
|
-
expect(setDataSpy).toHaveBeenNthCalledWith(4, 'climateControlMainZone', 'temperatureControl', '/operationModes/heating/setpoints/roomTemperature', 25);
|
|
283
|
-
|
|
284
|
-
await homebridgeAccessory.service?.handleTargetHeaterCoolerStateSet(1);
|
|
285
|
-
expect(setDataSpy).toHaveBeenNthCalledWith(5, 'climateControlMainZone', 'operationMode', 'heating', undefined);
|
|
286
|
-
expect(setDataSpy).toHaveBeenNthCalledWith(6, 'climateControlMainZone', 'onOffMode', 'on', undefined);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import {DaikinCloudPlatform} from '../../src/platform';
|
|
2
|
-
import {MockPlatformConfig} from '../mocks';
|
|
3
|
-
import {DaikinCloudController, DaikinCloudDevice} from '../../src/api';
|
|
4
|
-
import {AirConditioningAccessory, AlthermaAccessory} from '../../src/accessories';
|
|
5
|
-
import {HomebridgeAPI} from 'homebridge/lib/api.js';
|
|
6
|
-
import {Logger} from 'homebridge/lib/logger.js';
|
|
7
|
-
|
|
8
|
-
jest.mock('../../src/api/daikin-controller');
|
|
9
|
-
jest.mock('homebridge');
|
|
10
|
-
jest.mock('../../src/accessories/air-conditioning-accessory');
|
|
11
|
-
jest.mock('../../src/accessories/altherma-accessory');
|
|
12
|
-
|
|
13
|
-
// Use fake timers to prevent tests from hanging due to setInterval/setTimeout in platform
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
jest.useFakeTimers();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
jest.clearAllTimers();
|
|
20
|
-
jest.useRealTimers();
|
|
21
|
-
jest.resetAllMocks();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('Initialize platform', async () => {
|
|
25
|
-
const api = new HomebridgeAPI();
|
|
26
|
-
const platform = new DaikinCloudPlatform(new Logger(), new MockPlatformConfig(), api);
|
|
27
|
-
|
|
28
|
-
expect(DaikinCloudController).toHaveBeenCalledWith(expect.objectContaining({
|
|
29
|
-
'authMode': 'developer_portal',
|
|
30
|
-
'clientId': 'CLIENT_ID',
|
|
31
|
-
'clientSecret': 'CLIENT_SECRET',
|
|
32
|
-
'callbackServerExternalAddress': 'SERVER_EXTERNAL_ADDRESS',
|
|
33
|
-
'callbackServerPort': 'SERVER_PORT',
|
|
34
|
-
'oidcCallbackServerBindAddr': 'SERVER_BIND_ADDRESS',
|
|
35
|
-
'tokenFilePath': `${api.user.storagePath()}/.daikin-controller-cloud-tokenset`,
|
|
36
|
-
}));
|
|
37
|
-
expect(platform.updateIntervalDelay).toBe(900000);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('DaikinCloudPlatform with new Aircondition accessory', async () => {
|
|
41
|
-
const mockDevice = {
|
|
42
|
-
getId: () => 'MOCK_ID',
|
|
43
|
-
getDescription: () => ({
|
|
44
|
-
deviceModel: 'Airco',
|
|
45
|
-
}),
|
|
46
|
-
getData: () => 'MOCK_DATE',
|
|
47
|
-
desc: {
|
|
48
|
-
managementPoints: [
|
|
49
|
-
{
|
|
50
|
-
'embeddedId': 'climateControl',
|
|
51
|
-
'managementPointType': 'climateControl',
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
} as unknown as DaikinCloudDevice;
|
|
56
|
-
|
|
57
|
-
// Mock the constructor to set up getCloudDevices on the instance
|
|
58
|
-
(DaikinCloudController as unknown as jest.Mock).mockImplementation(() => ({
|
|
59
|
-
getCloudDevices: jest.fn().mockResolvedValue([mockDevice]),
|
|
60
|
-
isAuthenticated: jest.fn().mockReturnValue(true),
|
|
61
|
-
on: jest.fn(),
|
|
62
|
-
updateAllDeviceData: jest.fn().mockResolvedValue(undefined),
|
|
63
|
-
}));
|
|
64
|
-
|
|
65
|
-
const api = new HomebridgeAPI();
|
|
66
|
-
|
|
67
|
-
const registerPlatformAccessoriesSpy = jest.spyOn(api, 'registerPlatformAccessories');
|
|
68
|
-
|
|
69
|
-
new DaikinCloudPlatform(new Logger(), new MockPlatformConfig(true), api);
|
|
70
|
-
api.signalFinished();
|
|
71
|
-
|
|
72
|
-
// Wait for async device discovery to complete using fake timers
|
|
73
|
-
await jest.advanceTimersByTimeAsync(100);
|
|
74
|
-
|
|
75
|
-
expect(AirConditioningAccessory).toHaveBeenCalled();
|
|
76
|
-
expect(AlthermaAccessory).not.toHaveBeenCalled();
|
|
77
|
-
expect(registerPlatformAccessoriesSpy).toHaveBeenCalledWith('@mp-consulting/homebridge-daikin-cloud', 'DaikinCloud', expect.anything());
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('DaikinCloudPlatform with new Altherma accessory', async () => {
|
|
81
|
-
const mockDevice = {
|
|
82
|
-
getId: () => 'MOCK_ID',
|
|
83
|
-
getDescription: () => ({
|
|
84
|
-
deviceModel: 'Altherma',
|
|
85
|
-
}),
|
|
86
|
-
getData: () => 'MOCK_DATE',
|
|
87
|
-
desc: {
|
|
88
|
-
managementPoints: [
|
|
89
|
-
{
|
|
90
|
-
'embeddedId': 'climateControl',
|
|
91
|
-
'managementPointType': 'climateControl',
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
},
|
|
95
|
-
} as unknown as DaikinCloudDevice;
|
|
96
|
-
|
|
97
|
-
// Mock the constructor to set up getCloudDevices on the instance
|
|
98
|
-
(DaikinCloudController as unknown as jest.Mock).mockImplementation(() => ({
|
|
99
|
-
getCloudDevices: jest.fn().mockResolvedValue([mockDevice]),
|
|
100
|
-
isAuthenticated: jest.fn().mockReturnValue(true),
|
|
101
|
-
on: jest.fn(),
|
|
102
|
-
updateAllDeviceData: jest.fn().mockResolvedValue(undefined),
|
|
103
|
-
}));
|
|
104
|
-
|
|
105
|
-
const api = new HomebridgeAPI();
|
|
106
|
-
|
|
107
|
-
const registerPlatformAccessoriesSpy = jest.spyOn(api, 'registerPlatformAccessories');
|
|
108
|
-
|
|
109
|
-
new DaikinCloudPlatform(new Logger(), new MockPlatformConfig(true), api);
|
|
110
|
-
api.signalFinished();
|
|
111
|
-
|
|
112
|
-
// Wait for async device discovery to complete using fake timers
|
|
113
|
-
await jest.advanceTimersByTimeAsync(100);
|
|
114
|
-
|
|
115
|
-
expect(AlthermaAccessory).toHaveBeenCalled();
|
|
116
|
-
expect(AirConditioningAccessory).not.toHaveBeenCalled();
|
|
117
|
-
expect(registerPlatformAccessoriesSpy).toHaveBeenCalledWith('@mp-consulting/homebridge-daikin-cloud', 'DaikinCloud', expect.anything());
|
|
118
|
-
});
|
package/test/mocks/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// https://github.com/timcharper/homebridge-vivint/blob/5b3bfa4cc886c5680af3b2e31706ef9b1bf2705f/test/device_set_test.js
|
|
2
|
-
// https://github.com/break-pointer/homebridge-tion/blob/13f1c410c6ee8ca13b41b8700c4b1de96e04b263/test/mocks.ts#L49
|
|
3
|
-
|
|
4
|
-
import {PlatformConfig} from "homebridge";
|
|
5
|
-
|
|
6
|
-
export const MockLogger = (...args: any[]) => jest.fn();
|
|
7
|
-
MockLogger.debug = MockLogger;
|
|
8
|
-
MockLogger.info = MockLogger;
|
|
9
|
-
MockLogger.success = MockLogger;
|
|
10
|
-
MockLogger.warn = MockLogger;
|
|
11
|
-
MockLogger.error = MockLogger;
|
|
12
|
-
MockLogger.log = MockLogger;
|
|
13
|
-
|
|
14
|
-
export class MockPlatformConfig implements PlatformConfig {
|
|
15
|
-
name = 'Home';
|
|
16
|
-
platform = 'DaikinCloud';
|
|
17
|
-
clientId = 'CLIENT_ID';
|
|
18
|
-
clientSecret = 'CLIENT_SECRET';
|
|
19
|
-
oidcCallbackServerBindAddr = 'SERVER_BIND_ADDRESS';
|
|
20
|
-
callbackServerExternalAddress = 'SERVER_EXTERNAL_ADDRESS';
|
|
21
|
-
callbackServerPort = 'SERVER_PORT';
|
|
22
|
-
showExtraFeatures: boolean;
|
|
23
|
-
|
|
24
|
-
constructor(showExtraFeatures = false) {
|
|
25
|
-
this.showExtraFeatures = showExtraFeatures;
|
|
26
|
-
}
|
|
27
|
-
}
|