diff --git a/package.json b/package.json index 67fa28b..7145fa4 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/masterControllerAccessory.ts b/src/masterControllerAccessory.ts index 03256a5..635a85c 100644 --- a/src/masterControllerAccessory.ts +++ b/src/masterControllerAccessory.ts @@ -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'; @@ -107,6 +107,13 @@ 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); @@ -114,6 +121,7 @@ export class MasterControllerAccessory { } async setPowerState(value: CharacteristicValue) { + this.checkHvacComms(); switch (value) { case 0: await this.platform.hvacInstance.setPowerStateOff(); @@ -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(); @@ -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(); @@ -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(); @@ -233,6 +244,7 @@ export class MasterControllerAccessory { } async setFanMode(value: CharacteristicValue) { + this.checkHvacComms(); switch (true) { case (value <= 30): await this.platform.hvacInstance.setFanModeLow(); diff --git a/src/zoneControllerAccessory.ts b/src/zoneControllerAccessory.ts index e07bf96..291d5e9 100644 --- a/src/zoneControllerAccessory.ts +++ b/src/zoneControllerAccessory.ts @@ -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'; @@ -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); @@ -129,6 +136,7 @@ export class ZoneControllerAccessory { } async setEnableState(value: CharacteristicValue) { + this.checkHvacComms(); switch (value) { case 0: await this.zone.setZoneDisable(); @@ -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(); @@ -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); @@ -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);