Sync via token
kofec opened this issue · 5 comments
kofec commented
Is your feature request related to a problem? Please describe.
When I open a gate via remote control the google assistant has incorrect state of gate.
Describe the solution you'd like
diff --git a/smarthome.py b/smarthome.py
index 584d591..e23e959 100644
--- a/smarthome.py
+++ b/smarthome.py
@@ -820,6 +820,21 @@ class SmartHomeReqHandler(OAuthReqHandler):
else:
logger.error('Something went wrong, check your notification settings!')
+ 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: ' + str(r))
+
def smarthome(self, s):
s.send_message(500, "not supported")
@@ -827,7 +842,8 @@ class SmartHomeReqHandler(OAuthReqHandler):
userAgent = self.getUserAgent()
enableReport = ReportState.enable_report_state()
if userAgent is None:
- return 500 # internal error
+ # return 500 # internal error
+ userAgent = "1234"
data = {"agentUserId": userAgent}
if enableReport:
@@ -1360,7 +1376,8 @@ if 'userinterface' in configuration and configuration['userinterface'] == True:
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,
@@ -1371,7 +1388,8 @@ else:
"/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,
DewGew commented
I this still an issue?
kofec commented
@DewGew I don't see any commit in this repository so there is not code to support "sync" via token. Above you can see the code which I have to add.
DewGew commented
Make a PR to beta branch
Skickat från Outlook för iOS
Från: kofec ***@***.***>Skickat: torsdag, april 20, 2023 10:05 fmTill: DewGew/Domoticz-Google-Assistant ***@***.***>Kopia: DewGew ***@***.***>; Mention ***@***.***>Ämne: Re: [DewGew/Domoticz-Google-Assistant] Sync via token (Issue #308)
@DewGew I don't see any commit in this repository so there is not code to support "sync" via token. Above you can see the code which I have to add.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
kofec commented
Thanks