Skip to content

Commit

Permalink
Add deviceInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ejpenney committed Mar 7, 2023
1 parent 7e0ac6e commit b42e503
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions pyobihai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,27 @@ def get_device_mac(self):
_LOGGER.error(e)
return mac

def get_device_serial(self):
"""Get the device serial number."""
def get_model_name(self) -> str:
"""Get ModelName."""
return self._get_product_info("ModelName")

def get_hardware_version(self) -> str:
"""Get HardwareVersion."""
return self._get_product_info("HardwareVersion")

def get_software_version(self) -> str:
"""Get SoftwareVersion."""
return self._get_product_info("SoftwareVersion")

def get_device_serial(self) -> str:
"""Get Device Serial Number."""
return self._get_product_info("SerialNumber")

def _get_product_info(self, parameter: str) -> str:
"""Get the device Product Information."""

url = urljoin(self._server, DEFAULT_STATUS_PATH)
serial = None
result = None
try:
resp = requests.get(url, auth=requests.auth.HTTPDigestAuth(self._username,self._password), timeout=2)
root = xml.etree.ElementTree.fromstring(resp.text)
Expand All @@ -124,7 +140,7 @@ def get_device_serial(self):
serial = e.attrib.get('current')
except requests.exceptions.RequestException as e:
_LOGGER.error(e)
return serial
return result

def get_call_direction(self):
"""Get the call direction."""
Expand Down

0 comments on commit b42e503

Please sign in to comment.