Webserver API not sending moves or logs

I've gotten the WebAPI working with websockets where commands work well, and I'm getting the right responses, but I'm not getting moves or logEvents, but I do get temp and other events, so I know that bi-directional is working.

Here's the command I'm using the send request moves.

{  "data": {},  "action": "sendMoves",  "printer": "Hictop",  "callback_id": 7 }

I do get back a response, but there's no real information:


Is there something different I should put to get the correct behavior?



  • Should note: Running server 80.3 on Raspberry Pi. Just started 14 day trial period for this installation.
  • Read the event section. moves/logs are only send after you enable sending them. Then the moves or logs get send as events:


    Payload: {"x":1,"y":1,"z":0,"e":67.233,"de":0.023}
    When moves are enabled (sendMoves action) you will get a event for every move the printer does. This can be used to provide a live preview of what the printer does.


    Payload: {"id":1,"time":14535345345,"text":"ok","type":2}
    When the proper log level is set, you get events for each new log line you wish to see. Type indicates one of the following: 1 : Commands
    2 : ACK responses like ok, wait, temperature
    4 : Other responses
    8 : Non maskable messages

    Regasrding setting log level


    Parameter: level (int) = logging level you want events for.


    Select which logging messages you want to get as log events. Bit values for level types are:
    1 : Commands
    2 : ACK responses like ok, wait, temperature
    4 : Other responses
    8 : Non maskable messages

    I hope action setLogLevel is correct. I know it was wront at some time so might also be setLoglevel just not sure at the moment.
  • I'm aware that I have to enable them, as you can see from above, I posted a sample json blob that should enable sendMoves (in fact, that code did work at one point.)

    I'm asking if there is something additional that I need to send in the blob.

  • You only get moves for the active printer, so you need to send "activePrinter" with printer parameter to set which printer should report moves if enabled. That should be all needed.
  • In the above json, "Hictop" is the name of the active printer/slug that I want moves from. Should I send "Hictop" or "activePrinter". If it should be "activePrinter" how do I tell the API which one is the active printer before this?
  • Thats what I tried to say. action:"activePrinter" "printer":"Hictop", data empty. So you can use "printer" also to query other printers without them becoming active as it was before. 
  • Thank you. Sending activePrinter then sendMoves with no printer specified got things working again.

    You should add this to the API doc. There is nothing in the documentation that says to send the command "activePrinter"
  • edited October 2020
    Hello, i need some support for the latest version 0.94.3.
    i´ve 2 printers and I am sending the activePrinter ( action:"activePrinter", printer:"slug") ) and next the sendMoves (action: "sendMoves" ) for both but nothing happens. Is there something what i miss?
    I want to get the Event "move" as feedback to check the position of z-axis. 
  • That function is for drawing motions while printing. Therefor it is only possible for one printer to get moves. This is for the active printer when sendMoves is enabled. It will then send new coordinates for every G1/G0 move happening afterwards with the move event.

    When you just want the latest x,y,z position there is an other function that also works for all printers in parallel. action stateList returns states for all printers which also include x, y and z position form last send command.
  • Ok, thanks, i was trying to get it then even for 2...i know stateList would be another possibility...but even for one i didn´t get anything. 
  • You will get move event for the last activated printer. But as said you need to send G1 after activating to get a new value.
  • That means I'll get only on my send G1s a event back? I thought it's to get a printed file G1s which I get back. Or I'm wrong.
    Both printers have been printing during the test.
  • While printing it is sending constantly G1/G0 moves so it should send moves. If you watch our interface and monitor the socket you will see exactly this happens. But again watch out is will most likely be multiple events in one package again. The sendMoves actions does not return anything. It just enables the move events


    Payload: {"x":1,"y":1,"z":0,"e":67.233,"de":0.023}

    When moves are enabled (sendMoves action) you will get a event for every move the printer does. This can be used to provide a live preview of what the printer does.

  • Yes, my program is checking for multiple informations in the data{}. This l have found out when I didn't get the jobstarted action, which usually comes with 3 to 5 others in one dataset. So I do loop through each data array. I even only print to the console the move data, if I would receive then.
    Mine is not sending out the moves right now.
    I get all others during the print.
  • In theory it should send them. It has 2 filters so it needs sendMoves and a default printer you have set with activePrinter. Can you show your websocket communication where you send these 2 commands. Only reason I see so far is that there is an error in the syntax. e.g. do all request have a data field with {} ?
  • It still failed...but i think we get closer.

    Could it be, that it will be only send through the same websocket? Because i´ve one thread opening and closing the websocket to get single requests, like you see the output below...but i´ve another thread which listen to the Events.

    Do i need to use the same websocket to get this information or is it send to all websockets which are listening?
    (i believe it might be the first idea...only to the same ws...)

    And yes, i do check for multiple "data" entries in one response. I figured this out on another question, that there might be more then one data entry for a response...

    So, i´ve some output for you (my function is properly set up to get all datas from the ws):

    {"action": "listPrinter", "data": {}, "printer": "My Printer", "callback_id": 1}

    {"callback_id":1,"data":[{"active":true,"analysed":1,"done":0.0009631766851311205,"job":"AI3M_PTW-36-1-PT-0338_Ramp","jobid":8,"linesSend":9,"name":"Anycubic Mega X","ofLayer":242,"online":1,"pauseState":0,"paused":false,"printStart":1603298454.963,"printTime":89198.66885674557,"printedTimeComp":1292.929962158203,"slug":"Anycubic_Mega_X1","start":1603305654,"totalLines":934408},{"active":true,"job":"none","name":"Anycubic i3 Mega S","online":0,"pauseState":0,"paused":false,"slug":"Anycubic_i3_Mega_S"}],"session":"Z843RMRko@wu41Bbz7O^WkR1LHggCCI^"}
    (MainThread) - 2020-10-21 18:43:48,081 - WS Thread - INFO - Bot Data angelegt

    {"action": "stateList", "data": {}, "printer": "My Printer", "callback_id": 2}


    {"action": "sendMoves", "data": {}, "printer": "My Printer", "callback_id": 3}


    {"action": "activePrinter", "data": {}, "printer": "Anycubic_Mega_X1", "callback_id": 4}

    After checking the browser websocket i´ve tried with this one, like it is handled in your web application.

    {"action": "activePrinter", "data": {"printer": "Anycubic_Mega_X1"}, "printer": "Anycubic_Mega_X1", "callback_id": 4}



  • I guess you found your problem. Of course it is only send to the ws that send the active printer and sendMoves command. Why should other clients get these informations they never asked for? Also the session is only really valid as long as you are connected with the ws and events always require the ws to be open or there is no one listening for them. So each client should have exactly one ws for communication. You see this also in your sample javascript implementation.

    You see callback_id is meant exactly to allow this. That way you know which response matches which request and you can make a list of open callbacks. Events have id -1 as they are not result of an action. So all actions should have a callback function as well that get send for the ws dispatcher to get called once result is received..
  • Ok, many thanks for your help...
Sign In or Register to comment.