Skip to content

Commit

Permalink
Merge pull request #1 from jasper-seinhorst/1.4.0
Browse files Browse the repository at this point in the history
1.4.0
  • Loading branch information
jasper-seinhorst authored Mar 7, 2024
2 parents 6d9baff + b197e87 commit 0980c4b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
4 changes: 2 additions & 2 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "object",
"properties": {
"ip": {
"title": "P1 IP address",
"title": "Wi-Fi P1 Meter IP address",
"type": "string",
"required": true,
"default": ""
Expand All @@ -16,7 +16,7 @@
"type": "number",
"required": true,
"default": 60,
"minimum": 5,
"minimum": 1,
"maximum": 3600
},
"hidePowerConsumptionDevice": {
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

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

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"displayName": "Homebridge Homewizard Power Consumption",
"name": "homebridge-homewizard-power-consumption",
"version": "1.3.0",
"description": "See current power consumption or power return in Homekit",
"displayName": "Homebridge Homewizard Power Consumption",
"version": "1.4.0",
"description": "See current power consumption and power return in Homekit",
"license": "Apache-2.0",
"author": "Jasper Seinhorst",
"repository": {
Expand All @@ -21,21 +21,22 @@
"lint": "eslint src/**.ts --max-warnings=0",
"watch": "npm run build && npm link && nodemon",
"build": "rimraf ./dist && tsc",
"prepublishOnly": "npm run lint && npm run build"
"prepublishOnly": "npm run lint && npåm run build"
},
"keywords": [
"homebridge-plugin",
"homebridge",
"Homewizard",
"Eco",
"Power consumtion",
"Solar"
"homewizard",
"eco",
"power-consumption",
"solar",
"solar-panels"
],
"devDependencies": {
"@types/node": "^20.2.5",
"@types/node": "^20.11.25",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"homebridge": "^1.7.0",
"nodemon": "^2.0.22",
"rimraf": "^5.0.5",
Expand Down
17 changes: 17 additions & 0 deletions src/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,29 @@ export class HomewizardPowerConsumption implements DynamicPlatformPlugin {
return !!this.config.ip;
}

private async validateIp(): Promise<boolean> {
try {
const { data } = await axios.get(`http://${this.config.ip}/api/`, { timeout: 2000 });
if (data && data.product_type === 'HWE-P1') {
return true;
}
return false;
} catch(error) {
return false;
}
}

private async initialise() {
if (!this.validateConfig()) {
this.log.error('Configuration error. Please provide your Wi-Fi P1 meter\'s IP address');
return;
}

if (!await this.validateIp()) {
this.log.error('Your Wi-Fi P1 meter\'s IP address seems to be incorrect. No connection possible');
return;
}

this.setupAccessoires();

await this.heartBeat();
Expand Down

0 comments on commit 0980c4b

Please sign in to comment.