Something like this?
Use the following function for my events to see if someone is using a device or not.
But could also serve your purpose, i think.
It aint tested but should give you a headstart.
You could also include the "parasitic = total - lights - plugs - kitchen" into the function to make it cleaner
Code: Select all
function powerusage(powerplug)
local powerplug = powerplug
local reading
local usage
reading = otherdevices[powerplug]
_,_,usage = string.find(reading, "(.+)")
current_usage = tonumber(reading)
return current_usage
end
commandArray = {}
total = powerusage['total']
lights = powerusage['lights']
kitchen=powerusage['kitchen']
plugs = powerusage['plugs']
parasitic = total - lights - plugs - kitchen
commandArray['UpdateDevice']=tostring(parasitic)
return commandArray