def turn_fan_on(): lock.acquire() profile.turn_fan_on_button['active'] = True profile.turn_automatic_mode_on_button['active'] = False profile.turn_fan_off_button['active'] = False profile.connect_button['disabled'] = False profile.set_location_button['disabled'] = False profile.set_temperature_preferences_button['disabled'] = False profile.mode = "manual on" hardware.turn_fan_on() status = get_status() lock.release() return status
def run_automatic_mode(): ''' ''' while True: lock.acquire() if not profile.turn_automatic_mode_on_button['active']: lock.release() break outside_temp, error = outside_data.get_outside_temp(profile.lat, profile.lon) profile.weather_api_error = error inside_temp = sensor.get_inside_temp() inside_temp = float(inside_temp) outside_temp = float(outside_temp) if config.record_temp: record_temp(inside_temp, outside_temp) cooler_outside = outside_temp < inside_temp - float(profile.temp_margin) if cooler_outside and inside_temp > float(profile.min_temp): hardware.turn_fan_on() else: hardware.turn_fan_off() lock.release() time.sleep(float(profile.min_cycle_time))