Changed queries to be asynchronous and added functionality for setting valve states and sending them to the server