Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/KartoffelToby/better_thermostat
/ functions
Functions
2,184 in github.com/KartoffelToby/better_thermostat
⨍
Functions
2,184
◇
Types & classes
308
↳
Endpoints
5
↓ 137 callers
Function
_inp
Shortcut for creating MpcInput with defaults.
tests/unit/test_mpc_comprehensive.py:133
↓ 132 callers
Function
_compute
Call compute_mpc and return only the MpcOutput (discard state). Most tests only need the output; the few that inspect the returned state can
tests/unit/test_mpc_comprehensive.py:123
↓ 101 callers
Function
_make_bt_climate
Create a mock BT climate entity with sensible defaults.
tests/unit/test_sensor.py:60
↓ 100 callers
Function
_default_params
Return MpcParams with sane test defaults (fast updates, no hold-time). Parameters listed before the comment always override the dataclass default
tests/unit/test_mpc_comprehensive.py:50
↓ 79 callers
Function
_round_for_debug
(value: float | int | None, digits: int = 3)
custom_components/better_thermostat/utils/calibration/mpc.py:549
↓ 77 callers
Function
_make_state
Build a minimal HA State object.
tests/unit/test_trv_events.py:93
↓ 51 callers
Function
round_by_step
Round the value based on the allowed decimal 'step' size. Parameters ---------- value : float the value to round step : f
custom_components/better_thermostat/utils/helpers.py:473
↓ 50 callers
Function
trigger_trv_change
Trigger a change in the trv state.
custom_components/better_thermostat/events/trv.py:40
↓ 49 callers
Function
_make_event
Build a mock event whose context differs from bt.context.
tests/unit/test_trv_events.py:101
↓ 49 callers
Method
update
Process one temperature reading and return what changed.
custom_components/better_thermostat/utils/thermal_learning.py:426
↓ 42 callers
Function
_ts
Offset from _NOW by *minutes*.
tests/unit/test_thermal_learning.py:33
↓ 42 callers
Function
compute_mpc
Run the predictive controller and emit a valve recommendation. Parameters ---------- inp: Current measurements and context. p
custom_components/better_thermostat/utils/calibration/mpc.py:558
↓ 40 callers
Function
make_bt
Build a BetterThermostat stand-in carrying the attrs weather.py touches.
tests/unit/test_weather.py:61
↓ 40 callers
Function
make_hass
Build a hass mock wiring states.get and services.async_call.
tests/unit/test_weather.py:51
↓ 37 callers
Function
_make_trv_state
Build a TRV State with typical attributes.
tests/unit/test_climate_startup.py:87
↓ 37 callers
Function
compute_hvac_action
Compute the current HVAC action without mutating *hysteresis*. Rules ----- - OFF mode → OFF regardless of temperatures. - Open window
custom_components/better_thermostat/utils/hvac_action.py:82
↓ 37 callers
Function
trigger_temperature_change
Handle temperature changes. Parameters ---------- self : self instance of better_thermostat event : Event obj
custom_components/better_thermostat/events/temperature.py:164
↓ 36 callers
Function
_make_event
Build a mock event with the given new_state.
tests/unit/test_temperature_events.py:84
↓ 35 callers
Function
_default_kwargs
Return compute_hvac_action kwargs with sensible defaults.
tests/unit/test_hvac_action.py:24
↓ 35 callers
Function
convert_to_float
Convert value to float or print error message. Parameters ---------- value : str | int | float | None the value to convert to
custom_components/better_thermostat/utils/helpers.py:297
↓ 34 callers
Method
update
Process one temperature reading and return what changed.
custom_components/better_thermostat/utils/thermal_learning.py:196
↓ 33 callers
Function
_make_state
Build a minimal HA State object.
tests/unit/test_cooler_events.py:42
↓ 32 callers
Function
check_float
Check if a string is a float. Parameters ---------- potential_float : the value to check Returns ------- bool
custom_components/better_thermostat/utils/helpers.py:504
↓ 32 callers
Function
control_trv
Control a single TRV by setting temperature, HVAC mode, calibration, and valve position. All operations are executed within self._temp_lock to en
custom_components/better_thermostat/utils/controlling.py:364
↓ 32 callers
Method
create_task
Create and track an asyncio task with automatic cleanup on completion. Parameters ---------- coro : Coroutine The
custom_components/better_thermostat/utils/controlling.py:115
↓ 31 callers
Function
compute_pid
Compute PID-based valve opening percentage. Parameters ---------- params: PID tuning parameters. inp_target_temp_C: T
custom_components/better_thermostat/utils/calibration/pid.py:143
↓ 27 callers
Function
_make_state_manager
Create a StateManager with a mocked Store (empty initial state).
tests/unit/test_migrate_v0_stores.py:37
↓ 26 callers
Method
_should_heat_with_tolerance
Apply hysteresis so heating restarts only below target - tolerance.
custom_components/better_thermostat/climate.py:2375
↓ 26 callers
Method
_update_state
Update state from climate entity.
custom_components/better_thermostat/sensor.py:604
↓ 26 callers
Function
check_and_update_degraded_mode
Check optional sensors and update degraded mode status. Sets self.degraded_mode to True if any optional sensor is unavailable. Updates self.u
custom_components/better_thermostat/utils/watcher.py:313
↓ 26 callers
Function
trigger_cooler_change
Trigger a change in the cooler state.
custom_components/better_thermostat/events/cooler.py:18
↓ 25 callers
Function
_make_event
Build a mock event whose context differs from bt.context.
tests/unit/test_cooler_events.py:50
↓ 24 callers
Function
distribute_valve_percent
Distribute a group MPC valve command across TRVs based on internal temps. The **warmest TRV** is used as the reference and receives exactly `
custom_components/better_thermostat/utils/calibration/mpc.py:443
↓ 23 callers
Function
_make_entity_registry
Create a mock EntityRegistry.
tests/unit/test_sensor.py:89
↓ 22 callers
Function
_make_mock_store
Create a mock HA Store with configurable async_load return.
tests/unit/test_migrate_v0_stores.py:268
↓ 22 callers
Method
activate
Switch to *preset*. Returns new target temperature, or ``None``.
custom_components/better_thermostat/utils/preset_manager.py:54
↓ 22 callers
Method
add_measurement
Add a new measurement for a certain day (value: float).
custom_components/better_thermostat/utils/weather.py:355
↓ 20 callers
Function
_detect_regime_change
Detect systematic bias in prediction errors using Student's t-test. If the mean error deviates significantly from 0 relative to standard deviatio
custom_components/better_thermostat/utils/calibration/mpc.py:515
↓ 20 callers
Function
heating_power_valve_position
Compute an expected valve position from the heating power. Given the global `heating_power` estimate and the target/current temperature, a he
custom_components/better_thermostat/utils/helpers.py:196
↓ 20 callers
Function
mode_remap
Remap HVAC mode to correct mode if nessesary. Parameters ---------- self : FIXME hvac_mode : str HVAC mode to
custom_components/better_thermostat/utils/helpers.py:140
↓ 19 callers
Function
_make_mock_self
Create a mock BetterThermostat instance with common defaults. Parameters ---------- trv_state : str or None The state to return f
tests/unit/controlling/test_control_trv.py:51
↓ 19 callers
Function
is_entity_available
Check if an entity is available without side effects. Parameters ---------- hass : Home Assistant instance entity : str
custom_components/better_thermostat/utils/watcher.py:40
↓ 18 callers
Function
_convert_to_float
(value)
custom_components/better_thermostat/calibration.py:530
↓ 18 callers
Function
check_critical_entities
Check only critical entities (TRVs). Returns True if all TRVs are available. Does not block on optional sensors. Returns ------- boo
custom_components/better_thermostat/utils/watcher.py:181
↓ 18 callers
Function
control_queue
Process control commands from the queue and coordinate TRV control. This async task runs continuously, processing control requests from the c
custom_components/better_thermostat/utils/controlling.py:141
↓ 18 callers
Function
convert_outbound_states
Convert outbound states for TRV control. Returns the payload for setting the TRV state.
custom_components/better_thermostat/events/trv.py:437
↓ 17 callers
Function
_make_bt
Build a minimal mock BetterThermostat instance for calibration tests. ``bt_hvac_mode`` is set to ``HVACMode.OFF`` so that MPC / TPI / PID int
tests/test_aggressive_calibration.py:30
↓ 17 callers
Function
attr_to_celsius
Read a temperature attribute from a foreign state and return it in °C. The single inbound boundary for foreign temperatures: it resolves the sour
custom_components/better_thermostat/utils/helpers.py:402
↓ 17 callers
Function
check_weather_prediction
Check configured weather entity over roughly the next two days. The forecast horizon is normalised to about two days regardless of the entity
custom_components/better_thermostat/utils/weather.py:92
↓ 17 callers
Function
convert_to_float_celsius
Convert value to float and ensure it is in Celsius. If *unit_of_measurement* indicates Fahrenheit the value is converted to Celsius after the
custom_components/better_thermostat/utils/helpers.py:333
↓ 17 callers
Function
get_pid_state
Return the PIDState for key or None if missing. This is a small helper used externally to read persisted/learned gains.
custom_components/better_thermostat/utils/calibration/pid.py:536
↓ 17 callers
Function
import_mpc_state_map
Hydrate MPC states from a previously exported mapping.
custom_components/better_thermostat/utils/calibration/mpc.py:226
↓ 17 callers
Function
migrate_v0_stores
Migrate data from the four legacy Store files into the unified store. Skips silently when the unified store already contains data (i.e. the m
custom_components/better_thermostat/utils/migrate_v0_stores.py:96
↓ 16 callers
Method
_call
(self, bt)
tests/unit/test_climate_baseline.py:206
↓ 16 callers
Function
_info
Create a MaintenanceTrvInfo with sensible defaults.
tests/unit/test_valve_maintenance.py:55
↓ 16 callers
Function
_trv
Build a TRV State carrying a target temperature (and optional unit).
tests/unit/test_restore.py:23
↓ 16 callers
Function
_trv
Build a ``real_trvs[entity_id]`` dict for testing.
tests/unit/test_valve_maintenance.py:36
↓ 16 callers
Function
export_mpc_state_map
Return a serializable mapping of MPC states, optionally filtered by key prefix.
custom_components/better_thermostat/utils/calibration/mpc.py:213
↓ 15 callers
Function
_import_legacy_data
Deserialize raw dicts from legacy stores into the unified state. Parameters ---------- state_mgr: The StateManager to populate.
custom_components/better_thermostat/utils/migrate_v0_stores.py:41
↓ 15 callers
Function
calculate_calibration_local
Calculate local delta to adjust the setpoint of the TRV based on the air temperature of the external sensor. This calibration is for devices with
custom_components/better_thermostat/calibration.py:512
↓ 15 callers
Function
check_ambient_air_temperature
Get the history for two days and evaluates the necessary for heating. Returns ------- bool True if the average temperature is
custom_components/better_thermostat/utils/weather.py:222
↓ 15 callers
Function
clamp
Clamp *value* into ``[lo, hi]``.
custom_components/better_thermostat/utils/thermal_learning.py:99
↓ 15 callers
Function
is_reasonable_temperature
Return ``True`` iff ``value`` is a plausible indoor temperature in °C. Rejects ``None`` and any value outside ``MIN_REASONABLE_TEMPERATURE`` ..
custom_components/better_thermostat/utils/helpers.py:283
↓ 15 callers
Function
reduce_attribute
Simplified version of Home Assistant's reduce_attribute helper.
tests/test_cooler_minmax.py:19
↓ 15 callers
Function
restore_target_temperature
Resolve the restored heating target. With a usable numeric *saved* value, clamp it into ``[min_temp, max_temp]`` (defaults 5.0 / 30.0). When
custom_components/better_thermostat/utils/restore.py:49
↓ 15 callers
Function
weather_state
Build a weather entity state advertising forecast support and a temp.
tests/unit/test_weather.py:77
↓ 14 callers
Function
_apply_temperature_update
Apply the new external temperature and trigger updates.
custom_components/better_thermostat/events/temperature.py:76
↓ 14 callers
Function
compute_tpi
Compute TPI duty cycle and on/off durations. Parameters ---------- inp: Current measurements and context. params: Con
custom_components/better_thermostat/utils/calibration/tpi.py:122
↓ 13 callers
Method
_call
(self, bt, **kwargs)
tests/unit/test_climate_baseline.py:955
↓ 13 callers
Function
_deserialize
Reconstruct a RuntimeState from a raw dict (loaded from Store).
custom_components/better_thermostat/utils/state_manager.py:210
↓ 13 callers
Function
_prop
(name, bt)
tests/unit/test_climate_properties.py:28
↓ 13 callers
Function
_r
Round to decimals if not None.
custom_components/better_thermostat/utils/calibration/pid.py:135
↓ 13 callers
Method
_resolve_temperature_range
Derive min/max/step temperature from TRV states.
custom_components/better_thermostat/climate.py:1046
↓ 13 callers
Method
add_trv
Add a TRV configuration.
tests/unit/test_helpers_mode_remap.py:22
↓ 13 callers
Function
make_state
Build a minimal stand-in for a HA State with state and attributes.
tests/unit/test_weather.py:43
↓ 13 callers
Function
mean_trv_target
Mean of the valid TRV target temperatures, each converted to Celsius. Returns ``None`` when no TRV exposes a usable target temperature.
custom_components/better_thermostat/utils/restore.py:25
↓ 12 callers
Method
_call
(self, bt)
tests/unit/test_climate_baseline.py:338
↓ 12 callers
Function
_get_active_algorithms
Get set of calibration algorithms currently in use by any TRV.
custom_components/better_thermostat/sensor.py:273
↓ 12 callers
Function
_make_manager
Create a StateManager with a mocked Store.
tests/unit/test_state_manager.py:676
↓ 12 callers
Method
_restore_state
Restore previous state from HA state machine or fall back to defaults.
custom_components/better_thermostat/climate.py:1267
↓ 12 callers
Function
check_weather
Check weather predictions or ambient air temperature if available. Parameters ---------- self : self instance of better_therm
custom_components/better_thermostat/utils/weather.py:27
↓ 12 callers
Function
normalize_calibration_mode
Normalize a calibration_mode field from TRV advanced data.
custom_components/better_thermostat/utils/helpers.py:35
↓ 12 callers
Function
normalize_hvac_mode
Normalize a hvac_mode value to a proper HVACMode enum when possible. Accepts ------- value : HVACMode | str - HVACMode enum: retu
custom_components/better_thermostat/utils/helpers.py:104
↓ 12 callers
Method
set_mpc
Set MPC state for a key and mark dirty.
custom_components/better_thermostat/utils/state_manager.py:327
↓ 12 callers
Function
should_heat_with_tolerance
Determine whether heating should be active based on hysteresis. Band: ``[target - tolerance, target)`` * Start heating when ``cur_temp < targ
custom_components/better_thermostat/utils/hvac_action.py:58
↓ 11 callers
Method
_call
(self, bt, previous_action, tol)
tests/unit/test_climate_baseline.py:133
↓ 11 callers
Function
_default_trv_config
Return a default real_trvs entry for a single TRV.
tests/unit/controlling/test_control_trv.py:104
↓ 11 callers
Method
_initialize_sensors
Set up room temperature, humidity, cooler and window sensors.
custom_components/better_thermostat/climate.py:1107
↓ 11 callers
Function
_make_entry
Create a mock ConfigEntry.
tests/unit/test_sensor.py:82
↓ 11 callers
Method
_make_manager
Create a StateManager with a mocked Store.
tests/unit/test_state_manager.py:408
↓ 11 callers
Function
_make_sensor_state
Build a sensor State.
tests/unit/test_climate_startup.py:101
↓ 11 callers
Function
_round_dbg
(v: float | int | None, d: int = 3)
custom_components/better_thermostat/utils/calibration/tpi.py:113
↓ 11 callers
Function
deserialize_mpc
Deserialize a single MPC state dict into an MpcState dataclass.
custom_components/better_thermostat/utils/state_manager.py:140
↓ 10 callers
Function
_get_valve_control
Determine valve control settings based on boost mode or calibration. Returns a tuple of (valve_settings_dict, source_name). valve_settings_di
custom_components/better_thermostat/utils/controlling.py:47
↓ 10 callers
Function
_trv
(min_t=None, max_t=None, step=None, unit=None, eid="climate.trv")
tests/unit/test_climate_temp_range.py:33
↓ 10 callers
Function
build_mpc_group_key
Return a BT-level (group) key for MPC state tracking. All TRVs under the same BT instance share this key so that a single MPC model learns th
custom_components/better_thermostat/utils/calibration/mpc.py:416
↓ 9 callers
Method
_call
(self, bt)
tests/unit/test_climate_baseline.py:654
↓ 9 callers
Function
_compute_and_commit
Compute and commit the HVAC action, return the result.
tests/test_heating_tolerance.py:61
↓ 9 callers
Function
_compute_zero_open_offset
Compute the offset to push setpoint below TRV temp when valve fraction is zero. Returns the offset so that callers can set: _calibrated_s
custom_components/better_thermostat/calibration.py:53
↓ 9 callers
Function
_detect_trv_profile
( state: _MpcState, percent_out: float, temp_delta: float | None, time_delta: float | None,
custom_components/better_thermostat/utils/calibration/mpc.py:1650
next →
1–100 of 2,184, ranked by callers