소스 검색

Avoid errors when migrating multiple entities of the same type.

If a user upgrades after multiple entity configs are available and has already
configured the same device (an earlier version without multiple entities
perhaps), an error will be raised when trying to migrate the second entity
due to the config already being popped off the options.  Give a default when
popping to avoid raising an error.
Jason Rumney 4 년 전
부모
커밋
0b29ddc094
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      custom_components/tuya_local/__init__.py

+ 2 - 2
custom_components/tuya_local/__init__.py

@@ -116,12 +116,12 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
         }
         e = devcfg.primary_entity
         if e.config_id != e.entity:
-            newopts.pop(e.entity)
+            newopts.pop(e.entity, None)
             newopts[e.config_id] = opts[e.entity]
 
         for e in devcfg.secondary_entities():
             if e.config_id != e.entity:
-                newopts.pop(e.entity)
+                newopts.pop(e.entity, None)
                 newopts[e.config_id] = opts[e.entity]
 
         entry.options = {**newopts}