Skip to content

Commit 27f3cff

Browse files
committed
set hap status no response if hvac offline
1 parent 8e1575f commit 27f3cff

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": false,
33
"displayName": "Homebridge Actron Que",
44
"name": "homebridge-actron-que",
5-
"version": "1.2.0",
5+
"version": "1.2.1",
66
"description": "Homebridge plugin for controlling Actron Que controller systems",
77
"license": "Apache-2.0",
88
"repository": {

src/masterControllerAccessory.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
1+
import { Service, PlatformAccessory, CharacteristicValue, HAPStatus } from 'homebridge';
22
import { ClimateMode, CompressorMode, FanMode, PowerState } from './types';
33
import { ActronQuePlatform } from './platform';
44

@@ -107,13 +107,21 @@ export class MasterControllerAccessory {
107107
this.humidityService.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.getHumidity());
108108
}
109109

110+
checkHvacComms() {
111+
if (!this.platform.hvacInstance.cloudConnected) {
112+
this.platform.log.error('Master Controller is offline. Check Master Controller Internet/Wifi connection');
113+
throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
114+
}
115+
}
116+
110117
getHumidity(): CharacteristicValue {
111118
const currentHumidity = this.platform.hvacInstance.masterHumidity;
112119
// this.platform.log.debug('Got Master Humidity -> ', currentHumidity);
113120
return currentHumidity;
114121
}
115122

116123
async setPowerState(value: CharacteristicValue) {
124+
this.checkHvacComms();
117125
switch (value) {
118126
case 0:
119127
await this.platform.hvacInstance.setPowerStateOff();
@@ -157,6 +165,7 @@ export class MasterControllerAccessory {
157165
}
158166

159167
async setTargetClimateMode(value: CharacteristicValue) {
168+
this.checkHvacComms();
160169
switch (value) {
161170
case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
162171
await this.platform.hvacInstance.setClimateModeAuto();
@@ -201,6 +210,7 @@ export class MasterControllerAccessory {
201210
}
202211

203212
async setHeatingThresholdTemperature(value: CharacteristicValue) {
213+
this.checkHvacComms();
204214
if (this.platform.hvacInstance.controlAllZones === false &&
205215
this.platform.hvacInstance.zonesFollowMaster === true) {
206216
await this.platform.hvacInstance.setControlAllZonesOn();
@@ -217,6 +227,7 @@ export class MasterControllerAccessory {
217227
}
218228

219229
async setCoolingThresholdTemperature(value: CharacteristicValue) {
230+
this.checkHvacComms();
220231
if (this.platform.hvacInstance.controlAllZones === false &&
221232
this.platform.hvacInstance.zonesFollowMaster === true) {
222233
await this.platform.hvacInstance.setControlAllZonesOn();
@@ -233,6 +244,7 @@ export class MasterControllerAccessory {
233244
}
234245

235246
async setFanMode(value: CharacteristicValue) {
247+
this.checkHvacComms();
236248
switch (true) {
237249
case (value <= 30):
238250
await this.platform.hvacInstance.setFanModeLow();

src/zoneControllerAccessory.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
1+
import { Service, PlatformAccessory, CharacteristicValue, HAPStatus } from 'homebridge';
22
import { ClimateMode, CompressorMode } from './types';
33
import { ActronQuePlatform } from './platform';
44
import { HvacZone } from './hvacZone';
@@ -109,6 +109,13 @@ export class ZoneControllerAccessory {
109109
}
110110
}
111111

112+
checkHvacComms() {
113+
if (!this.platform.hvacInstance.cloudConnected) {
114+
this.platform.log.error('Master Controller is offline. Check Master Controller Internet/Wifi connection');
115+
throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
116+
}
117+
}
118+
112119
getHumidity(): CharacteristicValue {
113120
const currentHumidity = this.zone.currentHumidity;
114121
// this.platform.log.debug(`Got Zone ${this.zone.zoneName} Humidity -> `, currentHumidity);
@@ -129,6 +136,7 @@ export class ZoneControllerAccessory {
129136
}
130137

131138
async setEnableState(value: CharacteristicValue) {
139+
this.checkHvacComms();
132140
switch (value) {
133141
case 0:
134142
await this.zone.setZoneDisable();
@@ -172,6 +180,7 @@ export class ZoneControllerAccessory {
172180
}
173181

174182
async setTargetClimateMode(value: CharacteristicValue) {
183+
this.checkHvacComms();
175184
switch (value) {
176185
case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
177186
await this.platform.hvacInstance.setClimateModeAuto();
@@ -214,6 +223,7 @@ export class ZoneControllerAccessory {
214223
}
215224

216225
async setHeatingThresholdTemperature(value: CharacteristicValue) {
226+
this.checkHvacComms();
217227
if (this.platform.hvacInstance.zonesPushMaster === true) {
218228
if (value > this.zone.maxHeatSetPoint) {
219229
await this.platform.hvacInstance.setHeatTemp(value as number);
@@ -239,6 +249,7 @@ export class ZoneControllerAccessory {
239249
}
240250

241251
async setCoolingThresholdTemperature(value: CharacteristicValue) {
252+
this.checkHvacComms();
242253
if (this.platform.hvacInstance.zonesPushMaster === true) {
243254
if (value > this.zone.maxCoolSetPoint) {
244255
await this.platform.hvacInstance.setCoolTemp(value as number + 2);

0 commit comments

Comments
 (0)