예제 #1
0
파일: config.py 프로젝트: csuvbakka/myhouse
def get_devices_from_config():
    devices = []
    with open(main_config()['devices'], 'r') as f:
        device_data = json.load(f)

        for device_info in device_data:
            devices.append(
                Device.from_json_string(
                    json.dumps(device_info)))

    return devices
예제 #2
0
파일: status.py 프로젝트: csuvbakka/myhouse
    return '<td class="'+status+'">' + status + '</td>'


require_private_access()

output = html_output('status.html')
if 'Android' in os.environ['HTTP_USER_AGENT']:
    output.add_parameter('stylesheet', 'mobile.css')
else:
    output.add_parameter('stylesheet', 'desktop.css')

presence_data = json.loads(presence_data_request().get_response())
if not presence_data:
    html_data = '<p>Presence status is not available</p>'
else:
    html_data = ''
    for data in presence_data:
        if data['type'] == 'device':
            presence_item = Device.from_json_string(json.dumps(data['item']))
        elif data['type'] == 'person':
            presence_item = Person.from_json_string(json.dumps(data['item']))

        table_data = _device_status_row(presence_item.status)
        table_data += _device_last_changed(data['last_status_change'])

        html_data += '<tr><td>%s</td>%s</tr>' % (presence_item.name, table_data)


output.add_parameter('data', html_data)
print output