Skip to content

Commit

Permalink
Fix inverted glass break sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
chase9 committed Oct 15, 2023
1 parent 3d7c957 commit 83e8d44
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1785,11 +1785,15 @@ function getPartitionState(state: number): number {
function getSensorState(sensor: SensorState): CharacteristicValue {
// Some sensors remain "open" until they are disrupted and need special treatment.
if (sensor.attributes.deviceType == SensorType.Heat_Detector) {
if (sensor.attributes.state === 0) {
return hapCharacteristic.SmokeDetected.SMOKE_NOT_DETECTED;
} else {
return hapCharacteristic.SmokeDetected.SMOKE_DETECTED;
}
return sensor.attributes.state === 0
? hapCharacteristic.SmokeDetected.SMOKE_NOT_DETECTED
: hapCharacteristic.SmokeDetected.SMOKE_DETECTED;
}

if (sensor.attributes.deviceType == SensorType.Glass_Break) {
return sensor.attributes.state === 2
? hapCharacteristic.ContactSensorState.CONTACT_DETECTED
: hapCharacteristic.ContactSensorState.CONTACT_NOT_DETECTED;
}

switch (sensor.attributes.state) {
Expand Down

0 comments on commit 83e8d44

Please sign in to comment.