Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #312 from DewGew/beta
Browse files Browse the repository at this point in the history
  • Loading branch information
DewGew authored Apr 27, 2023
2 parents f348192 + 7abc28a commit 0998ced
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

"""Constants for Google Assistant."""
VERSION = '1.23.2'
VERSION = '1.23.3'
PUBLIC_URL = 'https://[your public url]'
CONFIGFILE = 'config/config.yaml'
LOGFILE = 'dzga.log'
Expand Down
21 changes: 19 additions & 2 deletions smarthome.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,21 @@ def smarthome_post(self, s):

s.send_json(200, json.dumps(response, ensure_ascii=False).encode('utf-8'), True)

def syncDevices_post(self, s):
logger.debug(s.headers)
a = s.headers.get('Authorization', None)
token = None
if a is not None:
types, tokenH = a.split()
if types.lower() == 'bearer':
token = Auth['tokens'].get(tokenH, None)

if token is None:
raise SmartHomeError(ERR_PROTOCOL_ERROR, 'not authorized access!!')

r = self.forceDevicesSync()
s.send_message(200, 'Synchronization request sent, status_code: ' + st(r))

def notification_post(self, s):
logger.debug(s.headers)
a = s.headers.get('Authorization', None)
Expand Down Expand Up @@ -1360,7 +1375,8 @@ def pycast(self, s):

smarthomePostMappings = {"/smarthome": SmartHomeReqHandler.smarthome_post,
"/notification": SmartHomeReqHandler.notification_post,
"/settings": SmartHomeReqHandler.settings_post}
"/settings": SmartHomeReqHandler.settings_post,
"/sync": SmartHomeReqHandler.syncDevices_post}
else:
smarthomeGetMappings = {"/smarthome": SmartHomeReqHandler.smarthome,
"/sync": SmartHomeReqHandler.syncDevices,
Expand All @@ -1371,7 +1387,8 @@ def pycast(self, s):
"/pycast": SmartHomeReqHandler.pycast}

smarthomePostMappings = {"/smarthome": SmartHomeReqHandler.smarthome_post,
"/notification": SmartHomeReqHandler.notification_post}
"/notification": SmartHomeReqHandler.notification_post,
"/sync": SmartHomeReqHandler.syncDevices_post}

smarthomeControlMappings = {'action.devices.SYNC': SmartHomeReqHandler.smarthome_sync,
'action.devices.QUERY': SmartHomeReqHandler.smarthome_query,
Expand Down

0 comments on commit 0998ced

Please sign in to comment.