added rounded distance

Signed-off-by: Ebbe Baß <ebbe@ping-mee.de>
master
Ebbe Baß 2022-07-12 11:54:25 +02:00
parent 6f89c8f73a
commit d6c0cec463
1 changed files with 4 additions and 4 deletions

View File

@ -58,8 +58,8 @@ def get_water_level():
TimeElapsed = StopTime - startTime TimeElapsed = StopTime - startTime
distance = (TimeElapsed * 34300) / 2 distance = (TimeElapsed * 34300) / 2
rounded_distance = int(distance)
return int(distance) return str(rounded_distance)
#temperature #temperature
def get_temperature(): def get_temperature():
@ -71,13 +71,13 @@ def get_temperature():
print(get_water_level()) print(get_water_level())
print(get_temperature()) 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/1")
client.subscribe("strawberry-pi-greenhouse/relay/channel/2") client.subscribe("strawberry-pi-greenhouse/relay/channel/2")
client.subscribe("strawberry-pi-greenhouse/relay/channel/3") client.subscribe("strawberry-pi-greenhouse/relay/channel/3")
client.subscribe("strawberry-pi-greenhouse/relay/channel/4") 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("topic: " ,str(msg.topic))
print("payload: " ,str(msg.payload.decode("utf-8"))) print("payload: " ,str(msg.payload.decode("utf-8")))
topic = str(msg.topic) topic = str(msg.topic)