Skip to content

Commit 0681bdb

Browse files
authored
Merge pull request #145 from JohanAlvedal/chore/pause-pylint-rules
feat(ci): reduce pylint rules
2 parents 2c8cfc3 + 359c521 commit 0681bdb

File tree

12 files changed

+65
-68
lines changed

12 files changed

+65
-68
lines changed

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
max-line-length=120
33

44
[MASTER]
5-
disable=C0114,C0115,C0116,R0801
5+
# TODO: Enable the following checks when code is cleaned up
6+
disable=C0114,C0115,C0116,R0801,R0911,R0914,R0912
67
ignore-paths=^tests/.*$
78
score=no
89

custom_components/pumpsteer/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""PumpSteer integration."""
1+
"""PumpSteer integration"""
22

33
import logging
44
from homeassistant.config_entries import ConfigEntry
@@ -11,18 +11,18 @@
1111

1212

1313
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
14-
"""Set up the PumpSteer integration."""
14+
"""Set up the PumpSteer integration"""
1515
await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])
1616

1717
_LOGGER.info("PumpSteer integration setup completed")
1818
return True
1919

2020

2121
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
22-
"""Unload the PumpSteer integration."""
22+
"""Unload the PumpSteer integration"""
2323
return await hass.config_entries.async_unload_platforms(entry, ["sensor"])
2424

2525

2626
async def async_get_options_flow():
27-
"""Return the options flow handler."""
27+
"""Return the options flow handler"""
2828
return PumpSteerOptionsFlowHandler()

custom_components/pumpsteer/config_flow.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525

2626

2727
class PumpSteerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
28-
"""Handle a config flow for pumpsteer."""
28+
"""Handle a config flow for pumpsteer"""
2929

3030
VERSION = 1
3131

3232
async def async_step_user(self, user_input=None):
33-
"""Handle the initial step of the config flow."""
33+
"""Handle the initial step of the config flow"""
3434
errors = {}
3535

3636
if user_input is not None:
@@ -60,7 +60,7 @@ async def async_step_user(self, user_input=None):
6060
)
6161

6262
async def _validate_entities(self, user_input):
63-
"""Validate that all required entities exist and are available."""
63+
"""Validate that all required entities exist and are available"""
6464
errors = {}
6565

6666
# Only the entities that the user actually selects
@@ -113,11 +113,11 @@ async def _validate_entities(self, user_input):
113113
return errors
114114

115115
async def _entity_exists(self, entity_id: str) -> bool:
116-
"""Check if entity exists in Home Assistant."""
116+
"""Check if entity exists in Home Assistant"""
117117
return self.hass.states.get(entity_id) is not None
118118

119119
async def _entity_available(self, entity_id: str) -> bool:
120-
"""Check if entity is available (not unavailable or unknown)."""
120+
"""Check if entity is available (not unavailable or unknown)"""
121121
entity = self.hass.states.get(entity_id)
122122
if not entity:
123123
return False
@@ -129,11 +129,11 @@ async def _entity_available(self, entity_id: str) -> bool:
129129
]
130130

131131
def is_matching(self, other_flow: vol.Self) -> bool:
132-
"""Return True if other_flow is matching this flow."""
132+
"""Return True if other_flow is matching this flow"""
133133
raise NotImplementedError
134134

135135
@staticmethod
136136
@callback
137137
def async_get_options_flow(config_entry):
138-
"""Get the options flow for this handler."""
138+
"""Get the options flow for this handler"""
139139
return PumpSteerOptionsFlowHandler()

custom_components/pumpsteer/ml_adaptive.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
###############################################################################
2-
# PumpSteer - ML Adaptive Engine (Learning Version)
3-
# Author: Johan Älvedal / GPT-5 Assistant
4-
# Description:
51
# This version extends the original ML collector with richer data logging,
62
# session summaries, and a simple self-learning regression model that
73
# derives optimal inertia and aggressiveness based on comfort drift and
84
# duration performance.
9-
###############################################################################
5+
106

117
from datetime import datetime
128
from pathlib import Path
@@ -37,7 +33,7 @@
3733

3834

3935
class PumpSteerMLCollector:
40-
"""Collects, analyzes, and learns from PumpSteer operation sessions."""
36+
"""Collects, analyzes, and learns from PumpSteer operation sessions"""
4137

4238
def __init__(self, hass: HomeAssistant, data_file_path: str = ML_DATA_FILE_PATH):
4339
self.hass = hass
@@ -57,7 +53,7 @@ def __init__(self, hass: HomeAssistant, data_file_path: str = ML_DATA_FILE_PATH)
5753
)
5854

5955
async def async_load_data(self) -> None:
60-
"""Load previously saved learning data from disk."""
56+
"""Load previously saved learning data from disk"""
6157
await self.hass.async_add_executor_job(self._load_data_sync)
6258
_LOGGER.info(
6359
"ML: Loaded %d sessions from %s",
@@ -104,7 +100,7 @@ def _save_data_sync(self) -> None:
104100
json.dump(data, f, indent=2)
105101

106102
def start_session(self, initial_data: Dict[str, Any]) -> None:
107-
"""Start a new learning session."""
103+
"""Start a new learning session"""
108104
if self.current_session is not None:
109105
self.end_session("interrupted")
110106

@@ -119,7 +115,7 @@ def start_session(self, initial_data: Dict[str, Any]) -> None:
119115
)
120116

121117
def update_session(self, update_data: Dict[str, Any]) -> None:
122-
"""Add detailed data points to the ongoing session."""
118+
"""Add detailed data points to the ongoing session"""
123119
if self.current_session is None:
124120
return
125121

@@ -150,7 +146,7 @@ def update_session(self, update_data: Dict[str, Any]) -> None:
150146
def end_session(
151147
self, reason: str = "normal", final_data: Optional[Dict[str, Any]] = None
152148
) -> None:
153-
"""Close the session, summarize it, and learn from results."""
149+
"""Close the session, summarize it, and learn from results"""
154150
if self.current_session is None:
155151
return
156152

@@ -233,7 +229,7 @@ def end_session(
233229
self.hass.async_create_task(self.async_save_data())
234230

235231
def _update_learning_model(self) -> None:
236-
"""Perform a simple regression analysis on collected sessions."""
232+
"""Perform a simple regression analysis on collected sessions"""
237233
heating_sessions = [
238234
s
239235
for s in self.learning_sessions
@@ -315,7 +311,7 @@ def _update_learning_model(self) -> None:
315311
)
316312

317313
def get_recommendations(self) -> List[str]:
318-
"""Generate adaptive recommendations based on learned model."""
314+
"""Generate adaptive recommendations based on learned model"""
319315
if not self.model_coefficients:
320316
return ["System is still learning — need more sessions."]
321317

@@ -346,7 +342,7 @@ def get_recommendations(self) -> List[str]:
346342
return msg
347343

348344
def get_learning_summary(self) -> Dict[str, Any]:
349-
"""Return current learning summary and model state."""
345+
"""Return current learning summary and model state"""
350346
return {
351347
"summary": self.learning_summary,
352348
"coefficients": self.model_coefficients,
@@ -355,7 +351,7 @@ def get_learning_summary(self) -> Dict[str, Any]:
355351
}
356352

357353
async def async_shutdown(self) -> None:
358-
"""Graceful shutdown and data save."""
354+
"""Graceful shutdown and data save"""
359355
if self.current_session is not None:
360356
self.end_session("shutdown")
361357
await self.async_save_data()

custom_components/pumpsteer/ml_settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565

6666
def validate_ml_settings() -> None:
67-
"""Validate ML-specific settings for consistency and logical values."""
67+
"""Validate ML-specific settings for consistency and logical values"""
6868
errors = []
6969

7070
# Validate session thresholds
@@ -142,7 +142,7 @@ def validate_ml_settings() -> None:
142142

143143

144144
def get_ml_settings_info() -> dict:
145-
"""Get information about current ML settings."""
145+
"""Get information about current ML settings"""
146146
return {
147147
"version": ML_MODULE_VERSION,
148148
"data_file": ML_DATA_FILE_PATH,

custom_components/pumpsteer/options_flow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222

2323
class PumpSteerOptionsFlowHandler(config_entries.OptionsFlow):
24-
"""Handle options flow for pumpsteer."""
24+
"""Handle options flow for pumpsteer"""
2525

2626
async def async_step_init(self, user_input=None):
27-
"""Manage the options flow."""
27+
"""Manage the options flow"""
2828
errors = {}
2929

3030
entry = self.config_entry
@@ -69,7 +69,7 @@ async def async_step_init(self, user_input=None):
6969
)
7070

7171
async def _validate_entities(self, user_input):
72-
"""Validate that entities exist and are available."""
72+
"""Validate that entities exist and are available"""
7373
errors = {}
7474

7575
user_configurable_entities = {
@@ -118,11 +118,11 @@ async def _validate_entities(self, user_input):
118118
return errors
119119

120120
async def _entity_exists(self, entity_id: str) -> bool:
121-
"""Check if entity exists."""
121+
"""Check if entity exists"""
122122
return self.hass.states.get(entity_id) is not None
123123

124124
async def _entity_available(self, entity_id: str) -> bool:
125-
"""Check if entity is available."""
125+
"""Check if entity is available"""
126126
entity = self.hass.states.get(entity_id)
127127
if not entity:
128128
return False

custom_components/pumpsteer/sensor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async def async_setup_entry(
1111
config_entry: ConfigEntry,
1212
async_add_entities: AddEntitiesCallback,
1313
) -> None:
14-
"""Register both control and ML analysis sensors."""
14+
"""Register both control and ML analysis sensors"""
1515
sensor = PumpSteerSensor(hass, config_entry)
1616
ml_sensor = PumpSteerMLSensor(hass, config_entry)
1717
async_add_entities([sensor, ml_sensor], update_before_add=True)

custom_components/pumpsteer/sensor/ml_sensor.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727

2828

2929
class PumpSteerMLSensor(Entity):
30-
"""Sensor that displays insights and learning results from PumpSteer ML."""
30+
"""Sensor that displays insights and learning results from PumpSteer ML"""
3131

3232
def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry):
33-
"""Initialize ML sensor."""
33+
"""Initialize ML sensor"""
3434
self.hass = hass
3535
self._attr_name = "PumpSteer ML Analysis"
3636
self._attr_unique_id = f"{config_entry.entry_id}_ml_analysis"
@@ -72,7 +72,7 @@ def available(self) -> bool:
7272

7373
@property
7474
def icon(self) -> str:
75-
"""Dynamic icon."""
75+
"""Dynamic icon"""
7676
if self._state == "error":
7777
return "mdi:alert-circle"
7878
if self._state == "collecting":
@@ -84,21 +84,21 @@ def icon(self) -> str:
8484
return "mdi:brain"
8585

8686
async def async_added_to_hass(self):
87-
"""Load ML data on startup."""
87+
"""Load ML data on startup"""
8888
if self.ml and hasattr(self.ml, "async_load_data"):
8989
await self.ml.async_load_data()
9090
_LOGGER.debug("ML sensor: Data loaded successfully")
9191

9292
async def async_will_remove_from_hass(self):
93-
"""Clean up when entity is removed."""
93+
"""Clean up when entity is removed"""
9494
if self.ml and hasattr(self.ml, "async_shutdown"):
9595
await self.ml.async_shutdown()
9696

9797
self.ml = None
9898
await super().async_will_remove_from_hass()
9999

100100
def _get_control_system_data(self) -> Dict[str, Any]:
101-
"""Fetch core control parameters from HA entities."""
101+
"""Fetch core control parameters from HA entities"""
102102

103103
autotune_state = self.hass.states.get(ML_RELATED_ENTITIES["autotune_boolean"])
104104
autotune_on = autotune_state and autotune_state.state == "on"
@@ -127,7 +127,7 @@ def _get_control_system_data(self) -> Dict[str, Any]:
127127
}
128128

129129
def _determine_state(self, insights: Dict[str, Any]) -> str:
130-
"""Decide what the main state string should be."""
130+
"""Decide what the main state string should be"""
131131
summary = insights.get("summary", {}) or {}
132132
total = summary.get("total_sessions", 0) or 0
133133
coeffs = summary.get("coefficients")
@@ -146,7 +146,7 @@ def _determine_state(self, insights: Dict[str, Any]) -> str:
146146
def _build_attributes(
147147
self, insights: Dict[str, Any], control_data: Dict[str, Any]
148148
) -> Dict[str, Any]:
149-
"""Build a clear and concise attribute dictionary."""
149+
"""Build a clear and concise attribute dictionary"""
150150
summary = insights.get("summary", {})
151151
recs = insights.get("recommendations", [])
152152

@@ -174,7 +174,7 @@ def _build_attributes(
174174
return {k: v for k, v in attributes.items() if v is not None}
175175

176176
async def async_update(self):
177-
"""Refresh ML information and update sensor attributes."""
177+
"""Refresh ML information and update sensor attributes"""
178178
if not self.ml:
179179
self._state = STATE_UNAVAILABLE
180180
self._attributes = {
@@ -207,6 +207,6 @@ async def async_setup_entry(
207207
config_entry: ConfigEntry,
208208
async_add_entities: AddEntitiesCallback,
209209
) -> None:
210-
"""Set up PumpSteer ML sensor entity."""
210+
"""Set up PumpSteer ML sensor entity"""
211211
ml_sensor = PumpSteerMLSensor(hass, config_entry)
212212
async_add_entities([ml_sensor], update_before_add=True)

0 commit comments

Comments
 (0)