How to use the hap-nodejs.Characteristic.ContactSensorState function in hap-nodejs

To help you get started, we’ve selected a few hap-nodejs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github htreu / OpenHAB-HomeKit-Bridge / lib / Text.js View on Github external
stateValue(state) {
    switch (this.textType) {

    case 'temperature':
      if ('Uninitialized' === state) {
        return 0.0;
      }
      return +state;

    case 'contact':
      if ('CLOSED' === state) {
        return Characteristic.ContactSensorState.CONTACT_DETECTED;
      }
      // fall back to 'no contact' if uninitialized or OPEN
      return Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;

    default:
      // For generic text values, we use labels rather than state
      return '';
    }
  };
github htreu / OpenHAB-HomeKit-Bridge / lib / ContactSensor.js View on Github external
convertState(state) {
    if ('CLOSED' === state) {
      return Characteristic.ContactSensorState.CONTACT_DETECTED;
    }
    // fall back to 'no contact' if uninitialized or OPEN
    return Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
  }
}
github htreu / OpenHAB-HomeKit-Bridge / lib / ContactSensor.js View on Github external
convertState(state) {
    if ('CLOSED' === state) {
      return Characteristic.ContactSensorState.CONTACT_DETECTED;
    }
    // fall back to 'no contact' if uninitialized or OPEN
    return Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
  }
}
github htreu / OpenHAB-HomeKit-Bridge / lib / Text.js View on Github external
buildAccessory(state, name) {
    let accessory = new Accessory(this.name,
      uuid.generate(this.constructor.name + this.name));

    let service = CustomServices.TextInfoService;
    let characteristic = CustomCharacteristics.TextInfoCharacteristic;
    let initialValue = this.labelValue(name);

    switch (this.textType) {

    case 'contact':
      service = Service.ContactSensor;
      characteristic = Characteristic.ContactSensorState;
      initialValue = this.stateValue(state);
      break;

    case 'temperature':
      service = Service.TemperatureSensor;
      characteristic = Characteristic.CurrentTemperature;
      initialValue = this.stateValue(state);
    }

    this.characteristic = accessory.addService(service, this.name).getCharacteristic(characteristic);
    this.characteristic.on('get', this.readOpenHabText.bind(this));
    this.characteristic.setValue(initialValue);

    return accessory;
  };
github nfarina / homebridge / accessories / FileSensor.js View on Github external
changeAction = function(newState){
            service.getCharacteristic(Characteristic.ContactSensorState)
                    .setValue(newState ? Characteristic.ContactSensorState.CONTACT_DETECTED : Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
        };
    } else {
github SphtKr / homebridge-zway / isy-js.js View on Github external
ISYDoorWindowSensorAccessory.prototype.handleExternalChange = function() {
	this.sensorService
		.setCharacteristic(Characteristic.ContactSensorState, this.translateCurrentDoorWindowState());
}
github nfarina / homebridge / accessories / FileSensor.js View on Github external
changeAction = function(newState){
            service.getCharacteristic(Characteristic.ContactSensorState)
                    .setValue(newState ? Characteristic.ContactSensorState.CONTACT_DETECTED : Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
        };
    } else {
github SphtKr / homebridge-zway / isy-js.js View on Github external
ISYDoorWindowSensorAccessory.prototype.translateCurrentDoorWindowState = function() {
	return (this.device.getCurrentDoorWindowState()) ? Characteristic.ContactSensorState.CONTACT_NOT_DETECTED : Characteristic.ContactSensorState.CONTACT_DETECTED;	
}
github htreu / OpenHAB-HomeKit-Bridge / lib / ContactSensor.js View on Github external
buildAccessory(state) {
    let accessory = new Accessory(this.name,
      uuid.generate(this.constructor.name + this.name));

    let charactersiticContactState = accessory
      .addService(Service.ContactSensor, this.name)
      .getCharacteristic(Characteristic.ContactSensorState);

    charactersiticContactState.setValue(this.convertState(state));
    charactersiticContactState.on('get', this.readOpenHabContact.bind(this));

    return accessory;
  }