diff --git a/main.py b/main.py index e5ba5c0..b845500 100644 --- a/main.py +++ b/main.py @@ -58,8 +58,8 @@ def get_water_level(): TimeElapsed = StopTime - startTime distance = (TimeElapsed * 34300) / 2 - - return int(distance) + rounded_distance = int(distance) + return str(rounded_distance) #temperature def get_temperature(): @@ -71,13 +71,13 @@ def get_temperature(): print(get_water_level()) print(get_temperature()) -def mqtt_on_connect(client): +def mqtt_on_connect(client, userdata, flags, rc): client.subscribe("strawberry-pi-greenhouse/relay/channel/1") client.subscribe("strawberry-pi-greenhouse/relay/channel/2") client.subscribe("strawberry-pi-greenhouse/relay/channel/3") client.subscribe("strawberry-pi-greenhouse/relay/channel/4") -def mqtt_on_message(msg): +def mqtt_on_message(client, userdata, msg): print("topic: " ,str(msg.topic)) print("payload: " ,str(msg.payload.decode("utf-8"))) topic = str(msg.topic)