Skip to content

Commit

Permalink
feat: toggles to disable single sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper-seinhorst committed Mar 3, 2024
1 parent 8f96bae commit ed7db29
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 20 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
[![npm](https://img.shields.io/npm/dt/homebridge-homewizard-power-consumption.svg)](https://www.npmjs.com/package/homebridge-homewizard-power-consumption)
[![npm](https://img.shields.io/npm/v/homebridge-homewizard-power-consumption.svg)](https://www.npmjs.com/package/homebridge-homewizard-power-consumption)

This Homebrudge plugin offers two sensors; one for the current power consumption and one for the current power return.
This Homebridge plugin presents two sensors: one dedicated to monitoring current power consumption within your household, and another tracking the power return for those equipped with solar panels. Gain real-time insights into your energy usage and optimize your home's efficiency effortlessly. These sensor allows you to add automations to your Apple Home based on power consumption or power return.

![Two sensors in Utility room](/assets/plugin-example.png) ![Automation example](/assets/automation-example.png)

## Installation
To install the *Homebridge Homewizard Power Consumption* plugin follow these steps:
Expand All @@ -17,9 +19,12 @@ To install the *Homebridge Homewizard Power Consumption* plugin follow these ste
{
"platform": "HomewizardPowerConsumption",
"ip": "<<IP of your P1>>",
"pollInterval": 60
"pollInterval": 60,
"hidePowerConsumptionDevice": false,
"hidePowerReturnDevice": false
}
```

## Caveats
Both sensors are exposed as Lux (light) sensors. The Lux level indicates the w level of the consumption. E.g. If your home has a power consumption of 2000w, the sensor will show 2000lux.
- Each sensor is represented as a Lux (light) sensor. The Lux level directly reflects the power consumption in watts. For example, if your home is consuming 2000 watts of power, the sensor will display 2000 Lux.
- Not every household has solar panels, by adding `"hidePowerReturnDevice": false` to the plugins config you can disable the power return sensor.
Binary file added assets/automation-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/plugin-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
"default": 60,
"minimum": 5,
"maximum": 3600
},
"hidePowerConsumptionDevice": {
"title": "Hide Power Consumption sensor",
"default": false,
"type": "boolean"
},
"hidePowerReturnDevice": {
"title": "Hide Power Return sensor",
"default": false,
"type": "boolean"
}
}
}
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.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Homebridge Homewizard Power Consumption",
"name": "homebridge-homewizard-power-consumption",
"version": "1.1.0",
"version": "1.2.0",
"description": "See current power consumption or power return in Homekit",
"license": "Apache-2.0",
"author": "Jasper Seinhorst",
Expand All @@ -25,7 +25,10 @@
},
"keywords": [
"homebridge-plugin",
"Homewizard"
"Homewizard",
"Eco",
"Power consumtion",
"Solar"
],
"devDependencies": {
"@types/node": "^20.2.5",
Expand Down
38 changes: 25 additions & 13 deletions src/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,39 @@ export class HomewizardPowerConsumption implements DynamicPlatformPlugin {
}

private setupAccessoires() {

const powerConsumptionUuid = this.api.hap.uuid.generate('homewizard-power-consumption');
const powerConsumptionExsistingAccessory = this.accessories.find(accessory => accessory.UUID === powerConsumptionUuid);
if (powerConsumptionExsistingAccessory) {
this.devices.push(new PowerConsumption(this.config, this.log, this.api, powerConsumptionExsistingAccessory));
if (this.config.hidePowerConsumptionDevice !== true) {
if (powerConsumptionExsistingAccessory) {
this.devices.push(new PowerConsumption(this.config, this.log, this.api, powerConsumptionExsistingAccessory));
} else {
this.log.info('Power Consumption added as accessory');
const accessory = new this.api.platformAccessory('Power Consumption', powerConsumptionUuid);
this.devices.push(new PowerConsumption(this.config, this.log, this.api, accessory));
this.api.registerPlatformAccessories('homebridge-homewizard-power-consumption', 'HomewizardPowerConsumption', [accessory]);
}
} else {
this.log.info('Power Consumption added as accessory');
const accessory = new this.api.platformAccessory('Power Consumption', powerConsumptionUuid);
this.devices.push(new PowerConsumption(this.config, this.log, this.api, accessory));
this.api.registerPlatformAccessories('homebridge-homewizard-power-consumption', 'HomewizardPowerConsumption', [accessory]);
if (powerConsumptionExsistingAccessory) {
this.api.unregisterPlatformAccessories(powerConsumptionUuid, 'homebridge-homewizard-power-consumption', [powerConsumptionExsistingAccessory]);
}
}


const powerReturnUuid = this.api.hap.uuid.generate('homewizard-power-return');
const powerReturnExsistingAccessory = this.accessories.find(accessory => accessory.UUID === powerReturnUuid);
if (powerReturnExsistingAccessory) {
this.devices.push(new PowerReturn(this.config, this.log, this.api, powerReturnExsistingAccessory));
if (this.config.hidePowerReturnDevice !== true) {
if (powerReturnExsistingAccessory) {
this.devices.push(new PowerReturn(this.config, this.log, this.api, powerReturnExsistingAccessory));
} else {
this.log.info('Power Return added as accessory');
const accessory = new this.api.platformAccessory('Power Return', powerReturnUuid);
this.devices.push(new PowerReturn(this.config, this.log, this.api, accessory));
this.api.registerPlatformAccessories('homebridge-homewizard-power-consumption', 'HomewizardPowerConsumption', [accessory]);
}
} else {
this.log.info('Power Return added as accessory');
const accessory = new this.api.platformAccessory('Power Return', powerReturnUuid);
this.devices.push(new PowerReturn(this.config, this.log, this.api, accessory));
this.api.registerPlatformAccessories('homebridge-homewizard-power-consumption', 'HomewizardPowerConsumption', [accessory]);
if (powerReturnExsistingAccessory) {
this.api.unregisterPlatformAccessories(powerReturnUuid, 'homebridge-homewizard-power-consumption', [powerReturnExsistingAccessory]);
}
}
}

Expand Down

0 comments on commit ed7db29

Please sign in to comment.