this line has no effect; please delete. in fact, the local variable cur_state has no effect. all you need is

    vm.runtime.powerState