forked from roseg0ld/Cura-Duet-Monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest.py
26 lines (20 loc) · 899 Bytes
/
request.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import requests
import json
def statusRetrieval(url, cat1, cat2, index):
return json.loads(requests.get('http://' + url + '/rr_status?type=1').text)[cat1][cat2][index]
def sendGcode(url,gcode):
return requests.get('http://' + url + '/rr_gcode?gcode='+gcode)
def altstatusRetrival(url,type):
return json.dumps(requests.get('http://' + url + '/rr_status?type='+type).text)
url = '10.1.10.156'
coordx = statusRetrieval(url, 'coords','xyz', 0)
coordy = statusRetrieval(url, 'coords','xyz', 1)
coordz = statusRetrieval(url, 'coords','xyz', 2)
tempbed = statusRetrieval(url, 'temps','current', 0)
tempext = statusRetrieval(url, 'temps','current', 1)
print('The Toolhead is at: (',coordx,', ',coordy,', ',coordz,')')
print('The Extruder is ',tempext,'°C')
print('The Bed is ',tempbed,'°C')
#sendGcode(url,'G10 P0 S0')
print(altstatusRetrival(url,'1'))
print(altstatusRetrival(url,'3'))