I'm new in python and I'm writing a simple script to work with Firebase but I'm stuck on a simple if statement that seems not working as expected:
## check for max values
if humidity > maxHumidity:
firebase.put("/Controls/Sensors", "/Humidity/max_inside", ""+humidity+"%")
print("Updating Humidity max_inside")
if temperature > maxTemperature:
firebase.put("/Controls/Sensors", "/Temperature/max_inside", ""+temperature+"C")
print("Updating Temperature max_inside")
## check for min values
if humidity < minHumidity:
firebase.put("/Controls/Sensors", "/Humidity/min_inside", ""+humidity+"%")
print("Updating Humidity min_inside")
if temperature < minTemperature:
firebase.put("/Controls/Sensors", "/Temperature/min_inside", ""+temperature+"C")
print("Updating Temperature min_inside")
The problem is that the first two if statements are working as expected, the last two not.. If the humidity < minHumidity, nothing happens.
The value that I'm using are double like 70.50..
Edit
##retrieve max & min humidity (remove the %)
maxHumidity = firebase.get("/Controls/Sensors/Humidity/max_inside", None)
maxHumidity = maxHumidity[:-1]
maxHumidity = float(maxHumidity)
minHumidity = firebase.get("/Controls/Sensors/Humidity/min_inside", None)
minHumidity = minHumidity[:-1]
minHumidity = float(minHumidity)
#retrieve max & min temperature (remove the C)
maxTemperature = firebase.get("/Controls/Sensors/Temperature/max_inside", None)
maxTemperature = maxTemperature[:-1]
maxTemperature = float(maxTemperature)
minTemperature = firebase.get("/Controls/Sensors/Temperature/min_inside", None)
minTemperature = minTemperature[:-1]
minTemperature = float(minTemperature)
#add current value
humidity, temperature = readDHT22()
firebase.put("/Controls/Sensors", "/Humidity/current_inside", ""+humidity+"%")
firebase.put("/Controls/Sensors", "/Temperature/current_inside", ""+temperature+"C")
##check for max values
if humidity > maxHumidity:
firebase.put("/Controls/Sensors", "/Humidity/max_inside", ""+humidity+"%")
print("Updating Humidity max_inside")
if temperature > maxTemperature:
firebase.put("/Controls/Sensors", "/Temperature/max_inside", ""+temperature+"C")
print("Updating Temperature max_inside")
## cehck for min values
if humidity < minHumidity:
firebase.put("/Controls/Sensors", "/Humidity/min_inside", ""+humidity+"%")
print("Updating Humidity min_inside")
if temperature < minTemperature:
firebase.put("/Controls/Sensors", "/Temperature/min_inside", ""+temperature+"C")
print("Updating Temperature min_inside")
Tried to use float but seems still not working! Is not going into the min ifs.