def report_state(self, states, token): """Send a state report to Google.""" data = { 'requestId': self._request_id, 'agentUserId': token.get('userAgentId', None), 'payload': { 'devices': { 'states': states, } } } ReportState.call_homegraph_api(REPORT_STATE_BASE_URL, data)
def forceDevicesSync(self): userAgent = self.getUserAgent() enableReport = ReportState.enable_report_state() if userAgent is None: return 500 # internal error data = {"agentUserId": userAgent} if enableReport: r = ReportState.call_homegraph_api(REQUEST_SYNC_BASE_URL, data) elif 'Homegraph_API_Key' in configuration and configuration['Homegraph_API_Key'] != 'ADD_YOUR HOMEGRAPH_API_KEY_HERE': r = ReportState.call_homegraph_api_key(REQUEST_SYNC_BASE_URL, data) else: logger.error("No configuration for request_sync available") return r