Site Navigation

Your Account

Choose Language

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/ by adding the following at the end of the file (I've also added import of fsm from bartendro at the top):

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!"     
        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?

Answered! View the answer I have this problem too

Is this a good question?

Score 0


I just realised that Http Get may be cached so I will check if that is the issue tomorrow.


Doesn't seem to be related to caching, so I'm still puzzled as to why I always get the same state.


Add a comment

1 Answer

Chosen Solution

The coded I post above was obviously missing a number of possible states but that's not important since it seems like you can only get a few of the machine's state with get_state() due to the lock being used on the state frequently in the code.

I solved it for my purposes by having the bartendro report it's state when doing things in through http POST requests to the connected PC using the requests library. So now I can know when it is pouring a drink etc by listening to those http requests.

Was this answer helpful?

Score 0
Add a comment

Add your answer

Bjorn will be eternally grateful.
View Statistics:

Past 24 Hours: 0

Past 7 Days: 0

Past 30 Days: 1

All Time: 75