Skip to content

Commit

Permalink
feat: add pollInterval option
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper-seinhorst committed Mar 24, 2024
1 parent db72526 commit 677cfcd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![npm](https://img.shields.io/npm/dt/homebridge-omnik.svg)](https://www.npmjs.com/package/homebridge-omnik)
[![npm](https://img.shields.io/npm/v/homebridge-omnik.svg)](https://www.npmjs.com/package/homebridge-omnik)

This Homebridge plugin connects your Omnik Converter with Homekit. The plugin provides three key sensors: Current Power Production, Today's Yield, and Total Yield. With these sensors, you can effortlessly create automations in your Apple Home based on your solar panel yield.
This Homebridge plugin connects your Omnik Converter with Homekit. The plugin provides three key sensors: Current Power Production (in Watts), Today's Yield (in kWh), and Total Yield (in kWh). With these sensors, you can effortlessly create automations in your Apple Home based on your solar panel yield.

## Installation
To install the *Homebridge Omnik* plugin follow these steps:
Expand All @@ -16,6 +16,7 @@ To install the *Homebridge Omnik* plugin follow these steps:
```
{
"platform": "Omnik",
"ip": "<<IP address of your Omnik Inverter>>"
"ip": "<<IP address of your Omnik Inverter>>",
"pollInterval": 5
}
```
8 changes: 8 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
"type": "string",
"required": true,
"default": ""
},
"pollInterval": {
"title": "Poll interval (in minutes)",
"type": "number",
"required": true,
"default": 5,
"minimum": 1,
"maximum": 15
}
}
}
Expand Down
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": "Homebridge Omnik",
"version": "1.0.0",
"version": "1.1.0",
"description": "Add your Omnik-Inverter to Homekit",
"license": "Apache-2.0",
"author": "Jasper Seinhorst",
Expand Down
11 changes: 6 additions & 5 deletions src/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ 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: number = 5 * 60 * 1000; // every 5 minutes
private heartBeatInterval;
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', () => {
this.initialise();
});
Expand Down Expand Up @@ -53,7 +54,7 @@ export class OmnikPlugin implements DynamicPlatformPlugin {
}

private setupAccessoires() {
const currentPowerProductionName = 'Current Power Production (W)';
const currentPowerProductionName = 'Current Power Production';
const currentPowerProductionUuid = this.api.hap.uuid.generate('omnik-inverter-current-power-production');
const currentPowerProductionExistingAccessory = this.accessories.find(accessory => accessory.UUID === currentPowerProductionUuid);
if (currentPowerProductionExistingAccessory) {
Expand All @@ -65,7 +66,7 @@ export class OmnikPlugin implements DynamicPlatformPlugin {
this.api.registerPlatformAccessories('homebridge-omnik', 'Omnik', [accessory]);
}

const totalProductionName = 'Total Yield (kWh)';
const totalProductionName = 'Total Yield in kWh';
const totalProductionUuid = this.api.hap.uuid.generate('omnik-inverter-total-production');
const totalProductionExistingAccessory = this.accessories.find(accessory => accessory.UUID === totalProductionUuid);
if (totalProductionExistingAccessory) {
Expand All @@ -77,7 +78,7 @@ export class OmnikPlugin implements DynamicPlatformPlugin {
this.api.registerPlatformAccessories('homebridge-omnik', 'Omnik', [accessory]);
}

const todayProductName = 'Today Yield (kWh)';
const todayProductName = 'Today Yield in kWh';
const todayProductionUuid = this.api.hap.uuid.generate('omnik-inverter-today-production');
const todayProductionExistingAccessory = this.accessories.find(accessory => accessory.UUID === todayProductionUuid);
if (todayProductionExistingAccessory) {
Expand All @@ -93,7 +94,7 @@ export class OmnikPlugin implements DynamicPlatformPlugin {
private async heartBeat() {
try {
const powerProductionInfo = await this.omnikApi.GetPowerProduction();
this.log.debug('Updating power production info');
this.log.debug('heart beat');
this.devices.forEach((device: OmnikAccessory) => {
device.beat(powerProductionInfo);
});
Expand Down

0 comments on commit 677cfcd

Please sign in to comment.