Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
longzheng committed Jun 24, 2023
2 parents 2dbd90f + 5420671 commit 516964c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export type Config = {
inverterIp: string;
pollInterval: number;
pvMaxPower?: number;
battery?: boolean;
};
20 changes: 18 additions & 2 deletions src/fronius-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class FroniusInverterLightsStaticPlatform implements StaticPlatformPlugin {
private readonly froniusApi: FroniusApi;
private readonly pollInterval: number;
private readonly pvMaxPower?: number;
private readonly battery?: boolean;

constructor(log: Logging, config: PlatformConfig, api: API) {

Check warning on line 29 in src/fronius-platform.ts

View workflow job for this annotation

GitHub Actions / build

'api' is defined but never used
this.log = log;
Expand All @@ -34,6 +35,7 @@ class FroniusInverterLightsStaticPlatform implements StaticPlatformPlugin {
this.froniusApi = new FroniusApi(pluginConfig.inverterIp, this.log);
this.pollInterval = pluginConfig.pollInterval || 10;
this.pvMaxPower = pluginConfig.pvMaxPower;
this.battery = pluginConfig.battery;
}

/*
Expand All @@ -43,7 +45,7 @@ class FroniusInverterLightsStaticPlatform implements StaticPlatformPlugin {
* The set of exposed accessories CANNOT change over the lifetime of the plugin!
*/
accessories(callback: (foundAccessories: AccessoryPlugin[]) => void): void {
callback([
const accessories = [
new FroniusAccessory(
hap,
this.log,
Expand Down Expand Up @@ -73,6 +75,20 @@ class FroniusInverterLightsStaticPlatform implements StaticPlatformPlugin {
this.pollInterval,
this.pvMaxPower,
),
]);
];

if (this.battery) {
accessories.push(
new FroniusAccessory(
hap,
this.log,
'Battery',
this.froniusApi,
this.pollInterval,
),
);
}

callback(accessories);
}
}

0 comments on commit 516964c

Please sign in to comment.