Get Hotend Temperature from websocket
Hello,
My ideas is to read the actual Hotend temperature with websocket with a bash script running in cron every x time using "curl" command.
This script manage the fan power (dedicated GPIO) according the temperature.
Now have the fan always on also when the temperature is about 20°C
Can help me with Websocket usage?
My ideas is to read the actual Hotend temperature with websocket with a bash script running in cron every x time using "curl" command.
This script manage the fan power (dedicated GPIO) according the temperature.
Now have the fan always on also when the temperature is about 20°C
Can help me with Websocket usage?
Comments
https://www.repetier-server.com/manuals/programming/API/index.html
User websocket commands directly
In the websocket chapter you will see all the small commands you normally use while you are displaying server status. Soem of them might also be useful for simple apps just wanting to show some informations. For these we offer a access over the REST api. The only thing that does not work are events as they are reported to open sockets only.
The above schema can be used to send any websocket command as REST call. Use GET or POST just as you like. For bigger data POSt should be preferred. You can replace apikey with sess, but you would normally do this only if you have no session open, so apikey is the normal way to use it.
Then use
stateList
Parameter: includeHistory (bool) include complete temperature history.
Response
Polls the detailed printer state with or without a complete temperature history.
with includeHistory false to get you json response.
http://printer_address:3344/printer/info
to get the api key.
after i put this line in web browser:
http://printer_address:3344/printer/api/<slug>a=<websocket command>&data=<json object properly url-escaped>&apikey=<14e7bf36-7537-46ad-a92b-08c43c81e82a>>
but always get
Parts in <> are placeholders and you need to replace them with the content.
http://printer_address:3344/printer/api/irapid?a=stateList&apikey=14e7bf36-7537-46ad-a92b-08c43c81e82a&data=%7BincludeHistory%3Afalse%7D
replace irapid with your printer.
To encode/decode the data part you can use this:
https://www.url-encode-decode.com/
many thanks.
Based on your indication, i've done my things and all work very well.
I want to share with you my project so if you do a thought you can implement directly in new version.
I'done this on raspberry pi 2:
Installed fbi with sudo apt-get install fbi
Have create a script called E_STOP.sh and background.sh and an image file estop.jpg.
E_STOP.sh:
background.sh:
and put all in /home/pi/Desktop directory
have assigned -x permission to all script
end have registered background.sh to start at boot with:
sudo update-rc.d background.sh defaults
Now the fan to cool the hothend is directly controlled by GPIO4 according the temperature.
If i press emergency button, script send a reset, and deactivate printer , activate hothend fan and blink every 2 seconds the image on display.
If i restore the emergency button the image stop blink and the printer is reactivated.
The server has a module system, so you could write more or less the same as a server module. That way you need to query of the server and can get data directly in the server as the script has access to important parts. We also have a emergency function in server.