1414from .const import CONF_PORT
1515from .const import CONF_PREFIX
1616from .const import CONF_SCAN_INTERVAL
17- from .const import CONF_SLAVE_ID
17+ from .const import CONF_UNIT_ID
1818from .const import DEFAULT_MODELS
1919from .const import DOMAIN
2020
@@ -37,15 +37,15 @@ async def async_step_user(self, user_input=None):
3737 if user_input is not None :
3838 host = user_input [CONF_HOST ]
3939 port = user_input [CONF_PORT ]
40- slave_id = user_input [CONF_SLAVE_ID ]
41- valid = await self ._test_connection (host , port , slave_id )
40+ unit_id = user_input [CONF_UNIT_ID ]
41+ valid = await self ._test_connection (host , port , unit_id )
4242 if valid :
4343 uid = self ._device_info .getValue ("SN" )
4444 _LOGGER .debug (f"Sunspec device unique id: { uid } " )
4545 await self .async_set_unique_id (uid )
4646
4747 self ._abort_if_unique_id_configured (
48- updates = {CONF_HOST : host , CONF_PORT : port , CONF_SLAVE_ID : slave_id }
48+ updates = {CONF_HOST : host , CONF_PORT : port , CONF_UNIT_ID : unit_id }
4949 )
5050 self .init_info = user_input
5151 return await self .async_step_settings ()
@@ -66,10 +66,10 @@ async def async_step_settings(self, user_input=None):
6666 self .init_info [CONF_SCAN_INTERVAL ] = user_input [CONF_SCAN_INTERVAL ]
6767 host = self .init_info [CONF_HOST ]
6868 port = self .init_info [CONF_PORT ]
69- slave_id = self .init_info [CONF_SLAVE_ID ]
69+ unit_id = self .init_info [CONF_UNIT_ID ]
7070 _LOGGER .debug ("Creating entry with data %s" , self .init_info )
7171 return self .async_create_entry (
72- title = f"{ host } :{ port } :{ slave_id } " , data = self .init_info
72+ title = f"{ host } :{ port } :{ unit_id } " , data = self .init_info
7373 )
7474
7575 return await self ._show_settings_form (user_input )
@@ -81,14 +81,14 @@ def async_get_options_flow(config_entry):
8181
8282 async def _show_config_form (self , user_input ): # pylint: disable=unused-argument
8383 """Show the configuration form to edit connection data."""
84- defaults = user_input or {CONF_HOST : "" , CONF_PORT : 502 , CONF_SLAVE_ID : 1 }
84+ defaults = user_input or {CONF_HOST : "" , CONF_PORT : 502 , CONF_UNIT_ID : 1 }
8585 return self .async_show_form (
8686 step_id = "user" ,
8787 data_schema = vol .Schema (
8888 {
8989 vol .Required (CONF_HOST , default = defaults [CONF_HOST ]): str ,
9090 vol .Required (CONF_PORT , default = defaults [CONF_PORT ]): int ,
91- vol .Required (CONF_SLAVE_ID , default = defaults [CONF_SLAVE_ID ]): int ,
91+ vol .Required (CONF_UNIT_ID , default = defaults [CONF_UNIT_ID ]): int ,
9292 }
9393 ),
9494 errors = self ._errors ,
@@ -116,17 +116,17 @@ async def _show_settings_form(self, user_input): # pylint: disable=unused-argum
116116 errors = self ._errors ,
117117 )
118118
119- async def _test_connection (self , host , port , slave_id ):
119+ async def _test_connection (self , host , port , unit_id ):
120120 """Return true if credentials is valid."""
121- _LOGGER .debug (f"Test connection to { host } :{ port } slave id { slave_id } " )
121+ _LOGGER .debug (f"Test connection to { host } :{ port } unit id { unit_id } " )
122122 try :
123- self .client = SunSpecApiClient (host , port , slave_id , self .hass )
123+ self .client = SunSpecApiClient (host , port , unit_id , self .hass )
124124 self ._device_info = await self .client .async_get_device_info ()
125125 _LOGGER .info (self ._device_info )
126126 return True
127127 except Exception as e : # pylint: disable=broad-except
128128 _LOGGER .error (
129- "Failed to connect to host %s:%s slave %s - %s" , host , port , slave_id , e
129+ "Failed to connect to host %s:%s unit %s - %s" , host , port , unit_id , e
130130 )
131131 pass
132132 return False
@@ -162,15 +162,15 @@ async def show_settings_form(self, data=None, errors=None):
162162 settings = data or self .config_entry .data
163163 host = settings .get (CONF_HOST )
164164 port = settings .get (CONF_PORT )
165- slave_id = settings .get (CONF_SLAVE_ID )
165+ unit_id = settings .get (CONF_UNIT_ID )
166166
167167 return self .async_show_form (
168168 step_id = "host_options" ,
169169 data_schema = vol .Schema (
170170 {
171171 vol .Required (CONF_HOST , default = host ): str ,
172172 vol .Required (CONF_PORT , default = port ): int ,
173- vol .Required (CONF_SLAVE_ID , default = slave_id ): int ,
173+ vol .Required (CONF_UNIT_ID , default = unit_id ): int ,
174174 }
175175 ),
176176 errors = errors ,
@@ -213,10 +213,10 @@ async def async_step_model_options(self, user_input=None):
213213 )
214214 except Exception as e : # pylint: disable=broad-except
215215 _LOGGER .error (
216- "Failed to connect to host %s:%s slave %s - %s" ,
216+ "Failed to connect to host %s:%s unit %s - %s" ,
217217 self .settings [CONF_HOST ],
218218 self .settings [CONF_PORT ],
219- self .settings [CONF_SLAVE_ID ],
219+ self .settings [CONF_UNIT_ID ],
220220 e ,
221221 )
222222 return await self .show_settings_form (
@@ -227,7 +227,7 @@ async def _update_options(self):
227227 """Update config entry options."""
228228 # self.settings[CONF_PORT] = 503
229229 # self.settings[CONF_ENABLED_MODELS] = [160, 103]
230- title = f"{ self .settings [CONF_HOST ]} :{ self .settings [CONF_PORT ]} :{ self .settings [CONF_SLAVE_ID ]} "
230+ title = f"{ self .settings [CONF_HOST ]} :{ self .settings [CONF_PORT ]} :{ self .settings [CONF_UNIT_ID ]} "
231231 _LOGGER .debug (
232232 "Saving config entry with title %s, data: %s options %s" ,
233233 title ,
0 commit comments