Skip to content

Commit

Permalink
define 7 as default for volume and fix current volume
Browse files Browse the repository at this point in the history
  • Loading branch information
pergolafabio committed Oct 2, 2023
1 parent c4bc15b commit 41ed626
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions hikvision-doorbell/src/doorbell.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ def isapi_device_info() -> int:
# Error out if we don't find attribute `max` inside the `doorNo` element
if com_number_element is None or com_number_element.text is None:
# Print a string representation of the response XML
logger.debug("No com ports found for the indoor device")
return 0
raise RuntimeError('Cannot find `alarmOutNum` node in XML response')
logger.debug("We have found {} com ports for the indoor device", com_number_element.text)
return int(com_number_element.text)

Expand Down Expand Up @@ -369,25 +368,27 @@ def get_audio_out_settings(self):
def mute_audio_output(self):
try:
current_settings = self.get_audio_out_settings()
currentTalkVolume = current_settings.find('{*}talkVolume')
logger.debug("Current talk volume is {}", currentTalkVolume)
currentTalkVolume = current_settings.find('.//{*}talkVolume')
if currentTalkVolume is None or currentTalkVolume.text is None:
talkVolume = "5"
talkVolume = "7"
logger.debug("Current talk volume not found, using 7 as default")
else:
talkVolume = currentTalkVolume.text
logger.debug("Current talk volume found: {}", talkVolume)

currentVolume = current_settings.find('{*}volume')
logger.debug("Current volume is {}", currentVolume)
currentVolume = current_settings.find('.//{*}volume')
if currentVolume is None or currentVolume.text is None:
self._previouse_audio_out_volume = 5
self._previouse_audio_out_volume = 7
logger.debug("Current volume not found, using 7 as default")
else:
# remember current audio out volume for the unmute of the doorbell
self._previouse_audio_out_volume = int(currentVolume.text)
logger.debug("Current volume found: {}", self._previouse_audio_out_volume)

except SDKError:
# Cannot get current audio out settings use default values
talkVolume = "5"
self._previouse_audio_out_volume = "5"
talkVolume = "7"
self._previouse_audio_out_volume = "7"

url = "/ISAPI/System/Audio/AudioOut/channels/1"
# mute audio out by changing the audio out volume to 0
Expand All @@ -400,15 +401,16 @@ def mute_audio_output(self):
def unmute_audio_output(self):
try:
current_settings = self.get_audio_out_settings()
currentTalkVolume = current_settings.find('{*}talkVolume')
logger.debug("Current talk volume is {}", currentTalkVolume)
currentTalkVolume = current_settings.find('.//{*}talkVolume')
if currentTalkVolume is None or currentTalkVolume.text is None:
talkVolume = "5"
talkVolume = "7"
logger.debug("Current talk volume not found, using 7 as default")
else:
talkVolume = currentTalkVolume.text
logger.debug("Current talk volume found: {}", talkVolume)
except SDKError:
# Cannot get current audio out settings use default values
talkVolume = "5"
talkVolume = "7"

url = "/ISAPI/System/Audio/AudioOut/channels/1"

Expand Down

0 comments on commit 41ed626

Please sign in to comment.