فهرست منبع

__init__: use old format strings for logging.

As recommended to avoid evaluation when not output.
Reformat long lines.
Jason Rumney 3 سال پیش
والد
کامیت
022d016aba
1فایلهای تغییر یافته به همراه37 افزوده شده و 14 حذف شده
  1. 37 14
      custom_components/tuya_local/__init__.py

+ 37 - 14
custom_components/tuya_local/__init__.py

@@ -40,7 +40,8 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
             config[CONF_TYPE] = await device.async_inferred_type()
             if config[CONF_TYPE] is None:
                 _LOGGER.error(
-                    f"Unable to determine type for device {config[CONF_DEVICE_ID]}."
+                    "Unable to determine type for device %s",
+                    config[CONF_DEVICE_ID],
                 )
                 return False
 
@@ -52,7 +53,7 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
         entry.version = 2
 
     if entry.version == 2:
-        # CONF_TYPE is not configurable, move it from options to the main config.
+        # CONF_TYPE is not configurable, move from options to main config.
         config = {**entry.data, **entry.options, "name": entry.title}
         opts = {**entry.options}
         # Ensure type has been migrated.  Some users are reporting errors which
@@ -63,7 +64,8 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
             config[CONF_TYPE] = await device.async_inferred_type()
             if config[CONF_TYPE] is None:
                 _LOGGER.error(
-                    f"Unable to determine type for device {config[CONF_DEVICE_ID]}."
+                    "Unable to determine type for device %s",
+                    config[CONF_DEVICE_ID],
                 )
                 return False
         entry.data = {
@@ -102,7 +104,10 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
         old_id = entry.unique_id
         conf_file = get_config(entry.data[CONF_TYPE])
         if conf_file is None:
-            _LOGGER.error(f"Configuration file for {entry.data[CONF_TYPE]} not found.")
+            _LOGGER.error(
+                "Configuration file for %s not found",
+                entry.data[CONF_TYPE],
+            )
             return False
 
         @callback
@@ -117,10 +122,16 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
                 new_id = e.unique_id(old_id)
                 if new_id != old_id:
                     _LOGGER.info(
-                        f"Migrating {e.entity} unique_id {old_id} to {new_id}."
+                        "Migrating %s unique_id %s to %s",
+                        e.entity,
+                        old_id,
+                        new_id,
                     )
                     return {
-                        "new_unique_id": entity_entry.unique_id.replace(old_id, new_id)
+                        "new_unique_id": entity_entry.unique_id.replace(
+                            old_id,
+                            new_id,
+                        )
                     }
 
         await async_migrate_entries(hass, entry.entry_id, update_unique_id)
@@ -170,7 +181,10 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
         device_id = entry.unique_id
         conf_file = get_config(entry.data[CONF_TYPE])
         if conf_file is None:
-            _LOGGER.error(f"Configuration file for {entry.data[CONF_TYPE]} not found.")
+            _LOGGER.error(
+                "Configuration file for %s not found",
+                entry.data[CONF_TYPE],
+            )
             return False
 
         @callback
@@ -196,10 +210,16 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
                 new_id = e.unique_id(device_id)
                 if new_id != old_id:
                     _LOGGER.info(
-                        f"Migrating {e.entity} unique_id {old_id} to {new_id}."
+                        "Migrating %s unique_id %s to %s",
+                        e.entity,
+                        old_id,
+                        new_id,
                     )
                     return {
-                        "new_unique_id": entity_entry.unique_id.replace(old_id, new_id)
+                        "new_unique_id": entity_entry.unique_id.replace(
+                            old_id,
+                            new_id,
+                        )
                     }
 
         await async_migrate_entries(hass, entry.entry_id, update_unique_id12)
@@ -209,12 +229,15 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
 
 
 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
-    _LOGGER.debug(f"Setting up entry for device: {entry.data[CONF_DEVICE_ID]}")
+    _LOGGER.debug(
+        "Setting up entry for device: %s",
+        entry.data[CONF_DEVICE_ID],
+    )
     config = {**entry.data, **entry.options, "name": entry.title}
     setup_device(hass, config)
     device_conf = get_config(entry.data[CONF_TYPE])
     if device_conf is None:
-        _LOGGER.error(f"Configuration file for {config[CONF_TYPE]} not found.")
+        _LOGGER.error("Configuration file for %s not found", config[CONF_TYPE])
         return False
 
     entities = set()
@@ -231,12 +254,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
 
 
 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
-    _LOGGER.debug(f"Unloading entry for device: {entry.data[CONF_DEVICE_ID]}")
+    _LOGGER.debug("Unloading entry for device: %s", entry.data[CONF_DEVICE_ID])
     config = entry.data
     data = hass.data[DOMAIN][config[CONF_DEVICE_ID]]
     device_conf = get_config(config[CONF_TYPE])
     if device_conf is None:
-        _LOGGER.error(f"Configuration file for {config[CONF_TYPE]} not found.")
+        _LOGGER.error("Configuration file for %s not found", config[CONF_TYPE])
         return False
 
     entities = {}
@@ -257,6 +280,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
 
 
 async def async_update_entry(hass: HomeAssistant, entry: ConfigEntry):
-    _LOGGER.debug(f"Updating entry for device: {entry.data[CONF_DEVICE_ID]}")
+    _LOGGER.debug("Updating entry for device: %s", entry.data[CONF_DEVICE_ID])
     await async_unload_entry(hass, entry)
     await async_setup_entry(hass, entry)