-
-
Notifications
You must be signed in to change notification settings - Fork 361
Power Measure
Power measuring characteristics can be added as extra service to any accessory and the power measurements can be reported to HomeKit.
You will need to use HAA Home Manager or other compatible HomeKit application to access the values that these sensors are reporting.
It is possible to declare this service as primary, but it is not recommended because it is incompatible with Apple's Home App and an incompatible icon will appear.
To declare a power measuring service type,
Type | Service Type |
---|---|
75 | Power measure |
Below are details on how to setup and use the power measurement capabilities.
The following configuration options are available for power measure:
Section | Key | Description |
---|---|---|
Chip Type | "n" | Chip type configuration |
Chip Data | "dt" | Chip configuration data array |
Reading Period | "j" | Period in seconds between readings |
Voltage Factor | "vf" | Voltage factor adjustment |
Voltage Offset | "vo" | Voltage offset adjustment |
Current Factor | "cf" | Current factor adjustment |
Current Offset | "co" | Current offset adjustment |
Power Factor | "pf" | Power factor adjustment |
Power Offset | "po" | Power offset adjustment |
Service Notifications | "m" | Notifications to send to another service |
Wildcard Actions | "y[n]" | Perform an action when an service reaches a target value |
Historical Data Characteristics |
{
"c":{"l":2,"b":[{"g":13,"t":5}]},
"a":[
{
"t":2,
"0":{"r":[{"g":15},{"g":0,"v":1}]},
"1":{"r":[{"g":15,"v":1},{"g":0}]},
"b":[{"g":13}],
"es":[{
"t":75,
"dt":[5,4,12],
"vf":0.13334,
"cf":0.01295,
"pf":1.5312,
"y0":[{"v":245,"0":{"m":[[1]]}}],
"y1":[{"v":15,"0":{"m":[[1]]}}]
}]
}
]
}
This is an example of a Gosund SP111 v1.1 with over voltage (245VAC) and over current (15A) protection.
See Measurement Calibration for setting "vf"
,
"cf"
& "pf"
factors.
{
"c": {"n":"2nice-1aptop","l":1,"b":[{"g":3,"t":5}],"u":1},
"a": [{
"t": 2,
"0": {"r":[{"g":14,"v":0},{"g":13,"v":1}]},
"1": {"r":[{"g":14,"v":1},{"g":13,"v":0}]},
"b": [{"g":3}]
"es":[{
"t": 75,
"h": 2,
"n": 0,
"dt": [4, 5, 12],
"j": 60,
"vf": 0.1674,
"cf": 0.01768,
"pf": 2.474,
"y2":[
{
"v": 0,
"r": 1,
"0": {"h":[{"h":"mynas.local","p": 8086,"m": 2,"u": "write?db=outletdb","c": "sensor,device=2nice-laptop,type=BL0937,location=hall voltage=#HAA@0000,current=#HAA@0001,power=#HAA@0002"}]}
},
{
"v": 2900,
"0":{"m":[[1,0]]}
}
]
}]
}]
}
This is an example of a 2nice UP111 WiFi smart plug with over voltage (245VAC) and over current (13A) protection.
See Measurement Calibration for setting "vf"
,
"cf"
& "pf"
factors.
Note the first entry in Wildcard "y2"
sends an entry containing the
voltage, current and power readings to an influx database every 60 seconds ("j":60
).
The second entry in the wildcard turns off the outlet if is consuming more than
2.9KW of power.
This example also makes use the HomeKit Visibility
option added in firmware v3.0.0
to hide service from Apple Home App, but keep it
enabled for sending readings to an influx databas, showing data in HAA Home Manager.
Key | Value | Description |
---|---|---|
"n" | 0 | HLW8012/BL0937 with Sel1 GPIO LOW to read current (_default) |
1 | HLW8012/BL0937 with Sel1 GPIO HIGH to read current | |
2 | ADE7953 Channel A | |
3 | ADE7953 Channel B |
This array is used to define configuration of desired chip.
Chip | Value | Description |
---|---|---|
HLW8012/BL0937 | "dt" : [ CF, CF1, Sel ] | GPIOs needed. If Only CF if used you can use "dt": [ CF ]
|
ADE7953 | "dt" : [ I2C Bus, Chip Address (decimal) ] | I2C Bus declaration is needed |
The option "j"
can be set to define the period of time to take between each
sensor reading.
If this option is omitted the default value of 5
will be used.
State inputs "f[n]"
& Status Inputs "g[n]"
are supported by these services.
Each of the measurement types Voltage, Current and Power need to be calibrated before the sensor will return accurate and meaningful readings. See the Measurement Calibration section on how to go about calibrating a sensor.
Once calibrated the "vf"
, "vo"
, "cf"
, "co"
, "pf"
& "po"
options
need to be set within the service definition.
The list of Service Notifications "m"
values supported are:
Key | Value | Notification |
---|---|---|
"v" | 0 | Reset consumption. Internal clock must be set. |
See the general Service Notifications section for details of how to configure these notifications.
Wildcard Actions "y[n]"
are supported by these services.
The supported list is:
Key | Action |
---|---|
"y0" | Trigger action when service reaches a specific voltage |
"y1" | Trigger action when service reaches a specific current |
"y2" | Trigger action when service reaches a specific power |
"y3" | Trigger action when service reaches a specific consumption |
Refer to Wildcard Actions for more detail.
In order for the device to return accurate measurements it must be calibrated. To calibrate the device you will require:
- An AC capable, calibrated multi-meter
- A known wattage load with a power factor as close to 1 as possible e.g. a resistive load such as a incandescent or halogen light bulb.
NOTE: Equipment such as an electric kettle, heater, or blow dryer are also options but you will also need a power meter since the power draw could vary.
Before attempting to calibrate set the service configuration to:
{"t":75, "j":10, "vf":0.1, "cf":0.1, "pf":1}
NOTE You will also need to include values for "dt":
.
## Calibrate the Voltage Factor
Run the device in debug mode and watch the debug output.
Look for a statement like PM Acc 2: V = 250.22, C = 0, P = 0
To set the voltage factor:
- Measure the mains voltage on the socket using the multimeter: we will call this the real value
- While measuring the real value record the 'V' value from the debug log output: we will call this the sensor value
- Get a few readings and take the average of both the real and sensor values
- To calculate the offset:
vf = real value average / (sensor value average * 10)
## Calibrate the Power Factor
Run the device in debug mode and watch the debug output.
Look for a statement like PM Acc 2: V = 250.22, C = 0, P = 0
To set the power factor:
- Turn on the constant current device
- Record at least 5 values of the 'P' measurement: call this the sensor value and take the average
- Record the value of the constant current device e.g. 60 and call this the real value
- To calculate the offset:
pf = real value / sensor value average
## Calibrate the Current Factor
Run the device in debug mode and watch the debug output.
Look for a statement like PM Acc 2: V = 250.22, C = 0, P = 0
To set the current factor:
- Turn on the constant current device
- Record at least 5 values of the 'C' measurement: call this the sensor value and take the average
- Use the multimeter to record the real voltage reading: call this the real voltage value
- Record the power value of the constant current device e.g. 60 and call this the real power value
- To calculate the offset:
cf = (real power value / real voltage value) / (sensor value average * 10)
Characteristic | Description |
---|---|
0 | * Voltage |
1 | * Current |
2 | * Power |
3 | * Consumption |
4 | Consumption before reset |
Home Accessory Architect
Home Accessory
Installation
Setup Mode
HAA Home Manager App
Configuration
About
General
| GPIOs Configuration
Accessory
| Actions
Service Types
Air Quality
Battery
Data History
Fan
Free Monitor
Garage Door
HAA iAirZoning
Heater Cooler
Humidifier
Light Sensor
Lightbulb
Lock Mechanism
Sensors
Power Measure
Security System
Stateless Button & Doorbell
Switch & Outlet
Temperature & Humidity
TV
Water Valve
Window Covering