Wait for controller state change and return state

def wait_for_state_change(self, state: str, waitsec) -> str:
        """Wait for controller state change and return state"""
        payload = """<ns1:waitForControllerStateChange1
                     xmlns:ns1=\"utcs\" xsi:type=\"ns1:WSControllerState\">
                     <ns1:state xsi:type=\"xsd:string\">{state}</ns1:state>
                     </ns1:waitForControllerStateChange1>
                     <ns2:waitForControllerStateChange2
                     xmlns:ns2=\"utcs\" xsi:type=\"xsd:int\">
                     {wait}</ns2:waitForControllerStateChange2>
                     """.format(state=state, wait=waitsec)
        xdoc = self.connection.soap_action('/ws/ControllerService',
                                           'waitForControllerStateChange',
                                           payload)
        if xdoc:
            return xdoc.find(
                './SOAP-ENV:Body/ns1:waitForControllerStateChange3/ns1:state',
                IHCSoapClient.ihcns).text
        return False