switchdoclabs/SDL_Pi_WeatherSense

Weather page of dash shows incorrect temperature(s)

Closed this issue · 1 comments

The temperature numbers on the Weather tab of the dash do not change when English_Metric = 1 in config.py is changed, even though the Displayed units (°C and °F) do change. It appears the outside Sensor (FT020TAIO) always displays Fahrenheit, and the inside sensor always Celsius.

In line 111 of SDL_Pi_WeatherSense.py the temp is read and converted to Fahrenheit, and that's what is stored in the DB:

wTemp = (wTemp - 400) / 10.0

In SDL_Pi_WeatherSense.py, the OutdoorTemperature and IndoorTemperature seem to be processed in opposite ways:

SDL_Pi_WeatherSense.py - Line 127

# convert temperature reading to Celsius but why?    
# OutdoorTemperature = round(((wTemp - 32.0) / (9.0 / 5.0)), 2)    
OutdoorTemperature = round(wTemp, 2)

SDL_Pi_WeatherSense.py - Line 236

IndoorTemperature = round(((var["temperature_F"] - 32.0) / (9.0 / 5.0)), 2)    
#IndoorTemperature = var["temperature_F"]

The dash problem seems to be that, when the temperature is read from the DB in dash_app/weather_page.py, the CTUnits function either converts the temp to Fahrenheit, or leaves as-is if the config is set to metric—but the default stored in the db for OutdoorTemperature is actually Fahrenheit.

dash_app/weather_page.py#L92

def CTUnits(temperature):    
    English_Metric = config.English_Metric

    if English_Metric:  # english units 
        temperature = (9.0 / 5.0 * temperature) + 32.0
    return temperature

Also, it's a bit confusing to call the config setting english_metric in this case, since England uses celsius...

Fixed in Version 004.