import click


def _validate_float_percentage_range(ctx, param, value):
    """ Used by the click framework to validate the a range of float values representing percentages."""
    if not (value >= 0.0 and value <= 1.0):
        raise click.BadParameter('must be in the range 0.0 - 1.0 (inclusive)')

    if value == 0.0:
        if param.name == 'brightness_level':
            click.secho('Brightness set to zero (0), no lights will be shown.', fg='red')
        if param.name == 'volume_level':
            click.secho('Volume set to zero (0), sound will not be audible.', fg='red')

    return value