Update Accessories
This commit is contained in:
+13
-10
@@ -87,16 +87,19 @@ export class motionSensorAccessory extends accessory {
|
||||
.then((response) => {
|
||||
const devices = JSON.parse(response.body)
|
||||
|
||||
for (const device of devices.motion) {
|
||||
if (device.id == this.accessory.context.device.typeId) {
|
||||
if (device.state == 'absent') {
|
||||
this.state.Motion = false
|
||||
} else { // present
|
||||
this.state.Motion = true
|
||||
if (devices.hasOwnProperty('motion')) {
|
||||
for (const device of devices.motion) {
|
||||
if (device.id == this.accessory.context.device.typeId) {
|
||||
if (device.state == 'absent') {
|
||||
this.state.Motion = false
|
||||
} else { // present
|
||||
this.state.Motion = true
|
||||
}
|
||||
|
||||
this.service.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.state.Motion)
|
||||
|
||||
break
|
||||
}
|
||||
return this.state.Motion
|
||||
this.service.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.state.Motion)
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -108,4 +111,4 @@ export class motionSensorAccessory extends accessory {
|
||||
getState(): CharacteristicValue {
|
||||
return this.state.Motion
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user