-3
I’m getting the string 24.120185722369005
from a MQTT(Hivemq) topic, but when converting to float
, it ignores the rest of the function.
def on_message(client, userdata, msg):
temperatura = msg.payload.decode()
print('-----------------------------------------------')
print('NUMERO DE ENTRADA :'+temperatura)
try:
print('tentando converter')
temperatura = float(temperatura)
except ValueError:
print('bugado')
#DEPOIS DAQUI ELE NÃO FAZ OS COMANDOS ABAIXO, MAS NÃO MOSTRA ERRO.
print('temperatura convertida: '+temperatura)
print('----------------------------------------------2')
# Validar temperatura de entrada para enviar on/off
if temperatura > float(50.00):
print('passando o OFF')
elif temperatura < float(50.00):
print('Passando o ONN')
You have no idea how much you helped Brother, God bless you. I tried it and it worked. I did a lot of research, but I didn’t know where the problem was. Heartfelt thanks.
– Waldecir
You’re welcome, man. Tmj
– Lucas Módolo