Think I finally figured out a way to estimate energy Usage per device and figured I would share. It is a little bit of a setup, but I think the #'s are accurate (as accurate as can be for an estimate).
This is based off using a script and passing variables from an event to make it all work. You will need to create 2 virtual devices and a timer, per physical device you want to monitor.
- One device to get the wattage usage
- Another to have a running total for kWh
- Timer is needed to aid in kWh calculation
I still need to create a button on this device to reset to 0 for monthly recycle.
You will need three events:
- One for physical device on, restart timer
- One for physical device off, stop timer and update kWh device
- Last one to update the wattage device for current usage (used to calculate kWh)
On your events that reference the script, you will need to have the data sent. I did this so that I only had to create one script and can send multiple devices thru it.
Example of how the parameter pass should look:
'Array setup for event / LightDevice,WattDevice,TimerName,kWhDevice,TotalLightWattage
'LightDevice = RefID for Light
'WattDevice = RefID for Virtual Device that maintains watt usage
'TimerName = Name of Timer being used to monitor light
'kWhDevice = Virtual Device to hold kWh
'TotalLightWattage = Maximum wattage for light
'Example = 33,836,Kitchen Ceiling Lights,837,60
Again this is only going to be an estimate and I have only found a way to update the kWh when the device is turned off. This gives you a running total, but does not update real time. I tried to do the update real time and couldn't figure out the math/script. But this works for my needs.
This is based off using a script and passing variables from an event to make it all work. You will need to create 2 virtual devices and a timer, per physical device you want to monitor.
- One device to get the wattage usage
- Another to have a running total for kWh
- Timer is needed to aid in kWh calculation
I still need to create a button on this device to reset to 0 for monthly recycle.
You will need three events:
- One for physical device on, restart timer
- One for physical device off, stop timer and update kWh device
- Last one to update the wattage device for current usage (used to calculate kWh)
On your events that reference the script, you will need to have the data sent. I did this so that I only had to create one script and can send multiple devices thru it.
Example of how the parameter pass should look:
'Array setup for event / LightDevice,WattDevice,TimerName,kWhDevice,TotalLightWattage
'LightDevice = RefID for Light
'WattDevice = RefID for Virtual Device that maintains watt usage
'TimerName = Name of Timer being used to monitor light
'kWhDevice = Virtual Device to hold kWh
'TotalLightWattage = Maximum wattage for light
'Example = 33,836,Kitchen Ceiling Lights,837,60
Again this is only going to be an estimate and I have only found a way to update the kWh when the device is turned off. This gives you a running total, but does not update real time. I tried to do the update real time and couldn't figure out the math/script. But this works for my needs.
Code:
'Updates kWh Device Sub kWh_Update(ByVal Parms As Object) dim ParmArray() As String = Split(Parms,",") dim kWh as decimal dim kWh_Previous as decimal dim Watts as integer = ParmArray(1) dim ts As TimeSpan = hs.TimerValue(ParmArray(2)) dim Time as decimal dim Session_kWh as decimal Time = ts.TotalHours kWh_Previous = hs.DeviceValueEx(ParmArray(3)) Session_kWh = (Time*Watts)/1000 kWh = (kWh_Previous + Session_kWh) hs.SetDeviceValueByRef(ParmArray(3), kWh, True) End Sub 'Update Wattage Virtual Device Sub Wattage_Update (ByVal Parms As Object) dim ParmArray() As String = Split(Parms,",") dim Lights as integer = hs.DeviceValue(ParmArray(0)) dim Actual_Wattage as integer dim Maximum_Wattage as integer = (ParmArray(4)) Actual_Wattage = (Lights*Maximum_Wattage)/100 hs.SetDeviceValueByRef(ParmArray(1), Actual_Wattage, True) End Sub