1- import { Service , PlatformAccessory , CharacteristicValue } from 'homebridge' ;
1+ import { Service , PlatformAccessory , CharacteristicValue , HAPStatus } from 'homebridge' ;
22import { ClimateMode , CompressorMode , FanMode , PowerState } from './types' ;
33import { 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 ( ) ;
0 commit comments