diff --git a/custom_components/xiaomi_home/config_flow.py b/custom_components/xiaomi_home/config_flow.py index 50eee361..98b132ff 100644 --- a/custom_components/xiaomi_home/config_flow.py +++ b/custom_components/xiaomi_home/config_flow.py @@ -145,7 +145,7 @@ def __init__(self) -> None: self._storage_path = None self._virtual_did = None self._uid = None - self._uuid = None # MQTT client id + self._uuid = None # MQTT client id self._ctrl_mode = None self._area_name_rule = None self._action_debug = False @@ -348,7 +348,7 @@ async def __check_oauth_async(self) -> None: ).hexdigest()[:32] try: self._nick_name = ( - await self._miot_http.get_user_info_async() or {} + await self._miot_http.get_user_info_async() or {} ).get('miliaoNick', DEFAULT_NICK_NAME) except (MIoTOauthError, json.JSONDecodeError): self._nick_name = DEFAULT_NICK_NAME @@ -392,7 +392,7 @@ async def __check_oauth_async(self) -> None: tip_devices = self._miot_i18n.translate(key='config.other.devices') # home list for home_id, home_info in self._home_info_buffer[ - 'homes']['home_list'].items(): + 'homes']['home_list'].items(): # i18n tip_central = '' group_id = home_info.get('group_id', None) @@ -401,9 +401,9 @@ async def __check_oauth_async(self) -> None: for device in list(self._home_info_buffer['devices'].values()) if device.get('home_id', None) == home_id} if ( - mips_list - and group_id in mips_list - and mips_list[group_id].get('did', None) in dev_list + mips_list + and group_id in mips_list + and mips_list[group_id].get('did', None) in dev_list ): # i18n tip_central = self._miot_i18n.translate( @@ -486,7 +486,8 @@ async def async_step_devices_filter(self, user_input=None): self._home_selected[home_id] = home_info self._area_name_rule = user_input.get('area_name_rule') # Check if advanced options should be shown - show_advanced_options = user_input.get('show_advanced_options', False) + show_advanced_options = user_input.get( + 'show_advanced_options', False) # Storage device list devices_list: dict[str, dict] = { did: dev_info @@ -565,8 +566,10 @@ async def display_device_filter_form(self, reason: str): async def async_step_advanced_options(self, user_input=None): if user_input is not None: - # Advanced options, the default values are specified alongside the definition of each variable - self._action_debug = user_input.get('action_debug', self._action_debug) + # Advanced options, the default values are specified alongside + # the definition of each variable + self._action_debug = user_input.get( + 'action_debug', self._action_debug) self._hide_non_standard_entities = user_input.get( 'hide_non_standard_entities', self._hide_non_standard_entities) return self.async_create_entry( @@ -982,8 +985,8 @@ async def async_step_update_user_info(self, user_input=None): return await self.async_step_devices_filter() if not user_input: nick_name_new = ( - await self._miot_http.get_user_info_async() or {}).get( - 'miliaoNick', DEFAULT_NICK_NAME) + await self._miot_http.get_user_info_async() or {}).get( + 'miliaoNick', DEFAULT_NICK_NAME) return self.async_show_form( step_id='update_user_info', data_schema=vol.Schema({ @@ -1024,7 +1027,7 @@ async def async_step_devices_filter(self, user_input=None): tip_devices = self._miot_i18n.translate(key='config.other.devices') # home list for home_id, home_info in self._home_info_buffer[ - 'homes']['home_list'].items(): + 'homes']['home_list'].items(): # i18n tip_central = '' group_id = home_info.get('group_id', None) @@ -1033,8 +1036,8 @@ async def async_step_devices_filter(self, user_input=None): self._home_info_buffer['devices'].values()) if device.get('home_id', None) == home_id} if ( - group_id in mips_list - and mips_list[group_id].get('did', None) in did_list + group_id in mips_list + and mips_list[group_id].get('did', None) in did_list ): # i18n tip_central = self._miot_i18n.translate( @@ -1058,7 +1061,7 @@ async def async_step_devices_filter(self, user_input=None): self._ctrl_mode = user_input.get('ctrl_mode') self._home_selected_dict = {} for home_id, home_info in self._home_info_buffer[ - 'homes']['home_list'].items(): + 'homes']['home_list'].items(): if home_id in self._home_selected_list: self._home_selected_dict[home_id] = home_info # Get device list @@ -1183,8 +1186,8 @@ async def async_step_update_lan_ctrl_config(self, user_input=None): selected_if = lan_ctrl_config.get('net_interfaces', []) enable_subscribe = lan_ctrl_config.get('enable_subscribe', False) if ( - set(selected_if_new) != set(selected_if) - or enable_subscribe_new != enable_subscribe + set(selected_if_new) != set(selected_if) + or enable_subscribe_new != enable_subscribe ): if not await self._miot_storage.update_user_config_async( 'global_config', 'all', { @@ -1243,7 +1246,7 @@ async def async_step_config_confirm(self, user_input=None): self._entry_data['home_selected'] = self._home_selected_dict devices_list_sort = dict(sorted( self._device_list.items(), key=lambda item: - item[1].get('home_id', '')+item[1].get('room_id', ''))) + item[1].get('home_id', '') + item[1].get('room_id', ''))) if not await self._miot_storage.save_async( domain='miot_devices', name=f'{self._uid}_{self._cloud_server}', @@ -1261,8 +1264,8 @@ async def async_step_config_confirm(self, user_input=None): self._entry_data['action_debug'] = self._action_debug_new self._need_reload = True if ( - self._hide_non_standard_entities_new != - self._hide_non_standard_entities + self._hide_non_standard_entities_new != + self._hide_non_standard_entities ): self._entry_data['hide_non_standard_entities'] = ( self._hide_non_standard_entities_new) @@ -1270,9 +1273,9 @@ async def async_step_config_confirm(self, user_input=None): if ( self._devices_remove and not await self._miot_storage.update_user_config_async( - uid=self._uid, - cloud_server=self._cloud_server, - config={'devices_remove': self._devices_remove}) + uid=self._uid, + cloud_server=self._cloud_server, + config={'devices_remove': self._devices_remove}) ): raise AbortFlow( reason='storage_error',