I have made a driver that implements Virtual Energy & Power Device and power & energy calculation.
Power & energy calculation is implemented using Energy & Power Device(s) and supporting Rules API rules.
You will need the following hardware: SmartThings Hub (V2 or V3 or Station) or Aeotec Hub
Channel enrollment and driver installation
Enroll your hub into my Smartthings channel
Invitation link: Channel
Then install the Edge Driver called Virtual Energy Power Switch Device Tx.
Push ACCEPT button
Push Enroll button
Push Available Drivers button
Install Virtual Energy Power Switch Device Tx
Add first device to Smartthings
Open the SmartThings app then select Add device > Scan nearby.
Configure the device settings
Device features and operation
Using Set Energy is possible to set Energy Meter value.
Using Set Power is possible to set Power Meter value.
Using Create New Device Button is possible to add more Virtual Energy & Power Devices.
Total calculation will be implemented using Rules API rule.
Total calculation can be used for Total Energy or Total Power calculation.
Total Energy Calculation
Write using Rules API rule energy measuring device’s Energy Meter value to this device’s Add Value. Each write’s value is added to Total’s previous value ( Like Calculator’s M+ ).
Total Energy calculation Rules API rule’s actions (principle)
Write 1. device's energyMeter value to Add Value -- Each write's value is added to Total
Sleep 3s
Write 2. device's energyMeter value to Add Value -- Each write's value is added to Total
Sleep 3s
...
Write N. device's energyMeter value to Add Value -- Each write's value is added to Total
Sleep 3s
Write Total value to Set Energy ( Energy meter )
The purpose of sleep 3s is simply to spread the rule’s actions over a longer period of time. The aim is that the performance of the routine has as little impact as possible on the rest of the hub’s operations.
Dozens of energy measuring devices can be used in Total calculation.
Total Power Calculation
Write using Rules API rule power measuring device’s Power Meter value to Add Value. Each write’s value is added to Total’s previous value ( Like Calculator’s M+ ).
Total Power calculation Rules API rule’s actions (principle)
Write 1. device's powerMeter value to Add Value -- Each write's value is added to Total
Sleep 3s
Write 2. device's powerMeter value to Add Value -- Each write's value is added to Total
Sleep 3s
...
Write N. device's powerMeter value to Add Value -- Each write's value is added to Total
Sleep 3s
Write Total value to Set Power ( Power meter )
Dozens of power measuring devices can be used in Total calculation.
If Setting Calculate Energy from Set Power is selected then from Set Power value is calculated Energy meter value using scaling.
Scaling Power to Energy calculation Setting:
Scaling depends on Rules API rule execution interval. Scaling idea is to get correct energy value when different rule execution intervals are used.
If rule is executed every 6 min use scaling 0.1 to get correct energy value.
If rule is executed every 3 min use scaling 0.05 to get correct energy value.
Using without any calculation
The Virtual Energy & Power Devices can also be used as virtual devices without any calculation.
The device’s switch does not affect the device’s operation. Only the Switch & Power Meter (Text) display changes according to the status of the switch.
Profiles (Dashboard Types)
Energy Meter
Power Meter
Switch & Power Meter (Text)
Switch Energy Power Meter
@Johnnybegoode thanks for the great help with the alpha testing earlier driver version.
@TAustin drivers in GitHub actually helped me a lot to understand how virtual devices (LAN) work.
I also find some Lua code examples from @Mariano_Colmenarejo drivers in GitHub.