4
0
Эх сурвалжийг харах

EV chargers: rename Delay time to Delay add duration class

Follow change made on PR #3072 for Vevor, and add migration for
rename.
Jason Rumney 9 сар өмнө
parent
commit
a255af277f

+ 26 - 0
custom_components/tuya_local/__init__.py

@@ -605,6 +605,32 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
         await async_migrate_entries(hass, entry.entry_id, update_unique_id13_8)
         hass.config_entries.async_update_entry(entry, minor_version=8)
 
+    if entry.version == 13 and entry.minor_version < 9:
+        # Migrate unique ids of existing entities to new id taking into
+        # account translation_key, and standardising naming
+        device_id = entry.unique_id
+        conf_file = await hass.async_add_executor_job(
+            get_config,
+            entry.data[CONF_TYPE],
+        )
+        if conf_file is None:
+            _LOGGER.error(
+                NOT_FOUND,
+                entry.data[CONF_TYPE],
+            )
+            return False
+
+        @callback
+        def update_unique_id13_9(entity_entry):
+            """Update the unique id of an entity entry."""
+            # Standardistion of entity naming to use translation_key
+            replacements = {
+                "number_delay_time": "number_delay",
+            }
+            return replace_unique_ids(entity_entry, device_id, conf_file, replacements)
+
+        await async_migrate_entries(hass, entry.entry_id, update_unique_id13_9)
+        hass.config_entries.async_update_entry(entry, minor_version=9)
     return True
 
 

+ 1 - 1
custom_components/tuya_local/config_flow.py

@@ -47,7 +47,7 @@ _LOGGER = logging.getLogger(__name__)
 
 class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
     VERSION = 13
-    MINOR_VERSION = 7
+    MINOR_VERSION = 9
     CONNECTION_CLASS = CONN_CLASS_LOCAL_PUSH
     device = None
     data = {}

+ 2 - 2
custom_components/tuya_local/devices/kolanky_evcharger.yaml

@@ -59,9 +59,9 @@ entities:
           min: 6
           max: 16
   - entity: number
-    name: Delay time
+    name: Delay
+    class: duration
     category: config
-    icon: "mdi:car-clock"
     dps:
       - id: 118
         type: integer

+ 2 - 2
custom_components/tuya_local/devices/vevor_l2_ev_charger.yaml

@@ -203,9 +203,9 @@ entities:
           - dps_val: offline
             value: false
   - entity: number
-    name: Delay time
+    name: Delay
+    class: duration
     category: config
-    icon: "mdi:clock"
     dps:
       - id: 28
         type: integer