def is_motion_detection_enabled(self):
        """ Get current state of Motion Detection """

        response = requests.get(self.motion_url, auth=HTTPBasicAuth(
            self._username, self._password))
        _LOGGING.debug('Response: %s', response.text)

        if response.status_code != 200:
            _LOGGING.error(
                "There was an error connecting to %s", self.motion_url)
            _LOGGING.error("status_code %s", response.status_code)
            return

        try:

            tree = ElementTree.fromstring(response.text)
            enabled_element = tree.findall(
                './/{%s}enabled' % self._xml_namespace)
            sensitivity_level_element = tree.findall(
                './/{%s}sensitivityLevel' % self._xml_namespace)
            if len(enabled_element) == 0:
                _LOGGING.error("Problem getting motion detection status")
                return
            if len(sensitivity_level_element) == 0:
                _LOGGING.error("Problem getting sensitivityLevel status")
                return

            result = enabled_element[0].text.strip()
            _LOGGING.info(
                'Current motion detection state? enabled: %s', result)

            if int(sensitivity_level_element[0].text) == 0:
                _LOGGING.warn(
                    "sensitivityLevel is 0.")
                sensitivity_level_element[0].text = str(
                    self._sensitivity_level)
                _LOGGING.info(
                    "sensitivityLevel now set to %s", self._sensitivity_level)

            if result == 'true':
                # Save this for future switch off
                self.xml_motion_detection_on = ElementTree.tostring(
                    tree, encoding=XML_ENCODING)
                enabled_element[0].text = 'false'
                self.xml_motion_detection_off = ElementTree.tostring(
                    tree, encoding=XML_ENCODING)
                return True
            else:
                # Save this for future switch on
                self.xml_motion_detection_off = ElementTree.tostring(
                    tree, encoding=XML_ENCODING)
                enabled_element[0].text = 'true'
                self.xml_motion_detection_on = ElementTree.tostring(
                    tree, encoding=XML_ENCODING)
                return False

        except AttributeError as attib_err:
            _LOGGING.error(
                'There was a problem parsing '
                'camera motion detection state: %s', attib_err)
            return
Get current state of Motion Detection