Skip to content

Commit 1bc1f28

Browse files
fix: minimum lux value and duplicate serial numbers
1 parent 37b1c0d commit 1bc1f28

File tree

6 files changed

+16
-17
lines changed

6 files changed

+16
-17
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "homebridge-omnik",
33
"displayName": "Omnik Inverter",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"description": "Add your Omnik-Inverter to Homekit",
66
"license": "Apache-2.0",
77
"author": "Jasper Seinhorst",

src/Accessories/CurrentPowerProduction.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export default class CurrentPowerProduction implements OmnikAccessory {
1010
this.accessory.getService(this.Service.AccessoryInformation)
1111
.setCharacteristic(this.Characteristic.Manufacturer, 'Omnik')
1212
.setCharacteristic(this.Characteristic.Model, device.name)
13-
.setCharacteristic(this.Characteristic.SerialNumber, device.serial);
14-
15-
13+
.setCharacteristic(this.Characteristic.SerialNumber, `${device.serial}-power-production`);
1614
this.powerService = this.accessory.getService(this.Service.LightSensor) || this.accessory.addService(this.Service.LightSensor);
1715
}
1816

1917
public beat(powerProduction: PowerProduction) {
18+
const minimumValue = 0.0001;
2019
const consumption = powerProduction.now;
21-
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, consumption);
20+
const newValue = consumption > minimumValue ? consumption : minimumValue;
21+
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, newValue);
2222
}
2323
}

src/Accessories/TodayYield.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export default class TodayYield implements OmnikAccessory {
1010
this.accessory.getService(this.Service.AccessoryInformation)
1111
.setCharacteristic(this.Characteristic.Manufacturer, 'Omnik')
1212
.setCharacteristic(this.Characteristic.Model, device.name)
13-
.setCharacteristic(this.Characteristic.SerialNumber, device.serial);
14-
15-
13+
.setCharacteristic(this.Characteristic.SerialNumber, `${device.serial}-today-yield`);
1614
this.powerService = this.accessory.getService(this.Service.LightSensor) || this.accessory.addService(this.Service.LightSensor);
1715
}
1816

1917
public beat(powerProduction: PowerProduction) {
18+
const minimumValue = 0.0001;
2019
const consumption = powerProduction.today / 100;
21-
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, consumption);
20+
const newValue = consumption > minimumValue ? consumption : minimumValue;
21+
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, newValue);
2222
}
2323
}

src/Accessories/TotalYield.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export default class TotalYield implements OmnikAccessory {
1010
this.accessory.getService(this.Service.AccessoryInformation)
1111
.setCharacteristic(this.Characteristic.Manufacturer, 'Omnik')
1212
.setCharacteristic(this.Characteristic.Model, device.name)
13-
.setCharacteristic(this.Characteristic.SerialNumber, device.serial);
14-
15-
13+
.setCharacteristic(this.Characteristic.SerialNumber, `${device.serial}-total-yield`);
1614
this.powerService = this.accessory.getService(this.Service.LightSensor) || this.accessory.addService(this.Service.LightSensor);
1715
}
1816

1917
public beat(powerProduction: PowerProduction) {
18+
const minimumValue = 0.0001;
2019
const consumption = powerProduction.total / 10;
21-
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, consumption);
20+
const newValue = consumption > minimumValue ? consumption : minimumValue;
21+
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, newValue);
2222
}
2323
}

src/Platform.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ export class OmnikPlugin implements DynamicPlatformPlugin {
99
public readonly Service: typeof Service = this.api.hap.Service;
1010
public readonly Characteristic: typeof Characteristic = this.api.hap.Characteristic;
1111
public readonly accessories: PlatformAccessory[] = [];
12-
private heartBeatInterval;
12+
private heartBeatInterval: number;
1313
private devices: OmnikAccessory[] = [];
1414
private omnikApi: OmnikApi;
1515
private device: OmnikDevice;
1616

17-
1817
constructor(public readonly log: Logger, public readonly config: PlatformConfig, public readonly api: API) {
1918
this.heartBeatInterval = (config.pollInterval || 5) * 60 * 1000; // minutes to miliseconds
2019
this.api.on('didFinishLaunching', () => {

0 commit comments

Comments
 (0)