Skip to content

Commit a14ab5e

Browse files
committed
Improve config flow UX for clarity and reduced cognitive load
1 parent 2f26a72 commit a14ab5e

File tree

6 files changed

+103
-127
lines changed

6 files changed

+103
-127
lines changed

custom_components/lunos/config_flow.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,13 @@ def __init__(self) -> None:
120120
"""Initialize the config flow."""
121121
self._coding_config: dict[str, Any] = {}
122122

123-
async def async_step_user(
124-
self, user_input: dict[str, Any] | None = None
125-
) -> FlowResult:
123+
async def async_step_user(self, user_input: dict[str, Any] | None = None) -> FlowResult:
126124
"""Handle the initial step."""
127125
errors: dict[str, str] = {}
128126

129127
# load coding configurations
130128
if not self._coding_config:
131-
self._coding_config = await self.hass.async_add_executor_job(
132-
load_lunos_codings
133-
)
129+
self._coding_config = await self.hass.async_add_executor_job(load_lunos_codings)
134130

135131
coding_options = get_coding_options(self._coding_config)
136132

@@ -159,9 +155,7 @@ async def async_step_user(
159155
errors=errors,
160156
)
161157

162-
async def async_step_import(
163-
self, import_data: dict[str, Any]
164-
) -> FlowResult:
158+
async def async_step_import(self, import_data: dict[str, Any]) -> FlowResult:
165159
"""Handle import from YAML configuration."""
166160
# convert old LUNOS_DOMAIN to DOMAIN if needed
167161
name = import_data.get(CONF_NAME, DEFAULT_NAME)
@@ -206,17 +200,13 @@ def __init__(self, config_entry: ConfigEntry) -> None:
206200
self._config_entry = config_entry
207201
self._coding_config: dict[str, Any] = {}
208202

209-
async def async_step_init(
210-
self, user_input: dict[str, Any] | None = None
211-
) -> FlowResult:
203+
async def async_step_init(self, user_input: dict[str, Any] | None = None) -> FlowResult:
212204
"""Manage the options."""
213205
errors: dict[str, str] = {}
214206

215207
# load coding configurations
216208
if not self._coding_config:
217-
self._coding_config = await self.hass.async_add_executor_job(
218-
load_lunos_codings
219-
)
209+
self._coding_config = await self.hass.async_add_executor_job(load_lunos_codings)
220210

221211
coding_options = get_coding_options(self._coding_config)
222212

custom_components/lunos/coordinator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ def _determine_speed_from_states(
145145
current_state = [w1_state, w2_state]
146146
for speed, relay_states in self._relay_state_map.items():
147147
if current_state == relay_states:
148-
LOG.debug(
149-
'Determined LUNOS speed=%s from W1/W2=%s', speed, current_state
150-
)
148+
LOG.debug('Determined LUNOS speed=%s from W1/W2=%s', speed, current_state)
151149
return speed
152150

153151
LOG.warning(

custom_components/lunos/fan.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ def __init__(
200200
self._vent_modes: list[str] = []
201201
self._init_vent_modes(model_config)
202202

203-
self._default_speed = (
204-
default_speed if default_speed in self._fan_speeds else DEFAULT_SPEED
205-
)
203+
self._default_speed = default_speed if default_speed in self._fan_speeds else DEFAULT_SPEED
206204

207205
self._preset_modes: list[str] = []
208206
self._preset_mode: str | None = None
@@ -524,7 +522,7 @@ def _determine_current_relay_speed(self) -> str | None:
524522
w1 = self.hass.states.get(self._relay_w1)
525523
if not w1:
526524
LOG.warning(
527-
"W1 entity %s not found, cannot determine %s LUNOS speed.",
525+
'W1 entity %s not found, cannot determine %s LUNOS speed.',
528526
self._relay_w1,
529527
self._name,
530528
)
@@ -533,7 +531,7 @@ def _determine_current_relay_speed(self) -> str | None:
533531
w2 = self.hass.states.get(self._relay_w2)
534532
if not w2:
535533
LOG.warning(
536-
"W2 entity %s not found, cannot determine %s LUNOS speed.",
534+
'W2 entity %s not found, cannot determine %s LUNOS speed.',
537535
self._relay_w2,
538536
self._name,
539537
)
@@ -589,7 +587,7 @@ async def _throttle_state_changes(self, required_delay: float) -> bool:
589587
delay = max(0, required_delay - time_passed)
590588
LOG.warning(
591589
"To avoid LUNOS '%s' controller race conditions, "
592-
"sleeping %s seconds before changing relay.",
590+
'sleeping %s seconds before changing relay.',
593591
self._name,
594592
delay,
595593
)
@@ -652,9 +650,7 @@ async def async_update(self) -> None:
652650
LOG.debug('%s async_update() = %s', self._name, actual_speed)
653651
self._update_speed(actual_speed)
654652

655-
async def async_call_switch_service(
656-
self, method: str, relay_entity_id: str
657-
) -> None:
653+
async def async_call_switch_service(self, method: str, relay_entity_id: str) -> None:
658654
"""Call the appropriate service for the relay entity."""
659655
domain = relay_entity_id.split('.', 1)[0]
660656
# Backward-compatible: original versions assumed relays were always switch entities.

custom_components/lunos/strings.json

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,81 +2,81 @@
22
"config": {
33
"step": {
44
"user": {
5-
"title": "Configure LUNOS Ventilation Fan",
6-
"description": "Set up your LUNOS Heat Recovery Ventilation fan control.",
5+
"title": "Add LUNOS Fan",
6+
"description": "Connect your LUNOS ventilation fan to Home Assistant.",
77
"data": {
88
"name": "Name",
9-
"relay_w1": "W1 Relay Switch",
10-
"relay_w2": "W2 Relay Switch",
11-
"controller_coding": "Controller Coding",
12-
"fan_count": "Number of Fans",
13-
"default_speed": "Default Speed"
9+
"relay_w1": "First Relay (W1)",
10+
"relay_w2": "Second Relay (W2)",
11+
"controller_coding": "Fan Model",
12+
"fan_count": "Fan Count",
13+
"default_speed": "Startup Speed"
1414
},
1515
"data_description": {
16-
"relay_w1": "Switch entity connected to the W1 terminal on the LUNOS controller",
17-
"relay_w2": "Switch entity connected to the W2 terminal on the LUNOS controller",
18-
"controller_coding": "The coding setting configured on your LUNOS controller hardware",
19-
"fan_count": "Number of LUNOS fans connected to this controller",
20-
"default_speed": "Default fan speed when turned on without specifying a speed"
16+
"relay_w1": "Select the switch entity controlling your first LUNOS relay.",
17+
"relay_w2": "Select the switch entity controlling your second LUNOS relay.",
18+
"controller_coding": "Select your LUNOS fan model. Check your controller's DIP switches if unsure.",
19+
"fan_count": "Number of fan units (most installations have 2).",
20+
"default_speed": "Speed used when turning on without specifying. Medium works for most homes."
2121
}
2222
}
2323
},
2424
"error": {
25-
"same_relay": "W1 and W2 relays must be different entities",
25+
"same_relay": "Both relays must be different switch entities.",
2626
"unknown": "An unexpected error occurred"
2727
},
2828
"abort": {
29-
"already_configured": "This LUNOS fan controller is already configured",
29+
"already_configured": "A LUNOS fan with these relays already exists.",
3030
"missing_relays": "YAML configuration must include both relay_w1 and relay_w2"
3131
}
3232
},
3333
"options": {
3434
"step": {
3535
"init": {
36-
"title": "LUNOS Fan Options",
36+
"title": "LUNOS Fan Settings",
3737
"description": "Adjust your LUNOS fan configuration.",
3838
"data": {
3939
"name": "Name",
40-
"relay_w1": "W1 Relay Switch",
41-
"relay_w2": "W2 Relay Switch",
42-
"controller_coding": "Controller Coding",
43-
"fan_count": "Number of Fans",
44-
"default_speed": "Default Speed"
40+
"relay_w1": "First Relay (W1)",
41+
"relay_w2": "Second Relay (W2)",
42+
"controller_coding": "Fan Model",
43+
"fan_count": "Fan Count",
44+
"default_speed": "Startup Speed"
4545
},
4646
"data_description": {
47-
"relay_w1": "Switch entity connected to the W1 terminal on the LUNOS controller",
48-
"relay_w2": "Switch entity connected to the W2 terminal on the LUNOS controller",
49-
"controller_coding": "The coding setting configured on your LUNOS controller hardware",
50-
"fan_count": "Number of LUNOS fans connected to this controller",
51-
"default_speed": "Default fan speed when turned on without specifying a speed"
47+
"relay_w1": "Select the switch entity controlling your first LUNOS relay.",
48+
"relay_w2": "Select the switch entity controlling your second LUNOS relay.",
49+
"controller_coding": "Select your LUNOS fan model. Check your controller's DIP switches if unsure.",
50+
"fan_count": "Number of fan units (most installations have 2).",
51+
"default_speed": "Speed used when turning on without specifying. Medium works for most homes."
5252
}
5353
}
5454
},
5555
"error": {
56-
"same_relay": "W1 and W2 relays must be different entities"
56+
"same_relay": "Both relays must be different switch entities."
5757
}
5858
},
5959
"selector": {
6060
"controller_coding": {
6161
"options": {
62-
"e2": "LUNOS e2 (non-USA)",
63-
"e2-4speed": "LUNOS e2 (4-speed)",
64-
"e2-short": "LUNOS e2 Short (non-USA)",
65-
"e2-usa": "LUNOS e2 (USA)",
66-
"e2-usa-v2": "LUNOS e2 v2 (USA)",
67-
"e2-short-usa": "LUNOS e2 Short (USA)",
68-
"e2-nz": "LUNOS e2 (New Zealand)",
69-
"e2-mini": "LUNOS e2 Mini",
70-
"e2-60": "LUNOS e2 60",
71-
"ego": "LUNOS eGO",
72-
"ego-4speed": "LUNOS eGO (4-speed)",
73-
"ego-exhaust-4speed": "LUNOS eGO (high=exhaust-only 4-speed)",
74-
"ego-exhaust": "LUNOS eGO (high=exhaust-only)",
75-
"ra-15-60": "LUNOS RA 15-60 radial duct fan",
76-
"ra-15-60-high": "LUNOS RA 15-60 radial duct fan (Extra High)",
77-
"ra-15-60-4speed": "LUNOS RA 15-60 radial duct fan (4-speed)",
78-
"e2-60-d": "LUNOS e2 60 D",
79-
"e2-60-short": "LUNOS e2 60 Short"
62+
"e2": "e2 (non-USA)",
63+
"e2-4speed": "e2 (4-speed)",
64+
"e2-short": "e2 Short (non-USA)",
65+
"e2-usa": "e2 (USA)",
66+
"e2-usa-v2": "e2 v2 (USA)",
67+
"e2-short-usa": "e2 Short (USA)",
68+
"e2-nz": "e2 (New Zealand)",
69+
"e2-mini": "e2 Mini",
70+
"e2-60": "e2 60",
71+
"ego": "eGO",
72+
"ego-4speed": "eGO (4-speed)",
73+
"ego-exhaust-4speed": "eGO (high=exhaust-only 4-speed)",
74+
"ego-exhaust": "eGO (high=exhaust-only)",
75+
"ra-15-60": "RA 15-60 radial duct fan",
76+
"ra-15-60-high": "RA 15-60 radial duct fan (Extra High)",
77+
"ra-15-60-4speed": "RA 15-60 radial duct fan (4-speed)",
78+
"e2-60-d": "e2 60 D",
79+
"e2-60-short": "e2 60 Short"
8080
}
8181
},
8282
"fan_speed": {

custom_components/lunos/translations/en.json

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,81 +2,81 @@
22
"config": {
33
"step": {
44
"user": {
5-
"title": "Configure LUNOS Ventilation Fan",
6-
"description": "Set up your LUNOS Heat Recovery Ventilation fan control.",
5+
"title": "Add LUNOS Fan",
6+
"description": "Connect your LUNOS ventilation fan to Home Assistant.",
77
"data": {
88
"name": "Name",
9-
"relay_w1": "W1 Relay Switch",
10-
"relay_w2": "W2 Relay Switch",
11-
"controller_coding": "Controller Coding",
12-
"fan_count": "Number of Fans",
13-
"default_speed": "Default Speed"
9+
"relay_w1": "First Relay (W1)",
10+
"relay_w2": "Second Relay (W2)",
11+
"controller_coding": "Fan Model",
12+
"fan_count": "Fan Count",
13+
"default_speed": "Startup Speed"
1414
},
1515
"data_description": {
16-
"relay_w1": "Switch entity connected to the W1 terminal on the LUNOS controller",
17-
"relay_w2": "Switch entity connected to the W2 terminal on the LUNOS controller",
18-
"controller_coding": "The coding setting configured on your LUNOS controller hardware",
19-
"fan_count": "Number of LUNOS fans connected to this controller",
20-
"default_speed": "Default fan speed when turned on without specifying a speed"
16+
"relay_w1": "Select the switch entity controlling your first LUNOS relay.",
17+
"relay_w2": "Select the switch entity controlling your second LUNOS relay.",
18+
"controller_coding": "Select your LUNOS fan model. Check your controller's DIP switches if unsure.",
19+
"fan_count": "Number of fan units (most installations have 2).",
20+
"default_speed": "Speed used when turning on without specifying. Medium works for most homes."
2121
}
2222
}
2323
},
2424
"error": {
25-
"same_relay": "W1 and W2 relays must be different entities",
25+
"same_relay": "Both relays must be different switch entities.",
2626
"unknown": "An unexpected error occurred"
2727
},
2828
"abort": {
29-
"already_configured": "This LUNOS fan controller is already configured",
29+
"already_configured": "A LUNOS fan with these relays already exists.",
3030
"missing_relays": "YAML configuration must include both relay_w1 and relay_w2"
3131
}
3232
},
3333
"options": {
3434
"step": {
3535
"init": {
36-
"title": "LUNOS Fan Options",
36+
"title": "LUNOS Fan Settings",
3737
"description": "Adjust your LUNOS fan configuration.",
3838
"data": {
3939
"name": "Name",
40-
"relay_w1": "W1 Relay Switch",
41-
"relay_w2": "W2 Relay Switch",
42-
"controller_coding": "Controller Coding",
43-
"fan_count": "Number of Fans",
44-
"default_speed": "Default Speed"
40+
"relay_w1": "First Relay (W1)",
41+
"relay_w2": "Second Relay (W2)",
42+
"controller_coding": "Fan Model",
43+
"fan_count": "Fan Count",
44+
"default_speed": "Startup Speed"
4545
},
4646
"data_description": {
47-
"relay_w1": "Switch entity connected to the W1 terminal on the LUNOS controller",
48-
"relay_w2": "Switch entity connected to the W2 terminal on the LUNOS controller",
49-
"controller_coding": "The coding setting configured on your LUNOS controller hardware",
50-
"fan_count": "Number of LUNOS fans connected to this controller",
51-
"default_speed": "Default fan speed when turned on without specifying a speed"
47+
"relay_w1": "Select the switch entity controlling your first LUNOS relay.",
48+
"relay_w2": "Select the switch entity controlling your second LUNOS relay.",
49+
"controller_coding": "Select your LUNOS fan model. Check your controller's DIP switches if unsure.",
50+
"fan_count": "Number of fan units (most installations have 2).",
51+
"default_speed": "Speed used when turning on without specifying. Medium works for most homes."
5252
}
5353
}
5454
},
5555
"error": {
56-
"same_relay": "W1 and W2 relays must be different entities"
56+
"same_relay": "Both relays must be different switch entities."
5757
}
5858
},
5959
"selector": {
6060
"controller_coding": {
6161
"options": {
62-
"e2": "LUNOS e2 (non-USA)",
63-
"e2-4speed": "LUNOS e2 (4-speed)",
64-
"e2-short": "LUNOS e2 Short (non-USA)",
65-
"e2-usa": "LUNOS e2 (USA)",
66-
"e2-usa-v2": "LUNOS e2 v2 (USA)",
67-
"e2-short-usa": "LUNOS e2 Short (USA)",
68-
"e2-nz": "LUNOS e2 (New Zealand)",
69-
"e2-mini": "LUNOS e2 Mini",
70-
"e2-60": "LUNOS e2 60",
71-
"ego": "LUNOS eGO",
72-
"ego-4speed": "LUNOS eGO (4-speed)",
73-
"ego-exhaust-4speed": "LUNOS eGO (high=exhaust-only 4-speed)",
74-
"ego-exhaust": "LUNOS eGO (high=exhaust-only)",
75-
"ra-15-60": "LUNOS RA 15-60 radial duct fan",
76-
"ra-15-60-high": "LUNOS RA 15-60 radial duct fan (Extra High)",
77-
"ra-15-60-4speed": "LUNOS RA 15-60 radial duct fan (4-speed)",
78-
"e2-60-d": "LUNOS e2 60 D",
79-
"e2-60-short": "LUNOS e2 60 Short"
62+
"e2": "e2 (non-USA)",
63+
"e2-4speed": "e2 (4-speed)",
64+
"e2-short": "e2 Short (non-USA)",
65+
"e2-usa": "e2 (USA)",
66+
"e2-usa-v2": "e2 v2 (USA)",
67+
"e2-short-usa": "e2 Short (USA)",
68+
"e2-nz": "e2 (New Zealand)",
69+
"e2-mini": "e2 Mini",
70+
"e2-60": "e2 60",
71+
"ego": "eGO",
72+
"ego-4speed": "eGO (4-speed)",
73+
"ego-exhaust-4speed": "eGO (high=exhaust-only 4-speed)",
74+
"ego-exhaust": "eGO (high=exhaust-only)",
75+
"ra-15-60": "RA 15-60 radial duct fan",
76+
"ra-15-60-high": "RA 15-60 radial duct fan (Extra High)",
77+
"ra-15-60-4speed": "RA 15-60 radial duct fan (4-speed)",
78+
"e2-60-d": "e2 60 D",
79+
"e2-60-short": "e2 60 Short"
8080
}
8181
},
8282
"fan_speed": {

0 commit comments

Comments
 (0)