@@ -68,11 +68,11 @@ async def async_step_bluetooth(
68
68
async def async_step_bluetooth_confirm (
69
69
self , user_input : dict [str , Any ] | None = None
70
70
) -> ConfigFlowResult :
71
- """Confirm discovery."""
71
+ """Confirm Bluetooth discovery."""
72
72
73
73
if user_input is not None :
74
74
self .pin = user_input [CONF_PIN ]
75
- return await self .async_step_confirm ()
75
+ return await self .async_step_bluetooth_finalise ()
76
76
77
77
return self .async_show_form (
78
78
step_id = "bluetooth_confirm" ,
@@ -86,14 +86,14 @@ async def async_step_bluetooth_confirm(
86
86
async def async_step_user (
87
87
self , user_input : dict [str , Any ] | None = None
88
88
) -> ConfigFlowResult :
89
- """Handle the initial step."""
89
+ """Handle the initial manual step."""
90
90
91
91
if user_input is not None :
92
92
self .address = user_input [CONF_ADDRESS ]
93
93
self .pin = user_input [CONF_PIN ]
94
94
await self .async_set_unique_id (self .address , raise_on_progress = False )
95
95
self ._abort_if_unique_id_configured ()
96
- return await self .async_step_confirm ()
96
+ return await self .async_step_finalise ()
97
97
98
98
return self .async_show_form (
99
99
step_id = "user" ,
@@ -114,7 +114,7 @@ async def probe_mower(self, device) -> str | None:
114
114
channel_id , self .address
115
115
).probe_gatts (device )
116
116
except (BleakError , TimeoutError ) as exception :
117
- LOGGER .exception ("Failed to connect to device: %s" , exception )
117
+ LOGGER .exception ("Failed to probe device: %s" , exception )
118
118
return None
119
119
120
120
title = manufacturer + " " + device_type
@@ -132,10 +132,12 @@ async def connect_mower(self, device) -> (int, Mower):
132
132
133
133
return (channel_id , mower )
134
134
135
- async def async_step_confirm (
136
- self , user_input : dict [str , Any ] | None = None
135
+ async def check_mower (
136
+ self ,
137
+ ble_flow : bool ,
138
+ user_input : dict [str , Any ] | None = None ,
137
139
) -> ConfigFlowResult :
138
- """Confirm discovery ."""
140
+ """Check that the mower exists and is setup ."""
139
141
device = bluetooth .async_ble_device_from_address (
140
142
self .hass , self .address , connectable = True
141
143
)
@@ -151,9 +153,25 @@ async def async_step_confirm(
151
153
if not await mower .connect (device ):
152
154
errors ["base" ] = "invalid_auth"
153
155
156
+ if ble_flow :
157
+ return self .async_show_form (
158
+ step_id = "bluetooth_confirm" ,
159
+ data_schema = vol .Schema (
160
+ {
161
+ vol .Required (CONF_ADDRESS ): str ,
162
+ vol .Required (CONF_PIN ): str ,
163
+ },
164
+ ),
165
+ errors = errors ,
166
+ )
154
167
return self .async_show_form (
155
- step_id = "reauth_confirm" ,
156
- data_schema = vol .Schema ({vol .Required (CONF_PIN ): str }),
168
+ step_id = "user" ,
169
+ data_schema = vol .Schema (
170
+ {
171
+ vol .Required (CONF_ADDRESS ): str ,
172
+ vol .Required (CONF_PIN ): str ,
173
+ },
174
+ ),
157
175
errors = errors ,
158
176
)
159
177
except (TimeoutError , BleakError ):
@@ -168,6 +186,20 @@ async def async_step_confirm(
168
186
},
169
187
)
170
188
189
+ async def async_step_bluetooth_finalise (
190
+ self ,
191
+ user_input : dict [str , Any ] | None = None ,
192
+ ) -> ConfigFlowResult :
193
+ """Finalise the Bluetooth setup."""
194
+ return await self .check_mower (True , user_input )
195
+
196
+ async def async_step_finalise (
197
+ self ,
198
+ user_input : dict [str , Any ] | None = None ,
199
+ ) -> ConfigFlowResult :
200
+ """Finalise the Manual setup."""
201
+ return await self .check_mower (False , user_input )
202
+
171
203
async def async_step_reauth (
172
204
self , entry_data : Mapping [str , Any ]
173
205
) -> ConfigFlowResult :
0 commit comments