Assembly level macro to calculate wattage of all lower level parts

I'm looking to create a macro at the assembly level that will look at all of my lower level parts/assemblies that have a global variable called "max wattage", add those numbers up and enter them into a global variable called "Total Wattage" then create a custom property called "Wattage" that is linked to the "Total Wattage" variable.  Bonus points if the precision can be controlled to different precisions.  Any help would be greatly appreciated.

SolidworksApi/macros