tariffkit 0.11.2__tar.gz → 0.11.3__tar.gz

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.
Files changed (145) hide show
  1. {tariffkit-0.11.2 → tariffkit-0.11.3}/CHANGELOG.md +49 -1
  2. {tariffkit-0.11.2 → tariffkit-0.11.3}/PKG-INFO +18 -11
  3. {tariffkit-0.11.2 → tariffkit-0.11.3}/README.md +17 -10
  4. {tariffkit-0.11.2 → tariffkit-0.11.3}/pyproject.toml +5 -2
  5. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/config.py +1 -0
  6. tariffkit-0.11.3/src/tariffkit/data/export/pge/nbt00.json.gz +0 -0
  7. tariffkit-0.11.3/src/tariffkit/data/export/pge/nbt23.json.gz +0 -0
  8. tariffkit-0.11.3/src/tariffkit/data/export/pge/nbt24.json.gz +0 -0
  9. tariffkit-0.11.3/src/tariffkit/data/export/pge/nbt25.json.gz +0 -0
  10. tariffkit-0.11.3/src/tariffkit/data/export/pge/nbt26.json.gz +0 -0
  11. tariffkit-0.11.3/src/tariffkit/data/export/pge/nbt27.json.gz +0 -0
  12. tariffkit-0.11.3/src/tariffkit/data/export/pge/nbt28.json.gz +0 -0
  13. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/holidays.toml +14 -15
  14. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/nsc/pge.toml +2 -1
  15. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/sources.json +28 -4
  16. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/export/nbt.py +6 -1
  17. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/sources/greenbutton.py +2 -2
  18. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/timeutil.py +26 -6
  19. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/fixtures/nbt_golden_rows.jsonl +1162 -174
  20. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_engine.py +33 -5
  21. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_export_golden.py +91 -4
  22. tariffkit-0.11.2/src/tariffkit/data/export/pge/nbt00.json.gz +0 -0
  23. tariffkit-0.11.2/src/tariffkit/data/export/pge/nbt23.json.gz +0 -0
  24. tariffkit-0.11.2/src/tariffkit/data/export/pge/nbt24.json.gz +0 -0
  25. tariffkit-0.11.2/src/tariffkit/data/export/pge/nbt25.json.gz +0 -0
  26. tariffkit-0.11.2/src/tariffkit/data/export/pge/nbt26.json.gz +0 -0
  27. tariffkit-0.11.2/tests/test_ha_backfill.py +0 -1153
  28. tariffkit-0.11.2/tests/test_ha_bank.py +0 -536
  29. tariffkit-0.11.2/tests/test_ha_energy.py +0 -1332
  30. tariffkit-0.11.2/tests/test_ha_external_statistics.py +0 -193
  31. tariffkit-0.11.2/tests/test_ha_repairs.py +0 -116
  32. {tariffkit-0.11.2 → tariffkit-0.11.3}/.gitignore +0 -0
  33. {tariffkit-0.11.2 → tariffkit-0.11.3}/LICENSE +0 -0
  34. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/__init__.py +0 -0
  35. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/account/__init__.py +0 -0
  36. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/account/errors.py +0 -0
  37. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/account/model.py +0 -0
  38. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/account/rates.py +0 -0
  39. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/billing/__init__.py +0 -0
  40. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/billing/bank.py +0 -0
  41. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/billing/cycles.py +0 -0
  42. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/billing/engine.py +0 -0
  43. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/billing/ledger.py +0 -0
  44. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/billing/models.py +0 -0
  45. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/billing/netting.py +0 -0
  46. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/billing/trueup.py +0 -0
  47. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/cca.py +0 -0
  48. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/cli/__init__.py +0 -0
  49. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/cli/__main__.py +0 -0
  50. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/cli/account_commands.py +0 -0
  51. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/cli/account_store.py +0 -0
  52. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/cli/availability.py +0 -0
  53. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/cli/commands.py +0 -0
  54. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/cli/meters.py +0 -0
  55. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/cli/setup.py +0 -0
  56. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/components.py +0 -0
  57. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/__init__.py +0 -0
  58. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/cca/mce/2023-01-01.toml +0 -0
  59. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/cca/mce/2023-12-01.toml +0 -0
  60. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/cca/mce/2025-10-01.toml +0 -0
  61. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/cca/mce/2026-04-01.toml +0 -0
  62. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/export/pge/acc_plus/2023-04-15.toml +0 -0
  63. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/e1/2026-03-01.toml +0 -0
  64. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/eelec/2025-01-01.toml +0 -0
  65. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/eelec/2025-03-01.toml +0 -0
  66. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/eelec/2025-09-01.toml +0 -0
  67. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/eelec/2026-01-01.toml +0 -0
  68. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/eelec/2026-03-01.toml +0 -0
  69. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/etouc/2025-01-01.toml +0 -0
  70. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/etouc/2025-03-01.toml +0 -0
  71. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/etouc/2025-09-01.toml +0 -0
  72. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/etouc/2026-01-01.toml +0 -0
  73. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/etouc/2026-03-01.toml +0 -0
  74. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/etoud/2026-03-01.toml +0 -0
  75. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/ev2a/2025-01-01.toml +0 -0
  76. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/ev2a/2025-03-01.toml +0 -0
  77. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/ev2a/2025-09-01.toml +0 -0
  78. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/ev2a/2026-01-01.toml +0 -0
  79. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/ev2a/2026-03-01.toml +0 -0
  80. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/program/dcare/2025-01-01.toml +0 -0
  81. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/program/dmedical/2026-03-01.toml +0 -0
  82. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/program/efera/2026-03-01.toml +0 -0
  83. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/program/ersmart/2022-05-01.toml +0 -0
  84. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tariff/pge/program/medicalbaseline/2023-03-23.toml +0 -0
  85. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tax/ca_energy_resources/2025-01-01.toml +0 -0
  86. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/tax/ca_energy_resources/2026-01-01.toml +0 -0
  87. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/data/versioned.py +0 -0
  88. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/engine.py +0 -0
  89. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/errors.py +0 -0
  90. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/export/__init__.py +0 -0
  91. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/interop/__init__.py +0 -0
  92. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/interop/emhass.py +0 -0
  93. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/interop/predbat.py +0 -0
  94. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/interop/slots.py +0 -0
  95. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/metering.py +0 -0
  96. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/models.py +0 -0
  97. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/mqtt/__init__.py +0 -0
  98. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/mqtt/discovery.py +0 -0
  99. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/mqtt/publisher.py +0 -0
  100. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/providers/__init__.py +0 -0
  101. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/providers/pge/__init__.py +0 -0
  102. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/providers/pge/reconcile.py +0 -0
  103. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/providers/pge/statements/__init__.py +0 -0
  104. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/providers/pge/statements/errors.py +0 -0
  105. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/providers/pge/statements/model.py +0 -0
  106. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/providers/pge/statements/ocr.py +0 -0
  107. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/providers/pge/statements/parse.py +0 -0
  108. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/py.typed +0 -0
  109. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/secrets.py +0 -0
  110. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/sources/__init__.py +0 -0
  111. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/sources/homeassistant.py +0 -0
  112. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/sources/influx.py +0 -0
  113. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/sources/meters.py +0 -0
  114. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/sources/pge.py +0 -0
  115. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/tariff/__init__.py +0 -0
  116. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/tariff/retail.py +0 -0
  117. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/web/__init__.py +0 -0
  118. {tariffkit-0.11.2 → tariffkit-0.11.3}/src/tariffkit/web/app.py +0 -0
  119. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/conftest.py +0 -0
  120. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/fixtures/statements/synthetic_cca_ratechange.txt +0 -0
  121. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_account.py +0 -0
  122. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_account_cli.py +0 -0
  123. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_billing.py +0 -0
  124. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_cli_availability.py +0 -0
  125. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_components.py +0 -0
  126. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_cycles.py +0 -0
  127. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_eelec.py +0 -0
  128. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_ev2a.py +0 -0
  129. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_integrations.py +0 -0
  130. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_interop.py +0 -0
  131. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_ledger.py +0 -0
  132. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_mce.py +0 -0
  133. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_mqtt_publisher.py +0 -0
  134. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_pge_reconcile.py +0 -0
  135. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_pge_statements.py +0 -0
  136. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_private_config.py +0 -0
  137. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_schedules.py +0 -0
  138. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_setup.py +0 -0
  139. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_sources_greenbutton.py +0 -0
  140. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_sources_ha.py +0 -0
  141. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_sources_influx.py +0 -0
  142. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_sources_meters.py +0 -0
  143. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_sources_pge.py +0 -0
  144. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_trueup.py +0 -0
  145. {tariffkit-0.11.2 → tariffkit-0.11.3}/tests/test_versioned.py +0 -0
@@ -5,6 +5,53 @@ All notable changes to this project are documented here. This project follows
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.11.3] - 2026-11-17
9
+
10
+ ### Added
11
+ - **NBT27 and NBT28 export rates**, from PG&E's November 2026 archive. A 2027
12
+ interconnection now resolves to NBT27 instead of being refused. 2028 still
13
+ floats, as Schedule NBT's lock covers applications through 2027 only;
14
+ NBT28 is available as an explicit `vintage`. Home Assistant offers 2027,
15
+ but its setup defaults to the current year rather than the newest one:
16
+ NBT27 has no 2026 rates, so defaulting to it would leave a setup made this
17
+ year unable to load.
18
+
19
+ ### Changed
20
+ - **Floating (NBT00) export rates from 2027 on follow PG&E's new file.** It is
21
+ forecast from the newer avoided cost calculator, and the split moves
22
+ sharply toward delivery: 2027 averages about $0.098/kWh delivery and
23
+ $0.065/kWh generation, against $0.006 and $0.094 before.
24
+ - November 2026's Net Surplus Compensation rate, $0.02781/kWh.
25
+ - `python -m tools.regen.export --download` prints the cached archive's age,
26
+ and `--refresh` fetches it again. It used to reuse a cached copy silently,
27
+ so a working copy regenerated the old data and reported it current. An
28
+ interrupted download no longer leaves a truncated archive in the cache.
29
+ Every vintage is now validated before anything is written, so a refusal
30
+ part-way through no longer leaves new matrices beside an old
31
+ `holidays.toml` and `sources.json`.
32
+
33
+ ### Fixed
34
+ - **Floating customers keep their 2025 and 2026 export prices.** PG&E's new
35
+ floating file starts at 2027, and taken as published it left every NBT00
36
+ account without an export price for the rest of 2026: the Home Assistant
37
+ entry stopped loading and past bills could not be priced. Years a newer file
38
+ drops are now kept from the vendored copy, along with the source they were
39
+ verified against.
40
+ - **The repeated fall-back hour is priced from its own year's label.** The
41
+ 2027 and 2028 vintages, and the new floating file, label the second 01:00
42
+ PST `HS1` where the earlier files used `HS2`. The label is now recorded per
43
+ year and followed, where it used to be assumed to be `HS2`. Regeneration
44
+ also refuses a vintage in which no year reproduces upstream's labels,
45
+ instead of writing it with every price marked inexact.
46
+ - **2047's Labor Day and Thanksgiving are in the right weeks.** The shared
47
+ holiday calendar was the intersection of the export files' own flags, which
48
+ drift in each file's far-future years. 2047 is covered by NBT28 alone and
49
+ came through with 5 September and 21 November instead of 2 September and
50
+ 28 November, so E-TOU-D would have charged its peak on both holidays and
51
+ off-peak on two ordinary evenings. The calendar is now derived from the
52
+ holiday rules, and regeneration refuses to write if any file's flags
53
+ disagree with them in a year that file is verified exact.
54
+
8
55
  ## [0.11.2] - 2026-11-10
9
56
 
10
57
  ### Changed
@@ -2216,7 +2263,8 @@ Initial release.
2216
2263
  - Holiday calendars are extracted per vintage from the source data rather than
2217
2264
  recomputed, because the vintage files disagree in far-future years.
2218
2265
 
2219
- [Unreleased]: https://github.com/eman/tariffkit/compare/v0.11.2...HEAD
2266
+ [Unreleased]: https://github.com/eman/tariffkit/compare/v0.11.3...HEAD
2267
+ [0.11.3]: https://github.com/eman/tariffkit/releases/tag/v0.11.3
2220
2268
  [0.11.2]: https://github.com/eman/tariffkit/releases/tag/v0.11.2
2221
2269
  [0.11.1]: https://github.com/eman/tariffkit/releases/tag/v0.11.1
2222
2270
  [0.11.0]: https://github.com/eman/tariffkit/releases/tag/v0.11.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tariffkit
3
- Version: 0.11.2
3
+ Version: 0.11.3
4
4
  Summary: Offline electricity tariff pricing, billing, and integration tools
5
5
  Project-URL: Homepage, https://github.com/eman/tariffkit
6
6
  Project-URL: Documentation, https://github.com/eman/tariffkit#documentation
@@ -91,7 +91,7 @@ PG&E publishes 20 years of hourly export rates per vintage, as CPUC Resolution
91
91
  E-5301 requires (roughly 40 MB of CSV per vintage). But that file is a lossless
92
92
  expansion of a 576-cell matrix per year (12 months × 2 day types × 24 hours) per
93
93
  component. `tariffkit` collapses it at build time, verifying losslessness cell by
94
- cell, so the entire five-vintage dataset ships inside the wheel at **268 KiB**
94
+ cell, so the entire seven-vintage dataset ships inside the wheel at **391 KiB**
95
95
  and every lookup is a few list indexes.
96
96
 
97
97
  The retail side is similar: generated effective-dated tables hold every active
@@ -251,17 +251,24 @@ outside that file with `tariffkit setup` or `tariffkit credentials set`; see
251
251
 
252
252
  ### Edge cases in PG&E's published data
253
253
 
254
- Found by round-tripping the vendored matrices against all 1.75 million source
254
+ Found by round-tripping the vendored matrices against all 2.45 million source
255
255
  rows. The library handles each; they are documented because they are surprising.
256
256
 
257
257
  - **The autumn DST hour.** The fall-back day has 25 real hours but only 24 rate
258
- labels. PG&E gives the repeated 01:00 PST the `HS2` label, so it is priced as
259
- 2am. Pricing it by wall-clock hour returns the wrong value for that hour.
260
- - **Far-future drift.** From 2036 onward PG&E's own hour labels stop tracking
261
- Pacific daylight time, and NBT25/26/00 duplicate some holidays onto the
262
- following day. Each vintage records the last year verified exact; prices past
263
- it are returned with `exact=False`. Every year inside a nine-year rate lock is
264
- exact, and those years are already published as illustrative only.
258
+ labels, so the repeated 01:00 PST shares one. Which one has changed: the
259
+ earlier files label it `HS2`, priced as 2am, while the 2027 and 2028 vintages
260
+ and the floating file published with them label it `HS1`. Each vintage
261
+ records the label per year, and the lookup follows it.
262
+ - **Far-future drift.** From about the eleventh year of a file (2036 in NBT25,
263
+ 2038 in NBT27) PG&E's own hour labels stop tracking Pacific daylight time,
264
+ and NBT25/26/00 duplicate some holidays onto the following day. Each vintage
265
+ records the last year verified exact; prices past it are returned with
266
+ `exact=False`. Every year inside a nine-year rate lock is exact, and those
267
+ years are already published as illustrative only.
268
+ - **The floating file drops the current year.** PG&E republishes NBT00 each
269
+ year starting from the next, so the November 2026 file begins at 2027. The
270
+ years it dropped are kept from the earlier copy, with the source they were
271
+ verified against, so a floating customer still has 2025 and 2026 prices.
265
272
  - **Vintages disagree about holidays** in those same late years, so the holiday
266
273
  calendar used for a lookup is the one embedded in that vintage's own file.
267
274
  - **Only the June 2026 tariff sheets are vendored**, for each of the three
@@ -307,7 +314,7 @@ Every vendored dataset is regenerated from the document that publishes it, by
307
314
  python -m tools.regen # rebuild every dataset
308
315
  python -m tools.regen --check # exit 1 if a publisher moved
309
316
  python -m tools.regen tariff --for-date 2025-12-15 # rebuild a superseded vintage
310
- python -m tools.regen.export --download # the 843 MB export-rate archive
317
+ python -m tools.regen.export --download --refresh # the 843 MB export-rate archive
311
318
  ```
312
319
 
313
320
  Export matrices come from PG&E's CSV archive, which is large enough to have its
@@ -46,7 +46,7 @@ PG&E publishes 20 years of hourly export rates per vintage, as CPUC Resolution
46
46
  E-5301 requires (roughly 40 MB of CSV per vintage). But that file is a lossless
47
47
  expansion of a 576-cell matrix per year (12 months × 2 day types × 24 hours) per
48
48
  component. `tariffkit` collapses it at build time, verifying losslessness cell by
49
- cell, so the entire five-vintage dataset ships inside the wheel at **268 KiB**
49
+ cell, so the entire seven-vintage dataset ships inside the wheel at **391 KiB**
50
50
  and every lookup is a few list indexes.
51
51
 
52
52
  The retail side is similar: generated effective-dated tables hold every active
@@ -206,17 +206,24 @@ outside that file with `tariffkit setup` or `tariffkit credentials set`; see
206
206
 
207
207
  ### Edge cases in PG&E's published data
208
208
 
209
- Found by round-tripping the vendored matrices against all 1.75 million source
209
+ Found by round-tripping the vendored matrices against all 2.45 million source
210
210
  rows. The library handles each; they are documented because they are surprising.
211
211
 
212
212
  - **The autumn DST hour.** The fall-back day has 25 real hours but only 24 rate
213
- labels. PG&E gives the repeated 01:00 PST the `HS2` label, so it is priced as
214
- 2am. Pricing it by wall-clock hour returns the wrong value for that hour.
215
- - **Far-future drift.** From 2036 onward PG&E's own hour labels stop tracking
216
- Pacific daylight time, and NBT25/26/00 duplicate some holidays onto the
217
- following day. Each vintage records the last year verified exact; prices past
218
- it are returned with `exact=False`. Every year inside a nine-year rate lock is
219
- exact, and those years are already published as illustrative only.
213
+ labels, so the repeated 01:00 PST shares one. Which one has changed: the
214
+ earlier files label it `HS2`, priced as 2am, while the 2027 and 2028 vintages
215
+ and the floating file published with them label it `HS1`. Each vintage
216
+ records the label per year, and the lookup follows it.
217
+ - **Far-future drift.** From about the eleventh year of a file (2036 in NBT25,
218
+ 2038 in NBT27) PG&E's own hour labels stop tracking Pacific daylight time,
219
+ and NBT25/26/00 duplicate some holidays onto the following day. Each vintage
220
+ records the last year verified exact; prices past it are returned with
221
+ `exact=False`. Every year inside a nine-year rate lock is exact, and those
222
+ years are already published as illustrative only.
223
+ - **The floating file drops the current year.** PG&E republishes NBT00 each
224
+ year starting from the next, so the November 2026 file begins at 2027. The
225
+ years it dropped are kept from the earlier copy, with the source they were
226
+ verified against, so a floating customer still has 2025 and 2026 prices.
220
227
  - **Vintages disagree about holidays** in those same late years, so the holiday
221
228
  calendar used for a lookup is the one embedded in that vintage's own file.
222
229
  - **Only the June 2026 tariff sheets are vendored**, for each of the three
@@ -262,7 +269,7 @@ Every vendored dataset is regenerated from the document that publishes it, by
262
269
  python -m tools.regen # rebuild every dataset
263
270
  python -m tools.regen --check # exit 1 if a publisher moved
264
271
  python -m tools.regen tariff --for-date 2025-12-15 # rebuild a superseded vintage
265
- python -m tools.regen.export --download # the 843 MB export-rate archive
272
+ python -m tools.regen.export --download --refresh # the 843 MB export-rate archive
266
273
  ```
267
274
 
268
275
  Export matrices come from PG&E's CSV archive, which is large enough to have its
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "tariffkit"
7
- version = "0.11.2"
7
+ version = "0.11.3"
8
8
  description = "Offline electricity tariff pricing, billing, and integration tools"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -94,9 +94,12 @@ include = ["/src", "/tests", "/README.md", "/LICENSE", "/CHANGELOG.md"]
94
94
  # These exercise repository-only surfaces that are intentionally absent from
95
95
  # the sdist; keeping them would make its otherwise self-contained suite fail.
96
96
  exclude = [
97
- "/tests/test_ha_component.py",
97
+ # The Home Assistant integration tests import custom_components, which the
98
+ # sdist does not carry; listing them one at a time missed five of six.
99
+ "/tests/test_ha_*.py",
98
100
  "/tests/test_packaging.py",
99
101
  "/tests/test_regen.py",
102
+ "/tests/test_regen_export.py",
100
103
  "/tests/test_release.py",
101
104
  ]
102
105
 
@@ -25,6 +25,7 @@ VINTAGE_BY_YEAR = {
25
25
  2024: "NBT24",
26
26
  2025: "NBT25",
27
27
  2026: "NBT26",
28
+ 2027: "NBT27",
28
29
  }
29
30
  FLOATING_VINTAGE = "NBT00"
30
31
  #: The interconnection-application years NBT grants a nine-year lock, from
@@ -1,21 +1,18 @@
1
1
  # Generated by `python -m tools.regen.export` -- do not edit by hand.
2
2
  #
3
- # Extracted from the DayStart==8 rows of PG&E's NBT export-rate files, so
4
- # the observed-date rules (Saturday -> preceding Friday, Sunday -> following
5
- # Monday) come from the source rather than being reimplemented here.
6
- # These holidays set the EXPORT day type, and also E-TOU-D's peak, which
7
- # applies on weekdays only and prices a holiday as off-peak. E-ELEC,
8
- # E-TOU-C and EV2-A make no weekday/weekend/holiday distinction.
3
+ # The eight tariff holidays by rule, observed Saturday -> preceding Friday
4
+ # and Sunday -> following Monday, for the years PG&E's NBT export-rate
5
+ # files cover. Regeneration checks them against those files' own holiday
6
+ # flags (DayStart==8) in every year a file is verified exact, and refuses
7
+ # to write on any disagreement. Later years are not evidence: each file's
8
+ # flags drift there along with its hour labels, and 2047, covered by one
9
+ # file alone, had Labor Day and Thanksgiving in the wrong weeks.
9
10
  #
10
- # This is the INTERSECTION across the vintage files covering each year,
11
- # less any date that immediately follows another. They agree through 2036;
12
- # beyond that NBT25/26/00 duplicate some holidays onto the following day.
13
- # Intersecting drops those wherever two vintages disagree, but 2044 is
14
- # covered by three files and 2045 by one, all carrying the duplicate, so
15
- # both years survived it at eleven holidays until the adjacency rule was
16
- # added. PG&E's observed-date rules never produce consecutive dates.
17
- # Export
18
- # lookups use the per-vintage calendar embedded in each matrix instead.
11
+ # These holidays set E-TOU-D's peak, which applies on weekdays only and
12
+ # prices a holiday as off-peak. E-ELEC, E-TOU-C and EV2-A make no
13
+ # weekday/weekend/holiday distinction. Export lookups use the per-vintage
14
+ # calendar embedded in each matrix instead, drift included, because that
15
+ # is how upstream labelled the rows the matrix was built from.
19
16
 
20
17
  [holidays]
21
18
  2024 = ["2024-01-01", "2024-02-19", "2024-05-27", "2024-07-04", "2024-09-02", "2024-11-11", "2024-11-28", "2024-12-25"]
@@ -40,3 +37,5 @@
40
37
  2043 = ["2043-01-01", "2043-02-16", "2043-05-25", "2043-07-03", "2043-09-07", "2043-11-11", "2043-11-26", "2043-12-25"]
41
38
  2044 = ["2044-01-01", "2044-02-15", "2044-05-30", "2044-07-04", "2044-09-05", "2044-11-11", "2044-11-24", "2044-12-26"]
42
39
  2045 = ["2045-01-02", "2045-02-20", "2045-05-29", "2045-07-04", "2045-09-04", "2045-11-10", "2045-11-23", "2045-12-25"]
40
+ 2046 = ["2046-01-01", "2046-02-19", "2046-05-28", "2046-07-04", "2046-09-03", "2046-11-12", "2046-11-22", "2046-12-25"]
41
+ 2047 = ["2047-01-01", "2047-02-18", "2047-05-27", "2047-07-04", "2047-09-02", "2047-11-11", "2047-11-28", "2047-12-25"]
@@ -23,7 +23,7 @@
23
23
  # statement exists. Anything computed from it for a CCA account is an
24
24
  # estimate and is flagged as one.
25
25
  #
26
- # A row is added each month; the series here ends at 2026-10. A true-up
26
+ # A row is added each month; the series here ends at 2026-11. A true-up
27
27
  # month later than that has no published rate yet, which is the normal
28
28
  # case rather than an edge one.
29
29
 
@@ -57,3 +57,4 @@ decision = "D.11-06-016"
57
57
  "2026-08" = 0.02684
58
58
  "2026-09" = 0.02751
59
59
  "2026-10" = 0.02740
60
+ "2026-11" = 0.02781
@@ -1,15 +1,19 @@
1
1
  {
2
- "archive_sha256": "9b554698025ed0cdaea0d48ab1ed1a58834f30d4af4e2cad2b879349626356d3",
2
+ "archive_sha256": "571e26429b60603d283a47a8b0032a6538ca7dc1b5596defb33f0e8e59220d5a",
3
3
  "source_url": "https://www.pge.com/assets/pge/docs/vanities/PGE-Solar-Billing-Plan-Export-Rates.zip",
4
4
  "vintages": {
5
5
  "NBT00": {
6
- "exact_through": 2035,
6
+ "exact_through": 2037,
7
7
  "file": "export/pge/nbt00.json.gz",
8
8
  "member": "PG&E NBT EEC Values Floating Vintage.csv",
9
- "member_sha256": "6e93d289a54c0d0f253bdaa2c7560555047cf91db85dc1810cc9ec1e9a003f6d",
9
+ "member_sha256": "4128493c77cd73177d92e5d30c461be303cd1c76fcdde82e7253f59e37424e1f",
10
+ "retained_years": [
11
+ 2025,
12
+ 2026
13
+ ],
10
14
  "years": [
11
15
  2025,
12
- 2044
16
+ 2046
13
17
  ]
14
18
  },
15
19
  "NBT23": {
@@ -51,6 +55,26 @@
51
55
  2026,
52
56
  2045
53
57
  ]
58
+ },
59
+ "NBT27": {
60
+ "exact_through": 2037,
61
+ "file": "export/pge/nbt27.json.gz",
62
+ "member": "PG&E NBT EEC Values 2027 Vintage.csv",
63
+ "member_sha256": "6face262517b2feb2435397fb8087801d33835b15073c61a933b7f0b8108e65e",
64
+ "years": [
65
+ 2027,
66
+ 2046
67
+ ]
68
+ },
69
+ "NBT28": {
70
+ "exact_through": 2038,
71
+ "file": "export/pge/nbt28.json.gz",
72
+ "member": "PG&E NBT EEC Values 2028 Vintage.csv",
73
+ "member_sha256": "1b49aecd1ee4a14954821113e4edbdfdd72f69c71b9c3ced09cab94469551af0",
74
+ "years": [
75
+ 2028,
76
+ 2047
77
+ ]
54
78
  }
55
79
  }
56
80
  }
@@ -148,7 +148,12 @@ class NbtExportRates:
148
148
  kind = day_type(moment, self._holidays)
149
149
  month_index = moment.month - 1
150
150
  day_index = 0 if kind is DayType.WEEKDAY else 1
151
- hour = export_hour(moment)
151
+ # The repeated fall-back hour's label is the year's own: PG&E has
152
+ # published it as HS2 and as HS1, sometimes within one vintage file.
153
+ # A year whose label fit neither has none recorded and is already past
154
+ # exact_through; it still prices, on the HS2 reading, flagged inexact.
155
+ fall_back_hour = int(self._payload.get("fall_back_hour", {}).get(year, 2))
156
+ hour = export_hour(moment, fall_back_hour)
152
157
 
153
158
  components, complete = self._components(data, month_index, day_index, hour, moment.date())
154
159
  return ExportPrice(
@@ -284,8 +284,8 @@ def _resolve_repeated_hour(rows: list[_Row]) -> list[_Row]:
284
284
 
285
285
  A naive timestamp on the autumn transition is genuinely ambiguous: 01:00
286
286
  happens twice. ``zoneinfo`` resolves both to ``fold=0``, the earlier PDT
287
- hour, so an hour of readings prices at the wrong export rate -- PG&E labels
288
- the repeat HS2 -- and coverage reports the file as overlapping itself.
287
+ hour, so an hour of readings prices at the wrong export rate -- PG&E gives
288
+ the repeat a label of its own -- and coverage reports the file as overlapping itself.
289
289
 
290
290
  Meter exports are chronological, which supplies the missing bit: if a row's
291
291
  instant does not advance, and setting ``fold=1`` makes it advance, then it
@@ -88,19 +88,39 @@ def is_holiday(day: date) -> bool:
88
88
  return day in holidays(day.year)
89
89
 
90
90
 
91
- def export_hour(moment: datetime) -> int:
91
+ #: The two labels PG&E has given the repeated 01:00 PST: ``HS2`` (priced as
92
+ #: 2am) through the 2026 vintage's early years, ``HS1`` (priced as the 1am it
93
+ #: is) in every year of the 2027 and 2028 vintages and the floating file
94
+ #: published with them, and in the far-future years of the 2025 and 2026
95
+ #: vintages.
96
+ FALL_BACK_LABELS = (1, 2)
97
+
98
+
99
+ def is_repeated_hour(moment: datetime) -> bool:
100
+ """Whether ``moment`` is in the second pass through the fall-back 01:00.
101
+
102
+ ``fold`` alone is not enough: ``zoneinfo`` ignores it on an unambiguous
103
+ time, so a caller can set it anywhere without moving the instant.
104
+ """
105
+ return bool(moment.fold) and moment.utcoffset() != moment.replace(fold=0).utcoffset()
106
+
107
+
108
+ def export_hour(moment: datetime, fall_back_hour: int = 2) -> int:
92
109
  """The hour index (``HS0``-``HS23``) upstream assigns to this instant.
93
110
 
94
111
  Almost always the wall-clock hour, but the fall-back day has 25 real hours
95
- and only 24 labels. PG&E resolves that by giving the repeated 01:00 PST the
96
- ``HS2`` label, so the second 1am is priced as 2am and the rest of the day
97
- stays aligned. ``fold`` is 1 only during that ambiguous hour, so adding it
98
- reproduces the published labelling exactly.
112
+ and only 24 labels, so one of them covers two hours. Which one is a choice
113
+ PG&E has made both ways (see :data:`FALL_BACK_LABELS`): ``fall_back_hour``
114
+ is the label the repeated 01:00 PST carries in the year being priced,
115
+ which each vintage file records per year. The default is the ``HS2``
116
+ reading the earlier files use.
99
117
 
100
118
  The spring-forward day needs no special case: 02:00 simply does not exist,
101
119
  and upstream correspondingly publishes no ``HS2`` row for it.
102
120
  """
103
- return moment.hour + moment.fold
121
+ if is_repeated_hour(moment):
122
+ return fall_back_hour
123
+ return moment.hour
104
124
 
105
125
 
106
126
  def day_type(moment: datetime, calendar: frozenset[date] | None = None) -> DayType: