Hi @Sgilk Thanks for the help i do still have the problem where it gets stuck on the .get i think it has somthing to do with where it still uses the import reqeust lib. Again thanks for all the help for some context im still a student so still learning allot in this field so thanks for your patience. import sseclient import pprint import ctypes import json import numpy as np import time from matplotlib import pyplot as plt urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) import requests BASE_URL = "https://192.168.1.1" USERNAME = "boschrexroth" PASSWORD = "boschrexroth" head = {'Content-Type': 'application/json'} creds = {"name":USERNAME, "password": PASSWORD} # sys.excepthook = customlogger.handle_exception kernel32 = ctypes.windll.kernel32 kernel32.SetConsoleMode(kernel32.GetStdHandle(-10), 439) #disable the quick edit function of terminal access_token = None ################### Step 1 ##################### functions with requests.post(BASE_URL + '/identity-manager/api/v2/auth/token',headers = head, verify= False, json=creds) as response: data = json.loads(response.text) token = data['access_token'] # 0.1 - authorization head = {"accept": "application/json", 'Authorization':'Bearer {}'.format(token)} payload = { "properties": { "id": "subID", "keepaliveInterval": 60000, "publishInterval": 1000, "rules": [{ "rule_type": "Queueing", "rule": { "queueSize": 10 } }, { "rule_type": "Sampling", "rule": { "samplingInterval": 1000 } }, { "rule_type": "ChangeEvents", "rule": { "valueChange": "StatusValueTimestamp" } } ] }, "nodes": ["motion/axs/X/state/values/actual/pos" ] } # Make the POST request motion_info = requests.post(BASE_URL + '/automation/api/v2/events?format=json', json=payload,headers = head, verify = False) # Check the response for the POST request if motion_info.status_code == 201: response_data = motion_info.json # Call the method to get JSON data print(response_data) # Print the response data else: print(f"Error: {motion_info.status_code} - {motion_info.text}") motion_sub = requests.get(BASE_URL + '/automation/api/v2/events/subID',headers = head, stream = True, verify= False) client = sseclient.SSEClient(motion_sub) if motion_sub.status_code == 200: print(motion_sub.json()) # Call the method to get JSON data else: print(f"Error: {motion_sub.status_code} - {motion_sub.text}") for event in client.events(): pprint.pprint(event.data)
... View more