@@ -54,7 +54,7 @@ async def async_set_device(self, device, raise_on_progress=True):
54
54
"host" : device .host [0 ],
55
55
}
56
56
async def async_step_ssdp (self , discovery_info : ssdp .SsdpServiceInfo ) -> FlowResult :
57
- """Handle a discovered UniFi device."""
57
+ """Handle a discovered HP iLO device."""
58
58
_LOGGER .info (
59
59
"discovery_info : %s." ,
60
60
discovery_info ,
@@ -110,65 +110,22 @@ async def async_step_confirm(self, user_input=None):
110
110
111
111
async def async_step_user (self , user_input = None ):
112
112
"""Handle a flow initiated by the user."""
113
- errors = {}
114
113
115
114
if user_input is not None :
116
- host = user_input [CONF_HOST ]
117
- #timeout = user_input.get(CONF_TIMEOUT, DEFAULT_TIMEOUT)
115
+ self .config = {}
116
+ self .config [CONF_HOST ] = user_input [CONF_HOST ]
117
+ self .config [CONF_NAME ] = user_input [CONF_HOST ].upper ()
118
+ self .config [CONF_PORT ] = user_input [CONF_PORT ]
119
+ self .config [CONF_PROTOCOL ] = user_input [CONF_PROTOCOL ]
120
+ return await self .async_step_confirm (user_input )
121
+ else :
122
+ data_schema = {
123
+ vol .Required (CONF_HOST , default = "host" ): str ,
124
+ vol .Required (CONF_PORT , default = "80" ): str ,
125
+ vol .Required (CONF_PROTOCOL , default = "http" ):str
126
+ }
127
+ return self .async_show_form (step_id = "user" , data_schema = vol .Schema (data_schema ))
118
128
119
- try :
120
- hello = partial (blk .hello , host , timeout = timeout )
121
- device = await self .hass .async_add_executor_job (hello )
122
-
123
- except NetworkTimeoutError :
124
- errors ["base" ] = "cannot_connect"
125
- err_msg = "Device not found"
126
-
127
- except OSError as err :
128
- if err .errno in {errno .EINVAL , socket .EAI_NONAME }:
129
- errors ["base" ] = "invalid_host"
130
- err_msg = "Invalid hostname or IP address"
131
- elif err .errno == errno .ENETUNREACH :
132
- errors ["base" ] = "cannot_connect"
133
- err_msg = str (err )
134
- else :
135
- errors ["base" ] = "unknown"
136
- err_msg = str (err )
137
-
138
- else :
139
- device .timeout = timeout
140
-
141
- if self .source != config_entries .SOURCE_REAUTH :
142
- await self .async_set_device (device )
143
- self ._abort_if_unique_id_configured (
144
- updates = {CONF_HOST : device .host [0 ], CONF_TIMEOUT : timeout }
145
- )
146
- return await self .async_step_auth ()
147
-
148
- if device .mac == self .device .mac :
149
- await self .async_set_device (device , raise_on_progress = False )
150
- return await self .async_step_auth ()
151
-
152
- errors ["base" ] = "invalid_host"
153
- err_msg = (
154
- "This is not the device you are looking for. The MAC "
155
- f"address must be { format_mac (self .device .mac )} "
156
- )
157
-
158
- _LOGGER .error ("Failed to connect to the device at %s: %s" , host , err_msg )
159
-
160
- if self .source == config_entries .SOURCE_IMPORT :
161
- return self .async_abort (reason = errors ["base" ])
162
-
163
- data_schema = {
164
- vol .Required (CONF_HOST ): str ,
165
- # vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
166
- }
167
- return self .async_show_form (
168
- step_id = "user" ,
169
- data_schema = vol .Schema (data_schema ),
170
- errors = errors ,
171
- )
172
129
173
130
async def _async_get_entry (self ):
174
131
"""Return config entry or update existing config entry."""
0 commit comments