def get_data(param, data):
    """Retrieve weather parameter."""

    try:
        for (_, selected_time_entry) in data:
            loc_data = selected_time_entry['location']
            if param not in loc_data:
                continue
            if param == 'precipitation':
                new_state = loc_data[param]['@value']
            elif param == 'symbol':
                new_state = int(float(loc_data[param]['@number']))
            elif param in ('temperature', 'pressure', 'humidity',
                           'dewpointTemperature'):
                new_state = round(float(loc_data[param]['@value']), 1)
            elif param in ('windSpeed', 'windGust'):
                new_state = round(float(loc_data[param]['@mps']) * 3.6, 1)
            elif param == 'windDirection':
                new_state = round(float(loc_data[param]['@deg']), 1)
            elif param in ('fog', 'cloudiness', 'lowClouds',
                           'mediumClouds', 'highClouds'):
                new_state = round(float(loc_data[param]['@percent']), 1)
            return new_state
    except (ValueError, IndexError, KeyError):
        return None
def get_data ( param , data ) : try : for ( _ , selected_time_entry ) in data : loc_data = selected_time_entry [ 'location' ] if param not in loc_data : continue if param == 'precipitation' : new_state = loc_data [ param ] [ '@value' ] elif param == 'symbol' : new_state = int ( float ( loc_data [ param ] [ '@number' ] ) ) elif param in ( 'temperature' , 'pressure' , 'humidity' , 'dewpointTemperature' ) : new_state = round ( float ( loc_data [ param ] [ '@value' ] ) , 1 ) elif param in ( 'windSpeed' , 'windGust' ) : new_state = round ( float ( loc_data [ param ] [ '@mps' ] ) * 3.6 , 1 ) elif param == 'windDirection' : new_state = round ( float ( loc_data [ param ] [ '@deg' ] ) , 1 ) elif param in ( 'fog' , 'cloudiness' , 'lowClouds' , 'mediumClouds' , 'highClouds' ) : new_state = round ( float ( loc_data [ param ] [ '@percent' ] ) , 1 ) return new_state except ( ValueError , IndexError , KeyError ) : return None
Retrieve weather parameter.