示例#1
0
    def get(self):
        device = request.args.get('device')

        response = requests.get(info.URL + 'devices/' + device +
                                '/usages/realtime',
                                headers=info.headers)
        json_obj = json.loads(response.text)
        json_obj['activePower'] = unit_conversion.convert(
            json_obj['activePower'])
        return json_obj
示例#2
0
    def get(self):
        site_id = info.site_ids[request.args.get('where')]

        response = requests.get(info.URL + 'sites/' + site_id +
                                '/usages/realtime',
                                headers=info.headers)
        json_obj = json.loads(response.text)
        print(json_obj)
        json_obj['activePower'] = unit_conversion.convert(
            json_obj['activePower'])
        return json_obj
示例#3
0
    def get(self):
        device = request.args.get('device')
        start = time_manager.date_to_timestamp(request.args.get('start'))
        end = time_manager.date_to_timestamp(request.args.get('end'))

        params = {'start': start, 'end': end}
        response = requests.get(info.URL + 'devices/' + device +
                                '/usages/periodic',
                                headers=info.headers,
                                params=params)
        json_obj = json.loads(response.text)
        json_obj['usage'] = unit_conversion.convert(json_obj['usage'])
        return json_obj
示例#4
0
    def get(self):
        site_id = info.site_ids[request.args.get('where')]
        tag_id = request.args.get('tag')
        start = time_manager.date_to_timestamp(request.args.get('start'))
        end = time_manager.date_to_timestamp(request.args.get('end'))

        params = {'start': start, 'end': end}
        response = requests.get(info.URL + 'sites/' + site_id + '/tags/' +
                                tag_id + '/usages/periodic',
                                headers=info.headers,
                                params=params)
        json_obj = json.loads(response.text)
        json_obj['usage'] = unit_conversion.convert(json_obj['usage'])
        return json_obj
示例#5
0
    def get(self):
        # 오늘 에너지 사용량 조회
        site_id = info.site_ids[request.args.get('where')]
        start = time_manager.date_to_timestamp(request.args.get('date'))
        end = time_manager.datetime_to_timestamp(
            time_manager.get_cur_datetime())

        params = {'start': start, 'end': end}
        response = requests.get(info.URL + 'sites/' + site_id +
                                '/usages/periodic',
                                headers=info.headers,
                                params=params)
        json_obj = json.loads(response.text)
        print(json_obj)
        json_obj['usage'] = unit_conversion.convert(json_obj['usage'])
        return json_obj