From 165b77b4f2447dec284ef6aaeef52b4ad07ea689 Mon Sep 17 00:00:00 2001 From: Ziming Date: Mon, 16 Nov 2026 18:02:44 -0500 Subject: [PATCH 1/5] Add shared electricity and natural gas provider inputs --- .../liheap-utility-provider-inputs.added.md | 1 + .../expense/utilities/electricity_provider.py | 39 +++++++++++++++++++ .../expense/utilities/natural_gas_provider.py | 37 ++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 changelog.d/liheap-utility-provider-inputs.added.md create mode 100644 policyengine_us/variables/household/expense/utilities/electricity_provider.py create mode 100644 policyengine_us/variables/household/expense/utilities/natural_gas_provider.py diff --git a/changelog.d/liheap-utility-provider-inputs.added.md b/changelog.d/liheap-utility-provider-inputs.added.md new file mode 100644 index 00000000000..5ef51d5f975 --- /dev/null +++ b/changelog.d/liheap-utility-provider-inputs.added.md @@ -0,0 +1 @@ +Add shared electricity and natural gas provider inputs for utility-dependent benefit rules. diff --git a/policyengine_us/variables/household/expense/utilities/electricity_provider.py b/policyengine_us/variables/household/expense/utilities/electricity_provider.py new file mode 100644 index 00000000000..3df6b1ee529 --- /dev/null +++ b/policyengine_us/variables/household/expense/utilities/electricity_provider.py @@ -0,0 +1,39 @@ +from policyengine_us.model_api import * + + +class ElectricityProvider(Enum): + UNSPECIFIED = "Unspecified" + AMEREN_ILLINOIS = "Ameren Illinois" + AVISTA = "Avista" + BLOCK_ISLAND_UTILITY_DISTRICT = "Block Island Utility District" + CLEAR_RIVER_ELECTRIC_AND_WATER_DISTRICT = ( + "Clear River Electric and Water District (formerly Pascoag)" + ) + COMED = "ComEd" + IDAHO_POWER = "Idaho Power" + RHODE_ISLAND_ENERGY = "Rhode Island Energy (Narragansett Electric)" + ROCKY_MOUNTAIN_POWER = "Rocky Mountain Power" + OTHER = "Other electricity provider" + + +class electricity_provider(Variable): + value_type = Enum + possible_values = ElectricityProvider + default_value = ElectricityProvider.UNSPECIFIED + entity = SPMUnit + definition_period = YEAR + label = "Electricity utility provider" + documentation = ( + "Company providing the home's electric distribution service, as named on " + "the utility bill. Report the distribution utility even when a separate " + "retailer supplies the energy. UNSPECIFIED means the company was not " + "reported; OTHER means a reported company outside the listed choices. " + "The choices initially cover named utilities needed for Idaho, Illinois " + "and Rhode Island heating assistance and can be extended for other " + "programs. This input does not imply program enrollment or bill receipt." + ) + reference = ( + "https://liheapch.acf.gov/docs/2026/benefits-matricies/ID_BenefitMatrix_Heating_2026.pdf#page=1", + "https://dceo.illinois.gov/communityservices/utilitybillassistance/howtoapply.html", + "https://webserver.rilegislature.gov/Statutes/TITLE39/39-1/39-1-27.12.htm", + ) diff --git a/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py b/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py new file mode 100644 index 00000000000..348a15a3d34 --- /dev/null +++ b/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py @@ -0,0 +1,37 @@ +from policyengine_us.model_api import * + + +class NaturalGasProvider(Enum): + UNSPECIFIED = "Unspecified" + AMEREN_ILLINOIS = "Ameren Illinois" + AVISTA = "Avista" + INTERMOUNTAIN_GAS = "Intermountain Gas" + NICOR_GAS = "Nicor Gas" + NORTH_SHORE_GAS = "North Shore Gas" + PEOPLES_GAS = "Peoples Gas" + RHODE_ISLAND_ENERGY = "Rhode Island Energy (Narragansett Electric)" + OTHER = "Other natural gas provider" + + +class natural_gas_provider(Variable): + value_type = Enum + possible_values = NaturalGasProvider + default_value = NaturalGasProvider.UNSPECIFIED + entity = SPMUnit + definition_period = YEAR + label = "Natural gas utility provider" + documentation = ( + "Company providing the home's natural gas distribution service, as named " + "on the utility bill. Report the distribution utility even when a " + "separate retailer supplies the gas. UNSPECIFIED means the company was " + "not reported; OTHER means a reported company outside the listed choices. " + "The choices initially cover named utilities needed for Idaho, Illinois " + "and Rhode Island heating assistance and can be extended for other " + "programs. Electricity and gas companies are reported independently. " + "This input does not imply program enrollment or bill receipt." + ) + reference = ( + "https://liheapch.acf.gov/docs/2026/benefits-matricies/ID_BenefitMatrix_Heating_2026.pdf#page=1", + "https://dceo.illinois.gov/communityservices/utilitybillassistance/howtoapply.html", + "https://webserver.rilegislature.gov/Statutes/TITLE39/39-1/39-1-27.12.htm", + ) From d32f054abc29d2155052b3af9256729877877c0b Mon Sep 17 00:00:00 2001 From: Ziming Date: Tue, 17 Nov 2026 10:43:01 -0500 Subject: [PATCH 2/5] Add named northern Idaho electric companies to shared input --- .../household/expense/utilities/electricity_provider.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/policyengine_us/variables/household/expense/utilities/electricity_provider.py b/policyengine_us/variables/household/expense/utilities/electricity_provider.py index 3df6b1ee529..e4f4592056a 100644 --- a/policyengine_us/variables/household/expense/utilities/electricity_provider.py +++ b/policyengine_us/variables/household/expense/utilities/electricity_provider.py @@ -6,11 +6,18 @@ class ElectricityProvider(Enum): AMEREN_ILLINOIS = "Ameren Illinois" AVISTA = "Avista" BLOCK_ISLAND_UTILITY_DISTRICT = "Block Island Utility District" + BONNERS_FERRY_LIGHT_AND_WATER = "Bonners Ferry Light and Water" CLEAR_RIVER_ELECTRIC_AND_WATER_DISTRICT = ( "Clear River Electric and Water District (formerly Pascoag)" ) + CLEARWATER_POWER = "Clearwater Power" COMED = "ComEd" + IDAHO_COUNTY_LIGHT_AND_POWER = "Idaho County Light and Power" IDAHO_POWER = "Idaho Power" + INLAND_POWER_AND_LIGHT = "Inland Power and Light" + KOOTENAI_ELECTRIC = "Kootenai Electric Cooperative" + NORTHERN_LIGHTS = "Northern Lights Incorporated" + PLUMMER_ELECTRIC = "Plummer Electric Department" RHODE_ISLAND_ENERGY = "Rhode Island Energy (Narragansett Electric)" ROCKY_MOUNTAIN_POWER = "Rocky Mountain Power" OTHER = "Other electricity provider" @@ -36,4 +43,6 @@ class electricity_provider(Variable): "https://liheapch.acf.gov/docs/2026/benefits-matricies/ID_BenefitMatrix_Heating_2026.pdf#page=1", "https://dceo.illinois.gov/communityservices/utilitybillassistance/howtoapply.html", "https://webserver.rilegislature.gov/Statutes/TITLE39/39-1/39-1-27.12.htm", + "https://oemr.idaho.gov/utilities/", + "https://www.inlandpower.com/", ) From 7f51ef0fe43105a84b8b78fc4c1ce37a40fa4966 Mon Sep 17 00:00:00 2001 From: Ziming Date: Wed, 18 Nov 2026 16:33:00 -0500 Subject: [PATCH 3/5] Map electric and gas provider choices to verified service states --- .../liheap-utility-provider-inputs.added.md | 2 +- .../unit/test_utility_provider_states.py | 38 +++++++++++++++++++ .../expense/utilities/electricity_provider.py | 33 ++++++++++++++-- .../expense/utilities/natural_gas_provider.py | 26 +++++++++++-- 4 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 policyengine_us/tests/unit/test_utility_provider_states.py diff --git a/changelog.d/liheap-utility-provider-inputs.added.md b/changelog.d/liheap-utility-provider-inputs.added.md index 5ef51d5f975..a271b4446f6 100644 --- a/changelog.d/liheap-utility-provider-inputs.added.md +++ b/changelog.d/liheap-utility-provider-inputs.added.md @@ -1 +1 @@ -Add shared electricity and natural gas provider inputs for utility-dependent benefit rules. +Add electricity and natural gas provider inputs with state service territories for filtering household choices by fuel. diff --git a/policyengine_us/tests/unit/test_utility_provider_states.py b/policyengine_us/tests/unit/test_utility_provider_states.py new file mode 100644 index 00000000000..7bfefe501c5 --- /dev/null +++ b/policyengine_us/tests/unit/test_utility_provider_states.py @@ -0,0 +1,38 @@ +import pytest + +from policyengine_us.variables.household.demographic.geographic.state_code import ( + StateCode, +) +from policyengine_us.variables.household.expense.utilities.electricity_provider import ( + electricity_provider, +) +from policyengine_us.variables.household.expense.utilities.natural_gas_provider import ( + natural_gas_provider, +) + + +@pytest.mark.parametrize("variable", [electricity_provider, natural_gas_provider]) +def test_every_provider_has_a_territory(variable): + territories = variable.metadata["states_by_value"] + assert territories.keys() == {choice.name for choice in variable.possible_values} + assert {key for key, value in territories.items() if value is None} == { + "OTHER", + "UNSPECIFIED", + } + for states in territories.values(): + if states is not None: + assert states and set(states) <= StateCode.__members__.keys() + assert len(states) == len(set(states)) + + +def test_avista_territory_depends_on_fuel(): + assert set(electricity_provider.metadata["states_by_value"]["AVISTA"]) == { + "ID", + "MT", + "WA", + } + assert set(natural_gas_provider.metadata["states_by_value"]["AVISTA"]) == { + "ID", + "OR", + "WA", + } diff --git a/policyengine_us/variables/household/expense/utilities/electricity_provider.py b/policyengine_us/variables/household/expense/utilities/electricity_provider.py index e4f4592056a..98b544ac88d 100644 --- a/policyengine_us/variables/household/expense/utilities/electricity_provider.py +++ b/policyengine_us/variables/household/expense/utilities/electricity_provider.py @@ -35,14 +35,39 @@ class electricity_provider(Variable): "the utility bill. Report the distribution utility even when a separate " "retailer supplies the energy. UNSPECIFIED means the company was not " "reported; OTHER means a reported company outside the listed choices. " - "The choices initially cover named utilities needed for Idaho, Illinois " - "and Rhode Island heating assistance and can be extended for other " - "programs. This input does not imply program enrollment or bill receipt." + "Named companies support Idaho, Illinois and Rhode Island heating " + "assistance. The state mapping includes their service in other states. " + "This input does not imply program enrollment or bill receipt." ) + # A null territory makes the choice available in every state. + metadata = { + "states_by_value": { + "UNSPECIFIED": None, + "AMEREN_ILLINOIS": ["IL"], + "AVISTA": ["ID", "MT", "WA"], + "BLOCK_ISLAND_UTILITY_DISTRICT": ["RI"], + "BONNERS_FERRY_LIGHT_AND_WATER": ["ID"], + "CLEAR_RIVER_ELECTRIC_AND_WATER_DISTRICT": ["RI"], + "CLEARWATER_POWER": ["ID", "OR", "WA"], + "COMED": ["IL"], + "IDAHO_COUNTY_LIGHT_AND_POWER": ["ID"], + "IDAHO_POWER": ["ID", "OR"], + "INLAND_POWER_AND_LIGHT": ["ID", "WA"], + "KOOTENAI_ELECTRIC": ["ID", "WA"], + "NORTHERN_LIGHTS": ["ID", "MT", "WA"], + "PLUMMER_ELECTRIC": ["ID"], + "RHODE_ISLAND_ENERGY": ["RI"], + "ROCKY_MOUNTAIN_POWER": ["ID", "UT", "WY"], + "OTHER": None, + } + } reference = ( "https://liheapch.acf.gov/docs/2026/benefits-matricies/ID_BenefitMatrix_Heating_2026.pdf#page=1", "https://dceo.illinois.gov/communityservices/utilitybillassistance/howtoapply.html", "https://webserver.rilegislature.gov/Statutes/TITLE39/39-1/39-1-27.12.htm", "https://oemr.idaho.gov/utilities/", - "https://www.inlandpower.com/", + # Form EIA-861, 2025 final, Service_Territory_2025 (utility by county). + "https://www.eia.gov/electricity/data/eia861/", + # EIA lists PacifiCorp as a whole. This is its Rocky Mountain Power brand. + "https://www.rockymountainpower.net/about.html", ) diff --git a/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py b/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py index 348a15a3d34..e92128f7f82 100644 --- a/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py +++ b/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py @@ -25,13 +25,33 @@ class natural_gas_provider(Variable): "on the utility bill. Report the distribution utility even when a " "separate retailer supplies the gas. UNSPECIFIED means the company was " "not reported; OTHER means a reported company outside the listed choices. " - "The choices initially cover named utilities needed for Idaho, Illinois " - "and Rhode Island heating assistance and can be extended for other " - "programs. Electricity and gas companies are reported independently. " + "Named companies support Idaho, Illinois and Rhode Island heating " + "assistance. The state mapping includes their service in other states. " + "Electricity and gas companies are reported independently. " "This input does not imply program enrollment or bill receipt." ) + # A null territory makes the choice available in every state. + metadata = { + "states_by_value": { + "UNSPECIFIED": None, + "AMEREN_ILLINOIS": ["IL"], + "AVISTA": ["ID", "OR", "WA"], + "INTERMOUNTAIN_GAS": ["ID"], + "NICOR_GAS": ["IL"], + "NORTH_SHORE_GAS": ["IL"], + "PEOPLES_GAS": ["IL"], + "RHODE_ISLAND_ENERGY": ["RI"], + "OTHER": None, + } + } reference = ( "https://liheapch.acf.gov/docs/2026/benefits-matricies/ID_BenefitMatrix_Heating_2026.pdf#page=1", "https://dceo.illinois.gov/communityservices/utilitybillassistance/howtoapply.html", "https://webserver.rilegislature.gov/Statutes/TITLE39/39-1/39-1-27.12.htm", + # Illinois distribution companies, including Peoples Gas Light & Coke. + "https://icc.illinois.gov/public-utility", + # Avista Utilities, Form 10-K, Part I, Item 1 (electric and gas territories). + "https://www.sec.gov/Archives/edgar/data/104918/000119312526067872/ava-20251231.htm", + "https://www.intgas.com/in-the-community/about-us/", + "https://ripuc.ri.gov/utility-information/regulated-utilities", ) From 8a10e5063f416063888952b04c386d1babc39a95 Mon Sep 17 00:00:00 2001 From: Ziming Date: Wed, 18 Nov 2026 16:35:12 -0500 Subject: [PATCH 4/5] Cite federal company-level gas customer records --- .../household/expense/utilities/natural_gas_provider.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py b/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py index e92128f7f82..4c6483fd779 100644 --- a/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py +++ b/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py @@ -48,6 +48,8 @@ class natural_gas_provider(Variable): "https://liheapch.acf.gov/docs/2026/benefits-matricies/ID_BenefitMatrix_Heating_2026.pdf#page=1", "https://dceo.illinois.gov/communityservices/utilitybillassistance/howtoapply.html", "https://webserver.rilegislature.gov/Statutes/TITLE39/39-1/39-1-27.12.htm", + # Form EIA-176, 2024, residential customers by reporting company and state. + "https://www.eia.gov/naturalgas/ngqs/", # Illinois distribution companies, including Peoples Gas Light & Coke. "https://icc.illinois.gov/public-utility", # Avista Utilities, Form 10-K, Part I, Item 1 (electric and gas territories). From 3b208d518e9bce90dd65d15796acafe791c0f816 Mon Sep 17 00:00:00 2001 From: Ziming Date: Thu, 19 Nov 2026 11:09:30 -0500 Subject: [PATCH 5/5] Package utility provider choices for household forms in the US model --- README.md | 9 ++ .../liheap-utility-provider-inputs.added.md | 2 +- policyengine_us/data/utility_providers.json | 136 ++++++++++++++++++ .../unit/test_utility_provider_states.py | 42 +++--- policyengine_us/tools/utility_providers.py | 20 +++ .../expense/utilities/electricity_provider.py | 45 +----- .../expense/utilities/natural_gas_provider.py | 27 +--- 7 files changed, 194 insertions(+), 87 deletions(-) create mode 100644 policyengine_us/data/utility_providers.json create mode 100644 policyengine_us/tools/utility_providers.py diff --git a/README.md b/README.md index c01b82139f7..fd8dabc7388 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,15 @@ bundle installer published by `policyengine`, for example: uvx --from policyengine policyengine bundle install --country us --venv .venv ``` +## Utility provider choices + +Household forms can load the electricity and natural gas provider lists from +[the model’s JSON file](policyengine_us/data/utility_providers.json) once per +model version. Select the input (`electricity_provider` or `natural_gas_provider`) +and display each choice whose `states` list includes the household’s state or whose +`states` is `null`. Show the `label` and submit the selected `value` on the SPM unit. +`OTHER` covers an unlisted distributor and `UNSPECIFIED` covers an unknown one. + ## Statutes, forms and agency practice When a statute conflicts with a regulation, form, instructions, manual or diff --git a/changelog.d/liheap-utility-provider-inputs.added.md b/changelog.d/liheap-utility-provider-inputs.added.md index a271b4446f6..013537ad3f3 100644 --- a/changelog.d/liheap-utility-provider-inputs.added.md +++ b/changelog.d/liheap-utility-provider-inputs.added.md @@ -1 +1 @@ -Add electricity and natural gas provider inputs with state service territories for filtering household choices by fuel. +Add electricity and natural gas provider inputs and a packaged JSON catalog of provider choices by fuel and state. diff --git a/policyengine_us/data/utility_providers.json b/policyengine_us/data/utility_providers.json new file mode 100644 index 00000000000..ba999d3fe1c --- /dev/null +++ b/policyengine_us/data/utility_providers.json @@ -0,0 +1,136 @@ +{ + "electricity_provider": [ + { + "value": "UNSPECIFIED", + "label": "Unspecified", + "states": null + }, + { + "value": "AMEREN_ILLINOIS", + "label": "Ameren Illinois", + "states": ["IL"] + }, + { + "value": "AVISTA", + "label": "Avista", + "states": ["ID", "MT", "WA"] + }, + { + "value": "BLOCK_ISLAND_UTILITY_DISTRICT", + "label": "Block Island Utility District", + "states": ["RI"] + }, + { + "value": "BONNERS_FERRY_LIGHT_AND_WATER", + "label": "Bonners Ferry Light and Water", + "states": ["ID"] + }, + { + "value": "CLEAR_RIVER_ELECTRIC_AND_WATER_DISTRICT", + "label": "Clear River Electric and Water District (formerly Pascoag)", + "states": ["RI"] + }, + { + "value": "CLEARWATER_POWER", + "label": "Clearwater Power", + "states": ["ID", "OR", "WA"] + }, + { + "value": "COMED", + "label": "ComEd", + "states": ["IL"] + }, + { + "value": "IDAHO_COUNTY_LIGHT_AND_POWER", + "label": "Idaho County Light and Power", + "states": ["ID"] + }, + { + "value": "IDAHO_POWER", + "label": "Idaho Power", + "states": ["ID", "OR"] + }, + { + "value": "INLAND_POWER_AND_LIGHT", + "label": "Inland Power and Light", + "states": ["ID", "WA"] + }, + { + "value": "KOOTENAI_ELECTRIC", + "label": "Kootenai Electric Cooperative", + "states": ["ID", "WA"] + }, + { + "value": "NORTHERN_LIGHTS", + "label": "Northern Lights Incorporated", + "states": ["ID", "MT", "WA"] + }, + { + "value": "PLUMMER_ELECTRIC", + "label": "Plummer Electric Department", + "states": ["ID"] + }, + { + "value": "RHODE_ISLAND_ENERGY", + "label": "Rhode Island Energy (Narragansett Electric)", + "states": ["RI"] + }, + { + "value": "ROCKY_MOUNTAIN_POWER", + "label": "Rocky Mountain Power", + "states": ["ID", "UT", "WY"] + }, + { + "value": "OTHER", + "label": "Other electricity provider", + "states": null + } + ], + "natural_gas_provider": [ + { + "value": "UNSPECIFIED", + "label": "Unspecified", + "states": null + }, + { + "value": "AMEREN_ILLINOIS", + "label": "Ameren Illinois", + "states": ["IL"] + }, + { + "value": "AVISTA", + "label": "Avista", + "states": ["ID", "OR", "WA"] + }, + { + "value": "INTERMOUNTAIN_GAS", + "label": "Intermountain Gas", + "states": ["ID"] + }, + { + "value": "NICOR_GAS", + "label": "Nicor Gas", + "states": ["IL"] + }, + { + "value": "NORTH_SHORE_GAS", + "label": "North Shore Gas", + "states": ["IL"] + }, + { + "value": "PEOPLES_GAS", + "label": "Peoples Gas", + "states": ["IL"] + }, + { + "value": "RHODE_ISLAND_ENERGY", + "label": "Rhode Island Energy (Narragansett Electric)", + "states": ["RI"] + }, + { + "value": "OTHER", + "label": "Other natural gas provider", + "states": null + } + ] +} diff --git a/policyengine_us/tests/unit/test_utility_provider_states.py b/policyengine_us/tests/unit/test_utility_provider_states.py index 7bfefe501c5..8b96f7ab1f2 100644 --- a/policyengine_us/tests/unit/test_utility_provider_states.py +++ b/policyengine_us/tests/unit/test_utility_provider_states.py @@ -1,3 +1,6 @@ +import json +from importlib.resources import files + import pytest from policyengine_us.variables.household.demographic.geographic.state_code import ( @@ -11,28 +14,35 @@ ) +@pytest.fixture(scope="module") +def providers(): + catalog = files("policyengine_us").joinpath("data", "utility_providers.json") + return json.loads(catalog.read_text(encoding="utf-8")) + + @pytest.mark.parametrize("variable", [electricity_provider, natural_gas_provider]) -def test_every_provider_has_a_territory(variable): - territories = variable.metadata["states_by_value"] - assert territories.keys() == {choice.name for choice in variable.possible_values} - assert {key for key, value in territories.items() if value is None} == { +def test_catalog_matches_model_choices(variable, providers): + options = providers[variable.__name__] + assert [(option["value"], option["label"]) for option in options] == [ + (choice.name, choice.value) for choice in variable.possible_values + ] + assert variable.default_value.name == "UNSPECIFIED" + assert {option["value"] for option in options if option["states"] is None} == { "OTHER", "UNSPECIFIED", } - for states in territories.values(): + for option in options: + states = option["states"] if states is not None: assert states and set(states) <= StateCode.__members__.keys() assert len(states) == len(set(states)) -def test_avista_territory_depends_on_fuel(): - assert set(electricity_provider.metadata["states_by_value"]["AVISTA"]) == { - "ID", - "MT", - "WA", - } - assert set(natural_gas_provider.metadata["states_by_value"]["AVISTA"]) == { - "ID", - "OR", - "WA", - } +def test_avista_territory_depends_on_fuel(providers): + def avista_states(variable): + return next( + row["states"] for row in providers[variable] if row["value"] == "AVISTA" + ) + + assert set(avista_states("electricity_provider")) == {"ID", "MT", "WA"} + assert set(avista_states("natural_gas_provider")) == {"ID", "OR", "WA"} diff --git a/policyengine_us/tools/utility_providers.py b/policyengine_us/tools/utility_providers.py new file mode 100644 index 00000000000..a99c3d7b1c4 --- /dev/null +++ b/policyengine_us/tools/utility_providers.py @@ -0,0 +1,20 @@ +"""Build the model enums from the same ordered choices that partners display.""" + +import json +from importlib.resources import files + +from policyengine_core.enums import Enum + +_catalog = json.loads( + files("policyengine_us") + .joinpath("data", "utility_providers.json") + .read_text(encoding="utf-8") +) + + +def _labels(variable: str) -> dict[str, str]: + return {choice["value"]: choice["label"] for choice in _catalog[variable]} + + +ElectricityProvider = Enum("ElectricityProvider", _labels("electricity_provider")) +NaturalGasProvider = Enum("NaturalGasProvider", _labels("natural_gas_provider")) diff --git a/policyengine_us/variables/household/expense/utilities/electricity_provider.py b/policyengine_us/variables/household/expense/utilities/electricity_provider.py index 98b544ac88d..e927dd476ed 100644 --- a/policyengine_us/variables/household/expense/utilities/electricity_provider.py +++ b/policyengine_us/variables/household/expense/utilities/electricity_provider.py @@ -1,26 +1,5 @@ from policyengine_us.model_api import * - - -class ElectricityProvider(Enum): - UNSPECIFIED = "Unspecified" - AMEREN_ILLINOIS = "Ameren Illinois" - AVISTA = "Avista" - BLOCK_ISLAND_UTILITY_DISTRICT = "Block Island Utility District" - BONNERS_FERRY_LIGHT_AND_WATER = "Bonners Ferry Light and Water" - CLEAR_RIVER_ELECTRIC_AND_WATER_DISTRICT = ( - "Clear River Electric and Water District (formerly Pascoag)" - ) - CLEARWATER_POWER = "Clearwater Power" - COMED = "ComEd" - IDAHO_COUNTY_LIGHT_AND_POWER = "Idaho County Light and Power" - IDAHO_POWER = "Idaho Power" - INLAND_POWER_AND_LIGHT = "Inland Power and Light" - KOOTENAI_ELECTRIC = "Kootenai Electric Cooperative" - NORTHERN_LIGHTS = "Northern Lights Incorporated" - PLUMMER_ELECTRIC = "Plummer Electric Department" - RHODE_ISLAND_ENERGY = "Rhode Island Energy (Narragansett Electric)" - ROCKY_MOUNTAIN_POWER = "Rocky Mountain Power" - OTHER = "Other electricity provider" +from policyengine_us.tools.utility_providers import ElectricityProvider class electricity_provider(Variable): @@ -39,28 +18,6 @@ class electricity_provider(Variable): "assistance. The state mapping includes their service in other states. " "This input does not imply program enrollment or bill receipt." ) - # A null territory makes the choice available in every state. - metadata = { - "states_by_value": { - "UNSPECIFIED": None, - "AMEREN_ILLINOIS": ["IL"], - "AVISTA": ["ID", "MT", "WA"], - "BLOCK_ISLAND_UTILITY_DISTRICT": ["RI"], - "BONNERS_FERRY_LIGHT_AND_WATER": ["ID"], - "CLEAR_RIVER_ELECTRIC_AND_WATER_DISTRICT": ["RI"], - "CLEARWATER_POWER": ["ID", "OR", "WA"], - "COMED": ["IL"], - "IDAHO_COUNTY_LIGHT_AND_POWER": ["ID"], - "IDAHO_POWER": ["ID", "OR"], - "INLAND_POWER_AND_LIGHT": ["ID", "WA"], - "KOOTENAI_ELECTRIC": ["ID", "WA"], - "NORTHERN_LIGHTS": ["ID", "MT", "WA"], - "PLUMMER_ELECTRIC": ["ID"], - "RHODE_ISLAND_ENERGY": ["RI"], - "ROCKY_MOUNTAIN_POWER": ["ID", "UT", "WY"], - "OTHER": None, - } - } reference = ( "https://liheapch.acf.gov/docs/2026/benefits-matricies/ID_BenefitMatrix_Heating_2026.pdf#page=1", "https://dceo.illinois.gov/communityservices/utilitybillassistance/howtoapply.html", diff --git a/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py b/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py index 4c6483fd779..2d379a51eda 100644 --- a/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py +++ b/policyengine_us/variables/household/expense/utilities/natural_gas_provider.py @@ -1,16 +1,5 @@ from policyengine_us.model_api import * - - -class NaturalGasProvider(Enum): - UNSPECIFIED = "Unspecified" - AMEREN_ILLINOIS = "Ameren Illinois" - AVISTA = "Avista" - INTERMOUNTAIN_GAS = "Intermountain Gas" - NICOR_GAS = "Nicor Gas" - NORTH_SHORE_GAS = "North Shore Gas" - PEOPLES_GAS = "Peoples Gas" - RHODE_ISLAND_ENERGY = "Rhode Island Energy (Narragansett Electric)" - OTHER = "Other natural gas provider" +from policyengine_us.tools.utility_providers import NaturalGasProvider class natural_gas_provider(Variable): @@ -30,20 +19,6 @@ class natural_gas_provider(Variable): "Electricity and gas companies are reported independently. " "This input does not imply program enrollment or bill receipt." ) - # A null territory makes the choice available in every state. - metadata = { - "states_by_value": { - "UNSPECIFIED": None, - "AMEREN_ILLINOIS": ["IL"], - "AVISTA": ["ID", "OR", "WA"], - "INTERMOUNTAIN_GAS": ["ID"], - "NICOR_GAS": ["IL"], - "NORTH_SHORE_GAS": ["IL"], - "PEOPLES_GAS": ["IL"], - "RHODE_ISLAND_ENERGY": ["RI"], - "OTHER": None, - } - } reference = ( "https://liheapch.acf.gov/docs/2026/benefits-matricies/ID_BenefitMatrix_Heating_2026.pdf#page=1", "https://dceo.illinois.gov/communityservices/utilitybillassistance/howtoapply.html",