Querying bartendro state with HTTP Get
I'm working with a Bartendro 15 and need to control it over http from another computer connected directly with an ethernet cable.
The networking connection is working fine and I can send Http Get requests and receive responses, so far so good.
Now I would like to be able to get some more feedback from the Bartendro like knowing it's state/status and if it's busy pouring a drink or ready to mix another.
So far I've edited bartendro/ui/bartendro/view/ws/misc.py by adding the following at the end of the file (I've also added import of fsm from bartendro at the top):
@app.route('/ws/query_state') def ws_query_state(): state = "state not set" bstate = app.globals.get_state() if bstate == fsm.STATE_START: state = "Bartendro is starting up." elif bstate == fsm.STATE_READY: state = "Bartendro is ready!" elif bstate == fsm.STATE_LOW: state = "Bartendro is ready, but one or more boozes is low!" elif bstate == fsm.STATE_OUT: state = "Bartendro is ready, but one or more boozes is out!" elif bstate == fsm.STATE_HARD_OUT: state = "Bartendro cannot make any drinks from the available booze!" elif bstate == fsm.STATE_ERROR: state = "Bartendro is out of commission. Please reset Bartendro!" else: state = "Bartendro is in bad state: %d" % bstate r = Response( state ) return r
I can now get a response with a http Get request to http://bartentro-ip/ws/query_state but I'm always getting "Bartendro is ready!" regardless if I also tell it to pour a drink or restart from the normal web interface.
Do you have any suggestions on how to make this work?
Is the state system working?
Can it be an issue related to the global_lock() functionality?
Am I better off trying to send http requests from the Bartendro software whenever a state changes?
I would appreciate any help towards adding the functionality I need to the Bartendro.
Side question: is there a log for python errors somewhere in the system?
Is this a good question?