Skip to content

Commit

Permalink
Merge pull request JurajNyiri#79 from JurajNyiri/add_microphone_speaker
Browse files Browse the repository at this point in the history
Add: getAudioConfig, setSpeakerVolume, setMicrophone
  • Loading branch information
JurajNyiri authored Nov 6, 2023
2 parents 25a5eb7 + 2e7aa0a commit 563c222
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pytapo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,33 @@ def getAudioSpec(self):
}
)

def getAudioConfig(self):
return self.executeFunction(
"getAudioConfig",
{"method": "get", "audio_config": {"name": ["speaker", "microphone"]}},
)

def setSpeakerVolume(self, volume):
return self.executeFunction(
"setSpeakerVolume",
{"method": "set", "audio_config": {"speaker": {"volume": volume}}},
)

def setMicrophone(self, volume=None, mute=None, noise_cancelling=None):
params = {"method": "set", "audio_config": {"microphone": {}}}
if volume is not None:
params["audio_config"]["microphone"]["volume"] = volume
if mute is not None:
params["audio_config"]["microphone"]["mute"] = "on" if mute else "off"
if noise_cancelling is not None:
params["audio_config"]["microphone"]["noise_cancelling"] = (
"on" if noise_cancelling else "off"
)
return self.executeFunction(
"setMicrophoneVolume",
params,
)

# does not work for child devices, function discovery needed
def getVhttpd(self):
return self.performRequest({"method": "get", "cet": {"name": ["vhttpd"]}})
Expand Down Expand Up @@ -1521,6 +1548,13 @@ def getMost(self):
"method": "getRecordPlan",
"params": {"record_plan": {"name": ["chn1_channel"]}},
},
{
"method": "getAudioConfig",
"params": {
"method": "get",
"audio_config": {"name": ["speaker", "microphone"]},
},
},
]
},
}
Expand Down

0 comments on commit 563c222

Please sign in to comment.