Skip to content

Commit

Permalink
Fixed setMute
Browse files Browse the repository at this point in the history
  • Loading branch information
thegoliathgeek committed Aug 22, 2019
1 parent 6202931 commit c87b3fa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions sinric/_cbhandler.py
Expand Up @@ -643,6 +643,35 @@ async def handleCallBacks(self, dataArr, connection, udp_client):
self.logger.exception('Error Occurred')



elif jsn.get(JSON_COMMANDS.get('ACTION')) == 'setMute':
try:
resp, value = await self.setMute(jsn, self.callbacks.get('setMute'))
response = {
"payloadVersion": 1,
"success": True,
"createdAt": int(time()),
"deviceId": jsn.get(JSON_COMMANDS.get('DEVICEID')),
'clientId': jsn.get(JSON_COMMANDS.get('CLIENTID')),
'messageId': jsn.get(JSON_COMMANDS.get('MESSAGEID')),
"deviceAttributes": [],
"type": "response",
"action": "setMute",
"value": {
"mute": value
}
}

if resp:
if self.trace_response:
self.logger.info(f"Response : {json.dumps(response)}")
if Trace == 'socket_response':
await connection.send(json.dumps(response))
elif Trace == 'udp_response':
udp_client.sendResponse(json.dumps(response).encode('ascii'), dataArr[2])
except Exception:
self.logger.exception('Error Occurred')

elif jsn.get(JSON_COMMANDS.get('ACTION')) == 'setBands':
try:
resp, value = await self.setBands(jsn, self.callbacks.get('setBands'))
Expand Down Expand Up @@ -758,6 +787,8 @@ async def handleCallBacks(self, dataArr, connection, udp_client):
self.logger.exception('Error Occurred')




elif jsn.get(JSON_COMMANDS.get('ACTION')) == 'setMode':
try:
resp, value = await self.setMode(jsn, self.callbacks.get('setMode'))
Expand Down
2 changes: 1 addition & 1 deletion sinric/_tvcontorller.py
Expand Up @@ -21,7 +21,7 @@ async def adjustVolume(self, jsn, callback):
return callback(jsn.get(JSON_COMMANDS.get('DEVICEID')), self.volume)

async def setMute(self, jsn, callback):
return callback(jsn.get(JSON_COMMANDS.get('DEVICEID')), )
return callback(jsn.get(JSON_COMMANDS.get('DEVICEID')), jsn.get('value').get('mute'))

async def mediaControl(self, jsn, callback):
return callback(jsn.get(JSON_COMMANDS.get('DEVICEID')), jsn.get(JSON_COMMANDS.get('VALUE')).get('control'))
Expand Down

0 comments on commit c87b3fa

Please sign in to comment.