Skip to content

Commit

Permalink
set hap status no response if hvac offline
Browse files Browse the repository at this point in the history
  • Loading branch information
jxg81 committed Aug 19, 2022
1 parent 8e1575f commit 27f3cff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"displayName": "Homebridge Actron Que",
"name": "homebridge-actron-que",
"version": "1.2.0",
"version": "1.2.1",
"description": "Homebridge plugin for controlling Actron Que controller systems",
"license": "Apache-2.0",
"repository": {
Expand Down
14 changes: 13 additions & 1 deletion src/masterControllerAccessory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
import { Service, PlatformAccessory, CharacteristicValue, HAPStatus } from 'homebridge';
import { ClimateMode, CompressorMode, FanMode, PowerState } from './types';
import { ActronQuePlatform } from './platform';

Expand Down Expand Up @@ -107,13 +107,21 @@ export class MasterControllerAccessory {
this.humidityService.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.getHumidity());
}

checkHvacComms() {
if (!this.platform.hvacInstance.cloudConnected) {
this.platform.log.error('Master Controller is offline. Check Master Controller Internet/Wifi connection');
throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
}
}

getHumidity(): CharacteristicValue {
const currentHumidity = this.platform.hvacInstance.masterHumidity;
// this.platform.log.debug('Got Master Humidity -> ', currentHumidity);
return currentHumidity;
}

async setPowerState(value: CharacteristicValue) {
this.checkHvacComms();
switch (value) {
case 0:
await this.platform.hvacInstance.setPowerStateOff();
Expand Down Expand Up @@ -157,6 +165,7 @@ export class MasterControllerAccessory {
}

async setTargetClimateMode(value: CharacteristicValue) {
this.checkHvacComms();
switch (value) {
case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
await this.platform.hvacInstance.setClimateModeAuto();
Expand Down Expand Up @@ -201,6 +210,7 @@ export class MasterControllerAccessory {
}

async setHeatingThresholdTemperature(value: CharacteristicValue) {
this.checkHvacComms();
if (this.platform.hvacInstance.controlAllZones === false &&
this.platform.hvacInstance.zonesFollowMaster === true) {
await this.platform.hvacInstance.setControlAllZonesOn();
Expand All @@ -217,6 +227,7 @@ export class MasterControllerAccessory {
}

async setCoolingThresholdTemperature(value: CharacteristicValue) {
this.checkHvacComms();
if (this.platform.hvacInstance.controlAllZones === false &&
this.platform.hvacInstance.zonesFollowMaster === true) {
await this.platform.hvacInstance.setControlAllZonesOn();
Expand All @@ -233,6 +244,7 @@ export class MasterControllerAccessory {
}

async setFanMode(value: CharacteristicValue) {
this.checkHvacComms();
switch (true) {
case (value <= 30):
await this.platform.hvacInstance.setFanModeLow();
Expand Down
13 changes: 12 additions & 1 deletion src/zoneControllerAccessory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
import { Service, PlatformAccessory, CharacteristicValue, HAPStatus } from 'homebridge';
import { ClimateMode, CompressorMode } from './types';
import { ActronQuePlatform } from './platform';
import { HvacZone } from './hvacZone';
Expand Down Expand Up @@ -109,6 +109,13 @@ export class ZoneControllerAccessory {
}
}

checkHvacComms() {
if (!this.platform.hvacInstance.cloudConnected) {
this.platform.log.error('Master Controller is offline. Check Master Controller Internet/Wifi connection');
throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
}
}

getHumidity(): CharacteristicValue {
const currentHumidity = this.zone.currentHumidity;
// this.platform.log.debug(`Got Zone ${this.zone.zoneName} Humidity -> `, currentHumidity);
Expand All @@ -129,6 +136,7 @@ export class ZoneControllerAccessory {
}

async setEnableState(value: CharacteristicValue) {
this.checkHvacComms();
switch (value) {
case 0:
await this.zone.setZoneDisable();
Expand Down Expand Up @@ -172,6 +180,7 @@ export class ZoneControllerAccessory {
}

async setTargetClimateMode(value: CharacteristicValue) {
this.checkHvacComms();
switch (value) {
case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
await this.platform.hvacInstance.setClimateModeAuto();
Expand Down Expand Up @@ -214,6 +223,7 @@ export class ZoneControllerAccessory {
}

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

async setCoolingThresholdTemperature(value: CharacteristicValue) {
this.checkHvacComms();
if (this.platform.hvacInstance.zonesPushMaster === true) {
if (value > this.zone.maxCoolSetPoint) {
await this.platform.hvacInstance.setCoolTemp(value as number + 2);
Expand Down

0 comments on commit 27f3cff

Please sign in to comment.