Skip to content

Commit

Permalink
fix: minimum lux value and duplicate serial numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper-seinhorst committed Mar 24, 2024
1 parent 37b1c0d commit 1bc1f28
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "homebridge-omnik",
"displayName": "Omnik Inverter",
"version": "1.2.0",
"version": "1.2.1",
"description": "Add your Omnik-Inverter to Homekit",
"license": "Apache-2.0",
"author": "Jasper Seinhorst",
Expand Down
8 changes: 4 additions & 4 deletions src/Accessories/CurrentPowerProduction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export default class CurrentPowerProduction implements OmnikAccessory {
this.accessory.getService(this.Service.AccessoryInformation)
.setCharacteristic(this.Characteristic.Manufacturer, 'Omnik')
.setCharacteristic(this.Characteristic.Model, device.name)
.setCharacteristic(this.Characteristic.SerialNumber, device.serial);


.setCharacteristic(this.Characteristic.SerialNumber, `${device.serial}-power-production`);
this.powerService = this.accessory.getService(this.Service.LightSensor) || this.accessory.addService(this.Service.LightSensor);
}

public beat(powerProduction: PowerProduction) {
const minimumValue = 0.0001;
const consumption = powerProduction.now;
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, consumption);
const newValue = consumption > minimumValue ? consumption : minimumValue;
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, newValue);
}
}
8 changes: 4 additions & 4 deletions src/Accessories/TodayYield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export default class TodayYield implements OmnikAccessory {
this.accessory.getService(this.Service.AccessoryInformation)
.setCharacteristic(this.Characteristic.Manufacturer, 'Omnik')
.setCharacteristic(this.Characteristic.Model, device.name)
.setCharacteristic(this.Characteristic.SerialNumber, device.serial);


.setCharacteristic(this.Characteristic.SerialNumber, `${device.serial}-today-yield`);
this.powerService = this.accessory.getService(this.Service.LightSensor) || this.accessory.addService(this.Service.LightSensor);
}

public beat(powerProduction: PowerProduction) {
const minimumValue = 0.0001;
const consumption = powerProduction.today / 100;
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, consumption);
const newValue = consumption > minimumValue ? consumption : minimumValue;
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, newValue);
}
}
8 changes: 4 additions & 4 deletions src/Accessories/TotalYield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export default class TotalYield implements OmnikAccessory {
this.accessory.getService(this.Service.AccessoryInformation)
.setCharacteristic(this.Characteristic.Manufacturer, 'Omnik')
.setCharacteristic(this.Characteristic.Model, device.name)
.setCharacteristic(this.Characteristic.SerialNumber, device.serial);


.setCharacteristic(this.Characteristic.SerialNumber, `${device.serial}-total-yield`);
this.powerService = this.accessory.getService(this.Service.LightSensor) || this.accessory.addService(this.Service.LightSensor);
}

public beat(powerProduction: PowerProduction) {
const minimumValue = 0.0001;
const consumption = powerProduction.total / 10;
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, consumption);
const newValue = consumption > minimumValue ? consumption : minimumValue;
this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, newValue);
}
}
3 changes: 1 addition & 2 deletions src/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ export class OmnikPlugin implements DynamicPlatformPlugin {
public readonly Service: typeof Service = this.api.hap.Service;
public readonly Characteristic: typeof Characteristic = this.api.hap.Characteristic;
public readonly accessories: PlatformAccessory[] = [];
private heartBeatInterval;
private heartBeatInterval: number;
private devices: OmnikAccessory[] = [];
private omnikApi: OmnikApi;
private device: OmnikDevice;


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

0 comments on commit 1bc1f28

Please sign in to comment.