In this short article, I’m going to show how to monitor most of your energy consumption without investing in special hardware. This solution is based on the fact, that most devices (prominently all your lights) have unchanging wattage only depending on their current state, which is already controlled by your openHAB system.
By the help of power consumption measuring modules, such as the Homematic HM-ES-PMSw1-Pl, Sonoff Pow or similar, we are able to monitor the consumption of dynamic consumers, be it our washing machine, fridge, TV and more. These modules are great to measure the energy these devices consume over time. The measurements can be used to graph consumption, calculate energy cost or even build higher level state machines from.
However, the mentioned devices are not the only power consumers in our home. You could continue adding these pricey consumption measurement modules to more devices but for many of these, that might not be practicable and is actually not needed. Your home is already controlled by openHAB and the chances are high, that you can derive consumption from that. Devices like light bulbs or LED stripes have a constant wattage when active. We can easily represent this information in openHAB.
Determining Wattage
There are a few ways to determine the wattage of a light/device. The first one is more than obvious: Just check the label or housing:
The second way to measure the constant power usage of a device is by using an energy meter. These devices can be bought for cheap (~20€) in most utility stores:
It’s a matter of minutes to determine and write down the wattage of most devices in your house.
Representation in openHAB
Let’s continue with an example. I have an LED stripe in my home and after connecting the energy meter in between plug and socket I found out that it is using approximately 17 Watts when turned on (and 0 Watts when turned off). We can now build a simple rule to reflect the consumption of this device in a new Number item:
lights.items
// a group for all consumers
Group:Number:SUM gPower "Overall Power Usage [%.1f W]" <energy> (gAll)
//the original switch and the additional power item
Switch myLEDstrip "LED strip" {channel="......"}
Number myLEDstrip_Power "LED strip power [%.0f W]" <energy> (gPower)
energy.rules
rule "myLEDstrip"
when
Item myLEDstrip received update
then
if (myLEDstrip.state == ON) {
myLEDstrip_Power.postUpdate(17.0)
} else {
myLEDstrip_Power.postUpdate(0)
}
end
I’ve decided to condense this rule to make my rules file with dozens of these easier to read:
rule "myLEDstrip" when Item myLEDstrip received update
then if (myLEDstrip.state == ON) myLEDstrip_Power.postUpdate(17.0) else myLEDstrip_Power.postUpdate(0) end
Adding all further devices in this way is as simple as copy&paste. The shown code lines are working in openHAB 2.0 but should just as well work in openHAB 1.8.
On the Influence of Dimmers
Some devices have a constant usage which is related to a dimmer level or some other openHAB Number item. By taking multiple measurements it’s possible to derive the power usage of your device in relation to this item. An example could be (Dimmer percentage on the left, measured power on the right):
Afterwards you need to find the mathematical correlation between these two. You can use a curve fitting tool to do so: https://www.mycurvefit.com
Depending on your device try y=a*x
, then y=m*x+c
and then continue with more complex functions like y=a*x²+b*x+c
till you find a good fit. The simplest form will be more than enough! It’s no rocket science.
The result for our example from above is pretty obvious:
y = 1.17 * x
Transferred to an openHAB rule:
energy.rules
rule "myDimmer" when Item myDimmer_Level received update
then myDimmer_Power.postUpdate((1.17 * (myDimmer_Level.state as PercentType)).intValue()) end
That’s it.
We have successfully added a Number item per device to represent the usage of these at all times. You can now do the next step. An example would be graphing all devices usage with InfluxDB+Grafana. You can also have the overall usage as a Text sitemap item. Lastly you could add logic to accumulate consumption over time and potentially decrease your energy bill Have fun!