I don't understand what you are trying to do but I think that all your parent.parent.parent.getChild().getChild().getChild()
code makes your application very brittle. If you move anything into another container it will break.
I recommend that you set up some custom properties on the view and write the values to those. Then bind your gauge properties to those.
I would also try to do all this with expression functions rather than a script. You could have custom props for calculated daily, weekly and monthly and switch the gauge bindings based on duration_type
.
You have one occurrence of "{:.2f}kwh"
. It should be "{:.2f}kWh"
(capital W for watt).