Exemple #1
0
def get_play_mode(heosobj, command, data):
    """CLI 4.2.13"""

    parts = get_message_parts(data, ['pid', 'repeat', 'shuffle'])

    if 'pid' in parts.keys():
        pid = parts['pid']
    else:
        raise HEOSException(message='Response does not contain PID, aborting')

    if 'repeat' in parts.keys():
        repeat_status = parts['repeat']
    else:
        raise HEOSException(
            message='Response does not contain repeat, aborting')

    if 'shuffle' in parts.keys():
        shuffle_status = parts['shuffle']
    else:
        raise HEOSException(
            message='Response does not contain shuffle, aborting')

    if repeat_status not in ['on', 'off']:
        raise HEOSException(
            message='Illegal repeat state received: {}'.format(repeat_status))

    if shuffle_status not in ['']:
        raise HEOSException(message='Illegal shuffle state received: {}'.
                            format(shuffle_status))
Exemple #2
0
def get_play_state(heosobj, command, data):
    """CLI 4.2.3"""

    parts = get_message_parts(data, ['pid', 'state'])

    if 'pid' in parts.keys():
        pid = parts['pid']
    else:
        raise HEOSException(message='Response does not contain PID, aborting')

    if 'state' in parts.keys():
        state = parts['state']
    else:
        raise HEOSException(
            message='Response does not contain state, aborting')

    if state not in ['play', 'pause', 'stop']:
        raise HEOSException(
            message='Invalid play state received: {}'.format(state))

    try:
        attrname = "_play_states['" + pid + "']"
        setattr(heosobj, attrname, state)
    except:
        e = sys.exc_info()
        raise HEOSException(message=e[1] + ": " + e[2])
Exemple #3
0
def play_input(heosobj, command, data):
    """CLI 4.4.9"""

    parts = get_message_parts(data, ['sid', 'pid', 'mid', 'spid', 'input'])

    heosobj._cur_play_state = parts

    return parts
Exemple #4
0
def play_preset(heosobj, command, data):
    """CLI 4.4.8"""

    parts = get_message_parts(data, ['pid', 'preset'])

    heosobj._cur_play_state = parts

    return parts
Exemple #5
0
def play_stream(heosobj, command, data):
    """CLI 4.4.7"""

    parts = get_message_parts(data, ['pid', 'sid', 'cid', 'mid', 'name'])

    heosobj._cur_play_state = parts

    return parts
Exemple #6
0
def add_track_to_queue(heosobj, command, data):
    """CLI 4.4.12"""

    parts = get_message_parts(data, ['sid', 'cid', 'mid', 'aid', 'pid'])

    heosobj._cur_play_state = parts

    return parts
Exemple #7
0
def play_url(heosobj, command, data):
    """CLI 4.4.10"""

    parts = get_message_parts(data, ['pid', 'url'])

    heosobj._cur_play_state = parts

    return parts
Exemple #8
0
def player_now_playing_changed(heosobj, command, data):
    """CLI 5.5"""

    if command == 'event/player_now_playing_changed':
        pid = get_message_parts(data, ['pid'])[0]

        heosobj.send_command(
            command='player/get_player_info?pid={}'.format(pid))
    else:
        raise HEOSException(message='{} is an unknown command'.format(command),
                            error=505)
Exemple #9
0
def volume_up(heosobj, command, data):
    """CLI 4.2.8"""

    parts = get_message_parts(data, ['pid', 'step'])

    if 'pid' in parts.keys():
        pid = parts['pid']
    else:
        raise HEOSException(message='Response does not contain PID, aborting')

    if 'step' in parts.keys():
        step_level = parts['step']
    else:
        raise HEOSException(
            message='Response does not contain volume level, aborting')
Exemple #10
0
def volume_up(heosobj, command, data):
    """CLI 4.3.6"""

    from datetime import datetime

    parts = get_message_parts(data, ['gid', 'step'])
    group_id = parts['gid']
    step_up = parts['step']

    old_groups = heosobj._groups
    new_groups = {}

    for group in old_groups:
        new_groups.update(group)
        if group['gid'] == group_id:
            new_groups.update({'gid': group_id, 'step': step_up})

    heosobj.save_groups(new_groups, datetime.now())
Exemple #11
0
def get_group_volume(heosobj, command, data):
    """CLI 4.3.4"""

    from datetime import datetime

    parts = get_message_parts(data, ['gid', 'level'])
    group_id = parts['gid']
    volumelevel = parts['level']

    old_groups = heosobj._groups
    new_groups = {}

    for group in old_groups:
        new_groups.update(group)
        if group['gid'] == group_id:
            new_groups.update({'gid': group_id, 'level': volumelevel})

    heosobj.save_groups(new_groups, datetime.now())
Exemple #12
0
def get_mute(heosobj, command, data):
    """CLI 4.3.8"""

    from datetime import datetime

    parts = get_message_parts(data, ['gid', 'state'])
    state = parts['state']
    group_id = parts['gid']

    old_groups = heosobj._groups
    new_groups = {}

    for group in old_groups:
        new_groups.update(group)
        if group['gid'] == group_id:
            new_groups.update({'gid': group_id, 'state': state})

    heosobj.save_groups(new_groups, datetime.now())
Exemple #13
0
def get_volume(heosobj, command, data):
    """CLI 4.2.6"""

    parts = get_message_parts(data, ['pid', 'level'])

    if 'pid' in parts.keys():
        pid = parts['pid']
    else:
        raise HEOSException(message='Response does not contain PID, aborting')

    if 'level' in parts.keys():
        vol_level = parts['level']
    else:
        raise HEOSException(
            message='Response does not contain volume level, aborting')

    try:
        attrname = "_player_volumes['" + pid + "']"
        setattr(heosobj, attrname, vol_level)
    except:
        e = sys.exc_info()
        raise HEOSException(message=e[1] + ": " + e[2])
Exemple #14
0
def set_group(heosobj, command, data):
    """CLI 4.3.3"""

    from datetime import datetime

    parts = get_message_parts(data, ['pid', 'gid', 'name'])
    player_list = parts['pid']
    new_group = parts['gid']
    new_group_name = parts['name']

    old_groups = heosobj._groups

    new_groups = {}

    for group in old_groups:
        new_groups.update(group)
        if group['gid'] == new_group:
            new_groups.update({
                'gid': new_group,
                'pid': player_list,
                'name': new_group_name
            })

    heosobj.save_groups(new_groups, datetime.now())
Exemple #15
0
def delete_playlist(heosobj, command, data):
    """CLI 4.4.15"""

    parts = get_message_parts(data, ['sid', 'cid'])

    return parts
Exemple #16
0
def rename_playlist(heodobj, command, data):
    """CLI 4.4.14"""

    parts = get_message_parts(data, ['sid', 'cid', 'name'])

    return parts