Skip to content

Commit e917399

Browse files
authored
Fix postcode lookup and options flow; clean up dependencies
Switch to the new carbon_intensity_uk API library and pin it (carbon_intensity_uk==1.0.1) so Home Assistant reliably installs and upgrades it. This fixes postcode validation in the config flow. Clean up manifest requirements: drop aiohttp (provided by Home Assistant core) and numpy (a transitive dependency of the library). Fix the options flow for Home Assistant 2025.12+, where OptionsFlow.config_entry became a read-only property: stop assigning it in the handler and read the entry options in async_step_init instead. Raise the HACS minimum Home Assistant version to 2024.11.0 accordingly (older versions also lacked APIs the integration already uses). Bump the integration version to 1.0.2 and clarify the postcode field label (outward code, e.g. SW1). Verified end-to-end on Home Assistant 2025.1.4: config flow, options flow, and all 10 sensors populated from the live API.
2 parents 175e622 + dc9ece0 commit e917399

5 files changed

Lines changed: 12 additions & 10 deletions

File tree

custom_components/carbon_intensity_uk/config_flow.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def async_step_user(
5252
@staticmethod
5353
@callback
5454
def async_get_options_flow(config_entry):
55-
return CarbonIntensityOptionsFlowHandler(config_entry)
55+
return CarbonIntensityOptionsFlowHandler()
5656

5757
async def _show_config_form(self, user_input): # pylint: disable=unused-argument
5858
"""Show the configuration form to edit location data."""
@@ -77,13 +77,15 @@ async def _test_credentials(self, postcode):
7777
class CarbonIntensityOptionsFlowHandler(config_entries.OptionsFlow):
7878
"""Carbon Intensity UK config flow options handler."""
7979

80-
def __init__(self, config_entry):
81-
"""Initialize HACS options flow."""
82-
self.config_entry = config_entry
83-
self.options = dict(config_entry.options)
80+
def __init__(self):
81+
"""Initialize options flow."""
82+
# self.config_entry is provided by the OptionsFlow base class (HA 2024.11+)
83+
# and must not be set here: it is a read-only property since HA 2025.12.
84+
self.options = {}
8485

8586
async def async_step_init(self, user_input=None): # pylint: disable=unused-argument
8687
"""Manage the options."""
88+
self.options = dict(self.config_entry.options)
8789
return await self.async_step_user()
8890

8991
async def async_step_user(self, user_input=None):

custom_components/carbon_intensity_uk/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
NAME = "Carbon Intensity UK"
44
DOMAIN = "carbon_intensity_uk"
55
DOMAIN_DATA = f"{DOMAIN}_data"
6-
VERSION = "1.0.1"
6+
VERSION = "1.0.2"
77

88
ISSUE_URL = "https://github.com/jscruz/sensor.carbon_intensity_uk/issues"
99

custom_components/carbon_intensity_uk/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"documentation": "https://github.com/jscruz/sensor.carbon_intensity_uk",
88
"iot_class": "cloud_polling",
99
"issue_tracker": "https://github.com/jscruz/sensor.carbon_intensity_uk/issues",
10-
"requirements": ["aiohttp", "numpy", "carbon_intensity_uk"],
11-
"version": "1.0.1"
10+
"requirements": ["carbon_intensity_uk==1.0.1"],
11+
"version": "1.0.2"
1212
}

custom_components/carbon_intensity_uk/translations/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"title": "Carbon Intensity UK",
66
"description": "Enter your UK postcode to get local carbon intensity data.",
77
"data": {
8-
"postcode": "UK Postcode (e.g. SW1)"
8+
"postcode": "UK Postcode or outward code (e.g. SW1)"
99
}
1010
}
1111
},

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "Carbon Intensity UK",
33
"hacs": "2.0.0",
4-
"homeassistant": "2022.8.0"
4+
"homeassistant": "2024.11.0"
55
}

0 commit comments

Comments
 (0)