Skip to content

Commit 94f7821

Browse files
committed
WIP
1 parent 409349e commit 94f7821

8 files changed

Lines changed: 430 additions & 12 deletions

File tree

‎custom_components/boiler_controller/__init__.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
2929
"controller": controller,
3030
}
3131

32+
# Set up sensor platform
33+
await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])
34+
3235
_LOGGER.info("Boiler Controller setup completed")
3336
return True
3437

@@ -37,6 +40,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
3740
"""Unload a config entry."""
3841
_LOGGER.info("Unloading Boiler Controller")
3942

43+
# Unload sensor platform
44+
unload_ok = await hass.config_entries.async_unload_platforms(entry, ["sensor"])
45+
4046
# Stop the controller
4147
controller_data = hass.data.get(DOMAIN, {}).get(entry.entry_id)
4248
if controller_data:
@@ -48,7 +54,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
4854
if DOMAIN in hass.data and entry.entry_id in hass.data[DOMAIN]:
4955
hass.data[DOMAIN].pop(entry.entry_id)
5056

51-
return True
57+
return unload_ok
5258

5359

5460
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:

‎custom_components/boiler_controller/config_flow.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ async def async_step_init(self, user_input=None):
212212
data_schema=vol.Schema({
213213
vol.Optional("change_devices", default=False): bool,
214214
vol.Optional("min_update_interval", default=self.config_entry.options.get("min_update_interval", 2)): int,
215-
vol.Optional("update_interval", default=self.config_entry.options.get("update_interval", 30)): int,
216215
vol.Optional("min_dimmer_value", default=self.config_entry.options.get("min_dimmer_value", 0)): int,
217216
vol.Optional("max_dimmer_value", default=self.config_entry.options.get("max_dimmer_value", 100)): int,
218217
})

‎custom_components/boiler_controller/const.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
DOMAIN = "boiler_controller"
2+
VERSION = "0.1.0"
23

34
# Configuration flow step IDs
45
STEP_POWER_SENSOR = "power_sensor"
@@ -11,7 +12,4 @@
1112
# Default settings for the controller
1213
DEFAULT_MIN_DIMMER_VALUE = 0
1314
DEFAULT_MAX_DIMMER_VALUE = 100
14-
DEFAULT_UPDATE_INTERVAL = 30
15-
16-
# Export for backwards compatibility (now mainly used for fallback/debugging)
17-
UPDATE_INTERVAL = DEFAULT_UPDATE_INTERVAL
15+
DEFAULT_MIN_UPDATE_INTERVAL = 2 # Minimum seconds between updates

‎custom_components/boiler_controller/controller.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
DOMAIN,
1111
CONF_DIMMER_DEVICE,
1212
CONF_P1_TOTAL_ENTITY,
13-
DEFAULT_UPDATE_INTERVAL,
13+
DEFAULT_MIN_UPDATE_INTERVAL,
1414
)
1515

1616
_LOGGER = logging.getLogger(__name__)
@@ -31,12 +31,11 @@ def __init__(self, hass: HomeAssistant, config_entry):
3131
self.power_sensor_id = config_entry.data[CONF_P1_TOTAL_ENTITY]
3232

3333
# Options
34-
self.update_interval = config_entry.options.get("update_interval", DEFAULT_UPDATE_INTERVAL)
3534
self.min_dimmer_value = config_entry.options.get("min_dimmer_value", 0)
3635
self.max_dimmer_value = config_entry.options.get("max_dimmer_value", 100)
3736

3837
# Throttling to prevent too frequent updates (configurable, default 2 seconds)
39-
self.min_update_interval = config_entry.options.get("min_update_interval", 2)
38+
self.min_update_interval = config_entry.options.get("min_update_interval", DEFAULT_MIN_UPDATE_INTERVAL)
4039

4140
_LOGGER.debug(
4241
"Initialized BoilerController: Power Sensor=%s, Dimmer=%s, min_update_interval=%ds",
@@ -93,6 +92,7 @@ async def _async_power_sensor_changed(self, event: Event):
9392
return
9493

9594
# Only update if power value actually changed significantly (more than 1W difference)
95+
# TODO: Consider making this threshold configurable as the controller needs more than 200 watt to perform well
9696
if self._last_power_value is not None and abs(new_power_value - self._last_power_value) < 1:
9797
_LOGGER.debug("Skipping update - power change too small: %.1fW", abs(new_power_value - self._last_power_value))
9898
return

‎custom_components/boiler_controller/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"iot_class": "local_polling",
99
"issue_tracker": "https://github.com/BoilerController/boiler-controller-ha/issues",
1010
"requirements": [],
11-
"version": "0.0.9"
11+
"version": "0.1.0"
1212
}

0 commit comments

Comments
 (0)