예제 #1
0
def html_menu_lhs():
    #
    html = ''
    #
    t = 0
    #
    a_list = get_cfg_idlist_accounts()
    a_num = 0
    #
    while a_num < len(a_list):
        #
        html += '<span class="sidebar_divider box-shadow"></span>'
        #
        label = get_cfg_account_name(a_list[a_num])
        img = get_device_logo(get_cfg_account_type(a_list[a_num]))
        #
        html += urlopen('web/html/html_menu/menu_sidebar_item.html').read().encode('utf-8').format(href=('/web/account/{account_id}').format(account_id=a_list[a_num]),
                                                                                              id='{account_id}'.format(account_id=a_list[a_num]),
                                                                                              cls='',
                                                                                              name=label,
                                                                                              img=img)

        #
        t += 1
        a_num += 1
    #
    r_list = get_cfg_idlist_rooms()
    r_num = 0
    #
    while r_num < len(r_list):
        d_list = get_cfg_idlist_devices(r_list[r_num])
        d_num = 0
        #
        html += '<span class="sidebar_divider box-shadow"></span>'
        #
        html += urlopen('web/html/html_menu/menu_sidebar_title.html').read().encode('utf-8').\
            format(name=get_cfg_room_name(r_list[r_num]))
        #
        while d_num < len(d_list):
            #
            label = get_cfg_device_name(r_list[r_num], d_list[d_num])
            img = get_device_logo(get_cfg_device_type(r_list[r_num], d_list[d_num]))
            #
            html += urlopen('web/html/html_menu/menu_sidebar_item.html').read().encode('utf-8').format(href=('/web/device/{room_id}/{device_id}').format(room_id=r_list[r_num],
                                                                                                                                                    device_id=d_list[d_num]),
                                                                                                  id='{room_id}_{device_id}'.format(room_id=r_list[r_num],
                                                                                                                                    device_id=d_list[d_num]),
                                                                                                  cls='',
                                                                                                  name=label,
                                                                                                  img=img)
            d_num += 1
        #
        r_num += 1
    #
    return urlopen('web/html/html_menu/menu_lhs.html').read().encode('utf-8').format(menu=html)
def settings_devices_selection(grpnum, dvcnum):
    #
    body = '<div class="row">'
    count = 0
    devices = read_list_devices()
    #
    device_keys = devices.keys()
    #
    for dvc_key in device_keys:
        if count> 0 and count % 4 == 0:
            body += '</div><div class="row">'
        #
        name = get_device_name(devices[dvc_key]['type'])
        img = get_device_logo(devices[dvc_key]['type'])
        #
        body += urlopen('web/html/html_settings/settings_devices_selection_item.html').read().encode('utf-8').format(name=name,
                                                                                                                img=img,
                                                                                                                grpnum=grpnum,
                                                                                                                dvcnum=dvcnum,
                                                                                                                type=devices[dvc_key]['type'].lower().replace(' ',''))
        count += 1
    #
    body += '</div>'
    #
    return body
예제 #3
0
def compile_setup():
    #
    data = get_cfg_device_json()
    #
    for a in data['structure']['accounts']:
        del data['structure']['accounts'][a]['details']
        data['structure']['accounts'][a]['logo'] = get_device_logo(data['structure']['accounts'][a]['account_type'])
        #
    for r in data['structure']['rooms']:
        for d in data['structure']['rooms'][r]['devices']:
            del data['structure']['rooms'][r]['devices'][d]['details']
            data['structure']['rooms'][r]['devices'][d]['logo'] = get_device_logo(data['structure']['rooms'][r]['devices'][d]['device_type'])
            #
    #
    try:
        return ast.literal_eval(data)
    except:
        return data
예제 #4
0
 def _logo(self):
     return get_device_logo(self._type)