def hass_brightness(device):
    """Home Assistant logic for determining brightness"""
    if 'level' in device:
        level = int(int(device['level']) / 100 * 255)
        return level
    else:
        return 0
