-
-
Notifications
You must be signed in to change notification settings - Fork 361
Power Measure
Power measuring characteristics can be added to sensors and the power measurements can be reported to HomeKit. At the time of writing these characteristics are not supported by Apple's Home application. You will need to use HAA Home Manager to access the values that these sensors are reporting.
To declare a power measuring service type,
Type | Device Type |
---|---|
75 | Power measure |
The sensor options remain the same, but additional power measure options can also be used. Follow the details in Sensors to define the sensor requirements. 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 |
CF GPIO | "c0" | GPIO connected to CF pin |
CF1 GPIO | "c1" | GPIO connected to CF1 pin |
Sel1 GPIO | "sl" | GPIO connected to Sel1 pin |
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 |
{
"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}]
},{
"t":75,
"c0":5,
"c1":4,
"sl":12,
"vf":0.13334,
"cf":0.01295,
"pf":1.5312,
"y0":[{"v":245,"0":{"m":[{"g":1}]}}],
"y1":[{"v":15,"0":{"m":[{"g":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}]
},{
"t": 75,
"h": 0,
"n": 0,
"c0": 4,
"c1": 5,
"sl": 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@0001,current=#HAA@0002,power=#HAA@0003"}]}
},
{
"v": 2900,
"0":{"m":[{"g":1,"v":0}]}
}
]
},{
"t": 1,
"i":0.5,
"1":{"s":[{"a":1}]}
}]
}
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 the sensor from HomeKit, but keep it
enabled for sending readings to an influx database.
Two chip types are currently supported; HLW8012 & BL0937.
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 |
The Digital Outputs
"r": [{}]
for each should be configured to attain the desired state.
The following GPIO settings are mandatory and need defining for readings to be taken from the power sensor.
Key | Value | Description |
---|---|---|
"c0" | GPIO # | Chip CF signal |
"c1" | GPIO # | Chip CF1 signal |
"sl" | GPIO # | Chip Sel signal |
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 accessories.
Each of the measurement types Voltage, Current & 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.
NOTE: Currently, only the factor options need to be set. The offset options are not required for the currently supported chip types.
Wildcard Actions "y[n]"
are supported by these accessories.
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 |
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 "c0"
, "c1"
& "sl"
.
## 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)
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