@golemio/energetics 1.17.2-dev.2897106860 → 2.0.0-dev.2954231424

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,8 @@
13
13
 
14
14
  INSERT INTO eno_budova (gid, zdroj, nazev, oznaceni, platnost_od) VALUES
15
15
  ('GIDCH1', 'mhmp', 'ZŠ Spotřeba', 'ZSS', '2019-01-01'),
16
- ('GIDCH2', 'mhmp', 'Objekt s více plynoměry', 'OVP', '2019-01-01');
16
+ ('GIDCH2', 'mhmp', 'Objekt s více plynoměry', 'OVP', '2019-01-01'),
17
+ ('GIDCH5', 'mhmp', 'Objekt s výměnou plynoměru', 'OVY', '2019-01-01');
17
18
 
18
19
  INSERT INTO enapo_gid_mapping (place_id, id_type, commodity, gid, is_first_gid, link_source, valid_from, valid_to) VALUES
19
20
  ('859182400000000101', 'ean', 'electricity', 'GIDCH1', true, 'mock', '2022-01-01', NULL),
@@ -21,7 +22,11 @@ INSERT INTO enapo_gid_mapping (place_id, id_type, commodity, gid, is_first_gid,
21
22
  -- one physical meter behind two PPAS registrations
22
23
  ('27ZG100Z0000CH02', 'eic', 'gas', 'GIDCH2', true, 'mock', '2022-01-01', NULL),
23
24
  -- two physical meters on one EIC
24
- ('27ZG100Z0000CH03', 'eic', 'gas', 'GIDCH2', true, 'mock', '2022-01-01', NULL);
25
+ ('27ZG100Z0000CH03', 'eic', 'gas', 'GIDCH2', true, 'mock', '2022-01-01', NULL),
26
+ -- two physical meters on one EIC that AVE lists under one serial
27
+ ('27ZG100Z0000CH04', 'eic', 'gas', 'GIDCH5', true, 'mock', '2022-01-01', NULL),
28
+ -- one meter whose serial changes mid-series, then a meter exchange
29
+ ('27ZG100Z0000CH05', 'eic', 'gas', 'GIDCH5', true, 'mock', '2022-01-01', NULL);
25
30
 
26
31
 
27
32
  -- =================================================================================================
@@ -68,9 +73,8 @@ FROM generate_series(timestamptz '2026-03-01 00:00:00+00', timestamptz '2026-03-
68
73
  -- Gas, metered (PPAS InternetAVE)
69
74
  -- =================================================================================================
70
75
  -- Value is core(first day of next month) - core(first day of current month), core being the
71
- -- cumulative meter state in m3. The corediff rows below carry no weight in that computation any
72
- -- more; they exist only to seed gas_registration, which picks the (device_serial_number, place_id)
73
- -- an EIC's 'core' readings must be joined through.
76
+ -- cumulative meter state in m3, paired per (id, place_id) and summed over the place_ids of an id.
77
+ -- The corediff rows below carry no weight in that computation.
74
78
 
75
79
  -- 27ZG100Z0000CH01: single registration, one meter.
76
80
  INSERT INTO enapo_measurements (id, id_type, value, "timestamp", var, source, place_id, device_serial_number) VALUES
@@ -86,9 +90,9 @@ INSERT INTO enapo_measurements (id, id_type, value, "timestamp", var, source, pl
86
90
  ('27ZG100Z0000CH01', 'eic', 900330.0, '2026-08-01 01:00:00+02', 'core', 'ppas_ave_api', '9900001', 'GAS-CH-1');
87
91
  -- June = 900180 - 900060 = 120; July = 900330 - 900180 = 150.
88
92
 
89
- -- 27ZG100Z0000CH02, 2026-07: TWO place_ids, ONE meter serial - two live registrations of the same
90
- -- physical meter. gas_registration picks one per serial (the most recently reporting one, here
91
- -- 9900012), so only that place_id's core readings feed the diff: 100 m3, NOT 200.
93
+ -- 27ZG100Z0000CH02, 2026-07: TWO place_ids, ONE meter serial, but only 9900012 carries core
94
+ -- readings, so only it feeds the diff: 100 m3, NOT 200. A registration without core readings adds
95
+ -- nothing.
92
96
  INSERT INTO enapo_measurements (id, id_type, value, "timestamp", var, source, place_id, device_serial_number) VALUES
93
97
  ('27ZG100Z0000CH02', 'eic', 100.0, '2026-07-01 01:00:00+02', 'corediff', 'ppas_ave_api', '9900011', 'GAS-CH-DUP'),
94
98
  ('27ZG100Z0000CH02', 'eic', 100.0, '2026-07-01 01:00:00+02', 'corediff', 'ppas_ave_api', '9900012', 'GAS-CH-DUP'),
@@ -105,6 +109,33 @@ INSERT INTO enapo_measurements (id, id_type, value, "timestamp", var, source, pl
105
109
  ('27ZG100Z0000CH03', 'eic', 800000.0, '2026-07-01 01:00:00+02', 'core', 'ppas_ave_api', '9900022', 'GAS-CH-B'),
106
110
  ('27ZG100Z0000CH03', 'eic', 800100.0, '2026-08-01 01:00:00+02', 'core', 'ppas_ave_api', '9900022', 'GAS-CH-B');
107
111
 
112
+ -- 27ZG100Z0000CH04, 2026-07: TWO place_ids with different readings under ONE serial. Production has
113
+ -- this (27ZG100Z0000197E): the integration stamps rows with the serial AVE lists at fetch time, so a
114
+ -- shared serial does not mean a shared meter. Both meters count: 100 + 1 = 101 m3. Picking one
115
+ -- place_id per serial would report 1 m3 and lose the main meter.
116
+ -- 2026-08: the small meter drops by 1 m3 while the main one adds 100. The negative check is on the
117
+ -- month total, so August is 100 - 1 = 99 m3, not empty.
118
+ INSERT INTO enapo_measurements (id, id_type, value, "timestamp", var, source, place_id, device_serial_number) VALUES
119
+ ('27ZG100Z0000CH04', 'eic', 100.0, '2026-07-01 01:00:00+02', 'corediff', 'ppas_ave_api', '9900041', 'GAS-CH-SHARED'),
120
+ ('27ZG100Z0000CH04', 'eic', 1.0, '2026-07-01 01:00:00+02', 'corediff', 'ppas_ave_api', '9900042', 'GAS-CH-SHARED'),
121
+ ('27ZG100Z0000CH04', 'eic', 600000.0, '2026-07-01 01:00:00+02', 'core', 'ppas_ave_api', '9900041', 'GAS-CH-SHARED'),
122
+ ('27ZG100Z0000CH04', 'eic', 600100.0, '2026-08-01 01:00:00+02', 'core', 'ppas_ave_api', '9900041', 'GAS-CH-SHARED'),
123
+ ('27ZG100Z0000CH04', 'eic', 4000.0, '2026-07-01 01:00:00+02', 'core', 'ppas_ave_api', '9900042', 'GAS-CH-SHARED'),
124
+ ('27ZG100Z0000CH04', 'eic', 4001.0, '2026-08-01 01:00:00+02', 'core', 'ppas_ave_api', '9900042', 'GAS-CH-SHARED'),
125
+ ('27ZG100Z0000CH04', 'eic', 600200.0, '2026-09-01 01:00:00+02', 'core', 'ppas_ave_api', '9900041', 'GAS-CH-SHARED'),
126
+ ('27ZG100Z0000CH04', 'eic', 4000.0, '2026-09-01 01:00:00+02', 'core', 'ppas_ave_api', '9900042', 'GAS-CH-SHARED');
127
+
128
+ -- 27ZG100Z0000CH05: one place_id whose serial flips between boundary readings, as a refetch after a
129
+ -- meter exchange leaves it (27ZG100Z00126318). June = 1050 - 1000 = 50 and July = 1120 - 1050 = 70
130
+ -- despite the flip. The exchanged meter restarts lower on 2026-09-01, so August is null rather than
131
+ -- a negative volume. September reads the same at both ends: 0 m3, which is also 0 kWh.
132
+ INSERT INTO enapo_measurements (id, id_type, value, "timestamp", var, source, place_id, device_serial_number) VALUES
133
+ ('27ZG100Z0000CH05', 'eic', 1000.0, '2026-06-01 01:00:00+02', 'core', 'ppas_ave_api', '9900051', 'GAS-CH-OLD'),
134
+ ('27ZG100Z0000CH05', 'eic', 1050.0, '2026-07-01 01:00:00+02', 'core', 'ppas_ave_api', '9900051', 'GAS-CH-NEW'),
135
+ ('27ZG100Z0000CH05', 'eic', 1120.0, '2026-08-01 01:00:00+02', 'core', 'ppas_ave_api', '9900051', 'GAS-CH-OLD'),
136
+ ('27ZG100Z0000CH05', 'eic', 15.0, '2026-09-01 01:00:00+02', 'core', 'ppas_ave_api', '9900051', 'GAS-CH-NEW'),
137
+ ('27ZG100Z0000CH05', 'eic', 15.0, '2026-10-01 01:00:00+02', 'core', 'ppas_ave_api', '9900051', 'GAS-CH-NEW');
138
+
108
139
 
109
140
  -- =================================================================================================
110
141
  -- Gas, invoices (PPAS distribution) for 27ZG100Z0000CH01
@@ -213,13 +244,16 @@ INSERT INTO enapo_eb_consumption (idodbmisto_rspotrebyfa, idodbmistoom, ean_eic,
213
244
  (9000005, 90401, '859182400000000401', 1, '2025-11-01', '2025-12-31', 4.0, 2.0, 6.0, 2025),
214
245
  (9000006, 90401, '859182400000000401', 1, '2025-10-15', '2025-10-31', 1.0, 0.0, 1.0, 2025),
215
246
  -- Gas: kWh as well, EB has no combustion heat to derive m3.
216
- (9000007, 90403, '27ZG100Z0000CH41', 2, '2026-01-01', '2026-01-31', 12.345, NULL, 12.345, 2026);
247
+ (9000007, 90403, '27ZG100Z0000CH41', 2, '2026-01-01', '2026-01-31', 12.345, NULL, 12.345, 2026),
248
+ (9000008, 90403, '27ZG100Z0000CH41', 2, '2026-02-01', '2026-02-28', 5.0, NULL, 5.0, 2026);
217
249
 
218
250
  -- The PPAS meter reads all of January too, but in m3 only: EB must still serve the month, being its only kWh.
251
+ -- February reads the same at both ends: 0 m3 is 0 kWh, a whole month read in kWh, so EB's 5000 kWh loses.
219
252
  INSERT INTO enapo_measurements (id, id_type, value, "timestamp", var, source, place_id, device_serial_number) VALUES
220
253
  ('27ZG100Z0000CH41', 'eic', 1200.0, '2026-02-01 01:00:00+01', 'corediff', 'ppas_ave_api', '9900041', 'GAS-CH-4'),
221
254
  ('27ZG100Z0000CH41', 'eic', 600000.0, '2026-01-01 01:00:00+01', 'core', 'ppas_ave_api', '9900041', 'GAS-CH-4'),
222
- ('27ZG100Z0000CH41', 'eic', 601200.0, '2026-02-01 01:00:00+01', 'core', 'ppas_ave_api', '9900041', 'GAS-CH-4');
255
+ ('27ZG100Z0000CH41', 'eic', 601200.0, '2026-02-01 01:00:00+01', 'core', 'ppas_ave_api', '9900041', 'GAS-CH-4'),
256
+ ('27ZG100Z0000CH41', 'eic', 601200.0, '2026-03-01 01:00:00+01', 'core', 'ppas_ave_api', '9900041', 'GAS-CH-4');
223
257
 
224
258
  INSERT INTO enapo_measurements (id, id_type, value, "timestamp", var, source, place_id, device_serial_number)
225
259
  SELECT '859182400000000401', 'ean', 10.0, d, 'EActi_VT_NT_DaySum', 'predi_input', '8110000401', 'EL-CH-4'
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var dbm;
4
+ var type;
5
+ var seed;
6
+ var fs = require('fs');
7
+ var path = require('path');
8
+ var Promise;
9
+
10
+ /**
11
+ * We receive the dbmigrate dependency from dbmigrate initially.
12
+ * This enables us to not have to rely on NODE_PATH.
13
+ */
14
+ exports.setup = function(options, seedLink) {
15
+ dbm = options.dbmigrate;
16
+ type = dbm.dataType;
17
+ seed = seedLink;
18
+ Promise = options.Promise;
19
+ };
20
+
21
+ exports.up = function(db) {
22
+ var filePath = path.join(__dirname, 'sqls', '20261013090000-enapo-ave-zero-core-up.sql');
23
+ return new Promise( function( resolve, reject ) {
24
+ fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
25
+ if (err) return reject(err);
26
+ console.log('received data: ' + data);
27
+
28
+ resolve(data);
29
+ });
30
+ })
31
+ .then(function(data) {
32
+ return db.runSql(data);
33
+ });
34
+ };
35
+
36
+ exports.down = function(db) {
37
+ var filePath = path.join(__dirname, 'sqls', '20261013090000-enapo-ave-zero-core-down.sql');
38
+ return new Promise( function( resolve, reject ) {
39
+ fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
40
+ if (err) return reject(err);
41
+ console.log('received data: ' + data);
42
+
43
+ resolve(data);
44
+ });
45
+ })
46
+ .then(function(data) {
47
+ return db.runSql(data);
48
+ });
49
+ };
50
+
51
+ exports._meta = {
52
+ "version": 1
53
+ };
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var dbm;
4
+ var type;
5
+ var seed;
6
+ var fs = require('fs');
7
+ var path = require('path');
8
+ var Promise;
9
+
10
+ /**
11
+ * We receive the dbmigrate dependency from dbmigrate initially.
12
+ * This enables us to not have to rely on NODE_PATH.
13
+ */
14
+ exports.setup = function(options, seedLink) {
15
+ dbm = options.dbmigrate;
16
+ type = dbm.dataType;
17
+ seed = seedLink;
18
+ Promise = options.Promise;
19
+ };
20
+
21
+ exports.up = function(db) {
22
+ var filePath = path.join(__dirname, 'sqls', '20261013090100-enapo-consumption-history-gas-up.sql');
23
+ return new Promise( function( resolve, reject ) {
24
+ fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
25
+ if (err) return reject(err);
26
+ console.log('received data: ' + data);
27
+
28
+ resolve(data);
29
+ });
30
+ })
31
+ .then(function(data) {
32
+ return db.runSql(data);
33
+ });
34
+ };
35
+
36
+ exports.down = function(db) {
37
+ var filePath = path.join(__dirname, 'sqls', '20261013090100-enapo-consumption-history-gas-down.sql');
38
+ return new Promise( function( resolve, reject ) {
39
+ fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
40
+ if (err) return reject(err);
41
+ console.log('received data: ' + data);
42
+
43
+ resolve(data);
44
+ });
45
+ })
46
+ .then(function(data) {
47
+ return db.runSql(data);
48
+ });
49
+ };
50
+
51
+ exports._meta = {
52
+ "version": 1
53
+ };
@@ -0,0 +1 @@
1
+ -- The deleted zero readings carried no information, so there is nothing to restore.
@@ -0,0 +1,7 @@
1
+ -- AVE sends a zero operating amount for an hour it has no reading for. `core` is a cumulative meter
2
+ -- reading, so a zero is never a real value: it only turns the monthly difference in
3
+ -- mv_enapo_om_consumption negative (shown as missing data) or absurdly large.
4
+ DELETE FROM enapo_measurements
5
+ WHERE source = 'ppas_ave_api'
6
+ AND var = 'core'
7
+ AND value = 0;