@fastybird/smart-panel-backend 1.1.0-alpha.0 → 1.1.0-alpha.2
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/dist/app.module.js +7 -0
- package/dist/app.module.js.map +1 -1
- package/dist/modules/devices/services/property-command.service.d.ts +8 -0
- package/dist/modules/devices/services/property-command.service.js +115 -0
- package/dist/modules/devices/services/property-command.service.js.map +1 -1
- package/dist/modules/mcp/oauth/mcp-oauth-provider.factory.js.map +1 -1
- package/dist/modules/remote-access/services/remote-access-proxy-contribution.service.js +4 -0
- package/dist/modules/remote-access/services/remote-access-proxy-contribution.service.js.map +1 -1
- package/dist/modules/remote-access/services/remote-access-status.service.d.ts +5 -1
- package/dist/modules/remote-access/services/remote-access-status.service.js +38 -4
- package/dist/modules/remote-access/services/remote-access-status.service.js.map +1 -1
- package/dist/modules/remote-access/services/remote-access-url.service.js +4 -0
- package/dist/modules/remote-access/services/remote-access-url.service.js.map +1 -1
- package/dist/modules/system/commands/command.utils.d.ts +2 -0
- package/dist/modules/system/commands/command.utils.js +14 -0
- package/dist/modules/system/commands/command.utils.js.map +1 -1
- package/dist/modules/system/commands/update-check.command.js +2 -3
- package/dist/modules/system/commands/update-check.command.js.map +1 -1
- package/dist/modules/system/commands/update-panel.command.js +2 -2
- package/dist/modules/system/commands/update-panel.command.js.map +1 -1
- package/dist/modules/system/commands/update-server.command.d.ts +1 -0
- package/dist/modules/system/commands/update-server.command.js +36 -11
- package/dist/modules/system/commands/update-server.command.js.map +1 -1
- package/dist/modules/system/dto/update-config.dto.d.ts +2 -1
- package/dist/modules/system/dto/update-config.dto.js +15 -0
- package/dist/modules/system/dto/update-config.dto.js.map +1 -1
- package/dist/modules/system/models/config.model.d.ts +2 -1
- package/dist/modules/system/models/config.model.js +13 -0
- package/dist/modules/system/models/config.model.js.map +1 -1
- package/dist/modules/system/services/update.service.d.ts +11 -1
- package/dist/modules/system/services/update.service.js +97 -35
- package/dist/modules/system/services/update.service.js.map +1 -1
- package/dist/modules/system/system.constants.d.ts +6 -0
- package/dist/modules/system/system.constants.js +8 -1
- package/dist/modules/system/system.constants.js.map +1 -1
- package/dist/modules/websocket/gateway/websocket.gateway.d.ts +3 -0
- package/dist/modules/websocket/gateway/websocket.gateway.js +39 -4
- package/dist/modules/websocket/gateway/websocket.gateway.js.map +1 -1
- package/dist/plugins/devices-homekit/controllers/homekit-bridge.controller.d.ts +14 -0
- package/dist/plugins/devices-homekit/controllers/homekit-bridge.controller.js +125 -0
- package/dist/plugins/devices-homekit/controllers/homekit-bridge.controller.js.map +1 -0
- package/dist/plugins/devices-homekit/devices-homekit.constants.d.ts +16 -0
- package/dist/plugins/devices-homekit/devices-homekit.constants.js +57 -0
- package/dist/plugins/devices-homekit/devices-homekit.constants.js.map +1 -0
- package/dist/plugins/devices-homekit/devices-homekit.exceptions.d.ts +12 -0
- package/dist/plugins/devices-homekit/devices-homekit.exceptions.js +32 -0
- package/dist/plugins/devices-homekit/devices-homekit.exceptions.js.map +1 -0
- package/dist/plugins/devices-homekit/devices-homekit.openapi.d.ts +6 -0
- package/dist/plugins/devices-homekit/devices-homekit.openapi.js +19 -0
- package/dist/plugins/devices-homekit/devices-homekit.openapi.js.map +1 -0
- package/dist/plugins/devices-homekit/devices-homekit.plugin.d.ts +24 -0
- package/dist/plugins/devices-homekit/devices-homekit.plugin.js +183 -0
- package/dist/plugins/devices-homekit/devices-homekit.plugin.js.map +1 -0
- package/dist/plugins/devices-homekit/dto/bridge-map.dto.d.ts +6 -0
- package/dist/plugins/devices-homekit/dto/bridge-map.dto.js +50 -0
- package/dist/plugins/devices-homekit/dto/bridge-map.dto.js.map +1 -0
- package/dist/plugins/devices-homekit/dto/update-config.dto.d.ts +11 -0
- package/dist/plugins/devices-homekit/dto/update-config.dto.js +138 -0
- package/dist/plugins/devices-homekit/dto/update-config.dto.js.map +1 -0
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.d.ts +8 -0
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js +72 -0
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/base.mapper.d.ts +15 -0
- package/dist/plugins/devices-homekit/mappers/base.mapper.js +74 -0
- package/dist/plugins/devices-homekit/mappers/base.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/battery.mapper.d.ts +6 -0
- package/dist/plugins/devices-homekit/mappers/battery.mapper.js +130 -0
- package/dist/plugins/devices-homekit/mappers/battery.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/homekit-mapper.interface.d.ts +28 -0
- package/dist/plugins/devices-homekit/mappers/homekit-mapper.interface.js +3 -0
- package/dist/plugins/devices-homekit/mappers/homekit-mapper.interface.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/lightbulb.mapper.d.ts +9 -0
- package/dist/plugins/devices-homekit/mappers/lightbulb.mapper.js +115 -0
- package/dist/plugins/devices-homekit/mappers/lightbulb.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/lock.mapper.d.ts +10 -0
- package/dist/plugins/devices-homekit/mappers/lock.mapper.js +59 -0
- package/dist/plugins/devices-homekit/mappers/lock.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/outlet.mapper.d.ts +9 -0
- package/dist/plugins/devices-homekit/mappers/outlet.mapper.js +44 -0
- package/dist/plugins/devices-homekit/mappers/outlet.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/sensor.mapper.d.ts +10 -0
- package/dist/plugins/devices-homekit/mappers/sensor.mapper.js +168 -0
- package/dist/plugins/devices-homekit/mappers/sensor.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/switch.mapper.d.ts +9 -0
- package/dist/plugins/devices-homekit/mappers/switch.mapper.js +35 -0
- package/dist/plugins/devices-homekit/mappers/switch.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.d.ts +43 -0
- package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js +430 -0
- package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/thermostat.mapper.d.ts +11 -0
- package/dist/plugins/devices-homekit/mappers/thermostat.mapper.js +97 -0
- package/dist/plugins/devices-homekit/mappers/thermostat.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/window-covering.mapper.d.ts +10 -0
- package/dist/plugins/devices-homekit/mappers/window-covering.mapper.js +94 -0
- package/dist/plugins/devices-homekit/mappers/window-covering.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/models/bridge-candidate.model.d.ts +15 -0
- package/dist/plugins/devices-homekit/models/bridge-candidate.model.js +150 -0
- package/dist/plugins/devices-homekit/models/bridge-candidate.model.js.map +1 -0
- package/dist/plugins/devices-homekit/models/bridge-status.model.d.ts +16 -0
- package/dist/plugins/devices-homekit/models/bridge-status.model.js +156 -0
- package/dist/plugins/devices-homekit/models/bridge-status.model.js.map +1 -0
- package/dist/plugins/devices-homekit/models/config.model.d.ts +12 -0
- package/dist/plugins/devices-homekit/models/config.model.js +134 -0
- package/dist/plugins/devices-homekit/models/config.model.js.map +1 -0
- package/dist/plugins/devices-homekit/services/homekit-actions.service.d.ts +14 -0
- package/dist/plugins/devices-homekit/services/homekit-actions.service.js +92 -0
- package/dist/plugins/devices-homekit/services/homekit-actions.service.js.map +1 -0
- package/dist/plugins/devices-homekit/services/homekit-bridge.service.d.ts +43 -0
- package/dist/plugins/devices-homekit/services/homekit-bridge.service.js +497 -0
- package/dist/plugins/devices-homekit/services/homekit-bridge.service.js.map +1 -0
- package/dist/plugins/devices-homekit/services/homekit-command.dispatcher.d.ts +11 -0
- package/dist/plugins/devices-homekit/services/homekit-command.dispatcher.js +68 -0
- package/dist/plugins/devices-homekit/services/homekit-command.dispatcher.js.map +1 -0
- package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.d.ts +34 -0
- package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js +179 -0
- package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js.map +1 -0
- package/dist/plugins/devices-homekit/services/homekit-wizard.service.d.ts +15 -0
- package/dist/plugins/devices-homekit/services/homekit-wizard.service.js +75 -0
- package/dist/plugins/devices-homekit/services/homekit-wizard.service.js.map +1 -0
- package/dist/plugins/devices-homekit/validators/is-not-forbidden-homekit-pin.validator.d.ts +2 -0
- package/dist/plugins/devices-homekit/validators/is-not-forbidden-homekit-pin.validator.js +30 -0
- package/dist/plugins/devices-homekit/validators/is-not-forbidden-homekit-pin.validator.js.map +1 -0
- package/dist/plugins/devices-shelly-ng/services/device-manager.service.js +5 -0
- package/dist/plugins/devices-shelly-ng/services/device-manager.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThermostatCoordinator = void 0;
|
|
4
|
+
const hap_nodejs_1 = require("@homebridge/hap-nodejs");
|
|
5
|
+
const devices_constants_1 = require("../../../modules/devices/devices.constants");
|
|
6
|
+
class ThermostatCoordinator {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
this.values = new Map();
|
|
10
|
+
this.revisions = new Map();
|
|
11
|
+
const { service } = config;
|
|
12
|
+
this.currentHeatingCoolingChar = service.getCharacteristic(hap_nodejs_1.Characteristic.CurrentHeatingCoolingState);
|
|
13
|
+
this.targetHeatingCoolingChar = service.getCharacteristic(hap_nodejs_1.Characteristic.TargetHeatingCoolingState);
|
|
14
|
+
this.currentTempChar = service.getCharacteristic(hap_nodejs_1.Characteristic.CurrentTemperature);
|
|
15
|
+
this.targetTempChar = service.getCharacteristic(hap_nodejs_1.Characteristic.TargetTemperature);
|
|
16
|
+
this.initValues();
|
|
17
|
+
this.configureValidValues();
|
|
18
|
+
this.setupGettersAndSetters();
|
|
19
|
+
this.registerEventListeners();
|
|
20
|
+
this.refreshCharacteristics();
|
|
21
|
+
}
|
|
22
|
+
initValues() {
|
|
23
|
+
const registerProp = (prop) => {
|
|
24
|
+
if (!prop)
|
|
25
|
+
return;
|
|
26
|
+
const unwrapped = prop.value !== null && typeof prop.value === 'object' && 'value' in prop.value
|
|
27
|
+
? prop.value.value
|
|
28
|
+
: prop.value;
|
|
29
|
+
this.values.set(prop.id, unwrapped);
|
|
30
|
+
this.revisions.set(prop.id, 0);
|
|
31
|
+
};
|
|
32
|
+
registerProp(this.config.ambientTempProperty);
|
|
33
|
+
registerProp(this.config.heaterOnProperty);
|
|
34
|
+
registerProp(this.config.heaterTempProperty);
|
|
35
|
+
registerProp(this.config.heaterStatusProperty);
|
|
36
|
+
registerProp(this.config.coolerOnProperty);
|
|
37
|
+
registerProp(this.config.coolerTempProperty);
|
|
38
|
+
registerProp(this.config.coolerStatusProperty);
|
|
39
|
+
registerProp(this.config.lockedProperty);
|
|
40
|
+
}
|
|
41
|
+
configureValidValues() {
|
|
42
|
+
const validValues = [hap_nodejs_1.Characteristic.TargetHeatingCoolingState.OFF];
|
|
43
|
+
const hasHeater = !!this.config.heaterOnProperty;
|
|
44
|
+
const hasCooler = !!this.config.coolerOnProperty;
|
|
45
|
+
if (hasHeater) {
|
|
46
|
+
validValues.push(hap_nodejs_1.Characteristic.TargetHeatingCoolingState.HEAT);
|
|
47
|
+
}
|
|
48
|
+
if (hasCooler) {
|
|
49
|
+
validValues.push(hap_nodejs_1.Characteristic.TargetHeatingCoolingState.COOL);
|
|
50
|
+
}
|
|
51
|
+
if (hasHeater && hasCooler) {
|
|
52
|
+
validValues.push(hap_nodejs_1.Characteristic.TargetHeatingCoolingState.AUTO);
|
|
53
|
+
this.heatingThresholdChar = this.config.service.getCharacteristic(hap_nodejs_1.Characteristic.HeatingThresholdTemperature);
|
|
54
|
+
this.coolingThresholdChar = this.config.service.getCharacteristic(hap_nodejs_1.Characteristic.CoolingThresholdTemperature);
|
|
55
|
+
}
|
|
56
|
+
this.targetHeatingCoolingChar.setProps({
|
|
57
|
+
validValues,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
isPropertyWritable(prop) {
|
|
61
|
+
if (!prop || !Array.isArray(prop.permissions))
|
|
62
|
+
return false;
|
|
63
|
+
return prop.permissions.some((p) => [devices_constants_1.PermissionType.READ_WRITE, devices_constants_1.PermissionType.WRITE_ONLY].includes(p));
|
|
64
|
+
}
|
|
65
|
+
setupGettersAndSetters() {
|
|
66
|
+
this.currentTempChar.onGet(() => this.getAmbientTemperature());
|
|
67
|
+
this.targetTempChar.onGet(() => this.getTargetTemperature());
|
|
68
|
+
const hasWritableTemp = this.isPropertyWritable(this.config.heaterTempProperty) ||
|
|
69
|
+
this.isPropertyWritable(this.config.coolerTempProperty);
|
|
70
|
+
if (hasWritableTemp && this.targetTempChar.props.perms.includes("pw")) {
|
|
71
|
+
this.targetTempChar.onSet(async (value) => {
|
|
72
|
+
const targetVal = Number(value);
|
|
73
|
+
const targetMode = this.deriveTargetHeatingCoolingState();
|
|
74
|
+
const commands = [];
|
|
75
|
+
if (targetMode === hap_nodejs_1.Characteristic.TargetHeatingCoolingState.HEAT) {
|
|
76
|
+
if (this.config.heaterTempProperty && this.isPropertyWritable(this.config.heaterTempProperty)) {
|
|
77
|
+
commands.push({ propertyId: this.config.heaterTempProperty.id, value: targetVal });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if (targetMode === hap_nodejs_1.Characteristic.TargetHeatingCoolingState.COOL) {
|
|
81
|
+
if (this.config.coolerTempProperty && this.isPropertyWritable(this.config.coolerTempProperty)) {
|
|
82
|
+
commands.push({ propertyId: this.config.coolerTempProperty.id, value: targetVal });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (targetMode === hap_nodejs_1.Characteristic.TargetHeatingCoolingState.AUTO) {
|
|
86
|
+
const heatProp = this.config.heaterTempProperty;
|
|
87
|
+
const coolProp = this.config.coolerTempProperty;
|
|
88
|
+
const heatRaw = heatProp ? this.values.get(heatProp.id) : null;
|
|
89
|
+
const coolRaw = coolProp ? this.values.get(coolProp.id) : null;
|
|
90
|
+
const currentHeat = heatRaw !== null && heatRaw !== undefined ? Number(heatRaw) : NaN;
|
|
91
|
+
const currentCool = coolRaw !== null && coolRaw !== undefined ? Number(coolRaw) : NaN;
|
|
92
|
+
const span = !isNaN(currentHeat) && !isNaN(currentCool) ? Math.max(0, currentCool - currentHeat) / 2 : 1;
|
|
93
|
+
if (heatProp && this.isPropertyWritable(heatProp)) {
|
|
94
|
+
commands.push({ propertyId: heatProp.id, value: targetVal - span });
|
|
95
|
+
}
|
|
96
|
+
if (coolProp && this.isPropertyWritable(coolProp)) {
|
|
97
|
+
commands.push({ propertyId: coolProp.id, value: targetVal + span });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (this.config.heaterTempProperty && this.isPropertyWritable(this.config.heaterTempProperty)) {
|
|
102
|
+
commands.push({ propertyId: this.config.heaterTempProperty.id, value: targetVal });
|
|
103
|
+
}
|
|
104
|
+
else if (this.config.coolerTempProperty && this.isPropertyWritable(this.config.coolerTempProperty)) {
|
|
105
|
+
commands.push({ propertyId: this.config.coolerTempProperty.id, value: targetVal });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (commands.length > 0) {
|
|
109
|
+
const targetRevs = new Map();
|
|
110
|
+
for (const cmd of commands) {
|
|
111
|
+
const nextRev = (this.revisions.get(cmd.propertyId) ?? 0) + 1;
|
|
112
|
+
this.revisions.set(cmd.propertyId, nextRev);
|
|
113
|
+
targetRevs.set(cmd.propertyId, nextRev);
|
|
114
|
+
}
|
|
115
|
+
await this.config.context.commandDispatcher.dispatchBatch(commands);
|
|
116
|
+
let hadConflict = false;
|
|
117
|
+
for (const cmd of commands) {
|
|
118
|
+
if (this.revisions.get(cmd.propertyId) === targetRevs.get(cmd.propertyId)) {
|
|
119
|
+
this.values.set(cmd.propertyId, cmd.value);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
hadConflict = true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
this.refreshCharacteristics();
|
|
126
|
+
if (hadConflict) {
|
|
127
|
+
process.nextTick(() => this.refreshCharacteristics());
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
this.currentHeatingCoolingChar.onGet(() => this.deriveCurrentHeatingCoolingState());
|
|
133
|
+
this.targetHeatingCoolingChar.onGet(() => this.deriveTargetHeatingCoolingState());
|
|
134
|
+
const hasWritableState = (this.config.heaterOnProperty && this.isPropertyWritable(this.config.heaterOnProperty)) ||
|
|
135
|
+
(this.config.coolerOnProperty && this.isPropertyWritable(this.config.coolerOnProperty));
|
|
136
|
+
if (hasWritableState && this.targetHeatingCoolingChar.props.perms.includes("pw")) {
|
|
137
|
+
this.targetHeatingCoolingChar.onSet(async (value) => {
|
|
138
|
+
const targetMode = Number(value);
|
|
139
|
+
const commands = [];
|
|
140
|
+
if (targetMode === hap_nodejs_1.Characteristic.TargetHeatingCoolingState.OFF) {
|
|
141
|
+
if (this.config.heaterOnProperty && this.isPropertyWritable(this.config.heaterOnProperty)) {
|
|
142
|
+
commands.push({ propertyId: this.config.heaterOnProperty.id, value: false });
|
|
143
|
+
}
|
|
144
|
+
if (this.config.coolerOnProperty && this.isPropertyWritable(this.config.coolerOnProperty)) {
|
|
145
|
+
commands.push({ propertyId: this.config.coolerOnProperty.id, value: false });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else if (targetMode === hap_nodejs_1.Characteristic.TargetHeatingCoolingState.HEAT) {
|
|
149
|
+
if (this.config.heaterOnProperty && this.isPropertyWritable(this.config.heaterOnProperty)) {
|
|
150
|
+
commands.push({ propertyId: this.config.heaterOnProperty.id, value: true });
|
|
151
|
+
}
|
|
152
|
+
if (this.config.coolerOnProperty && this.isPropertyWritable(this.config.coolerOnProperty)) {
|
|
153
|
+
commands.push({ propertyId: this.config.coolerOnProperty.id, value: false });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else if (targetMode === hap_nodejs_1.Characteristic.TargetHeatingCoolingState.COOL) {
|
|
157
|
+
if (this.config.heaterOnProperty && this.isPropertyWritable(this.config.heaterOnProperty)) {
|
|
158
|
+
commands.push({ propertyId: this.config.heaterOnProperty.id, value: false });
|
|
159
|
+
}
|
|
160
|
+
if (this.config.coolerOnProperty && this.isPropertyWritable(this.config.coolerOnProperty)) {
|
|
161
|
+
commands.push({ propertyId: this.config.coolerOnProperty.id, value: true });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else if (targetMode === hap_nodejs_1.Characteristic.TargetHeatingCoolingState.AUTO) {
|
|
165
|
+
if (this.config.heaterOnProperty && this.isPropertyWritable(this.config.heaterOnProperty)) {
|
|
166
|
+
commands.push({ propertyId: this.config.heaterOnProperty.id, value: true });
|
|
167
|
+
}
|
|
168
|
+
if (this.config.coolerOnProperty && this.isPropertyWritable(this.config.coolerOnProperty)) {
|
|
169
|
+
commands.push({ propertyId: this.config.coolerOnProperty.id, value: true });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (commands.length > 0) {
|
|
173
|
+
const targetRevs = new Map();
|
|
174
|
+
for (const cmd of commands) {
|
|
175
|
+
const nextRev = (this.revisions.get(cmd.propertyId) ?? 0) + 1;
|
|
176
|
+
this.revisions.set(cmd.propertyId, nextRev);
|
|
177
|
+
targetRevs.set(cmd.propertyId, nextRev);
|
|
178
|
+
}
|
|
179
|
+
await this.config.context.commandDispatcher.dispatchBatch(commands);
|
|
180
|
+
let hadConflict = false;
|
|
181
|
+
for (const cmd of commands) {
|
|
182
|
+
if (this.revisions.get(cmd.propertyId) === targetRevs.get(cmd.propertyId)) {
|
|
183
|
+
this.values.set(cmd.propertyId, cmd.value);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
hadConflict = true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
this.refreshCharacteristics();
|
|
190
|
+
if (hadConflict) {
|
|
191
|
+
process.nextTick(() => this.refreshCharacteristics());
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (this.heatingThresholdChar && this.config.heaterTempProperty) {
|
|
197
|
+
const heaterTempProp = this.config.heaterTempProperty;
|
|
198
|
+
this.heatingThresholdChar.onGet(() => {
|
|
199
|
+
const val = this.values.get(heaterTempProp.id);
|
|
200
|
+
if (val !== null && val !== undefined) {
|
|
201
|
+
const num = Number(val);
|
|
202
|
+
return !isNaN(num) ? num : 20;
|
|
203
|
+
}
|
|
204
|
+
return 20;
|
|
205
|
+
});
|
|
206
|
+
if (this.isPropertyWritable(heaterTempProp) &&
|
|
207
|
+
this.heatingThresholdChar.props.perms.includes("pw")) {
|
|
208
|
+
this.heatingThresholdChar.onSet(async (value) => {
|
|
209
|
+
const target = Number(value);
|
|
210
|
+
const targetRev = (this.revisions.get(heaterTempProp.id) ?? 0) + 1;
|
|
211
|
+
this.revisions.set(heaterTempProp.id, targetRev);
|
|
212
|
+
await this.config.context.commandDispatcher.dispatch(heaterTempProp.id, target);
|
|
213
|
+
const hasConflict = this.revisions.get(heaterTempProp.id) !== targetRev;
|
|
214
|
+
if (!hasConflict) {
|
|
215
|
+
this.values.set(heaterTempProp.id, target);
|
|
216
|
+
}
|
|
217
|
+
this.refreshCharacteristics();
|
|
218
|
+
if (hasConflict) {
|
|
219
|
+
process.nextTick(() => this.refreshCharacteristics());
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (this.coolingThresholdChar && this.config.coolerTempProperty) {
|
|
225
|
+
const coolerTempProp = this.config.coolerTempProperty;
|
|
226
|
+
this.coolingThresholdChar.onGet(() => {
|
|
227
|
+
const val = this.values.get(coolerTempProp.id);
|
|
228
|
+
if (val !== null && val !== undefined) {
|
|
229
|
+
const num = Number(val);
|
|
230
|
+
return !isNaN(num) ? num : 25;
|
|
231
|
+
}
|
|
232
|
+
return 25;
|
|
233
|
+
});
|
|
234
|
+
if (this.isPropertyWritable(coolerTempProp) &&
|
|
235
|
+
this.coolingThresholdChar.props.perms.includes("pw")) {
|
|
236
|
+
this.coolingThresholdChar.onSet(async (value) => {
|
|
237
|
+
const target = Number(value);
|
|
238
|
+
const targetRev = (this.revisions.get(coolerTempProp.id) ?? 0) + 1;
|
|
239
|
+
this.revisions.set(coolerTempProp.id, targetRev);
|
|
240
|
+
await this.config.context.commandDispatcher.dispatch(coolerTempProp.id, target);
|
|
241
|
+
const hasConflict = this.revisions.get(coolerTempProp.id) !== targetRev;
|
|
242
|
+
if (!hasConflict) {
|
|
243
|
+
this.values.set(coolerTempProp.id, target);
|
|
244
|
+
}
|
|
245
|
+
this.refreshCharacteristics();
|
|
246
|
+
if (hasConflict) {
|
|
247
|
+
process.nextTick(() => this.refreshCharacteristics());
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (this.config.lockedProperty) {
|
|
253
|
+
const lockProp = this.config.lockedProperty;
|
|
254
|
+
this.lockPhysicalControlsChar = this.config.service.getCharacteristic(hap_nodejs_1.Characteristic.LockPhysicalControls);
|
|
255
|
+
this.lockPhysicalControlsChar.onGet(() => this.getLockPhysicalControls());
|
|
256
|
+
if (this.isPropertyWritable(lockProp) && this.lockPhysicalControlsChar.props.perms.includes("pw")) {
|
|
257
|
+
this.lockPhysicalControlsChar.onSet(async (value) => {
|
|
258
|
+
const isLocked = value === hap_nodejs_1.Characteristic.LockPhysicalControls.CONTROL_LOCK_ENABLED;
|
|
259
|
+
const targetRev = (this.revisions.get(lockProp.id) ?? 0) + 1;
|
|
260
|
+
this.revisions.set(lockProp.id, targetRev);
|
|
261
|
+
await this.config.context.commandDispatcher.dispatch(lockProp.id, isLocked);
|
|
262
|
+
const hasConflict = this.revisions.get(lockProp.id) !== targetRev;
|
|
263
|
+
if (!hasConflict) {
|
|
264
|
+
this.values.set(lockProp.id, isLocked);
|
|
265
|
+
}
|
|
266
|
+
this.refreshCharacteristics();
|
|
267
|
+
if (hasConflict) {
|
|
268
|
+
process.nextTick(() => this.refreshCharacteristics());
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
registerEventListeners() {
|
|
275
|
+
const propsToListen = [
|
|
276
|
+
this.config.ambientTempProperty,
|
|
277
|
+
this.config.heaterOnProperty,
|
|
278
|
+
this.config.heaterTempProperty,
|
|
279
|
+
this.config.heaterStatusProperty,
|
|
280
|
+
this.config.coolerOnProperty,
|
|
281
|
+
this.config.coolerTempProperty,
|
|
282
|
+
this.config.coolerStatusProperty,
|
|
283
|
+
this.config.lockedProperty,
|
|
284
|
+
].filter((p) => !!p);
|
|
285
|
+
for (const prop of propsToListen) {
|
|
286
|
+
const listener = {
|
|
287
|
+
deviceId: this.config.device.id,
|
|
288
|
+
propertyId: prop.id,
|
|
289
|
+
onPropertyChanged: (_property, rawValue) => {
|
|
290
|
+
this.revisions.set(prop.id, (this.revisions.get(prop.id) ?? 0) + 1);
|
|
291
|
+
this.values.set(prop.id, rawValue);
|
|
292
|
+
this.refreshCharacteristics();
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
this.config.context.registerPropertyListener(listener);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
refreshCharacteristics() {
|
|
299
|
+
this.currentTempChar.updateValue(this.getAmbientTemperature());
|
|
300
|
+
this.currentHeatingCoolingChar.updateValue(this.deriveCurrentHeatingCoolingState());
|
|
301
|
+
this.targetHeatingCoolingChar.updateValue(this.deriveTargetHeatingCoolingState());
|
|
302
|
+
this.targetTempChar.updateValue(this.getTargetTemperature());
|
|
303
|
+
if (this.heatingThresholdChar && this.config.heaterTempProperty) {
|
|
304
|
+
const val = this.values.get(this.config.heaterTempProperty.id);
|
|
305
|
+
if (val !== null && val !== undefined) {
|
|
306
|
+
const num = Number(val);
|
|
307
|
+
if (!isNaN(num)) {
|
|
308
|
+
this.heatingThresholdChar.updateValue(num);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (this.coolingThresholdChar && this.config.coolerTempProperty) {
|
|
313
|
+
const val = this.values.get(this.config.coolerTempProperty.id);
|
|
314
|
+
if (val !== null && val !== undefined) {
|
|
315
|
+
const num = Number(val);
|
|
316
|
+
if (!isNaN(num)) {
|
|
317
|
+
this.coolingThresholdChar.updateValue(num);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (this.lockPhysicalControlsChar && this.config.lockedProperty) {
|
|
322
|
+
this.lockPhysicalControlsChar.updateValue(this.getLockPhysicalControls());
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
getLockPhysicalControls() {
|
|
326
|
+
if (!this.config.lockedProperty) {
|
|
327
|
+
return hap_nodejs_1.Characteristic.LockPhysicalControls.CONTROL_LOCK_DISABLED;
|
|
328
|
+
}
|
|
329
|
+
const val = this.values.get(this.config.lockedProperty.id);
|
|
330
|
+
return val === true || val === 'true' || val === 1 || val === 'locked'
|
|
331
|
+
? hap_nodejs_1.Characteristic.LockPhysicalControls.CONTROL_LOCK_ENABLED
|
|
332
|
+
: hap_nodejs_1.Characteristic.LockPhysicalControls.CONTROL_LOCK_DISABLED;
|
|
333
|
+
}
|
|
334
|
+
getAmbientTemperature() {
|
|
335
|
+
const val = this.values.get(this.config.ambientTempProperty.id);
|
|
336
|
+
if (val !== null && val !== undefined) {
|
|
337
|
+
const num = Number(val);
|
|
338
|
+
return !isNaN(num) ? num : 20;
|
|
339
|
+
}
|
|
340
|
+
return 20;
|
|
341
|
+
}
|
|
342
|
+
getTargetTemperature() {
|
|
343
|
+
const mode = this.deriveTargetHeatingCoolingState();
|
|
344
|
+
if (mode === hap_nodejs_1.Characteristic.TargetHeatingCoolingState.COOL && this.config.coolerTempProperty) {
|
|
345
|
+
const val = this.values.get(this.config.coolerTempProperty.id);
|
|
346
|
+
if (val !== null && val !== undefined) {
|
|
347
|
+
const num = Number(val);
|
|
348
|
+
return !isNaN(num) ? num : 25;
|
|
349
|
+
}
|
|
350
|
+
return 25;
|
|
351
|
+
}
|
|
352
|
+
if (this.config.heaterTempProperty) {
|
|
353
|
+
const val = this.values.get(this.config.heaterTempProperty.id);
|
|
354
|
+
if (val !== null && val !== undefined) {
|
|
355
|
+
const num = Number(val);
|
|
356
|
+
return !isNaN(num) ? num : 20;
|
|
357
|
+
}
|
|
358
|
+
return 20;
|
|
359
|
+
}
|
|
360
|
+
if (this.config.coolerTempProperty) {
|
|
361
|
+
const val = this.values.get(this.config.coolerTempProperty.id);
|
|
362
|
+
if (val !== null && val !== undefined) {
|
|
363
|
+
const num = Number(val);
|
|
364
|
+
return !isNaN(num) ? num : 25;
|
|
365
|
+
}
|
|
366
|
+
return 25;
|
|
367
|
+
}
|
|
368
|
+
return 20;
|
|
369
|
+
}
|
|
370
|
+
deriveCurrentHeatingCoolingState() {
|
|
371
|
+
const ambientTemp = this.getAmbientTemperature();
|
|
372
|
+
if (this.config.heaterOnProperty) {
|
|
373
|
+
const isOn = Boolean(this.values.get(this.config.heaterOnProperty.id));
|
|
374
|
+
if (isOn) {
|
|
375
|
+
const statusRaw = this.config.heaterStatusProperty
|
|
376
|
+
? this.values.get(this.config.heaterStatusProperty.id)
|
|
377
|
+
: undefined;
|
|
378
|
+
if (statusRaw === true || statusRaw === 'heating') {
|
|
379
|
+
return hap_nodejs_1.Characteristic.CurrentHeatingCoolingState.HEAT;
|
|
380
|
+
}
|
|
381
|
+
if (statusRaw === false || statusRaw === 'idle' || statusRaw === 'off') {
|
|
382
|
+
}
|
|
383
|
+
else if (statusRaw === undefined || statusRaw === null) {
|
|
384
|
+
const targetRaw = this.config.heaterTempProperty ? this.values.get(this.config.heaterTempProperty.id) : null;
|
|
385
|
+
const targetTemp = targetRaw !== null && targetRaw !== undefined ? Number(targetRaw) : NaN;
|
|
386
|
+
if (!isNaN(targetTemp) && targetTemp > ambientTemp) {
|
|
387
|
+
return hap_nodejs_1.Characteristic.CurrentHeatingCoolingState.HEAT;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (this.config.coolerOnProperty) {
|
|
393
|
+
const isOn = Boolean(this.values.get(this.config.coolerOnProperty.id));
|
|
394
|
+
if (isOn) {
|
|
395
|
+
const statusRaw = this.config.coolerStatusProperty
|
|
396
|
+
? this.values.get(this.config.coolerStatusProperty.id)
|
|
397
|
+
: undefined;
|
|
398
|
+
if (statusRaw === true || statusRaw === 'cooling') {
|
|
399
|
+
return hap_nodejs_1.Characteristic.CurrentHeatingCoolingState.COOL;
|
|
400
|
+
}
|
|
401
|
+
if (statusRaw === false || statusRaw === 'idle' || statusRaw === 'off') {
|
|
402
|
+
}
|
|
403
|
+
else if (statusRaw === undefined || statusRaw === null) {
|
|
404
|
+
const targetRaw = this.config.coolerTempProperty ? this.values.get(this.config.coolerTempProperty.id) : null;
|
|
405
|
+
const targetTemp = targetRaw !== null && targetRaw !== undefined ? Number(targetRaw) : NaN;
|
|
406
|
+
if (!isNaN(targetTemp) && targetTemp < ambientTemp) {
|
|
407
|
+
return hap_nodejs_1.Characteristic.CurrentHeatingCoolingState.COOL;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return hap_nodejs_1.Characteristic.CurrentHeatingCoolingState.OFF;
|
|
413
|
+
}
|
|
414
|
+
deriveTargetHeatingCoolingState() {
|
|
415
|
+
const heaterOn = this.config.heaterOnProperty ? Boolean(this.values.get(this.config.heaterOnProperty.id)) : false;
|
|
416
|
+
const coolerOn = this.config.coolerOnProperty ? Boolean(this.values.get(this.config.coolerOnProperty.id)) : false;
|
|
417
|
+
if (heaterOn && coolerOn) {
|
|
418
|
+
return hap_nodejs_1.Characteristic.TargetHeatingCoolingState.AUTO;
|
|
419
|
+
}
|
|
420
|
+
if (heaterOn) {
|
|
421
|
+
return hap_nodejs_1.Characteristic.TargetHeatingCoolingState.HEAT;
|
|
422
|
+
}
|
|
423
|
+
if (coolerOn) {
|
|
424
|
+
return hap_nodejs_1.Characteristic.TargetHeatingCoolingState.COOL;
|
|
425
|
+
}
|
|
426
|
+
return hap_nodejs_1.Characteristic.TargetHeatingCoolingState.OFF;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
exports.ThermostatCoordinator = ThermostatCoordinator;
|
|
430
|
+
//# sourceMappingURL=thermostat-coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thermostat-coordinator.js","sourceRoot":"","sources":["../../../../src/plugins/devices-homekit/mappers/thermostat-coordinator.ts"],"names":[],"mappings":";;;AAAA,uDAA6F;AAE7F,kFAA4E;AAsB5E,MAAa,qBAAqB;IAYjC,YAA6B,MAAmC;QAAnC,WAAM,GAAN,MAAM,CAA6B;QAX/C,WAAM,GAAG,IAAI,GAAG,EAAmB,CAAC;QACpC,cAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;QAWtD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAE3B,IAAI,CAAC,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC,2BAAc,CAAC,0BAA0B,CAAC,CAAC;QACtG,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,iBAAiB,CAAC,2BAAc,CAAC,yBAAyB,CAAC,CAAC;QACpG,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,2BAAc,CAAC,kBAAkB,CAAC,CAAC;QACpF,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,2BAAc,CAAC,iBAAiB,CAAC,CAAC;QAElF,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5B,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC9B,IAAI,CAAC,sBA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s';
|
|
2
|
+
import { DeviceEntity } from '../../../modules/devices/entities/devices.entity';
|
|
3
|
+
import { BaseHomeKitMapper } from './base.mapper';
|
|
4
|
+
import { HomeKitMapperContext } from './homekit-mapper.interface';
|
|
5
|
+
export declare class ThermostatMapper extends BaseHomeKitMapper {
|
|
6
|
+
canMap(device: DeviceEntity): boolean;
|
|
7
|
+
getSuggestedServiceType(_device: DeviceEntity): string;
|
|
8
|
+
buildAccessory(device: DeviceEntity, context: HomeKitMapperContext): Accessory | null;
|
|
9
|
+
private findAmbientTemperature;
|
|
10
|
+
private isValidHeaterOrCoolerChannel;
|
|
11
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThermostatMapper = void 0;
|
|
4
|
+
const hap_nodejs_1 = require("@homebridge/hap-nodejs");
|
|
5
|
+
const devices_constants_1 = require("../../../modules/devices/devices.constants");
|
|
6
|
+
const base_mapper_1 = require("./base.mapper");
|
|
7
|
+
const thermostat_coordinator_1 = require("./thermostat-coordinator");
|
|
8
|
+
class ThermostatMapper extends base_mapper_1.BaseHomeKitMapper {
|
|
9
|
+
canMap(device) {
|
|
10
|
+
const ambient = this.findAmbientTemperature(device);
|
|
11
|
+
if (!ambient) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const heaterChannel = this.findChannel(device, devices_constants_1.ChannelCategory.HEATER) ?? this.findChannel(device, devices_constants_1.ChannelCategory.THERMOSTAT);
|
|
15
|
+
const coolerChannel = this.findChannel(device, devices_constants_1.ChannelCategory.COOLER);
|
|
16
|
+
return this.isValidHeaterOrCoolerChannel(heaterChannel) || this.isValidHeaterOrCoolerChannel(coolerChannel);
|
|
17
|
+
}
|
|
18
|
+
getSuggestedServiceType(_device) {
|
|
19
|
+
return 'thermostat';
|
|
20
|
+
}
|
|
21
|
+
buildAccessory(device, context) {
|
|
22
|
+
const ambient = this.findAmbientTemperature(device);
|
|
23
|
+
if (!ambient) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const heaterChannel = this.findChannel(device, devices_constants_1.ChannelCategory.HEATER) ?? this.findChannel(device, devices_constants_1.ChannelCategory.THERMOSTAT);
|
|
27
|
+
const coolerChannel = this.findChannel(device, devices_constants_1.ChannelCategory.COOLER);
|
|
28
|
+
const validHeater = this.isValidHeaterOrCoolerChannel(heaterChannel) ? heaterChannel : undefined;
|
|
29
|
+
const validCooler = this.isValidHeaterOrCoolerChannel(coolerChannel) ? coolerChannel : undefined;
|
|
30
|
+
if (!validHeater && !validCooler) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const accessory = this.createBaseAccessory(device, 9);
|
|
34
|
+
const service = accessory.addService(hap_nodejs_1.Service.Thermostat, device.name);
|
|
35
|
+
service
|
|
36
|
+
.getCharacteristic(hap_nodejs_1.Characteristic.TemperatureDisplayUnits)
|
|
37
|
+
.onGet(() => hap_nodejs_1.Characteristic.TemperatureDisplayUnits.CELSIUS);
|
|
38
|
+
const thermostatChannel = this.findChannel(device, devices_constants_1.ChannelCategory.THERMOSTAT);
|
|
39
|
+
const lockedProp = (thermostatChannel && this.findProperty(thermostatChannel, devices_constants_1.PropertyCategory.LOCKED)) ??
|
|
40
|
+
(validHeater && this.findProperty(validHeater, devices_constants_1.PropertyCategory.LOCKED)) ??
|
|
41
|
+
(validCooler && this.findProperty(validCooler, devices_constants_1.PropertyCategory.LOCKED)) ??
|
|
42
|
+
(ambient.channel && this.findProperty(ambient.channel, devices_constants_1.PropertyCategory.LOCKED));
|
|
43
|
+
new thermostat_coordinator_1.ThermostatCoordinator({
|
|
44
|
+
device,
|
|
45
|
+
service,
|
|
46
|
+
context,
|
|
47
|
+
ambientTempChannel: ambient.channel,
|
|
48
|
+
ambientTempProperty: ambient.property,
|
|
49
|
+
heaterChannel: validHeater,
|
|
50
|
+
heaterOnProperty: validHeater ? this.findProperty(validHeater, devices_constants_1.PropertyCategory.ON) : undefined,
|
|
51
|
+
heaterTempProperty: validHeater ? this.findProperty(validHeater, devices_constants_1.PropertyCategory.TEMPERATURE) : undefined,
|
|
52
|
+
heaterStatusProperty: validHeater ? this.findProperty(validHeater, devices_constants_1.PropertyCategory.STATUS) : undefined,
|
|
53
|
+
coolerChannel: validCooler,
|
|
54
|
+
coolerOnProperty: validCooler ? this.findProperty(validCooler, devices_constants_1.PropertyCategory.ON) : undefined,
|
|
55
|
+
coolerTempProperty: validCooler ? this.findProperty(validCooler, devices_constants_1.PropertyCategory.TEMPERATURE) : undefined,
|
|
56
|
+
coolerStatusProperty: validCooler ? this.findProperty(validCooler, devices_constants_1.PropertyCategory.STATUS) : undefined,
|
|
57
|
+
lockedProperty: lockedProp,
|
|
58
|
+
});
|
|
59
|
+
return accessory;
|
|
60
|
+
}
|
|
61
|
+
findAmbientTemperature(device) {
|
|
62
|
+
const tempChannel = this.findChannel(device, devices_constants_1.ChannelCategory.TEMPERATURE);
|
|
63
|
+
if (tempChannel) {
|
|
64
|
+
const tempProp = this.findProperty(tempChannel, devices_constants_1.PropertyCategory.TEMPERATURE);
|
|
65
|
+
if (tempProp &&
|
|
66
|
+
tempProp.permissions.includes(devices_constants_1.PermissionType.READ_ONLY) &&
|
|
67
|
+
!tempProp.permissions.includes(devices_constants_1.PermissionType.READ_WRITE)) {
|
|
68
|
+
return { channel: tempChannel, property: tempProp };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const ch of device.channels ?? []) {
|
|
72
|
+
if (ch.category === devices_constants_1.ChannelCategory.HEATER ||
|
|
73
|
+
ch.category === devices_constants_1.ChannelCategory.COOLER ||
|
|
74
|
+
ch.category === devices_constants_1.ChannelCategory.THERMOSTAT) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const prop = this.findProperty(ch, devices_constants_1.PropertyCategory.TEMPERATURE);
|
|
78
|
+
if (prop &&
|
|
79
|
+
prop.permissions.includes(devices_constants_1.PermissionType.READ_ONLY) &&
|
|
80
|
+
!prop.permissions.includes(devices_constants_1.PermissionType.READ_WRITE)) {
|
|
81
|
+
return { channel: ch, property: prop };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
isValidHeaterOrCoolerChannel(channel) {
|
|
87
|
+
if (!channel) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
const onProp = this.findProperty(channel, devices_constants_1.PropertyCategory.ON);
|
|
91
|
+
const tempProp = this.findProperty(channel, devices_constants_1.PropertyCategory.TEMPERATURE);
|
|
92
|
+
const isWritable = (p) => !!p && p.permissions.some((perm) => [devices_constants_1.PermissionType.READ_WRITE, devices_constants_1.PermissionType.WRITE_ONLY].includes(perm));
|
|
93
|
+
return isWritable(onProp) && isWritable(tempProp);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.ThermostatMapper = ThermostatMapper;
|
|
97
|
+
//# sourceMappingURL=thermostat.mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thermostat.mapper.js","sourceRoot":"","sources":["../../../../src/plugins/devices-homekit/mappers/thermostat.mapper.ts"],"names":[],"mappings":";;;AAAA,uDAAwF;AAExF,kFAA+G;AAG/G,+CAAkD;AAElD,qEAAiE;AAEjE,MAAa,gBAAiB,SAAQ,+BAAiB;IACtD,MAAM,CAAC,MAAoB;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,KAAK,CAAC;QACd,CAAC;QAED,MAAM,aAAa,GAClB,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,mCAAe,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,mCAAe,CAAC,UAAU,CAAC,CAAC;QAC1G,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,mCAAe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oCAAgB,CAAC,WAAW,CAAC,CAAC;YACjE,IACC,IAAI;gBACJ,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,kCAAc,CAAC,SAAS,CAAC;gBACnD,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,kCAAc,CAAC,UAAU,CAAC,EACpD,CAAC;gBACF,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACxC,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAEO,4BAA4B,CAAC,OAAuB;QAC3D,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,KAAK,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,oCAAgB,CAAC,EAAE,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,oCAAgB,CAAC,WAAW,CAAC,CAAC;QAC1E,MAAM,UAAU,GAAG,CAAC,CAAyB,EAAE,EAAE,CAChD,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,kCAAc,CAAC,UAAU,EAAE,kCAAc,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAE5G,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;CACD;AArHD,4CAqHC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Accessory } from '@homebridge/hap-nodejs';
|
|
2
|
+
import { DeviceEntity } from '../../../modules/devices/entities/devices.entity';
|
|
3
|
+
import { BaseHomeKitMapper } from './base.mapper';
|
|
4
|
+
import { HomeKitMapperContext } from './homekit-mapper.interface';
|
|
5
|
+
export declare class WindowCoveringMapper extends BaseHomeKitMapper {
|
|
6
|
+
canMap(device: DeviceEntity): boolean;
|
|
7
|
+
getSuggestedServiceType(_device: DeviceEntity): string;
|
|
8
|
+
buildAccessory(device: DeviceEntity, context: HomeKitMapperContext): Accessory | null;
|
|
9
|
+
private isValidCoveringChannel;
|
|
10
|
+
}
|