Standardize uuid generation for events/storage/registry (#39184)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-08-24 17:21:30 +02:00
1 parent 28332f23b3
commit bee6d87e7a
6 files changed
+34 -15

No files matched your search

+2 -2
View File
@@ -3,12 +3,12 @@ from asyncio import Event
from collections import OrderedDict
import logging
from typing import Dict, Iterable, List, MutableMapping, Optional, cast
import uuid
import attr
from homeassistant.core import callback
from homeassistant.loader import bind_hass
import homeassistant.util.uuid as uuid_util
from .typing import HomeAssistantType
@@ -26,7 +26,7 @@ class AreaEntry:
"""Area Registry Entry."""
name: Optional[str] = attr.ib(default=None)
id: str = attr.ib(factory=lambda: uuid.uuid4().hex)
id: str = attr.ib(factory=uuid_util.uuid_v1mc_hex)
class AreaRegistry:
+2 -2
View File
@@ -2,12 +2,12 @@
from collections import OrderedDict
import logging
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple, Union
import uuid
import attr
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
from homeassistant.core import Event, callback
import homeassistant.util.uuid as uuid_util
from .debounce import Debouncer
from .singleton import singleton
@@ -73,7 +73,7 @@ class DeviceEntry:
area_id: str = attr.ib(default=None)
name_by_user: str = attr.ib(default=None)
entry_type: str = attr.ib(default=None)
id: str = attr.ib(factory=lambda: uuid.uuid4().hex)
id: str = attr.ib(factory=uuid_util.uuid_v1mc_hex)
# This value is not stored, just used to keep track of events to fire.
is_new: bool = attr.ib(default=False)