@mp-consulting/homebridge-daikin-cloud 1.0.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/.claude/settings.json +3 -0
- package/.claude/settings.local.json +8 -0
- package/CLAUDE.md +34 -0
- package/LICENSE +176 -0
- package/README.md +180 -0
- package/changelog.md +217 -0
- package/config.md +2 -0
- package/config.schema.json +146 -0
- package/dist/src/accessories/air-conditioning-accessory.d.ts +9 -0
- package/dist/src/accessories/air-conditioning-accessory.d.ts.map +1 -0
- package/dist/src/accessories/air-conditioning-accessory.js +19 -0
- package/dist/src/accessories/air-conditioning-accessory.js.map +1 -0
- package/dist/src/accessories/altherma-accessory.d.ts +11 -0
- package/dist/src/accessories/altherma-accessory.d.ts.map +1 -0
- package/dist/src/accessories/altherma-accessory.js +31 -0
- package/dist/src/accessories/altherma-accessory.js.map +1 -0
- package/dist/src/accessories/base-accessory.d.ts +16 -0
- package/dist/src/accessories/base-accessory.d.ts.map +1 -0
- package/dist/src/accessories/base-accessory.js +56 -0
- package/dist/src/accessories/base-accessory.js.map +1 -0
- package/dist/src/accessories/index.d.ts +4 -0
- package/dist/src/accessories/index.d.ts.map +1 -0
- package/dist/src/accessories/index.js +20 -0
- package/dist/src/accessories/index.js.map +1 -0
- package/dist/src/api/daikin-cloud.repository.d.ts +4 -0
- package/dist/src/api/daikin-cloud.repository.d.ts.map +1 -0
- package/dist/src/api/daikin-cloud.repository.js +31 -0
- package/dist/src/api/daikin-cloud.repository.js.map +1 -0
- package/dist/src/api/index.d.ts +2 -0
- package/dist/src/api/index.d.ts.map +1 -0
- package/dist/src/api/index.js +18 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/device/accessory-factory.d.ts +36 -0
- package/dist/src/device/accessory-factory.d.ts.map +1 -0
- package/dist/src/device/accessory-factory.js +61 -0
- package/dist/src/device/accessory-factory.js.map +1 -0
- package/dist/src/device/capability-detector.d.ts +36 -0
- package/dist/src/device/capability-detector.d.ts.map +1 -0
- package/dist/src/device/capability-detector.js +130 -0
- package/dist/src/device/capability-detector.js.map +1 -0
- package/dist/src/device/capability-docs.d.ts +20 -0
- package/dist/src/device/capability-docs.d.ts.map +1 -0
- package/dist/src/device/capability-docs.js +98 -0
- package/dist/src/device/capability-docs.js.map +1 -0
- package/dist/src/device/index.d.ts +5 -0
- package/dist/src/device/index.d.ts.map +1 -0
- package/dist/src/device/index.js +21 -0
- package/dist/src/device/index.js.map +1 -0
- package/dist/src/device/profiles/device-profile.d.ts +42 -0
- package/dist/src/device/profiles/device-profile.d.ts.map +1 -0
- package/dist/src/device/profiles/device-profile.js +103 -0
- package/dist/src/device/profiles/device-profile.js.map +1 -0
- package/dist/src/device/profiles/index.d.ts +2 -0
- package/dist/src/device/profiles/index.d.ts.map +1 -0
- package/dist/src/device/profiles/index.js +18 -0
- package/dist/src/device/profiles/index.js.map +1 -0
- package/dist/src/features/base-feature.d.ts +65 -0
- package/dist/src/features/base-feature.d.ts.map +1 -0
- package/dist/src/features/base-feature.js +99 -0
- package/dist/src/features/base-feature.js.map +1 -0
- package/dist/src/features/feature-manager.d.ts +37 -0
- package/dist/src/features/feature-manager.d.ts.map +1 -0
- package/dist/src/features/feature-manager.js +68 -0
- package/dist/src/features/feature-manager.js.map +1 -0
- package/dist/src/features/index.d.ts +4 -0
- package/dist/src/features/index.d.ts.map +1 -0
- package/dist/src/features/index.js +20 -0
- package/dist/src/features/index.js.map +1 -0
- package/dist/src/features/modes/dry-operation-mode.feature.d.ts +16 -0
- package/dist/src/features/modes/dry-operation-mode.feature.d.ts.map +1 -0
- package/dist/src/features/modes/dry-operation-mode.feature.js +40 -0
- package/dist/src/features/modes/dry-operation-mode.feature.js.map +1 -0
- package/dist/src/features/modes/econo-mode.feature.d.ts +15 -0
- package/dist/src/features/modes/econo-mode.feature.d.ts.map +1 -0
- package/dist/src/features/modes/econo-mode.feature.js +37 -0
- package/dist/src/features/modes/econo-mode.feature.js.map +1 -0
- package/dist/src/features/modes/fan-only-operation-mode.feature.d.ts +16 -0
- package/dist/src/features/modes/fan-only-operation-mode.feature.d.ts.map +1 -0
- package/dist/src/features/modes/fan-only-operation-mode.feature.js +40 -0
- package/dist/src/features/modes/fan-only-operation-mode.feature.js.map +1 -0
- package/dist/src/features/modes/index.d.ts +8 -0
- package/dist/src/features/modes/index.d.ts.map +1 -0
- package/dist/src/features/modes/index.js +24 -0
- package/dist/src/features/modes/index.js.map +1 -0
- package/dist/src/features/modes/indoor-silent-mode.feature.d.ts +17 -0
- package/dist/src/features/modes/indoor-silent-mode.feature.d.ts.map +1 -0
- package/dist/src/features/modes/indoor-silent-mode.feature.js +47 -0
- package/dist/src/features/modes/indoor-silent-mode.feature.js.map +1 -0
- package/dist/src/features/modes/outdoor-silent-mode.feature.d.ts +15 -0
- package/dist/src/features/modes/outdoor-silent-mode.feature.d.ts.map +1 -0
- package/dist/src/features/modes/outdoor-silent-mode.feature.js +37 -0
- package/dist/src/features/modes/outdoor-silent-mode.feature.js.map +1 -0
- package/dist/src/features/modes/powerful-mode.feature.d.ts +15 -0
- package/dist/src/features/modes/powerful-mode.feature.d.ts.map +1 -0
- package/dist/src/features/modes/powerful-mode.feature.js +37 -0
- package/dist/src/features/modes/powerful-mode.feature.js.map +1 -0
- package/dist/src/features/modes/streamer-mode.feature.d.ts +15 -0
- package/dist/src/features/modes/streamer-mode.feature.d.ts.map +1 -0
- package/dist/src/features/modes/streamer-mode.feature.js +37 -0
- package/dist/src/features/modes/streamer-mode.feature.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/platform.d.ts +33 -0
- package/dist/src/platform.d.ts.map +1 -0
- package/dist/src/platform.js +209 -0
- package/dist/src/platform.js.map +1 -0
- package/dist/src/services/climate-control.service.d.ts +43 -0
- package/dist/src/services/climate-control.service.d.ts.map +1 -0
- package/dist/src/services/climate-control.service.js +366 -0
- package/dist/src/services/climate-control.service.js.map +1 -0
- package/dist/src/services/hot-water-tank.service.d.ts +23 -0
- package/dist/src/services/hot-water-tank.service.d.ts.map +1 -0
- package/dist/src/services/hot-water-tank.service.js +214 -0
- package/dist/src/services/hot-water-tank.service.js.map +1 -0
- package/dist/src/services/index.d.ts +3 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +19 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/settings.d.ts +9 -0
- package/dist/src/settings.d.ts.map +1 -0
- package/dist/src/settings.js +12 -0
- package/dist/src/settings.js.map +1 -0
- package/dist/src/types/daikin-enums.d.ts +61 -0
- package/dist/src/types/daikin-enums.d.ts.map +1 -0
- package/dist/src/types/daikin-enums.js +76 -0
- package/dist/src/types/daikin-enums.js.map +1 -0
- package/dist/src/types/device-capabilities.d.ts +47 -0
- package/dist/src/types/device-capabilities.d.ts.map +1 -0
- package/dist/src/types/device-capabilities.js +7 -0
- package/dist/src/types/device-capabilities.js.map +1 -0
- package/dist/src/types/index.d.ts +3 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +19 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/strings.d.ts +5 -0
- package/dist/src/utils/strings.d.ts.map +1 -0
- package/dist/src/utils/strings.js +22 -0
- package/dist/src/utils/strings.js.map +1 -0
- package/docs/Screenshot 2024-07-04 at 18.41.28.png +0 -0
- package/docs/api-response-for-BRP069A8x.json +520 -0
- package/docs/api-response-for-BRP069C4x-2.json +881 -0
- package/docs/api-response-for-BRP069C4x.json +916 -0
- package/docs/api-response-for-altherma.json +759 -0
- package/docs/api-response-for-altherma2.json +2735 -0
- package/docs/api-response-with-multiple-devices-incl-heatpump.json +2544 -0
- package/docs/cr-insance-altherma-id-0.json +834 -0
- package/docs/mock-air-to-air-dx23.json +759 -0
- package/docs/mock-air-to-air-dx4.json +1134 -0
- package/docs/mock-airpurifier-with-humidifier.json +732 -0
- package/docs/mock-airpurifier.json +450 -0
- package/docs/mock-altherma-air-to-water-lan.json +845 -0
- package/docs/mock-altherma-air-to-water-wlan.json +845 -0
- package/docs/mock-d2cnd-gas-boiler.json +649 -0
- package/docs/setpointmode-vs-controlmode-vs-setpoints-vs-sensorydata.txt +6 -0
- package/homebridge-ui/README.md +35 -0
- package/homebridge-ui/public/index.html +222 -0
- package/homebridge-ui/public/script.js +796 -0
- package/homebridge-ui/public/styles.css +456 -0
- package/homebridge-ui/server.js +909 -0
- package/jest.config.ts +13 -0
- package/package.json +63 -0
- package/test/fixtures/altherma-crSense-2.ts +834 -0
- package/test/fixtures/altherma-fraction.ts +719 -0
- package/test/fixtures/altherma-heat-pump-2.ts +479 -0
- package/test/fixtures/altherma-heat-pump.ts +758 -0
- package/test/fixtures/altherma-miladcerkic-off.ts +524 -0
- package/test/fixtures/altherma-miladcerkic.ts +524 -0
- package/test/fixtures/altherma-v1ckoeln.ts +645 -0
- package/test/fixtures/altherma-with-embedded-id-zero.ts +834 -0
- package/test/fixtures/dx23-airco-2.ts +343 -0
- package/test/fixtures/dx23-airco.ts +519 -0
- package/test/fixtures/dx4-airco.ts +915 -0
- package/test/fixtures/unknown-jan.ts +489 -0
- package/test/fixtures/unknown-kitchen-guests.ts +489 -0
- package/test/hbConfig/.daikin-controller-cloud-tokenset +8 -0
- package/test/hbConfig/.uix-dashboard.json +1 -0
- package/test/hbConfig/.uix-secrets +1 -0
- package/test/hbConfig/accessories/.cachedAccessories.bak +1 -0
- package/test/hbConfig/accessories/cachedAccessories +1 -0
- package/test/hbConfig/accessories/uiAccessoriesLayout.json +1 -0
- package/test/hbConfig/auth.json +10 -0
- package/test/hbConfig/backups/config-backups/config.json.1767953686461 +25 -0
- package/test/hbConfig/backups/config-backups/config.json.1767953695236 +29 -0
- package/test/hbConfig/backups/config-backups/config.json.1767953814763 +29 -0
- package/test/hbConfig/backups/config-backups/config.json.1767953823101 +29 -0
- package/test/hbConfig/backups/config-backups/config.json.1767954822835 +29 -0
- package/test/hbConfig/backups/config-backups/config.json.1767954859218 +29 -0
- package/test/hbConfig/config.json +33 -0
- package/test/hbConfig/daikin-cloud-certs/server.crt +22 -0
- package/test/hbConfig/daikin-cloud-certs/server.key +28 -0
- package/test/hbConfig/persist/AccessoryInfo.1E4A432551BA.json +1 -0
- package/test/hbConfig/persist/IdentifierCache.1E4A432551BA.json +1 -0
- package/test/integration/air-conditioning.test.ts +396 -0
- package/test/integration/altherma.test.ts +288 -0
- package/test/integration/platform.test.ts +101 -0
- package/test/mocks/index.ts +27 -0
- package/test/unit/api/__snapshots__/daikinCloud.test.ts.snap +1323 -0
- package/test/unit/api/daikinCloud.test.ts +12 -0
- package/test/unit/device/daikin-device.test.ts +29 -0
- package/test/unit/services/hot-water-tank.service.test.ts +107 -0
|
@@ -0,0 +1,288 @@
|
|
|
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} from 'daikin-controller-cloud/dist/device';
|
|
6
|
+
import {OnectaClient} from 'daikin-controller-cloud/dist/onecta/oidc-client';
|
|
7
|
+
import {DaikinCloudController} from 'daikin-controller-cloud/dist/index.js';
|
|
8
|
+
import {althermaV1ckoeln} from '../fixtures/altherma-v1ckoeln';
|
|
9
|
+
import {althermaCrSense2} from '../fixtures/altherma-crSense-2';
|
|
10
|
+
import {althermaWithEmbeddedIdZero} from '../fixtures/altherma-with-embedded-id-zero';
|
|
11
|
+
import {althermaHeatPump} from '../fixtures/altherma-heat-pump';
|
|
12
|
+
import {althermaHeatPump2} from '../fixtures/altherma-heat-pump-2';
|
|
13
|
+
import {althermaFraction} from '../fixtures/altherma-fraction';
|
|
14
|
+
import {althermaMiladcerkic} from '../fixtures/altherma-miladcerkic';
|
|
15
|
+
|
|
16
|
+
import {HomebridgeAPI} from 'homebridge/lib/api.js';
|
|
17
|
+
import { Logger } from 'homebridge/lib/logger.js';
|
|
18
|
+
|
|
19
|
+
type DeviceState = {
|
|
20
|
+
activeState: boolean;
|
|
21
|
+
currentTemperature: number;
|
|
22
|
+
targetHeaterCoolerState: string;
|
|
23
|
+
coolingThresholdTemperature: number;
|
|
24
|
+
heatingThresholdTemperature: number;
|
|
25
|
+
hotWaterTankCurrentHeatingCoolingState: number;
|
|
26
|
+
hotWaterTankCurrentTemperature: number;
|
|
27
|
+
hotWaterTankHeatingTargetTemperature: number;
|
|
28
|
+
hotWaterTankTargetHeaterCoolerState: number;
|
|
29
|
+
powerfulMode: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
test.each<Array<string | string | any | DeviceState>>([
|
|
33
|
+
[
|
|
34
|
+
'altherma',
|
|
35
|
+
'climateControlMainZone',
|
|
36
|
+
althermaHeatPump,
|
|
37
|
+
{
|
|
38
|
+
activeState: true,
|
|
39
|
+
currentTemperature: 22.4,
|
|
40
|
+
targetHeaterCoolerState: 1,
|
|
41
|
+
coolingThresholdTemperature: undefined,
|
|
42
|
+
heatingThresholdTemperature: 22,
|
|
43
|
+
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
44
|
+
hotWaterTankCurrentTemperature: 48,
|
|
45
|
+
hotWaterTankHeatingTargetTemperature: 48,
|
|
46
|
+
hotWaterTankTargetHeaterCoolerState: 1,
|
|
47
|
+
powerfulMode: false,
|
|
48
|
+
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
'altherma',
|
|
53
|
+
'climateControlMainZone',
|
|
54
|
+
althermaHeatPump2,
|
|
55
|
+
{
|
|
56
|
+
activeState: false,
|
|
57
|
+
currentTemperature: 33,
|
|
58
|
+
targetHeaterCoolerState: 1,
|
|
59
|
+
coolingThresholdTemperature: 0,
|
|
60
|
+
heatingThresholdTemperature: 0,
|
|
61
|
+
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
62
|
+
hotWaterTankCurrentTemperature: 50,
|
|
63
|
+
hotWaterTankHeatingTargetTemperature: 50,
|
|
64
|
+
hotWaterTankTargetHeaterCoolerState: 1,
|
|
65
|
+
powerfulMode: false,
|
|
66
|
+
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
'altherma2',
|
|
71
|
+
'1',
|
|
72
|
+
althermaWithEmbeddedIdZero,
|
|
73
|
+
{
|
|
74
|
+
activeState: false,
|
|
75
|
+
currentTemperature: 27.7,
|
|
76
|
+
targetHeaterCoolerState: 1,
|
|
77
|
+
coolingThresholdTemperature: 20,
|
|
78
|
+
heatingThresholdTemperature: 21,
|
|
79
|
+
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
80
|
+
hotWaterTankCurrentTemperature: 42,
|
|
81
|
+
hotWaterTankHeatingTargetTemperature: 45,
|
|
82
|
+
hotWaterTankTargetHeaterCoolerState: 1,
|
|
83
|
+
powerfulMode: false,
|
|
84
|
+
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
'altherma3',
|
|
89
|
+
'1',
|
|
90
|
+
althermaCrSense2,
|
|
91
|
+
{
|
|
92
|
+
activeState: false,
|
|
93
|
+
currentTemperature: 27.8,
|
|
94
|
+
targetHeaterCoolerState: 1,
|
|
95
|
+
coolingThresholdTemperature: 20,
|
|
96
|
+
heatingThresholdTemperature: 21,
|
|
97
|
+
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
98
|
+
hotWaterTankCurrentTemperature: 45,
|
|
99
|
+
hotWaterTankHeatingTargetTemperature: 45,
|
|
100
|
+
hotWaterTankTargetHeaterCoolerState: 1,
|
|
101
|
+
powerfulMode: false,
|
|
102
|
+
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
'altherma4',
|
|
107
|
+
'climateControlMainZone',
|
|
108
|
+
althermaV1ckoeln,
|
|
109
|
+
{
|
|
110
|
+
activeState: false,
|
|
111
|
+
currentTemperature: 34, // or should we always show the roomTemperature here which is 27.5
|
|
112
|
+
targetHeaterCoolerState: 1,
|
|
113
|
+
coolingThresholdTemperature: 20,
|
|
114
|
+
heatingThresholdTemperature: 0,
|
|
115
|
+
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
116
|
+
hotWaterTankCurrentTemperature: 42,
|
|
117
|
+
hotWaterTankHeatingTargetTemperature: 46,
|
|
118
|
+
hotWaterTankTargetHeaterCoolerState: 1,
|
|
119
|
+
powerfulMode: false,
|
|
120
|
+
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
'althermaFraction',
|
|
125
|
+
'climateControlMainZone',
|
|
126
|
+
althermaFraction,
|
|
127
|
+
{
|
|
128
|
+
activeState: true,
|
|
129
|
+
currentTemperature: 35, // has no roomTemperature :(
|
|
130
|
+
targetHeaterCoolerState: 1,
|
|
131
|
+
coolingThresholdTemperature: 0,
|
|
132
|
+
heatingThresholdTemperature: 0,
|
|
133
|
+
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
134
|
+
hotWaterTankCurrentTemperature: 45,
|
|
135
|
+
hotWaterTankHeatingTargetTemperature: 47,
|
|
136
|
+
hotWaterTankTargetHeaterCoolerState: 1,
|
|
137
|
+
powerfulMode: false,
|
|
138
|
+
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
[
|
|
142
|
+
'althermaMiladcerkic',
|
|
143
|
+
'climateControlMainZone',
|
|
144
|
+
althermaMiladcerkic,
|
|
145
|
+
{
|
|
146
|
+
activeState: true,
|
|
147
|
+
currentTemperature: 45,
|
|
148
|
+
targetHeaterCoolerState: 1,
|
|
149
|
+
coolingThresholdTemperature: 20,
|
|
150
|
+
heatingThresholdTemperature: 45,
|
|
151
|
+
hotWaterTankCurrentHeatingCoolingState: 1,
|
|
152
|
+
hotWaterTankCurrentTemperature: 49,
|
|
153
|
+
hotWaterTankHeatingTargetTemperature: 50,
|
|
154
|
+
hotWaterTankTargetHeaterCoolerState: 1,
|
|
155
|
+
powerfulMode: false,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
])('Create DaikinCloudThermostatAccessory with %s device', async (name, climateControlEmbeddedId, deviceJson, state) => {
|
|
159
|
+
const device = new DaikinCloudDevice(deviceJson, undefined as unknown as OnectaClient);
|
|
160
|
+
|
|
161
|
+
jest.spyOn(DaikinCloudController.prototype, 'getCloudDevices').mockImplementation(async () => {
|
|
162
|
+
return [device];
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const config = new MockPlatformConfig(true);
|
|
166
|
+
const api = new HomebridgeAPI();
|
|
167
|
+
|
|
168
|
+
const uuid = api.hap.uuid.generate(device.getId());
|
|
169
|
+
const accessory = new api.platformAccessory("NAME_FOR_TEST", uuid);
|
|
170
|
+
accessory.context['device'] = device;
|
|
171
|
+
|
|
172
|
+
expect(() => {
|
|
173
|
+
new AlthermaAccessory(new DaikinCloudPlatform(new Logger(), config, api), accessory as unknown as PlatformAccessory<DaikinCloudAccessoryContext>);
|
|
174
|
+
}).not.toThrow();
|
|
175
|
+
|
|
176
|
+
const homebridgeAccessory = new AlthermaAccessory(new DaikinCloudPlatform(new Logger(), config, api), accessory as unknown as PlatformAccessory<DaikinCloudAccessoryContext>);
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
if (typeof state.activeState !== 'undefined') {
|
|
180
|
+
expect(await homebridgeAccessory.service?.handleActiveStateGet()).toBe(state.activeState);
|
|
181
|
+
expect(async () => {
|
|
182
|
+
await homebridgeAccessory.service?.handleActiveStateSet(1);
|
|
183
|
+
}).not.toThrow();
|
|
184
|
+
expect(async () => {
|
|
185
|
+
await homebridgeAccessory.service?.handleActiveStateSet(0);
|
|
186
|
+
}).not.toThrow();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
expect(await homebridgeAccessory.service?.handleCurrentTemperatureGet()).toBe(state.currentTemperature);
|
|
190
|
+
|
|
191
|
+
if (typeof state.coolingThresholdTemperature !== 'undefined') {
|
|
192
|
+
expect(await homebridgeAccessory.service?.handleCoolingThresholdTemperatureGet()).toBe(state.coolingThresholdTemperature);
|
|
193
|
+
expect(async () => {
|
|
194
|
+
await homebridgeAccessory.service?.handleCoolingThresholdTemperatureSet(21);
|
|
195
|
+
}).not.toThrow();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (typeof state.heatingThresholdTemperature !== 'undefined') {
|
|
199
|
+
expect(await homebridgeAccessory.service?.handleHeatingThresholdTemperatureGet()).toBe(state.heatingThresholdTemperature);
|
|
200
|
+
expect(async () => {
|
|
201
|
+
await homebridgeAccessory.service?.handleHeatingThresholdTemperatureSet(25);
|
|
202
|
+
}).not.toThrow();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (typeof state.targetHeaterCoolerState !== 'undefined') {
|
|
206
|
+
expect(await homebridgeAccessory.service?.handleTargetHeaterCoolerStateGet()).toBe(state.targetHeaterCoolerState);
|
|
207
|
+
expect(async () => {
|
|
208
|
+
await homebridgeAccessory.service?.handleTargetHeaterCoolerStateSet(1);
|
|
209
|
+
}).not.toThrow();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
if (typeof state.hotWaterTankCurrentHeatingCoolingState !== 'undefined') {
|
|
214
|
+
expect(await homebridgeAccessory.hotWaterTankService?.handleHotWaterTankCurrentHeatingCoolingStateGet()).toBe(state.hotWaterTankCurrentHeatingCoolingState);
|
|
215
|
+
}
|
|
216
|
+
if (typeof state.hotWaterTankCurrentTemperature !== 'undefined') {
|
|
217
|
+
expect(await homebridgeAccessory.hotWaterTankService?.handleHotWaterTankCurrentTemperatureGet()).toBe(state.hotWaterTankCurrentTemperature);
|
|
218
|
+
}
|
|
219
|
+
if (typeof state.hotWaterTankHeatingTargetTemperature !== 'undefined') {
|
|
220
|
+
expect(await homebridgeAccessory.hotWaterTankService?.handleHotWaterTankHeatingTargetTemperatureGet()).toBe(state.hotWaterTankHeatingTargetTemperature);
|
|
221
|
+
}
|
|
222
|
+
if (typeof state.hotWaterTankTargetHeaterCoolerState !== 'undefined') {
|
|
223
|
+
expect(await homebridgeAccessory.hotWaterTankService?.handleHotWaterTankTargetHeatingCoolingStateGet()).toBe(state.hotWaterTankTargetHeaterCoolerState);
|
|
224
|
+
}
|
|
225
|
+
if (typeof state.powerfulMode !== 'undefined') {
|
|
226
|
+
expect(await homebridgeAccessory.hotWaterTankService?.handlePowerfulModeGet()).toBe(state.powerfulMode);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test('DaikinCloudAirConditioningAccessory Getters', async () => {
|
|
232
|
+
const device = new DaikinCloudDevice(althermaHeatPump, undefined as unknown as OnectaClient);
|
|
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, 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 device = new DaikinCloudDevice(althermaHeatPump, undefined as unknown as OnectaClient);
|
|
255
|
+
|
|
256
|
+
jest.spyOn(DaikinCloudController.prototype, 'getCloudDevices').mockImplementation(async () => {
|
|
257
|
+
return [device];
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
const setDataSpy = jest.spyOn(DaikinCloudDevice.prototype, 'setData').mockImplementation();
|
|
261
|
+
|
|
262
|
+
const config = new MockPlatformConfig(false);
|
|
263
|
+
const api = new HomebridgeAPI();
|
|
264
|
+
|
|
265
|
+
const uuid = api.hap.uuid.generate(device.getId());
|
|
266
|
+
const accessory = new api.platformAccessory(device.getData('climateControlMainZone', 'name', undefined).value, uuid);
|
|
267
|
+
accessory.context['device'] = device;
|
|
268
|
+
|
|
269
|
+
const homebridgeAccessory = new AlthermaAccessory(new DaikinCloudPlatform(new Logger(), config, api), accessory as unknown as PlatformAccessory<DaikinCloudAccessoryContext>);
|
|
270
|
+
|
|
271
|
+
await homebridgeAccessory.service?.handleActiveStateSet(1);
|
|
272
|
+
expect(setDataSpy).toHaveBeenNthCalledWith(1, 'climateControlMainZone', 'onOffMode', 'on', undefined);
|
|
273
|
+
|
|
274
|
+
await homebridgeAccessory.service?.handleActiveStateSet(0);
|
|
275
|
+
expect(setDataSpy).toHaveBeenNthCalledWith(2, 'climateControlMainZone', 'onOffMode', 'off', undefined);
|
|
276
|
+
|
|
277
|
+
await homebridgeAccessory.service?.handleCoolingThresholdTemperatureSet(21);
|
|
278
|
+
expect(setDataSpy).toHaveBeenNthCalledWith(3, 'climateControlMainZone', 'temperatureControl', '/operationModes/cooling/setpoints/roomTemperature', 21);
|
|
279
|
+
|
|
280
|
+
await homebridgeAccessory.service?.handleHeatingThresholdTemperatureSet(25);
|
|
281
|
+
expect(setDataSpy).toHaveBeenNthCalledWith(4, 'climateControlMainZone', 'temperatureControl', '/operationModes/heating/setpoints/roomTemperature', 25);
|
|
282
|
+
|
|
283
|
+
await homebridgeAccessory.service?.handleTargetHeaterCoolerStateSet(1);
|
|
284
|
+
expect(setDataSpy).toHaveBeenNthCalledWith(5, 'climateControlMainZone', 'operationMode', 'heating', undefined);
|
|
285
|
+
expect(setDataSpy).toHaveBeenNthCalledWith(6, 'climateControlMainZone', 'onOffMode', 'on', undefined);
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {DaikinCloudPlatform} from '../../src/platform';
|
|
2
|
+
import {MockPlatformConfig} from '../mocks';
|
|
3
|
+
import {DaikinCloudController} from 'daikin-controller-cloud';
|
|
4
|
+
import {AirConditioningAccessory, AlthermaAccessory} from '../../src/accessories';
|
|
5
|
+
import {HomebridgeAPI} from 'homebridge/lib/api.js';
|
|
6
|
+
import {Logger} from 'homebridge/lib/logger.js';
|
|
7
|
+
import {DaikinCloudDevice} from 'daikin-controller-cloud/dist/device';
|
|
8
|
+
|
|
9
|
+
jest.mock('daikin-controller-cloud');
|
|
10
|
+
jest.mock('homebridge');
|
|
11
|
+
jest.mock('../../src/accessories/air-conditioning-accessory');
|
|
12
|
+
jest.mock('../../src/accessories/altherma-accessory');
|
|
13
|
+
jest.mock('daikin-controller-cloud/dist/device');
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
jest.resetAllMocks();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('Initialize platform', async () => {
|
|
20
|
+
const api = new HomebridgeAPI();
|
|
21
|
+
const platform = new DaikinCloudPlatform(new Logger(), new MockPlatformConfig(), api);
|
|
22
|
+
|
|
23
|
+
expect(DaikinCloudController).toHaveBeenCalledWith({
|
|
24
|
+
'oidcAuthorizationTimeoutS': 300,
|
|
25
|
+
'oidcCallbackServerBindAddr': 'SERVER_BIND_ADDRESS',
|
|
26
|
+
'oidcCallbackServerExternalAddress': 'SERVER_EXTERNAL_ADDRESS',
|
|
27
|
+
'oidcCallbackServerPort': 'SERVER_PORT',
|
|
28
|
+
'oidcClientId': 'CLIENT_ID',
|
|
29
|
+
'oidcClientSecret': 'CLIENT_SECRET',
|
|
30
|
+
'oidcTokenSetFilePath': `${api.user.storagePath()}/.daikin-controller-cloud-tokenset`,
|
|
31
|
+
});
|
|
32
|
+
expect(platform.updateIntervalDelay).toBe(900000);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('DaikinCloudPlatform with new Aircondition accessory', (done) => {
|
|
36
|
+
jest.spyOn(DaikinCloudController.prototype, 'getCloudDevices').mockResolvedValue([{
|
|
37
|
+
getId: () => 'MOCK_ID',
|
|
38
|
+
getDescription: () => {
|
|
39
|
+
return {
|
|
40
|
+
deviceModel: 'Airco',
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
getData: () => 'MOCK_DATE',
|
|
44
|
+
desc: {
|
|
45
|
+
managementPoints: [
|
|
46
|
+
{
|
|
47
|
+
'embeddedId': 'climateControl',
|
|
48
|
+
'managementPointType': 'climateControl',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
} as unknown as DaikinCloudDevice]);
|
|
53
|
+
|
|
54
|
+
const api = new HomebridgeAPI();
|
|
55
|
+
|
|
56
|
+
const registerPlatformAccessoriesSpy = jest.spyOn(api, 'registerPlatformAccessories');
|
|
57
|
+
|
|
58
|
+
new DaikinCloudPlatform(new Logger(), new MockPlatformConfig(true), api);
|
|
59
|
+
api.signalFinished();
|
|
60
|
+
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
expect(AirConditioningAccessory).toHaveBeenCalled();
|
|
63
|
+
expect(AlthermaAccessory).not.toHaveBeenCalled();
|
|
64
|
+
expect(registerPlatformAccessoriesSpy).toBeCalledWith('@mp-consulting/homebridge-daikin-cloud', 'DaikinCloud', expect.anything());
|
|
65
|
+
done();
|
|
66
|
+
}, 10);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('DaikinCloudPlatform with new Altherma accessory', (done) => {
|
|
70
|
+
jest.spyOn(DaikinCloudController.prototype, 'getCloudDevices').mockResolvedValue([{
|
|
71
|
+
getId: () => 'MOCK_ID',
|
|
72
|
+
getDescription: () => {
|
|
73
|
+
return {
|
|
74
|
+
deviceModel: 'Altherma',
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
getData: () => 'MOCK_DATE',
|
|
78
|
+
desc: {
|
|
79
|
+
managementPoints: [
|
|
80
|
+
{
|
|
81
|
+
'embeddedId': 'climateControl',
|
|
82
|
+
'managementPointType': 'climateControl',
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
} as unknown as DaikinCloudDevice]);
|
|
87
|
+
|
|
88
|
+
const api = new HomebridgeAPI();
|
|
89
|
+
|
|
90
|
+
const registerPlatformAccessoriesSpy = jest.spyOn(api, 'registerPlatformAccessories');
|
|
91
|
+
|
|
92
|
+
new DaikinCloudPlatform(new Logger(), new MockPlatformConfig(true), api);
|
|
93
|
+
api.signalFinished();
|
|
94
|
+
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
expect(AlthermaAccessory).toHaveBeenCalled();
|
|
97
|
+
expect(AirConditioningAccessory).not.toHaveBeenCalled();
|
|
98
|
+
expect(registerPlatformAccessoriesSpy).toHaveBeenCalledWith('@mp-consulting/homebridge-daikin-cloud', 'DaikinCloud', expect.anything());
|
|
99
|
+
done();
|
|
100
|
+
}, 10);
|
|
101
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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) => 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
|
+
}
|