Skip to content

Commit

Permalink
Fixed several bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mfkrause committed Jan 22, 2021
1 parent eca184d commit 247038f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions base/accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class SunsensorAccessory {

if (SensorService) {
SensorService.getCharacteristic(Characteristic.OccupancyDetected);

SensorService.setCharacteristic(Characteristic.OccupancyDetected, this.updateState());
setInterval(() => {
SensorService.setCharacteristic(Characteristic.OccupancyDetected, this.updateState());
}, 10000);
}

this.setAccessory(accessory);
Expand All @@ -61,6 +56,11 @@ class SunsensorAccessory {
SensorService
.getCharacteristic(Characteristic.OccupancyDetected)
.on('get', this.getState.bind(this));

SensorService.setCharacteristic(Characteristic.OccupancyDetected, this.updateState());
setInterval(() => {
SensorService.setCharacteristic(Characteristic.OccupancyDetected, this.updateState());
}, 10000);
}
}

Expand Down
6 changes: 4 additions & 2 deletions base/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class SunsensorPlatform {
(sensor) => sensor.name === accessory.displayName,
);
if (
!sensorConfig.lowerThreshold
|| !sensorConfig.upperThreshold
sensorConfig.lowerThreshold === undefined
|| sensorConfig.upperThreshold === undefined
|| typeof sensorConfig.lowerThreshold !== 'number'
|| typeof sensorConfig.upperThreshold !== 'number'
|| sensorConfig.lowerThreshold > 720
Expand All @@ -65,6 +65,8 @@ class SunsensorPlatform {
log('Could not unregister platform accessory!', e);
}
} else {
const sensor = this.sensors[sensorConfig.name];
sensor.setAccessory(accessory);
tempAccessories.push(accessory);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-sunsensors",
"version": "0.1.1",
"version": "0.1.2",
"description": "Homebridge plugin to set-up sensors which monitor the current sun position.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 247038f

Please sign in to comment.