@@ 114-130 (lines=17) @@ | ||
111 | (reporting_start_datetime_utc, |
|
112 | reporting_end_datetime_utc)) |
|
113 | rows_hourly = cursor_energy_db.fetchall() |
|
114 | if rows_hourly is not None and len(rows_hourly) > 0: |
|
115 | for row_hourly in rows_hourly: |
|
116 | if row_hourly[0] not in discharge_report_dict.keys(): |
|
117 | discharge_report_dict[row_hourly[0]] = dict() |
|
118 | discharge_report_dict[row_hourly[0]]['discharge_times'] = list() |
|
119 | discharge_report_dict[row_hourly[0]]['discharge_values'] = list() |
|
120 | # today total discharge, not 24 hours |
|
121 | discharge_report_dict[row_hourly[0]]['today_total_discharge'] = Decimal(0.0) |
|
122 | ||
123 | current_datetime_local = row_hourly[1].replace(tzinfo=timezone.utc) + timedelta( |
|
124 | minutes=timezone_offset) |
|
125 | discharge_report_dict[row_hourly[0]]['discharge_times'].append( |
|
126 | current_datetime_local.isoformat()[11:16]) |
|
127 | actual_value = Decimal(0.0) if row_hourly[2] is None else row_hourly[2] |
|
128 | discharge_report_dict[row_hourly[0]]['discharge_values'].append(actual_value) |
|
129 | if current_datetime_local >= today_start_datetime_local: |
|
130 | discharge_report_dict[row_hourly[0]]['today_total_discharge'] += actual_value |
|
131 | ||
132 | cursor_energy_db.close() |
|
133 | cnx_energy_db.close() |
|
@@ 86-102 (lines=17) @@ | ||
83 | (reporting_start_datetime_utc, |
|
84 | reporting_end_datetime_utc)) |
|
85 | rows_hourly = cursor_energy_db.fetchall() |
|
86 | if rows_hourly is not None and len(rows_hourly) > 0: |
|
87 | for row_hourly in rows_hourly: |
|
88 | if row_hourly[0] not in charge_report_dict.keys(): |
|
89 | charge_report_dict[row_hourly[0]] = dict() |
|
90 | charge_report_dict[row_hourly[0]]['charge_times'] = list() |
|
91 | charge_report_dict[row_hourly[0]]['charge_values'] = list() |
|
92 | # today total charge, not 24 hours |
|
93 | charge_report_dict[row_hourly[0]]['today_total_charge'] = Decimal(0.0) |
|
94 | ||
95 | current_datetime_local = row_hourly[1].replace(tzinfo=timezone.utc) + timedelta( |
|
96 | minutes=timezone_offset) |
|
97 | charge_report_dict[row_hourly[0]]['charge_times'].append( |
|
98 | current_datetime_local.isoformat()[11:16]) |
|
99 | actual_value = Decimal(0.0) if row_hourly[2] is None else row_hourly[2] |
|
100 | charge_report_dict[row_hourly[0]]['charge_values'].append(actual_value) |
|
101 | if current_datetime_local >= today_start_datetime_local: |
|
102 | charge_report_dict[row_hourly[0]]['today_total_charge'] += actual_value |
|
103 | ||
104 | # get discharge data in latest 24 hours |
|
105 | discharge_report_dict = dict() |