Skip to content

Commit

Permalink
Add Etotal in mwh; Add extra checks for temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
dblommesteijn committed Oct 2, 2023
1 parent ba8cfc2 commit 1676af6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@

<p align="center">
<img src="https://github.com/homebridge/branding/raw/master/logos/homebridge-wordmark-logo-vertical.png" width="150">
</p>


# Homebridge GoodWe Inverter

This homebridge plugin consumes the local broadcasted status by GoodWe Inverters.
This homebridge plugin consumes the local broadcasted status by GoodWe Inverters on port 8899 (UDP).

## Setup Development Environment

Expand Down
8 changes: 7 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@
"default": true
},
"showDayTotal": {
"title": "Show total Day generation (Watt)",
"title": "Show total Day generation (Watt hour)",
"type": "boolean",
"required": true,
"default": true
},
"showTotal": {
"title": "Show total generation (Mega Watt hour)",
"type": "boolean",
"required": true,
"default": true
Expand Down
25 changes: 19 additions & 6 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ export class HomebridgeGoodWeInverter implements DynamicPlatformPlugin {

parseInverter(output) {
this.log.debug('parseInverter:output', output);
const ret = { internalTemperature: 0, mode: '', generationToday: 0, power: 0 };

const ret = { internalTemperature: -1, mode: '', generationToday: -1, power: -1, generationTotal: -1 };
const temperatureIndex = 174;
const temperature = Number('0x' + output.substring(temperatureIndex, temperatureIndex + 4)) / 10;
if(temperature && temperature > 0) {
if(temperature && temperature < 80 && temperature > -20) {
ret.internalTemperature = temperature;
}

Expand Down Expand Up @@ -160,6 +161,13 @@ export class HomebridgeGoodWeInverter implements DynamicPlatformPlugin {
ret.power = power;
}

const generationTotalIndex = 190;
const generationTotal = Number('0x' + output.substring(generationTotalIndex, generationTotalIndex + 8)) / 10000;
if (generationTotal > 0) {
ret.generationTotal = generationTotal;
}


return ret;
}

Expand All @@ -170,17 +178,21 @@ export class HomebridgeGoodWeInverter implements DynamicPlatformPlugin {
const inverterData = await this.lookupLocalInstance(localInstanceConfig);
if(this.config.showCurrentPowerLevel) {
accessories.push(
this.loadElectricityAccessory(localInstanceConfig, inverterData, ['power'], 'Current Production W'));
this.loadElectricityAccessory(localInstanceConfig, inverterData, ['power'], 'Generation Watt'));
}
if(this.config.showDayTotal) {
accessories.push(
this.loadElectricityAccessory(localInstanceConfig, inverterData, ['generationToday'], 'Day Production Wh'));
this.loadElectricityAccessory(localInstanceConfig, inverterData, ['generationToday'], 'Day Generation Wh'));
}
if(this.config.showInternalTemperature) {
accessories.push(
this.loadTemperatureAccessory(localInstanceConfig, inverterData, ['internalTemperature'], 'Internal Temp C'));
this.loadTemperatureAccessory(localInstanceConfig, inverterData, ['internalTemperature'], 'Internal Temperature'));
}
if(this.config.showTotal) {
accessories.push(
this.loadElectricityAccessory(localInstanceConfig, inverterData, ['generationTotal'], 'Total Generation MWh'));
}
this.fetchLocalInstanceUpdate(10000, localInstanceConfig, accessories);
this.fetchLocalInstanceUpdate(localInstanceConfig.timeout + 500, localInstanceConfig, accessories);
}
}

Expand All @@ -189,6 +201,7 @@ export class HomebridgeGoodWeInverter implements DynamicPlatformPlugin {
const inverterData = await this.lookupLocalInstance(localInstanceConfig);
this.log.debug(`fetchPowerStationUpdate local-instance: ${localInstanceConfig.localIp}:${localInstanceConfig.port} ` +
`with # ${accessories.length} accessories`);
this.log.debug('inverterData', inverterData);
for(const accessory of accessories) {
accessory.update(inverterData);
}
Expand Down

0 comments on commit 1676af6

Please sign in to comment.