Skip to content

Commit b5b2ddd

Browse files
Juliana MashonJuliana Mashon
Juliana Mashon
authored and
Juliana Mashon
committed
Moved some stuff around in read_status()
1 parent 3581512 commit b5b2ddd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

functions/broker.py

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def on_connect(self, _client, _userdata, _flags, _rc, channel):
6666

6767
self.client.subscribe(
6868
f"bot/{self.state.token['token']['unencoded']['bot']}/{channel}")
69+
70+
self.state.print_status("on_connect()", description=f"Connected to message broker channel {channel}")
6971

7072
def on_message(self, _client, _userdata, msg):
7173
"""Callback function when message received from message broker."""
@@ -85,11 +87,13 @@ def start_listen(self, channel="#"):
8587
self.client.on_message = self.on_message
8688

8789
self.client.loop_start()
90+
self.state.print_status("start_listen()", description=f"Now listening to message broker channel {channel}.")
8891

8992
def stop_listen(self):
9093
"""End subscription to all message broker channels."""
9194

9295
self.client.loop_stop()
9396
self.client.disconnect()
9497

98+
self.state.print_status("stop_listen()", description="Stopped listening to all message broker channels.")
9599
return

functions/information.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def soil_height(self):
118118
def read_status(self):
119119
"""Returns the FarmBot status tree."""
120120

121+
self.broker.start_listen("status")
121122
status_message = {
122123
"kind": "rpc_request",
123124
"args": {
@@ -131,8 +132,7 @@ def read_status(self):
131132
}
132133
self.broker.publish(status_message)
133134

134-
self.broker.start_listen("status")
135-
time.sleep(15)
135+
time.sleep(5)
136136
self.broker.stop_listen()
137137

138138
status_tree = self.broker.state.last_message

0 commit comments

Comments
 (0)